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,31 +1,50 @@
<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);
var vars = searchQuery.split('&');
function getQueryVariable(variable) {
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) {
return decodeURIComponent(pair[1]);
}
}
return null;
}
if (searchQuery && searchQuery.length >= 1) {
var oldTitle = (window.document.title === undefined) ? "" : window.document.title;
var state=getQueryVariable("state");
var code=getQueryVariable("code");
var error=getQueryVariable("error") || "unknown";
if (error == null && (state || code)) {
window.document.title=oldTitle + "?state=" + state + "&code=" + code;
} else {
window.document.title=oldTitle + "?error=" + error;
function getQueryVariable(variable) {
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) {
return decodeURIComponent(pair[1]);
}
}
return null;
}
}
else {
window.document.title=oldTitle + "?error=noquery";
}
</script>
var index = 0;
var titles = [];
var nrOfTitles = 0;
function updateTitle() {
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)) {
var numberOfArguments = vars.length;
nrOfTitles = numberOfArguments -1;
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";
}
</script>