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

Aus ConanWiki
Zur Navigation springen Zur Suche springen
Inhalt hinzugefügt Inhalt gelöscht
K (function(){?anon})
K (Wikimedia gat schon hotkeys :fp:)
Zeile 5: Zeile 5:
 
var container = document.createElement("li");
 
var container = document.createElement("li");
 
container.setAttribute("class","TottoCustomContainer");
 
container.setAttribute("class","TottoCustomContainer");
container.innerHTML='<a href="/wiki/ConanWiki:NextHints" dir="auto" title="Quick Acess Hints" accesskey=".">Hints</a>';
+
container.innerHTML='<a href="/wiki/ConanWiki:NextHints" dir="auto" title="Quick Acess Hints" >Hints</a>';
 
container.setAttribute("id","TottoHints");
 
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" accesskey=".">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" accesskey=".">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);
 
 
addHotkey("s","scrollToBottom");
+
//addHotkey("s","scrollToBottom");
addHotkey("p","preview");
+
//addHotkey("u","scrollToTop");
  +
//addHotkey("p","preview");
 
//AddAcessKeys();
 
//AddAcessKeys();
 
}
 
}
Zeile 34: Zeile 35:
 
}
 
}
 
 
  +
  +
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(){
 
function scrollToBottom(){
  +
window.scrollTo(0,document,0)
  +
  +
}
  +
function scrollToTop(){
 
window.scrollTo(0,document.body.scrollHeight);
 
window.scrollTo(0,document.body.scrollHeight);
 
 
 
}
 
}
 
 
function addHotkey(hotkey,function_to_call){
 
function addHotkey(hotkey,function_to_call){
 
var num= hotkey.toUpperCase().charCodeAt(0);
 
var num= hotkey.toUpperCase().charCodeAt(0);
   
document.addEventListener("keydown", function(event) { const key = event.keyCode; if(key===num){ window[function_to_call](); } } );
+
document.addEventListener("keydown", function(event) { const key = event.keyCode; if(key===num&&event.altKey&&event.shiftKey){ window[function_to_call](); } } );
   
 
}
 
}
Zeile 51: Zeile 71:
 
function addHotkeyF(hotkey,function_to_call){
 
function addHotkeyF(hotkey,function_to_call){
 
var num= hotkey.toUpperCase().charCodeAt(0);
 
var num= hotkey.toUpperCase().charCodeAt(0);
document.addEventListener("keydown", function(event) { const key = event.keyCode; if(key===num){ function_to_call(); } } );
+
document.addEventListener("keydown", function(event) { const key = event.keyCode; if(key===num&&event.altKey&&event.shiftKey){ function_to_call(); } } );
 
}
 
}
   

Version vom 1. Februar 2021, 18:54 Uhr

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);		
	
	//addHotkey("s","scrollToBottom");
    //addHotkey("u","scrollToTop");
	//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 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,0)
	
}
function scrollToTop(){
	window.scrollTo(0,document.body.scrollHeight);
	
}
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]));
		}
		
	}
	
	
}


mainTotto();