Benutzer:Totto/common.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Inhalt hinzugefügt Inhalt gelöscht
Totto (Diskussion | Beiträge) (xD) |
Totto (Diskussion | Beiträge) K (Schlechte Pareser vollen das in einer Zeile :yum:) |
||
Zeile 45: | Zeile 45: | ||
var num= hotkey.toUpperCase().charCodeAt(0); |
var num= hotkey.toUpperCase().charCodeAt(0); |
||
− | document.addEventListener("keydown", event => |
+ | document.addEventListener("keydown", event => { const key = event.keyCode;if(key==num){ window[function_to_call]() } } ); |
− | { const key = event.keyCode; |
||
− | if(key==num){ window[function_to_call]() } |
||
− | |||
− | } ); |
||
} |
} |
Version vom 1. Februar 2021, 17:31 Uhr
function mainTotto(){ var containerQuickJump=document.getElementById("p-personal").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" accesskey=".">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" accesskey=".">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" accesskey=".">Downscroll</a>'; container3.setAttribute("id","TottoScrollDown"); containerQuickJump.prepend(container3); addHotkey("s","scrollToBottom"); addHotkey("p","preview"); //AddAcessKeys(); } function preview(){ var ed= document.getElementsByClassName("editButtons"); if(ed.length>=1){ ///Auto HotkeyPreview Preview :yum: var previewbt=document.getElementById("wpPreview"); previewbt.click(); } } function scrollToBottom(){ window.scrollTo(0,document.body.scrollHeight); } function addHotkey(hotkey,function_to_call){ var num= hotkey.toUpperCase().charCodeAt(0); document.addEventListener("keydown", event => { const key = event.keyCode;if(key==num){ window[function_to_call]() } } ); } function addHotkeyF(hotkey,function_to_call){ var num= hotkey.toUpperCase().charCodeAt(0); document.addEventListener("keydown", event => { const key = event.keyCode; if(key==num){ 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])); } } } mainTotto();