MediaWiki:Mobile.js: Difference between revisions
Jump to navigation
Jump to search
m (1 revision imported) |
KokoroSenshi (talk | contribs) m (Replaced the Tabs.js with the Gadget Tabs set to run for mobile in addition to desktop) |
||
Line 39: | Line 39: | ||
// copy of the needed parts of `mediawiki.legacy.wikibits` – end | // copy of the needed parts of `mediawiki.legacy.wikibits` – end | ||
// ----------------------------------------------------------------------------- | // ----------------------------------------------------------------------------- | ||
Revision as of 11:35, 3 July 2017
/* Any JavaScript here will be loaded for users using the mobile site */
// -----------------------------------------------------------------------------
// copy of the needed parts of `mediawiki.legacy.wikibits` – begin
// -----------------------------------------------------------------------------
var loadedScripts = {};
function importScript(page) {
var uri = mw.config.get('wgScript') + '?title=' + mw.util.wikiUrlencode(page) + '&action=raw&ctype=text/javascript';
return importScriptURI(uri);
}
function importScriptURI(url) {
if (loadedScripts[url]) {
return null ;
}
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) {
var uri = mw.config.get('wgScript') + '?title=' + mw.util.wikiUrlencode(page) + '&action=raw&ctype=text/css';
return importStylesheetURI(uri);
}
function importStylesheetURI(url, media) {
var l = document.createElement('link');
l.rel = 'stylesheet';
l.href = url;
if (media) {
l.media = media;
}
document.getElementsByTagName('head')[0].appendChild(l);
return l;
}
// -----------------------------------------------------------------------------
// copy of the needed parts of `mediawiki.legacy.wikibits` – end
// -----------------------------------------------------------------------------