Page MenuHomePhabricator

import_diff.patch

Authored By
bzimport
Nov 21 2014, 10:06 PM
Size
1 KB
Referenced Files
None
Subscribers
None

import_diff.patch

Index: skins/common/wikibits.js
===================================================================
--- skins/common/wikibits.js (revision 31607)
+++ skins/common/wikibits.js (working copy)
@@ -27,7 +27,11 @@
function addOnloadHook(hookFunct) {
// Allows add-on scripts to add onload functions
- onloadFuncts[onloadFuncts.length] = hookFunct;
+ if(!doneOnloadHook) {
+ onloadFuncts[onloadFuncts.length] = hookFunct;
+ } else {
+ hookFunct(); // bug in MSIE script loading
+ }
}
function hookEvent(hookName, hookFunct) {
@@ -38,6 +42,41 @@
}
}
+function importScript(page) {
+ return importScriptURI(wgScript + '?action=raw&ctype=text/javascript&title=' + encodeURIComponent(page.replace(/ /g,'_')));
+}
+
+var loadedScripts = {}; // included-scripts tracker
+function importScriptURI(url) {
+ if (loadedScripts[url]) {
+ return;
+ }
+ loadedScripts[url] = true;
+ var s = document.createElement('script');
+ s.setAttribute('src',url);
+ s.setAttribute('type','text/javascript');
+ document.getElementsByTagName('head')[0].appendChild(s);
+ return s;
+}
+
+function importStylesheet(page) {
+ return importStylesheetURI(wgScript + '?action=raw&ctype=text/css&title=' + encodeURIComponent(page.replace(/ /g,'_')));
+}
+
+function importStylesheetURI(url) {
+ return document.createStyleSheet ? document.createStyleSheet(url) : appendCSS('@import "' + url + '";');
+}
+
+function appendCSS(text) {
+ var s = document.createElement('style');
+ s.type = 'text/css';
+ s.rel = 'stylesheet';
+ if (s.styleSheet) s.styleSheet.cssText = text //IE
+ else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null
+ document.getElementsByTagName('head')[0].appendChild(s);
+ return s;
+}
+
// document.write special stylesheet links
if (typeof stylepath != 'undefined' && typeof skin != 'undefined') {
if (is_opera_preseven) {

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4323
Default Alt Text
import_diff.patch (1 KB)

Event Timeline