As the title got to large, it's now providing every field single and changing the title quickly.

This commit is contained in:
Robin Krom 2020-10-22 23:37:08 +02:00
commit 5b2062daeb

View file

@ -1,9 +1,9 @@
<script language="JavaScript"> <script language="JavaScript">
var oldTitle = window.document.title;
var searchQuery = window.location.href.split('?')[1].replace("#", "&");
var vars = searchQuery.split('&');
var searchQuery = window.location.search.substring(1); function getQueryVariable(variable) {
var vars = searchQuery.split('&');
function getQueryVariable(variable) {
for (var i = 0; i < vars.length; i++) { for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('='); var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) { if (decodeURIComponent(pair[0]) == variable) {
@ -11,21 +11,40 @@ function getQueryVariable(variable) {
} }
} }
return null; return null;
} }
if (searchQuery && searchQuery.length >= 1) { var index = 0;
var oldTitle = (window.document.title === undefined) ? "" : window.document.title; var titles = [];
var state=getQueryVariable("state"); var nrOfTitles = 0;
var code=getQueryVariable("code"); function updateTitle() {
var error=getQueryVariable("error") || "unknown"; if (index >= nrOfTitles) {
index = 0;
}
window.document.title = titles[index];
index = index+1;
}
if (searchQuery && searchQuery.length >= 1) {
var state = getQueryVariable("state");
var error = getQueryVariable("error");
if (error == null && (state || code)) { if (error == null && (state || code)) {
window.document.title=oldTitle + "?state=" + state + "&code=" + code; var numberOfArguments = vars.length;
} else { nrOfTitles = numberOfArguments -1;
window.document.title=oldTitle + "?error=" + error; for (var i = 0; i < numberOfArguments; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == "state") {
continue;
}
titles.push(oldTitle + "?nr=" + numberOfArguments + "&state=" + state + "&" + decodeURIComponent(pair[0]) + "=" + decodeURIComponent(pair[1]));
}
// Update the title in a loop
setInterval(updateTitle, 100);
} else {
window.document.title = oldTitle + "?error=" + error;
}
}
else {
window.document.title = oldTitle + "?error=noquery";
} }
}
else {
window.document.title=oldTitle + "?error=noquery";
}
</script> </script>