MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus Planet 3DNow! Distributed Computing Wiki
Zur Navigation springen Zur Suche springen
(CSS-Änderungen)
(Code Style angepasst)
Zeile 3: Zeile 3:
 
  // ============================================================
 
  // ============================================================
 
  // BEGIN Event Hooking
 
  // BEGIN Event Hooking
  function hookEvent(hookName, hookFunct)
+
  function HookEvent(hookName, hookFunction)
 
  {
 
  {
 
   if(window.addEventListener) {
 
   if(window.addEventListener) {
     window.addEventListener(hookName, hookFunct, false);
+
     window.addEventListener(hookName, hookFunction, false);
 
   } else if(window.attachEvent) {
 
   } else if(window.attachEvent) {
     window.attachEvent("on" + hookName, hookFunct);
+
     window.attachEvent("on" + hookName, hookFunction);
 
   }
 
   }
 
  }
 
  }
Zeile 17: Zeile 17:
 
  // BEGIN Dynamic Navigation Bars
 
  // BEGIN Dynamic Navigation Bars
 
   
 
   
// set up the words in your language
+
  var strNavigationBarHide = "Einklappen";
  var NavigationBarHide = 'Einklappen';
+
  var strNavigationBarShow = "Ausklappen";
  var NavigationBarShow = 'Ausklappen';
 
 
   
 
   
  // set up max count of Navigation Bars on page,
+
  var navigationBarShowDefault = 0;
// if there are more, all will be hidden
 
// NavigationBarShowDefault = 0; // all bars will be hidden
 
// NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
 
if(typeof NavigationBarShowDefault == 'undefined' ) {
 
    var NavigationBarShowDefault = 1;
 
}
 
 
   
 
   
 
  // shows and hides content and picture (if available) of navigation bars
 
  // shows and hides content and picture (if available) of navigation bars
 
  // Parameters:
 
  // Parameters:
 
  //    indexNavigationBar: the index of navigation bar to be toggled
 
  //    indexNavigationBar: the index of navigation bar to be toggled
  function toggleNavigationBar(indexNavigationBar)
