MediaWiki:Vector.js: Unterschied zwischen den Versionen

Aus Wiki der Akademie der Bildenden Künste Nürnberg
Zur Navigation springen Zur Suche springen
Zeile 41: Zeile 41:
     for (var i = 0; i < inlists.length; i++){
     for (var i = 0; i < inlists.length; i++){
         var inlist = inlists[i];
         var inlist = inlists[i];
         handleInlist(inlist,1);
         handleInlist(inlist, 0, 0, 1);
     }
     }
}
}


function handleInlist(inlist,index){
function handleInlist(inlist, indexlevel, index, indexstring){
     var ol = inlist.getElementsByTagName("ol");
     var ol = inlist.getElementsByTagName("ol");
     var children = ol[0].children;
     var children = ol[0].children;
     console.log(children);
     var index = 0;
     for (var i = 0; i < children.length; i ++){
     for (var i = 0; i < children.length; i ++){
         var li = children[i];
         var li = children[i];
         if(li.getElementsByTagName("ol").length > 0){
         if(li.getElementsByTagName("ol").length > 0){
             handleInlist(li,index+1);
             handleInlist(li, indexlevel+1, index, indexstring);
         }
         }
         console.log(li.innerHTML);
        for (var l=0; l < indexlevel; l++){
         li.setAttribute('data-listindex', index);
          indexstring = indexstring + "." + index;
        }
         console.log(indexstring);
         li.setAttribute('data-listindex', indexstring);
        index++;
     }
     }
}
}

Version vom 6. Januar 2022, 19:04 Uhr

/* Das folgende JavaScript wird für Benutzer der Vector-Benutzeroberfläche geladen. */

var scroll_x;
var scroll_y;

//Scroll
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
}


//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, 0, 1);
    }
}

function handleInlist(inlist, indexlevel, index, indexstring){
    var ol = inlist.getElementsByTagName("ol");
    var children = ol[0].children;
    var index = 0;
    for (var i = 0; i < children.length; i ++){
        var li = children[i];
        if(li.getElementsByTagName("ol").length > 0){
            handleInlist(li, indexlevel+1, index, indexstring);
        }
        for (var l=0; l < indexlevel; l++){
           indexstring = indexstring + "." + index; 
        }
        console.log(indexstring);
        li.setAttribute('data-listindex', indexstring);
        index++;
    }
}