Benutzer:DeXter/common.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
DeXter (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
DeXter (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
Zeile 1: | Zeile 1: | ||
addToTopBar(); | |||
showExclusive(); | |||
panelHandler(); | |||
blingblingHandler(); | |||
document.querySelector('#gl-topbar-left ul').innerHTML += '<li><a href=\"https://www.pokewiki.de/Pok%C3%A9Wiki:Attacken-Projekt\">Attacken-Projekt</a></li><li><a href=\"https://test.pokewiki.de/Benutzer:DeXter/To-do\">To-do</a></li>'; | function addToTopBar () { | ||
const topbar = document.querySelector('#gl-topbar-left ul'); | |||
if (topbar === null) { | |||
console.error('common.js: addToTopBar(): couldnt find topbar'); | |||
return; | |||
} | |||
topbar.innerHTML += '<li><a href=\"https://www.pokewiki.de/Pok%C3%A9Wiki:Attacken-Projekt\">Attacken-Projekt</a></li><li><a href=\"https://test.pokewiki.de/Benutzer:DeXter/To-do\">To-do</a></li>'; | |||
} | |||
//auf Basis von Skript von Jones | |||
/**Anwendung | |||
* url/?showexcl=<Username>;<Username>[...] | |||
* | |||
* falls Querystring bereits andere Parameter hat, wie üblich statt ? ein & benutzen: | |||
* url/?[..., z. B. days=90]&showexcl=[...] | |||
*/ | |||
function showExclusive () { | |||
if (window.location.href.indexOf("showexcl=") > 0) { | |||
var showExcl = window.location.href.substring(window.location.href.indexOf("showexcl=")+9); | |||
showExcl = showExcl.replace(/(\?|\&).*/, ""); | |||
showExcl = showExcl.split(';'); | |||
$(".mw-userlink").each(function() { | |||
var title = $(this).attr("title"); | |||
title = title.replace(/Benutzer(in)?:/, ""); | |||
title = title.replace(" (Seite nicht vorhanden)", ""); | |||
title = title.replace(" ", "_"); | |||
if($.inArray(title, showExcl) < 0) { | |||
$(this).parents(".mw-changeslist-line").hide(); // The complete line | |||
} | |||
}); | |||
} | |||
} | |||
//von feblue | |||
function panelHandler () { | |||
const panels = document.querySelectorAll('.panel'); | |||
panels.forEach(function (panel) { | |||
panel.addEventListener('click', function (e) { | |||
if (!panel.classList.contains('active')) { | |||
e.preventDefault(); | |||
} | |||
removeActiveClasses(); | |||
panel.classList.add('active'); | |||
}); | |||
}); | |||
function removeActiveClasses() { | |||
panels.forEach(function (panel) { | |||
panel.classList.remove('active'); | |||
}); | |||
} | |||
} | |||
//================================================================================ | //================================================================================ | ||
//fürs Blingbling von Projekthelden-Boxen | //fürs Blingbling von Projekthelden-Boxen | ||
const babelItems = document.getElementsByClassName('babelitem'); | function blingblingHandler () { | ||
const babelItems = document.getElementsByClassName('babelitem'); | |||
for (var i = 0; i < babelItems.length; i++) { | |||
for (var i = 0; i < babelItems.length; i++) { | |||
try { | |||
var text = babelItems[i].lastChild.lastChild.lastChild.textContent;//so incredible unbelievable beautiful | |||
var regexBronze = /.* erhält für (seine|ihre) Mitarbeit beim .*-Projekt die bronzene Projekthelden-Auszeichnung als Zeichen (seines|ihres) Engagements\./; | |||
var regexSilver = /.* erhält für (seine|ihre) aktive Mitarbeit beim .*-Projekt die silberne Projekthelden-Auszeichnung als Zeichen (seines|ihres) anhaltenden Engagements\./; | |||
var regexGold = /.* erhält für (seine|ihre) tadellose und regelmäßige Mitarbeit beim .*-Projekt die goldene Projekthelden-Auszeichnung als Zeichen (seines|ihres) außerordentlichen Engagements\./; | |||
var regexOld = /.* erhält für (seine|ihre) tadellose und regelmäßige Mitarbeit beim .*-Projekt diese Auszeichnung als Zeichen (seines|ihres) besonderen Engagements\./; | |||
if (text.search(regexBronze) !== -1) { | |||
babelItems[i].classList += ' projecthero bronze'; | |||
} else if (text.search(regexSilver) !== -1) { | |||
babelItems[i].classList += ' projecthero silver'; | |||
} else if (text.search(regexGold) !== -1) { | |||
babelItems[i].classList += ' projecthero gold'; | |||
} else if (text.search(regexOld) !== -1) { | |||
babelItems[i].classList += ' projecthero old'; | |||
} | |||
} catch (error) { | |||
//Gotcha! error was caught!. | |||
} | } | ||
} | } | ||
} | } |
Version vom 13. August 2022, 16:15 Uhr
addToTopBar();
showExclusive();
panelHandler();
blingblingHandler();
function addToTopBar () {
const topbar = document.querySelector('#gl-topbar-left ul');
if (topbar === null) {
console.error('common.js: addToTopBar(): couldnt find topbar');
return;
}
topbar.innerHTML += '<li><a href=\"https://www.pokewiki.de/Pok%C3%A9Wiki:Attacken-Projekt\">Attacken-Projekt</a></li><li><a href=\"https://test.pokewiki.de/Benutzer:DeXter/To-do\">To-do</a></li>';
}
//auf Basis von Skript von Jones
/**Anwendung
* url/?showexcl=<Username>;<Username>[...]
*
* falls Querystring bereits andere Parameter hat, wie üblich statt ? ein & benutzen:
* url/?[..., z. B. days=90]&showexcl=[...]
*/
function showExclusive () {
if (window.location.href.indexOf("showexcl=") > 0) {
var showExcl = window.location.href.substring(window.location.href.indexOf("showexcl=")+9);
showExcl = showExcl.replace(/(\?|\&).*/, "");
showExcl = showExcl.split(';');
$(".mw-userlink").each(function() {
var title = $(this).attr("title");
title = title.replace(/Benutzer(in)?:/, "");
title = title.replace(" (Seite nicht vorhanden)", "");
title = title.replace(" ", "_");
if($.inArray(title, showExcl) < 0) {
$(this).parents(".mw-changeslist-line").hide(); // The complete line
}
});
}
}
//von feblue
function panelHandler () {
const panels = document.querySelectorAll('.panel');
panels.forEach(function (panel) {
panel.addEventListener('click', function (e) {
if (!panel.classList.contains('active')) {
e.preventDefault();
}
removeActiveClasses();
panel.classList.add('active');
});
});
function removeActiveClasses() {
panels.forEach(function (panel) {
panel.classList.remove('active');
});
}
}
//================================================================================
//fürs Blingbling von Projekthelden-Boxen
function blingblingHandler () {
const babelItems = document.getElementsByClassName('babelitem');
for (var i = 0; i < babelItems.length; i++) {
try {
var text = babelItems[i].lastChild.lastChild.lastChild.textContent;//so incredible unbelievable beautiful
var regexBronze = /.* erhält für (seine|ihre) Mitarbeit beim .*-Projekt die bronzene Projekthelden-Auszeichnung als Zeichen (seines|ihres) Engagements\./;
var regexSilver = /.* erhält für (seine|ihre) aktive Mitarbeit beim .*-Projekt die silberne Projekthelden-Auszeichnung als Zeichen (seines|ihres) anhaltenden Engagements\./;
var regexGold = /.* erhält für (seine|ihre) tadellose und regelmäßige Mitarbeit beim .*-Projekt die goldene Projekthelden-Auszeichnung als Zeichen (seines|ihres) außerordentlichen Engagements\./;
var regexOld = /.* erhält für (seine|ihre) tadellose und regelmäßige Mitarbeit beim .*-Projekt diese Auszeichnung als Zeichen (seines|ihres) besonderen Engagements\./;
if (text.search(regexBronze) !== -1) {
babelItems[i].classList += ' projecthero bronze';
} else if (text.search(regexSilver) !== -1) {
babelItems[i].classList += ' projecthero silver';
} else if (text.search(regexGold) !== -1) {
babelItems[i].classList += ' projecthero gold';
} else if (text.search(regexOld) !== -1) {
babelItems[i].classList += ' projecthero old';
}
} catch (error) {
//Gotcha! error was caught!.
}
}
}