document.addEventListener('DOMContentLoaded', function(){
body.addEventListener('click', function (e) {
if (e.target.classList.contains("ajax") || e.target.classList.contains("page-link")) {
e.preventDefault();
const url=e.target.getAttribute('href');
getPageWithAjax(url);
}
if (e.target.id=='searchButton') {
e.preventDefault();
const searchWords=this.querySelector('#title').value;
const action=this.querySelector('#searchForm').action;
const url =action+'?title='+searchWords;
getPageWithAjax(url);
}
});
if (window.history && window.history.pushState) {
//window.history.pushState('forward', null, './#forward');
$(window).on('popstate', function() {
getPageWithAjax(window.location.href);
});
}
});