Zum Inhalt springen
MediaWiki:Common.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
TiKu (Diskussion | Beiträge) (Navi-Toggle-Button als Bild) |
TiKu (Diskussion | Beiträge) (Navi-Toggle-Button als Bild) |
||
Zeile 28: | Zeile 28: | ||
function ToggleNavigationBar(indexNavigationBar) | function ToggleNavigationBar(indexNavigationBar) | ||
{ | { | ||
− | var | + | var naviToggleImg = document.getElementById("dcw_navitoggleimg" + indexNavigationBar); |
var naviFrame = document.getElementById("dcw_naviframe" + indexNavigationBar); | var naviFrame = document.getElementById("dcw_naviframe" + indexNavigationBar); | ||
− | if(!naviFrame || ! | + | if(!naviFrame || !naviToggleImg) { |
return false; | return false; | ||
} | } | ||
// if shown now | // if shown now | ||
− | if( | + | if(naviToggleImg.getAttribute("alt") == strNavigationBarHide) { |
for(var naviChild = naviFrame.firstChild; naviChild != null; naviChild = naviChild.nextSibling) { | for(var naviChild = naviFrame.firstChild; naviChild != null; naviChild = naviChild.nextSibling) { | ||
if(naviChild.className == "dcw_navipicture") { | if(naviChild.className == "dcw_navipicture") { | ||
Zeile 44: | Zeile 44: | ||
naviChild.style.display = "none"; | naviChild.style.display = "none"; | ||
} | } | ||
− | if(naviChild.className == " | + | if(naviChild.className == "dcw_navitoggleimg") { |
− | naviChild. | + | naviChild.setAttribute("alt", strNavigationBarShow); |
+ | naviChild.setAttribute("src", "http://www.planet3dnow.de/vbulletin/images/buttons/collapse_tcat_collapsed.gif"); | ||
} | } | ||
} | } | ||
// if hidden now | // if hidden now | ||
− | } else if(naviToggle. | + | } else if(naviToggle.getAttribute("alt") == strNavigationBarShow) { |
for(var naviChild = naviFrame.firstChild; naviChild != null; naviChild = naviChild.nextSibling) { | for(var naviChild = naviFrame.firstChild; naviChild != null; naviChild = naviChild.nextSibling) { | ||
if(naviChild.className == "dcw_navipicture") { | if(naviChild.className == "dcw_navipicture") { | ||
Zeile 58: | Zeile 59: | ||
naviChild.style.display = "block"; | naviChild.style.display = "block"; | ||
} | } | ||
− | if(naviChild.className == " | + | if(naviChild.className == "dcw_navitoggleimg") { |
− | naviChild. | + | naviChild.setAttribute("alt", strNavigationBarHide); |
+ | naviChild.setAttribute("src", "http://www.planet3dnow.de/vbulletin/images/buttons/collapse_tcat.gif"); | ||
} | } | ||
} | } | ||
Zeile 79: | Zeile 81: | ||
naviToggle.setAttribute("href", "javascript:ToggleNavigationBar(" + indexNavigationBar + ");"); | naviToggle.setAttribute("href", "javascript:ToggleNavigationBar(" + indexNavigationBar + ");"); | ||
− | + | var naviToogleImg = document.createElement("img"); | |
− | //naviToggle.appendChild( | + | naviToogleImg.setAttribute("id", "dcw_navitoggleimg" + indexNavigationBar); |
+ | naviToogleImg.setAttribute("border", "0"); | ||
+ | naviToogleImg.setAttribute("alt", strNavigationBarHide); | ||
+ | naviToggleImg.setAttribute("src", "http://www.planet3dnow.de/vbulletin/images/buttons/collapse_tcat.gif"); | ||
+ | naviToggle.appendChild(naviToggleImg); | ||
// add naviToggle-Button as first div-element | // add naviToggle-Button as first div-element |
Version vom 2. Juli 2007, 17:55 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 naviToggleImg = document.getElementById("dcw_navitoggleimg" + indexNavigationBar); var naviFrame = document.getElementById("dcw_naviframe" + indexNavigationBar); if(!naviFrame || !naviToggleImg) { return false; } // if shown now if(naviToggleImg.getAttribute("alt") == 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_navitoggleimg") { naviChild.setAttribute("alt", strNavigationBarShow); naviChild.setAttribute("src", "http://www.planet3dnow.de/vbulletin/images/buttons/collapse_tcat_collapsed.gif"); } } // if hidden now } else if(naviToggle.getAttribute("alt") == 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_navitoggleimg") { naviChild.setAttribute("alt", strNavigationBarHide); naviChild.setAttribute("src", "http://www.planet3dnow.de/vbulletin/images/buttons/collapse_tcat.gif"); } } } } // 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); naviToggle.setAttribute("href", "javascript:ToggleNavigationBar(" + indexNavigationBar + ");"); var naviToogleImg = document.createElement("img"); naviToogleImg.setAttribute("id", "dcw_navitoggleimg" + indexNavigationBar); naviToogleImg.setAttribute("border", "0"); naviToogleImg.setAttribute("alt", strNavigationBarHide); naviToggleImg.setAttribute("src", "http://www.planet3dnow.de/vbulletin/images/buttons/collapse_tcat.gif"); naviToggle.appendChild(naviToggleImg); // 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 // ============================================================ // ============================================================ // BEGIN AJAX Teamstatistiken var dcw_TeamStatsLoader = null; function TeamStatsLoader(statsSpan, project) { this.statsSpan = statsSpan; this.project = project; this.xml_sender = null; this.teamPosition = ''; var me = this; this.OnLoadReadyStateChange = function() { //alert("in OnLoadReadyStateChange()"); if(me.xml_sender.handler.readyState == 4 && me.xml_sender.handler.status == 200) { alert(me.xml_sender.handler.responseXML); if(me.xml_sender.handler.responseXML) { me.teamPosition = me.xml_sender.fetch_data(fetch_tags(me.xml_sender.handler.responseXML, 'teamposition')); } if(is_ie) { me.xml_sender.handler.abort(); } var textNode = document.createTextNode(me.teamPosition); me.statsSpan.appendChild(textNode); } } // TODO: implement a replacement for vB_AJAX_Handler this.xml_sender = new vB_AJAX_Handler(true); this.xml_sender.onreadystatechange(this.OnLoadReadyStateChange); // TODO: change ajax.php this.xml_sender.send('ajax.php?do=getteamposition&project=' + me.project, 'do=getteamposition&project=' + me.project); } function LoadTeamStats() { // iterate over all < span >-elements for(var i = 0; statsSpan = document.getElementsByTagName("span")[i]; ++i) { if(statsSpan.className == "dcw_span_teamstats") { var friendlyProjectName = statsSpan.id.replace(/.40/g, "@"); dcw_TeamStatsLoader = new TeamStatsLoader(statsSpan, friendlyProjectName); } } } HookEvent("load", LoadTeamStats); // END AJAX Teamstatistiken // ============================================================