MediaWiki:Vector.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Wendl (Diskussion | Beiträge) |
Wendl (Diskussion | Beiträge) |
||
Zeile 1: | Zeile 1: | ||
/* Das folgende JavaScript wird für Benutzer der Vector-Benutzeroberfläche geladen. */ | /* Das folgende JavaScript wird für Benutzer der Vector-Benutzeroberfläche geladen. */ | ||
//--------------------------------------------- Parameters | |||
var scroll_x; | var scroll_x; | ||
var scroll_y; | var scroll_y; | ||
//Scroll | |||
//--------------------------------------------- Scroll Actions | |||
window.addEventListener("scroll", function(event) { | window.addEventListener("scroll", function(event) { | ||
scroll_y = this.scrollY; | scroll_y = this.scrollY; | ||
Zeile 17: | Zeile 21: | ||
}); | }); | ||
//Search Field | |||
//--------------------------------------------- Search Field | |||
document.querySelector("#searchInput").placeholder = "Suche…"; | document.querySelector("#searchInput").placeholder = "Suche…"; | ||
document.querySelector("#searchInput").focus(); | document.querySelector("#searchInput").focus(); | ||
//Add Scroll to top button | |||
//--------------------------------------------- Add Scroll to top button | |||
sc_t = document.createElement("div"); | sc_t = document.createElement("div"); | ||
sc_t.id = "scroll-top-button"; | sc_t.id = "scroll-top-button"; | ||
Zeile 33: | Zeile 39: | ||
// | //--------------------------------------------- Link Styling (Inactive via CSS) | ||
var links = document.querySelectorAll("a"); | var links = document.querySelectorAll("a"); | ||
for(var i=0; i<links.length;i++){ | for(var i=0; i<links.length;i++){ | ||
var link = links[i]; | var link = links[i]; | ||
if(link.getElementsByTagName("img").length==0){ | if(link.getElementsByTagName("img").length==0){ | ||
console.log(link); | console.log(link); | ||
link.classList.add("adbk-link"); | |||
} | } | ||
} | } | ||
//Inlist Incrementor | |||
//--------------------------------------------- Inlist Incrementor | |||
incrementInlist(); | incrementInlist(); | ||
function incrementInlist(){ | function incrementInlist(){ |
Version vom 6. Januar 2022, 23:13 Uhr
/* Das folgende JavaScript wird für Benutzer der Vector-Benutzeroberfläche geladen. */ //--------------------------------------------- Parameters var scroll_x; var scroll_y; //--------------------------------------------- Scroll Actions window.addEventListener("scroll", function(event) { scroll_y = this.scrollY; scroll_x = this.scrollX; if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { sc_t.style.display = "block"; } else { sc_t.style.display = "none"; } }); //--------------------------------------------- Search Field document.querySelector("#searchInput").placeholder = "Suche…"; document.querySelector("#searchInput").focus(); //--------------------------------------------- Add Scroll to top button sc_t = document.createElement("div"); sc_t.id = "scroll-top-button"; document.querySelector("body").append(sc_t); sc_t.addEventListener("click", topFunction); function topFunction() { document.body.scrollTop = 0; // For Safari document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera } //--------------------------------------------- Link Styling (Inactive via CSS) var links = document.querySelectorAll("a"); for(var i=0; i<links.length;i++){ var link = links[i]; if(link.getElementsByTagName("img").length==0){ console.log(link); link.classList.add("adbk-link"); } } //--------------------------------------------- Inlist Incrementor incrementInlist(); function incrementInlist(){ var inlists = document.querySelectorAll(".inlist"); for (var i = 0; i < inlists.length; i++){ var inlist = inlists[i]; handleInlist(inlist, 0); } } function handleInlist(inlist, p_listindex){ var ol = inlist.getElementsByTagName("ol"); var children = ol[0].children; for (var i = 0; i < children.length; i ++){ var listindex = p_listindex + i + 1; var li = children[i]; if(li.getElementsByTagName("ol").length > 0){ handleInlist(li, listindex*10); } var str = listindex.toString(); var str_n = ""; for (var c = 0; c < str.length; c++){ str_n = str_n + "." + str.charAt(c); } str_n = str_n.slice(1) li.setAttribute('data-listindex', str_n); } }