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

Zur Navigation springen Zur Suche springen
K
updated, kategorien anzeigen bei bildern, brauche ich oft :)
KKeine Bearbeitungszusammenfassung
K (updated, kategorien anzeigen bei bildern, brauche ich oft :))
Zeile 1:
 
var id=null;
 
function mainTotto(){
Zeile 22 ⟶ 23:
var container4 = document.createElement("li");
container4.setAttribute("class","TottoCustomContainer");
container4.innerHTML='<a onclick="onlinecounterrefresh()" dir="auto" title="Online Counter">0</a>';
container4.setAttribute("id","TottoOnlineCounter");
containerQuickJump.prepend(container4);
Zeile 30 ⟶ 31:
//AddAcessKeys();
onlinecounter();
id=setInterval(onlinecounter,60*1000)
alertinit()
isDatei()
}
Zeile 112 ⟶ 116:
function refresh(){
onlinecounter();
var url="https://conanwiki.org/wiki/Spezial:Wer_ist_gerade_online"
window.open(url,"_blank")
}
 
Zeile 129 ⟶ 135:
num=c.getElementsByTagName("ul")[0].getElementsByTagName("li").length;
cont.innerHTML=num;
//console.log(num);
}catch(err) {
// There was an error
Zeile 137 ⟶ 143:
});
 
 
}
 
function isDatei(){
var is=window.location.pathname.split("/").map((a)=>{return a.startsWith("Datei:")}).reduce((a,b)=>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((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(()=>{
var d=document.getElementById("alert-box") ;
d.style.display="none";
d.classList.remove("fade-out-20");
},20*1000);
 
}
1.060

Bearbeitungen

Navigationsmenü