Benutzer:Totto/common.js: Unterschied zwischen den Versionen

Aus ConanWiki
Zur Navigation springen Zur Suche springen
Inhalt hinzugefügt Inhalt gelöscht
K (Männo Es6 :()
K (Änderungen, damit es nicht zu früh geladen wird)
 
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
  +
var id = null;
   
  +
function mainTotto() {
var id=null;
 
   
  +
var tf = document.getElementById("p-personal");
function mainTotto(){
 
  +
var containerQuickJump = tf.getElementsByTagName("ul")[0];
 
var tf=document.getElementById("p-personal");
+
var container = document.createElement("li");
  +
container.setAttribute("class", "TottoCustomContainer");
var containerQuickJump= tf.getElementsByTagName("ul")[0];
 
  +
container.innerHTML = '<a href="/wiki/ConanWiki:NextHints" dir="auto" title="Quick Acess Hints" >Hints</a>';
var container = document.createElement("li");
 
container.setAttribute("class","TottoCustomContainer");
+
container.setAttribute("id", "TottoHints");
container.innerHTML='<a href="/wiki/ConanWiki:NextHints" dir="auto" title="Quick Acess Hints" >Hints</a>';
 
container.setAttribute("id","TottoHints");
 
 
containerQuickJump.prepend(container);
 
containerQuickJump.prepend(container);
var container2 = document.createElement("li");
+
var container2 = document.createElement("li");
container2.setAttribute("class","TottoCustomContainer");
+
container2.setAttribute("class", "TottoCustomContainer");
container2.innerHTML='<a href="/wiki/Vorlage:Anime-JP" dir="auto" title="Quick Acess Vorlage JP" >Vorlage JP</a>';
+
container2.innerHTML = '<a href="/wiki/Vorlage:Anime-JP" dir="auto" title="Quick Acess Vorlage JP" >Vorlage JP</a>';
container2.setAttribute("id","TottoVorlageJP");
+
container2.setAttribute("id", "TottoVorlageJP");
 
containerQuickJump.prepend(container2);
 
containerQuickJump.prepend(container2);
var container3 = document.createElement("li");
+
var container3 = document.createElement("li");
container3.setAttribute("class","TottoCustomContainer");
+
container3.setAttribute("class", "TottoCustomContainer");
container3.innerHTML='<a onclick="scrollToBottom();" dir="auto" title="Quick Acess Down" >Downscroll</a>';
+
container3.innerHTML = '<a onclick="scrollToBottom();" dir="auto" title="Quick Acess Down" >Downscroll</a>';
container3.setAttribute("id","TottoScrollDown");
+
container3.setAttribute("id", "TottoScrollDown");
containerQuickJump.prepend(container3);
+
containerQuickJump.prepend(container3);
var container4 = document.createElement("li");
+
var container4 = document.createElement("li");
container4.setAttribute("class","TottoCustomContainer");
+
container4.setAttribute("class", "TottoCustomContainer");
container4.innerHTML='<a onclick="refresh()" dir="auto" title="Online Counter">0</a>';
+
container4.innerHTML = '<a onclick="refresh()" dir="auto" title="Online Counter">0</a>';
container4.setAttribute("id","TottoOnlineCounter");
+
container4.setAttribute("id", "TottoOnlineCounter");
containerQuickJump.prepend(container4);
+
containerQuickJump.prepend(container4);
//addHotkey("s","scrollToBottom");
+
//addHotkey("s","scrollToBottom");
 
//addHotkey("u","scrollToTop");
 
//addHotkey("u","scrollToTop");
//addHotkey("p","preview");
+
//addHotkey("p","preview");
//AddAcessKeys();
+
//AddAcessKeys();
onlinecounter();
+
onlinecounter();
id=setInterval(onlinecounter,60*1000)
+
id = setInterval(onlinecounter, 60 * 1000)
alertinit()
+
alertinit()
isDatei()
+
isDatei()
  +
executeLocalScripts()
}
 
 
function preview(){
 
var ed= document.getElementsByClassName("editButtons");
 
if(ed.length>=1){
 
///Auto HotkeyPreview Preview :yum:
 
var previewbt=document.getElementById("wpPreview");
 
previewbt.click();
 
 
 
}
 
}
  +
  +
function preview() {
  +
var ed = document.getElementsByClassName("editButtons");
  +
if (ed.length >= 1) {
  +
///Auto HotkeyPreview Preview :yum:
  +
var previewbt = document.getElementById("wpPreview");
  +
previewbt.click();
  +
  +
}
 
}
 
}
  +
 
  +
 
function addToQuicklink(title,link){
+
function addToQuicklink(title, link) {
var tf=document.getElementById("p-personal");
+
var tf = document.getElementById("p-personal");
var containerQuickJump= tf.getElementsByTagName("ul")[0];
+
var containerQuickJump = tf.getElementsByTagName("ul")[0];
var container = document.createElement("li");
+
var container = document.createElement("li");
container.setAttribute("class","TottoCustomContainer");
+
container.setAttribute("class", "TottoCustomContainer");
container.innerHTML='<a href="'+link+'" dir="auto" title="Quick Acess '+title+'" >'+title+'</a>';
+
container.innerHTML = '<a href="' + link + '" dir="auto" title="Quick Acess ' + title + '" >' + title + '</a>';
container.setAttribute("id","TottoHints");
+
container.setAttribute("id", "TottoHints");
 
containerQuickJump.prepend(container);
 
containerQuickJump.prepend(container);
   
 
   
   
   
   
  +
}
 
 
function scrollToBottom(){
 
 
window.scrollTo(0,document.body.scrollHeight);
 
 
}
 
}
  +
function scrollToTop(){
 
  +
function scrollToBottom() {
window.scrollTo(0,document,0)
 
  +
 
  +
window.scrollTo(0, document.body.scrollHeight);
 
}
 
}
function addHotkey(hotkey,function_to_call){
 
var num= hotkey.toUpperCase().charCodeAt(0);
 
   
  +
function scrollToTop() {
document.addEventListener("keydown", function(event) { const key = event.keyCode; if(key===num&&event.altKey&&event.shiftKey){ window[function_to_call](); } } );
 
  +
window.scrollTo(0, document, 0)
   
 
}
 
}
   
  +
function addHotkey(hotkey, function_to_call) {
  +
var num = hotkey.toUpperCase().charCodeAt(0);
   
  +
document.addEventListener("keydown", function(event) { const key = event.keyCode; if (key === num && event.altKey && event.shiftKey) { window[function_to_call](); } });
   
function addHotkeyF(hotkey,function_to_call){
 
var num= hotkey.toUpperCase().charCodeAt(0);
 
document.addEventListener("keydown", function(event) { const key = event.keyCode; if(key===num&&event.altKey&&event.shiftKey){ function_to_call(); } } );
 
 
}
 
}
   
   
  +
function getAllElementsWithAttribute(attribute){
 
  +
function addHotkeyF(hotkey, function_to_call) {
var matchingElements = [];
 
  +
var num = hotkey.toUpperCase().charCodeAt(0);
var allElements = document.getElementsByTagName('*');
 
  +
document.addEventListener("keydown", function(event) { const key = event.keyCode; if (key === num && event.altKey && event.shiftKey) { function_to_call(); } });
for (var i = 0, n = allElements.length; i < n; i++){
 
  +
}
if (allElements[i].getAttribute(attribute) !== null) {
 
  +
// Element exists with attribute. Add to array.
 
  +
matchingElements.push(allElements[i]);
 
  +
function getAllElementsWithAttribute(attribute) {
  +
var matchingElements = [];
  +
var allElements = document.getElementsByTagName('*');
  +
for (var i = 0, n = allElements.length; i < n; i++) {
  +
if (allElements[i].getAttribute(attribute) !== null) {
  +
// Element exists with attribute. Add to array.
  +
matchingElements.push(allElements[i]);
  +
}
 
}
 
}
  +
return matchingElements;
}
 
return matchingElements;
 
 
}
 
}
   
function clickf(elementr){
+
function clickf(elementr) {
elementr.click();
+
elementr.click();
 
}
 
}
   
function AddAcessKeys(){
+
function AddAcessKeys() {
var t= getAllElementsWithAttribute("accesskey");
+
var t = getAllElementsWithAttribute("accesskey");
for(var i=0;i<t.length;i++){
+
for (var i = 0; i < t.length; i++) {
var key=t[i].getAttribute("accesskey");
+
var key = t[i].getAttribute("accesskey");
if(key!="."&&key!=""){
+
if (key != "." && key != "") {
addHotkeyF(key,clickf(t[i]));
+
addHotkeyF(key, clickf(t[i]));
  +
}
}
 
  +
 
  +
}
}
 
  +
 
  +
 
 
}
 
}
  +
function refresh(){
 
  +
function refresh() {
onlinecounter();
 
  +
onlinecounter();
var url="https://conanwiki.org/wiki/Spezial:Wer_ist_gerade_online"
 
  +
var url = "https://conanwiki.org/wiki/Spezial:Wer_ist_gerade_online"
window.open(url,"_blank")
 
  +
window.open(url, "_blank")
 
}
 
}
   
function onlinecounter(){
+
function onlinecounter() {
var url="https://conanwiki.org/wiki/Spezial:Wer_ist_gerade_online"
+
var url = "https://conanwiki.org/wiki/Spezial:Wer_ist_gerade_online"
fetch(url).then(function (response) {
+
fetch(url).then(function(response) {
// The API call was successful!
+
// The API call was successful!
return response.text();
+
return response.text();
}).then(function (html) {
+
}).then(function(html) {
try{
+
try {
var num=0;
+
var num = 0;
// Convert the HTML string into a document object
+
// Convert the HTML string into a document object
var parser = new DOMParser();
+
var parser = new DOMParser();
var doc = parser.parseFromString(html, 'text/html');
+
var doc = parser.parseFromString(html, 'text/html');
var cont=document.getElementById("TottoOnlineCounter").getElementsByTagName("a")[0];
+
var cont = document.getElementById("TottoOnlineCounter").getElementsByTagName("a")[0];
var c=doc.getElementById("mw-content-text");
+
var c = doc.getElementById("mw-content-text");
num=c.getElementsByTagName("ul")[0].getElementsByTagName("li").length;
+
var t = c.getElementsByTagName("ul")[0].getElementsByTagName("li")
  +
num = t.length;
cont.innerHTML=num;
 
  +
window["users"] = []
//console.log(num);
 
  +
window["nums"] = {}
}catch(err) {
 
  +
for (var i = 0; i < t.length; i++) {
// There was an error
 
  +
var r = t[i].getElementsByTagName("a")[0]
console.warn('Something went wrong.', err);
 
  +
//console.log(r.innerHTML)
document.getElementById("TottoOnlineCounter").getElementsByTagName("a")[0].innerHTML=0;
 
  +
var u = window.getComputedStyle(r, null).color
}
 
  +
window["users"].push(u);
});
 
  +
var key = u.split(" ").join("")
  +
if (window["nums"][key]) {
  +
window["nums"][key] = window["nums"][key] + 1
  +
} else {
  +
window["nums"][key] = 1
  +
}
  +
}
  +
cont.innerHTML = Object.entries(window["nums"]).map(function(a) { return "<a style='color:" + a[0] + ";margin-left:10px;'>" + a[1] + "</a>" }).join("")
  +
//console.log(num);
  +
} catch (err) {
  +
// There was an error
  +
console.warn('Something went wrong.', err);
  +
document.getElementById("TottoOnlineCounter").getElementsByTagName("a")[0].innerHTML = 0;
  +
}
  +
});
  +
   
 
   
 
}
 
}
   
function isDatei(){
+
function isDatei() {
var is=window.location.pathname.split("/").map(function (a){return a.startsWith("Datei:")}).reduce(function (a,b){return a||b})
+
var is = window.location.pathname.split("/").map(function(a) { return a.startsWith("Datei:") }).reduce(function(a, b) { return a || b })
if(is){
+
if (is) {
document.getElementById("file").addEventListener('contextmenu',getText,false)
+
document.getElementById("file").addEventListener('contextmenu', getText, false)
  +
}
}
 
   
 
}
 
}
  +
function getText(){
 
  +
function getText() {
// ev.preventDefault();
 
  +
// ev.preventDefault();
 
// alert('success!');
 
// alert('success!');
 
// return false;
 
// return false;
var url="https://conanwiki.org/index.php?title="+(window.location.pathname.split("/").reduce(function (a,b){return b}))+"&action=edit"
+
var url = "https://conanwiki.org/index.php?title=" + (window.location.pathname.split("/").reduce(function(a, b) { return b })) + "&action=edit"
fetch(url).then(function (response) {
+
fetch(url).then(function(response) {
// The API call was successful!
+
// The API call was successful!
return response.text();
+
return response.text();
}).then(function (html) {
+
}).then(function(html) {
try{
+
try {
var num=0;
+
var num = 0;
// Convert the HTML string into a document object
+
// Convert the HTML string into a document object
var parser = new DOMParser();
+
var parser = new DOMParser();
var doc = parser.parseFromString(html, 'text/html');
+
var doc = parser.parseFromString(html, 'text/html');
var text=doc.getElementById("wpTextbox1").innerHTML;
+
var text = doc.getElementById("wpTextbox1").innerHTML;
navigator.clipboard.writeText(text);
+
navigator.clipboard.writeText(text);
alertSucess("Inhalt kopiert");
+
alertSucess("Inhalt kopiert");
}catch(err) {
+
} catch (err) {
// There was an error
+
// There was an error
console.warn('Something went wrong.', err);
+
console.warn('Something went wrong.', err);
document.getElementById("TottoOnlineCounter").getElementsByTagName("a")[0].innerHTML=0;
+
document.getElementById("TottoOnlineCounter").getElementsByTagName("a")[0].innerHTML = 0;
  +
}
}
 
});
+
});
 
}
 
}
   
function alertinit(){
+
function alertinit() {
var div = document.createElement('div');
+
var div = document.createElement('div');
var style = document.createElement('style');
+
var style = document.createElement('style');
style.innerHTML = '.alert { padding: 20px; background-color: #4bac4f; color: white; margin-bottom: 15px;}.closebtn { margin-left: 15px; color: white; font-weight: bold; float: right; font-size: 22px; line-height: 20px; cursor: pointer; transition: 0.3s;} .closebtn:hover { color: black;} .fade-out-20 { animation: fadeOut ease 20s; -moz-animation: fadeOut ease 20s; } .fade-out-5 { animation: fadeOut ease 5s; -moz-animation: fadeOut ease 5s; } @keyframes fadeOut { 0% { opacity:1; } 100% { opacity:0; } } @-moz-keyframes fadeOut { 0% { opacity:1; } 100% { opacity:0; } } ';
+
style.innerHTML = '.alert { padding: 20px; background-color: #4bac4f; color: white; margin-bottom: 15px;}.closebtn { margin-left: 15px; color: white; font-weight: bold; float: right; font-size: 22px; line-height: 20px; cursor: pointer; transition: 0.3s;} .closebtn:hover { color: black;} .fade-out-20 { animation: fadeOut ease 20s; -moz-animation: fadeOut ease 20s; } .fade-out-5 { animation: fadeOut ease 5s; -moz-animation: fadeOut ease 5s; } @keyframes fadeOut { 0% { opacity:1; } 100% { opacity:0; } } @-moz-keyframes fadeOut { 0% { opacity:1; } 100% { opacity:0; } } ';
div.innerHTML = ' <div id="alert-box" class="alert" style="display:none;position: fixed;top: 50%;z-index: 100;left: 25%;width: 50%;text-align: center;font-size: 49px;"><span onclick="this.parentElement.style.display=\'none\'" class="closebtn" style="font-size: 63px;">×</span><span id="alert-text">Alert</span></div>';
+
div.innerHTML = ' <div id="alert-box" class="alert" style="display:none;position: fixed;top: 50%;z-index: 100;left: 25%;width: 50%;text-align: center;font-size: 49px;"><span onclick="this.parentElement.style.display=\'none\'" class="closebtn" style="font-size: 63px;">×</span><span id="alert-text">Alert</span></div>';
document.head.appendChild(style);
+
document.head.appendChild(style);
document.body.appendChild(div);
+
document.body.appendChild(div);
 
}
 
}
   
function alertSucess(text){
+
function alertSucess(text) {
alert(text,"#4bac4f");
+
alert(text, "#4bac4f");
 
}
 
}
   
function alert(text,color){
+
function alert(text, color) {
var d=document.getElementById("alert-box") ;
+
var d = document.getElementById("alert-box");
d.classList.remove("fade-out-20");
+
d.classList.remove("fade-out-20");
d.style.display="block";
+
d.style.display = "block";
d.style.opacity=1;
+
d.style.opacity = 1;
d.style["background-color"]=color;
+
d.style["background-color"] = color;
d.classList.add("fade-out-20");
+
d.classList.add("fade-out-20");
var t=document.getElementById("alert-text");
+
var t = document.getElementById("alert-text");
t.innerHTML=text;
+
t.innerHTML = text;
setTimeout(function (){
+
setTimeout(function() {
var d=document.getElementById("alert-box") ;
+
var d = document.getElementById("alert-box");
d.style.display="none";
+
d.style.display = "none";
d.classList.remove("fade-out-20");
+
d.classList.remove("fade-out-20");
},20*1000);
+
}, 20 * 1000);
   
 
}
 
}
   
  +
function executeLocalScripts() {
  +
if (!window.LocalScript) {
  +
window.LocalScript = {};
  +
}
  +
if (window.LocalScript.wiki) {
  +
window.LocalScript.wiki();
  +
} else {
  +
window.LocalScript.startWiki = true;
  +
}
  +
}
   
   
  +
function domReady(fn) {
mainTotto();
 
  +
document.addEventListener("DOMContentLoaded", fn);
  +
if (document.readyState === "interactive" || document.readyState === "complete" ) {
  +
fn();
  +
}
  +
}
  +
  +
domReady(mainTotto);

Aktuelle Version vom 6. November 2021, 20:42 Uhr

var id = null;

function mainTotto() {

    var tf = document.getElementById("p-personal");
    var containerQuickJump = tf.getElementsByTagName("ul")[0];
    var container = document.createElement("li");
    container.setAttribute("class", "TottoCustomContainer");
    container.innerHTML = '<a href="/wiki/ConanWiki:NextHints" dir="auto" title="Quick Acess Hints" >Hints</a>';
    container.setAttribute("id", "TottoHints");
    containerQuickJump.prepend(container);
    var container2 = document.createElement("li");
    container2.setAttribute("class", "TottoCustomContainer");
    container2.innerHTML = '<a href="/wiki/Vorlage:Anime-JP" dir="auto" title="Quick Acess Vorlage JP" >Vorlage JP</a>';
    container2.setAttribute("id", "TottoVorlageJP");
    containerQuickJump.prepend(container2);
    var container3 = document.createElement("li");
    container3.setAttribute("class", "TottoCustomContainer");
    container3.innerHTML = '<a onclick="scrollToBottom();" dir="auto" title="Quick Acess Down" >Downscroll</a>';
    container3.setAttribute("id", "TottoScrollDown");
    containerQuickJump.prepend(container3);
    var container4 = document.createElement("li");
    container4.setAttribute("class", "TottoCustomContainer");
    container4.innerHTML = '<a onclick="refresh()" dir="auto" title="Online Counter">0</a>';
    container4.setAttribute("id", "TottoOnlineCounter");
    containerQuickJump.prepend(container4);
    //addHotkey("s","scrollToBottom");
    //addHotkey("u","scrollToTop");
    //addHotkey("p","preview");
    //AddAcessKeys();
    onlinecounter();
    id = setInterval(onlinecounter, 60 * 1000)
    alertinit()
    isDatei()
    executeLocalScripts()
}

function preview() {
    var ed = document.getElementsByClassName("editButtons");
    if (ed.length >= 1) {
        ///Auto HotkeyPreview Preview :yum:
        var previewbt = document.getElementById("wpPreview");
        previewbt.click();

    }
}


function addToQuicklink(title, link) {
    var tf = document.getElementById("p-personal");
    var containerQuickJump = tf.getElementsByTagName("ul")[0];
    var container = document.createElement("li");
    container.setAttribute("class", "TottoCustomContainer");
    container.innerHTML = '<a href="' + link + '" dir="auto" title="Quick Acess ' + title + '" >' + title + '</a>';
    container.setAttribute("id", "TottoHints");
    containerQuickJump.prepend(container);






}

function scrollToBottom() {

    window.scrollTo(0, document.body.scrollHeight);
}

function scrollToTop() {
    window.scrollTo(0, document, 0)

}

function addHotkey(hotkey, function_to_call) {
    var num = hotkey.toUpperCase().charCodeAt(0);

    document.addEventListener("keydown", function(event) { const key = event.keyCode; if (key === num && event.altKey && event.shiftKey) { window[function_to_call](); } });

}



function addHotkeyF(hotkey, function_to_call) {
    var num = hotkey.toUpperCase().charCodeAt(0);
    document.addEventListener("keydown", function(event) { const key = event.keyCode; if (key === num && event.altKey && event.shiftKey) { function_to_call(); } });
}


function getAllElementsWithAttribute(attribute) {
    var matchingElements = [];
    var allElements = document.getElementsByTagName('*');
    for (var i = 0, n = allElements.length; i < n; i++) {
        if (allElements[i].getAttribute(attribute) !== null) {
            // Element exists with attribute. Add to array.
            matchingElements.push(allElements[i]);
        }
    }
    return matchingElements;
}

function clickf(elementr) {
    elementr.click();
}

function AddAcessKeys() {
    var t = getAllElementsWithAttribute("accesskey");
    for (var i = 0; i < t.length; i++) {
        var key = t[i].getAttribute("accesskey");
        if (key != "." && key != "") {
            addHotkeyF(key, clickf(t[i]));
        }

    }


}

function refresh() {
    onlinecounter();
    var url = "https://conanwiki.org/wiki/Spezial:Wer_ist_gerade_online"
    window.open(url, "_blank")
}

function onlinecounter() {
    var url = "https://conanwiki.org/wiki/Spezial:Wer_ist_gerade_online"
    fetch(url).then(function(response) {
        // The API call was successful!
        return response.text();
    }).then(function(html) {
        try {
            var num = 0;
            // Convert the HTML string into a document object
            var parser = new DOMParser();
            var doc = parser.parseFromString(html, 'text/html');
            var cont = document.getElementById("TottoOnlineCounter").getElementsByTagName("a")[0];
            var c = doc.getElementById("mw-content-text");
            var t = c.getElementsByTagName("ul")[0].getElementsByTagName("li")
            num = t.length;
            window["users"] = []
            window["nums"] = {}
            for (var i = 0; i < t.length; i++) {
                var r = t[i].getElementsByTagName("a")[0]
                    //console.log(r.innerHTML)
                var u = window.getComputedStyle(r, null).color
                window["users"].push(u);
                var key = u.split(" ").join("")
                if (window["nums"][key]) {
                    window["nums"][key] = window["nums"][key] + 1
                } else {
                    window["nums"][key] = 1
                }
            }
            cont.innerHTML = Object.entries(window["nums"]).map(function(a) { return "<a style='color:" + a[0] + ";margin-left:10px;'>" + a[1] + "</a>" }).join("")
                //console.log(num);
        } catch (err) {
            // There was an error
            console.warn('Something went wrong.', err);
            document.getElementById("TottoOnlineCounter").getElementsByTagName("a")[0].innerHTML = 0;
        }
    });



}

function isDatei() {
    var is = window.location.pathname.split("/").map(function(a) { return a.startsWith("Datei:") }).reduce(function(a, b) { return a || b })
    if (is) {
        document.getElementById("file").addEventListener('contextmenu', getText, false)
    }

}

function getText() {
    // ev.preventDefault();
    // alert('success!');
    // return false;
    var url = "https://conanwiki.org/index.php?title=" + (window.location.pathname.split("/").reduce(function(a, b) { return b })) + "&action=edit"
    fetch(url).then(function(response) {
        // The API call was successful!
        return response.text();
    }).then(function(html) {
        try {
            var num = 0;
            // Convert the HTML string into a document object
            var parser = new DOMParser();
            var doc = parser.parseFromString(html, 'text/html');
            var text = doc.getElementById("wpTextbox1").innerHTML;
            navigator.clipboard.writeText(text);
            alertSucess("Inhalt kopiert");
        } catch (err) {
            // There was an error
            console.warn('Something went wrong.', err);
            document.getElementById("TottoOnlineCounter").getElementsByTagName("a")[0].innerHTML = 0;
        }
    });
}

function alertinit() {
    var div = document.createElement('div');
    var style = document.createElement('style');
    style.innerHTML = '.alert { padding: 20px; background-color: #4bac4f;  color: white; margin-bottom: 15px;}.closebtn {  margin-left: 15px;  color: white;  font-weight: bold;  float: right;  font-size: 22px;  line-height: 20px;  cursor: pointer;  transition: 0.3s;} .closebtn:hover {  color: black;}   .fade-out-20 {  animation: fadeOut ease 20s; -moz-animation: fadeOut ease 20s; }  .fade-out-5 {  animation: fadeOut ease 5s; -moz-animation: fadeOut ease 5s; } @keyframes fadeOut {  0% {    opacity:1;  }  100% {  opacity:0; } } @-moz-keyframes fadeOut {  0% {    opacity:1;  } 100% { opacity:0; } }  ';
    div.innerHTML = ' <div id="alert-box" class="alert" style="display:none;position: fixed;top: 50%;z-index: 100;left: 25%;width: 50%;text-align: center;font-size: 49px;"><span onclick="this.parentElement.style.display=\'none\'" class="closebtn" style="font-size: 63px;">×</span><span id="alert-text">Alert</span></div>';
    document.head.appendChild(style);
    document.body.appendChild(div);
}

function alertSucess(text) {
    alert(text, "#4bac4f");
}

function alert(text, color) {
    var d = document.getElementById("alert-box");
    d.classList.remove("fade-out-20");
    d.style.display = "block";
    d.style.opacity = 1;
    d.style["background-color"] = color;
    d.classList.add("fade-out-20");
    var t = document.getElementById("alert-text");
    t.innerHTML = text;
    setTimeout(function() {
        var d = document.getElementById("alert-box");
        d.style.display = "none";
        d.classList.remove("fade-out-20");
    }, 20 * 1000);

}

function executeLocalScripts() {
    if (!window.LocalScript) {
        window.LocalScript = {};
    }
    if (window.LocalScript.wiki) {
        window.LocalScript.wiki();
    } else {
        window.LocalScript.startWiki = true;
    }
}


function domReady(fn) {
  document.addEventListener("DOMContentLoaded", fn);
  if (document.readyState === "interactive" || document.readyState === "complete" ) {
    fn();
  }
}

domReady(mainTotto);