MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
David Mason (talk | contribs) No edit summary |
David Mason (talk | contribs) No edit summary |
||
Line 14: | Line 14: | ||
include('/js/jquery.timers-1.1.2.js'); | include('/js/jquery.timers-1.1.2.js'); | ||
include('/js/loadgallery.js'); | include('/js/loadgallery.js'); | ||
onload=function(){ | |||
if (document.getElementsByClassName == undefined) { | |||
document.getElementsByClassName = function(className) { | |||
var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)"); | |||
var allElements = document.getElementsByTagName("*"); | |||
var results = []; | |||
var element; | |||
for (var i = 0; (element = allElements[i]) != null; i++) { | |||
var elementClass = element.className; | |||
if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass)) | |||
results.push(element); | |||
} | |||
return results; | |||
} | |||
} | |||
makeExt('external'); | |||
function makeExt(lclass) { | |||
links = document.getElementsByClassName(lclass); | |||
// add onClick handler to links | |||
for (var i = 0; (element = links[i]) != null; i++) { | |||
element.href = "/frame/?l="+escape(element.href); | |||
} | |||
} | |||
} |
Revision as of 01:48, 30 July 2010
/* Any JavaScript here will be loaded for all users on every page load. */
function include(destination) {
var e=window.document.createElement('script');
e.setAttribute('type','text/javascript');
e.setAttribute('src',destination);
document.getElementsByTagName('head')[0].appendChild(e);
}
include('/js/jquery-1.3.2.min.js');
include('/js/jquery.easing.1.3.js');
include('/js/jquery.galleryview-1.1.js');
include('/js/jquery.timers-1.1.2.js');
include('/js/loadgallery.js');
onload=function(){
if (document.getElementsByClassName == undefined) {
document.getElementsByClassName = function(className) {
var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
var allElements = document.getElementsByTagName("*");
var results = [];
var element;
for (var i = 0; (element = allElements[i]) != null; i++) {
var elementClass = element.className;
if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
results.push(element);
}
return results;
}
}
makeExt('external');
function makeExt(lclass) {
links = document.getElementsByClassName(lclass);
// add onClick handler to links
for (var i = 0; (element = links[i]) != null; i++) {
element.href = "/frame/?l="+escape(element.href);
}
}
}