MediaWiki:Mobile.js

/* Any JavaScript here will be loaded for users using the mobile site */

/* a bug prevents Mobile.css from loading, this fixes it */ mw.loader.using('mobile.site.styles')

// Made by FunPL with slight help from google

// Utility functions

window.resolveID=function(id){ var replaced = id.replaceAll(".26","&"); replaced = replaced.replaceAll(".21","!"); replaced = replaced.replaceAll(".28","(");   replaced = replaced.replaceAll(".29",")"); replaced = replaced.replaceAll(".CF.89","ω"); replaced = replaced.replaceAll(".7E","~"); replaced = replaced.replaceAll(".27","'"); replaced = replaced.replaceAll(".40","@"); replaced = replaced.replaceAll(".23","#"); replaced = replaced.replaceAll(".24","$"); replaced = replaced.replaceAll(".25","%"); return replaced; }; String.prototype.replaceAll = function(search, replacement) { var target = this; return target.split(search).join(replacement); };

var firstParse = true;

window.parseApi=function(parsetext, fn) { if (firstParse) { setTimeout(parseApi, 1000, parsetext, fn) setTimeout(function {           firstParse = false        }, 900) return }   new mw.Api.get({        action: 'parse',        text: parsetext,        title: mw.config.values.wgPageName,    }).done(function(data) {        const wikitext = data.parse.text['*'];        if (wikitext) {            fn(wikitext);        } else {            fn("")        }    }); };

window.parseApiAdd=function(parsetext, add, fn) { if (firstParse) { setTimeout(parseApiAdd, 1000, parsetext, add, fn) setTimeout(function {           firstParse = false        }, 900) return }   new mw.Api.get({        action: 'parse',        text: parsetext,        title: mw.config.values.wgPageName,    }).done(function(data) {        const wikitext = data.parse.text['*'];        if (wikitext) {            fn(wikitext, add);        } else {            fn("", null)        }    }); };

// Audio players

// Initialize all load buttons

// Load/Unload var unloadedtext = "Load media "; var loadels = document.getElementsByClassName("load-media"); [].forEach.call(loadels, function(el) {   el.innerHTML = unloadedtext + el.id + unloadedtext2; });

// Load/Unload all var loadalltext = "Load all media files "; var unloadalltext = "Unload all media files "; var allels = document.getElementsByClassName("loadall-media"); var allels2 = document.getElementsByClassName("unloadall-media"); [].forEach.call(allels, function(el) {   el.innerHTML = loadalltext; }); [].forEach.call(allels2, function(el) {   el.innerHTML = unloadalltext; });

window.loadmedia=function(text) { try { if (text.innerHTML == unloadedtext + text.id + unloadedtext2) { text.innerHTML = "Wait "; var id = resolveID(text.id); console.log(text.id); console.log(id); if(id.endsWith('mp4')){ id = id + "|500px" }           parseApi("" + id + "", function(wikitext) {                text.innerHTML = "Unload media " + " " + wikitext;            }); } else { text.innerHTML = unloadedtext + text.id + unloadedtext2; }   } catch (error) { text.innerHTML = "Error "; console.error(error); } }; window.loadallmedia=function { try { [].forEach.call(loadels, function(el) {           loadforce(el)        }); } catch (error) { console.error(error); } };

window.unloadallmedia=function { try { [].forEach.call(loadels, function(el) {           unloadforce(el)        }); } catch (error) { console.error(error); } };

window.loadforce=function(text) { try { if (text.innerHTML == unloadedtext + text.id + unloadedtext2) { text.innerHTML = "Wait "; var id = resolveID(text.id); console.log(text.id); console.log(id); if(id.endsWith('mp4')){ id = id + "|500px" }           parseApi("" + id + "", function(wikitext) {                text.innerHTML = "Unload audio  " + wikitext;            }); }   } catch (error) { text.innerHTML = "Error "; console.error(error); } };

window.unloadforce=function(text) { try { if (text.innerHTML != unloadedtext + text.id + unloadedtext2) { text.innerHTML = unloadedtext + text.id + unloadedtext2; }   } catch (error) { text.innerHTML = "Error "; console.error(error); } };