Fixed issues with next/prev post functionality not working with certin URL setups, as the query was not making it back to the server, or was being lost on redirect

This commit is contained in:
Matthew Barbour
2020-10-08 17:19:08 -05:00
parent fe7b93d6d3
commit 7cea8592ee
3 changed files with 25 additions and 8 deletions

View File

@@ -1,18 +1,29 @@
function joinUrlSegments(base, query) {
let separatorChar = "?";
if(base.includes("?")) {
separatorChar = "&";
}
return base + separatorChar + query;
}
document.addEventListener('DOMContentLoaded', () => {
if(document.location.hash.length > 3) {
var query = document.location.hash.substring(1);
$('LINK#prevlink').attr('href', function(i, attr) {
return attr + '?' + query;
return joinUrlSegments(attr,query);
});
$('LINK#nextlink').attr('href', function(i, attr) {
return attr + '?' + query;
return joinUrlSegments(attr,query);
});
$('A#prevlink').attr('href', function(i, attr) {
return attr + '?' + query;
return joinUrlSegments(attr,query);
});
$('A#nextlink').attr('href', function(i, attr) {
return attr + '?' + query;
return joinUrlSegments(attr,query);
});
$('span#image_delete_form form').attr('action', function(i, attr) {
return joinUrlSegments(attr,query);
});
}
});