Zum Inhalt springen
MediaWiki:Common.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
TiKu (Diskussion | Beiträge) |
TiKu (Diskussion | Beiträge) |
||
Zeile 21: | Zeile 21: | ||
// END Event Hooking | // END Event Hooking | ||
// ============================================================ | // ============================================================ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
// ============================================================ | // ============================================================ |
Version vom 25. September 2014, 00:12 Uhr
/* Jedes JavaScript hier wird für alle Benutzer für jede Seite geladen. */ var userAgent = navigator.userAgent.toLowerCase(); var ua_webtv = (userAgent.indexOf('webtv') != -1); var ua_safari = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.')); var ua_opera = ((userAgent.indexOf('opera') != -1) || (typeof(window.opera) != 'undefined')); var ua_iexplorer = ((userAgent.indexOf('msie') != -1) && (!ua_opera) && (!ua_safari) && (!ua_webtv)); var ua_iexplorer7 = ((ua_iexplorer) && (userAgent.indexOf('msie 7.') != -1)); // ============================================================ // 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 AJAX Teamstatistiken var dcw_TeamStatsLoader = null; function TeamStatsLoader(statsSpan, project) { project = encodeURIComponent(project); this.statsSpan = statsSpan; this.project = project; this.xml_sender = null; this.teamPosition = ''; var me = this; this.OnLoadReadyStateChange = function() { if(me.xml_sender.handler.readyState == 4 && me.xml_sender.handler.status == 200) { if(me.xml_sender.handler.responseXML) { me.teamPosition = me.xml_sender.fetch_data(fetch_tags(me.xml_sender.handler.responseXML, 'worldrank')[0]); } if(me.teamPosition.length == 0) { me.teamPosition = "n/a"; } if(ua_iexplorer) { me.xml_sender.handler.abort(); } var textNode = document.createTextNode(me.teamPosition); me.statsSpan.innerHTML = textNode.nodeValue; } } this.xml_sender = new DCW_AJAX_Handler(true); this.xml_sender.onreadystatechange(this.OnLoadReadyStateChange); this.xml_sender.send('../livestats/ajax.php?do=getworldrank&project=' + me.project, 'do=getworldrank&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 projectName = statsSpan.id.replace(/.40/g, "@"); projectName = projectName.replace(/_/g, " "); projectName = projectName.replace(/.2B/g, "+"); dcw_TeamStatsLoader = new TeamStatsLoader(statsSpan, projectName); } } } HookEvent("load", LoadTeamStats); // END AJAX Teamstatistiken // ============================================================ // ============================================================ // BEGIN AJAX DCW_AJAX_Handler function DCW_AJAX_Handler(async) { this.async = async; } DCW_AJAX_Handler.prototype.init = function() { if(typeof XMLHttpRequest != "undefined") { this.handler = new XMLHttpRequest(); return (this.handler.setRequestHeader ? true : false); } else if(ua_iexplorer && !ua_iexplorer7) { this.handler = eval("new Activ" + "eX" + "Ob" + "ject('Micr" + "osoft.XM" + "LHTTP');"); return true; } else { return false; } } DCW_AJAX_Handler.prototype.not_ready = function() { return (this.handler.readyState && (this.handler.readyState < 4)); } DCW_AJAX_Handler.prototype.onreadystatechange = function(event) { if(!this.handler) { if(!this.init()) { return false; } } if(typeof event == 'function') { this.handler.onreadystatechange = event; } return false; } DCW_AJAX_Handler.prototype.send = function(desturl, datastream) { if(!this.handler) { if(!this.init()) { return false; } } if(!this.not_ready()) { this.handler.open('POST', desturl, this.async); this.handler.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); this.handler.send(datastream + '&s=' + fetch_sessionhash()); if(!this.async && this.handler.readyState == 4 && this.handler.status == 200) { return true; } } return false; } DCW_AJAX_Handler.prototype.fetch_data = function(xml_node) { if(xml_node && xml_node.firstChild && xml_node.firstChild.nodeValue) { return PHP.unescape_cdata(xml_node.firstChild.nodeValue); } else { return ''; } } // END AJAX DCW_AJAX_Handler // ============================================================