+
  function ToggleNavigationBar(indexNavigationBar)
 
  {
 
  {
     var NavToggle = document.getElementById("dcw_navitoggle" + indexNavigationBar);
+
     var naviToggle = document.getElementById("dcw_navitoggle" + indexNavigationBar);
     var NavFrame = document.getElementById("dcw_naviframe" + indexNavigationBar);
+
     var naviFrame = document.getElementById("dcw_naviframe" + indexNavigationBar);
 
   
 
   
     if(!NavFrame || !NavToggle) {
+
     if(!naviFrame || !naviToggle) {
 
         return false;
 
         return false;
 
     }
 
     }
 
   
 
   
 
     // if shown now
 
     // if shown now
     if(NavToggle.firstChild.data == NavigationBarHide) {
+
     if(naviToggle.firstChild.data == strNavigationBarHide) {
         for(var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
+
         for(var naviChild = naviFrame.firstChild; naviChild != null; naviChild = naviChild.nextSibling) {
             if(NavChild.className == 'dcw_navipicture') {
+
             if(naviChild.className == "dcw_navipicture") {
                 NavChild.style.display = 'none';
+
                 naviChild.style.display = "none";
 
             }
 
             }
             if(NavChild.className == 'dcw_navicontent') {
+
             if(naviChild.className == "dcw_navicontent") {
                 NavChild.style.display = 'none';
+
                 naviChild.style.display = "none";
 
             }
 
             }
             if(NavChild.className == 'dcw_navitoggle') {
+
             if(naviChild.className == "dcw_navitoggle") {
                 NavChild.firstChild.data = NavigationBarShow;
+
                 naviChild.firstChild.data = strNavigationBarShow;
 
             }
 
             }
 
         }
 
         }
 
   
 
   
 
     // if hidden now
 
     // if hidden now
     } else if(NavToggle.firstChild.data == NavigationBarShow) {
+
     } else if(naviToggle.firstChild.data == strNavigationBarShow) {
         for(var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
+
         for(var naviChild = naviFrame.firstChild; naviChild != null; naviChild = naviChild.nextSibling) {
             if(NavChild.className == 'dcw_navipicture') {
+
             if(naviChild.className == "dcw_navipicture") {
                 NavChild.style.display = 'block';
+
                 naviChild.style.display = "block";
 
             }
 
             }
             if(NavChild.className == 'dcw_navicontent') {
+
             if(naviChild.className == "dcw_navicontent") {
                 NavChild.style.display = 'block';
+
                 naviChild.style.display = "block";
 
             }
 
             }
             if(NavChild.className == 'dcw_navitoggle') {
+
             if(naviChild.className == "dcw_navitoggle") {
                 NavChild.firstChild.data = NavigationBarHide;
+
                 naviChild.firstChild.data = strNavigationBarHide;
 
             }
 
             }
 
         }
 
         }
Zeile 72: Zeile 65:
 
   
 
   
 
  // adds show/hide-button to navigation bars
 
  // adds show/hide-button to navigation bars
  function createNavigationBarToggleButton()
+
  function CreateNavigationBarToggleButton()
 
  {
 
  {
 
     var indexNavigationBar = 0;
 
     var indexNavigationBar = 0;
     // iterate over all < div >-elements
+
     // iterate over all <div>-elements
     for(var i = 0; NavFrame = document.getElementsByTagName("div")[i]; ++i) {
+
     for(var i = 0; naviFrame = document.getElementsByTagName("div")[i]; ++i) {
 
         // if found a navigation bar
 
         // if found a navigation bar
         if(NavFrame.className == "dcw_naviframe") {
+
         if(naviFrame.className == "dcw_naviframe") {
 
             ++indexNavigationBar;
 
             ++indexNavigationBar;
             var NavToggle = document.createElement("a");
+
             var naviToggle = document.createElement("a");
             NavToggle.className = 'dcw_navitoggle';
+
             naviToggle.className = "dcw_navitoggle";
             NavToggle.setAttribute('id', 'dcw_navitoggle' + indexNavigationBar);
+
             naviToggle.setAttribute("id", "dcw_navitoggle" + indexNavigationBar);
             NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
+
             NavToggle.setAttribute("href", "javascript:ToggleNavigationBar(" + indexNavigationBar + ");");
 
   
 
   
             var NavToggleText = document.createTextNode(NavigationBarHide);
+
             var naviToggleText = document.createTextNode(strNavigationBarHide);
             NavToggle.appendChild(NavToggleText);
+
             naviToggle.appendChild(naviToggleText);
 
   
 
   
             // add NavToggle-Button as first div-element  
+
             // add naviToggle-Button as first div-element  
             // in < div class="dcw_naviframe" >
+
             // in <div class="dcw_naviframe">
             NavFrame.insertBefore(NavToggle, NavFrame.firstChild);
+
             naviFrame.insertBefore(naviToggle, naviFrame.firstChild);
             NavFrame.setAttribute('id', 'dcw_naviframe' + indexNavigationBar);
+
             naviFrame.setAttribute("id", "dcw_naviframe" + indexNavigationBar);
 
         }
 
         }
 
     }
 
     }
     // if more Navigation Bars found than Default: hide all
+
     // if more navigation bars found than default: hide all
     if(NavigationBarShowDefault < indexNavigationBar) {
+
     if(navigationBarShowDefault < indexNavigationBar) {
 
         for(var i = 1; i <= indexNavigationBar; ++i) {
 
         for(var i = 1; i <= indexNavigationBar; ++i) {
             toggleNavigationBar(i);
+
             ToggleNavigationBar(i);
 
         }
 
         }
 
     }
 
     }
 
  }
 
  }
 
   
 
   
  hookEvent("load", createNavigationBarToggleButton);
+
  HookEvent("load", CreateNavigationBarToggleButton);
 
   
 
   
 
  // END Dynamic Navigation Bars
 
  // END Dynamic Navigation Bars
 
  // ============================================================
 
  // ============================================================

Version vom 27. Juni 2007, 12:33 Uhr

/* Jedes JavaScript hier wird für alle Benutzer für jede Seite geladen. */

 // ============================================================
 // BEGIN Event Hooking
 function HookEvent(hookName, hookFunction)
 {
   if(window.addEventListener) {
     window.addEventListener(hookName, hookFunction, false);
   } else if(window.attachEvent) {
     window.attachEvent("on" + hookName, hookFunction);
   }
 }
 // END Event Hooking
 // ============================================================
 
 // ============================================================
 // BEGIN Dynamic Navigation Bars
 
 var strNavigationBarHide = "Einklappen";
 var strNavigationBarShow = "Ausklappen";
 
 var navigationBarShowDefault = 0;
 
 // shows and hides content and picture (if available) of navigation bars
 // Parameters:
 //     indexNavigationBar: the index of navigation bar to be toggled
 function ToggleNavigationBar(indexNavigationBar)
 {
    var naviToggle = document.getElementById("dcw_navitoggle" + indexNavigationBar);
    var naviFrame = document.getElementById("dcw_naviframe" + indexNavigationBar);
 
    if(!naviFrame || !naviToggle) {
        return false;
    }
 
    // if shown now
    if(naviToggle.firstChild.data == strNavigationBarHide) {
        for(var naviChild = naviFrame.firstChild; naviChild != null; naviChild = naviChild.nextSibling) {
            if(naviChild.className == "dcw_navipicture") {
                naviChild.style.display = "none";
            }
            if(naviChild.className == "dcw_navicontent") {
                naviChild.style.display = "none";
            }
            if(naviChild.className == "dcw_navitoggle") {
                naviChild.firstChild.data = strNavigationBarShow;
            }
        }
 
    // if hidden now
    } else if(naviToggle.firstChild.data == strNavigationBarShow) {
        for(var naviChild = naviFrame.firstChild; naviChild != null; naviChild = naviChild.nextSibling) {
            if(naviChild.className == "dcw_navipicture") {
                naviChild.style.display = "block";
            }
            if(naviChild.className == "dcw_navicontent") {
                naviChild.style.display = "block";
            }
            if(naviChild.className == "dcw_navitoggle") {
                naviChild.firstChild.data = strNavigationBarHide;
            }
        }
    }
 }
 
 // adds show/hide-button to navigation bars
 function CreateNavigationBarToggleButton()
 {
    var indexNavigationBar = 0;
    // iterate over all <div>-elements
    for(var i = 0; naviFrame = document.getElementsByTagName("div")[i]; ++i) {
        // if found a navigation bar
        if(naviFrame.className == "dcw_naviframe") {
            ++indexNavigationBar;
            var naviToggle = document.createElement("a");
            naviToggle.className = "dcw_navitoggle";
            naviToggle.setAttribute("id", "dcw_navitoggle" + indexNavigationBar);
            NavToggle.setAttribute("href", "javascript:ToggleNavigationBar(" + indexNavigationBar + ");");
 
            var naviToggleText = document.createTextNode(strNavigationBarHide);
            naviToggle.appendChild(naviToggleText);
 
            // add naviToggle-Button as first div-element 
            // in <div class="dcw_naviframe">
            naviFrame.insertBefore(naviToggle, naviFrame.firstChild);
            naviFrame.setAttribute("id", "dcw_naviframe" + indexNavigationBar);
        }
    }
    // if more navigation bars found than default: hide all
    if(navigationBarShowDefault < indexNavigationBar) {
        for(var i = 1; i <= indexNavigationBar; ++i) {
            ToggleNavigationBar(i);
        }
    }
 }
 
 HookEvent("load", CreateNavigationBarToggleButton);
 
 // END Dynamic Navigation Bars
 // ============================================================