Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
(25 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
overlay = document.getElementById('overlay'); | overlay = document.getElementById('overlay'); | ||
− | confirmButtons = document.getElementsByClassName('button-confirm'); | + | confirmButtons = Array.from(document.getElementsByClassName('button-confirm')); |
− | cancelButtons = document.getElementsByClassName('button-cancel'); | + | cancelButtons = Array.from(document.getElementsByClassName('button-cancel')); |
+ | cursors = Array.from(document.getElementsByClassName('custom-cursor')); | ||
goBack = function(){ history.back() }; | goBack = function(){ history.back() }; | ||
Line 7: | Line 8: | ||
if(overlay != null){ | if(overlay != null){ | ||
hideOverlay = function(){ overlay.style.visibility = 'hidden' }; | hideOverlay = function(){ overlay.style.visibility = 'hidden' }; | ||
− | + | cancelButtons.forEach(function(butt){ | |
butt.addEventListener('click', goBack); | butt.addEventListener('click', goBack); | ||
− | } | + | }); |
− | + | confirmButtons.forEach(function(butt){ | |
butt.addEventListener('click', hideOverlay ); | butt.addEventListener('click', hideOverlay ); | ||
− | } | + | }); |
} | } | ||
+ | |||
+ | tools = document.getElementById('p-tb').children[1].children[0]; | ||
+ | |||
+ | sideLinks = [ | ||
+ | {'name':'Templates', | ||
+ | 'url' :'https://dwaia.site/wiki/Category:Templates'}, | ||
+ | {'name':'Help expand the lore!', | ||
+ | 'url' :'https://dwaia.site/wiki/Help_expand_the_lore!'} | ||
+ | ] | ||
+ | |||
+ | sideLinks.forEach(function(link){ | ||
+ | var li = document.createElement('li'); | ||
+ | tools.appendChild(li); | ||
+ | var a = document.createElement('a'); | ||
+ | li.appendChild(a); | ||
+ | a.innerText = link.name; | ||
+ | a.href = link.url; | ||
+ | }) | ||
+ | |||
+ | if(cursors.length > 0){ | ||
+ | document.body.style.cursor = 'none'; | ||
+ | cursors.forEach(function(cur){ | ||
+ | cur.style.position = 'fixed'; | ||
+ | cur.style.pointerEvents = 'none'; | ||
+ | cur.style.zIndex = '100'; | ||
+ | }); | ||
+ | document.body.onmousemove = function(event){ | ||
+ | cursors.forEach(function(cur){ | ||
+ | cur.style.left = event.clientX-cur.clientWidth/2+'px'; | ||
+ | cur.style.top = event.clientY-cur.clientHeight/2+'px'; | ||
+ | }); | ||
+ | }; | ||
+ | }; | ||
+ | |||
+ | title = document.getElementById('firstHeading'); | ||
+ | |||
+ | if(title.innerText == "Main Page"){ | ||
+ | subtitle = document.getElementsByClassName("MainpageHeading")[0]; | ||
+ | title.innerHTML = subtitle.innerHTML; | ||
+ | subtitle.outerHTML = ""; | ||
+ | }; |
Latest revision as of 15:42, 13 August 2020
overlay = document.getElementById('overlay'); confirmButtons = Array.from(document.getElementsByClassName('button-confirm')); cancelButtons = Array.from(document.getElementsByClassName('button-cancel')); cursors = Array.from(document.getElementsByClassName('custom-cursor')); goBack = function(){ history.back() }; if(overlay != null){ hideOverlay = function(){ overlay.style.visibility = 'hidden' }; cancelButtons.forEach(function(butt){ butt.addEventListener('click', goBack); }); confirmButtons.forEach(function(butt){ butt.addEventListener('click', hideOverlay ); }); } tools = document.getElementById('p-tb').children[1].children[0]; sideLinks = [ {'name':'Templates', 'url' :'https://dwaia.site/wiki/Category:Templates'}, {'name':'Help expand the lore!', 'url' :'https://dwaia.site/wiki/Help_expand_the_lore!'} ] sideLinks.forEach(function(link){ var li = document.createElement('li'); tools.appendChild(li); var a = document.createElement('a'); li.appendChild(a); a.innerText = link.name; a.href = link.url; }) if(cursors.length > 0){ document.body.style.cursor = 'none'; cursors.forEach(function(cur){ cur.style.position = 'fixed'; cur.style.pointerEvents = 'none'; cur.style.zIndex = '100'; }); document.body.onmousemove = function(event){ cursors.forEach(function(cur){ cur.style.left = event.clientX-cur.clientWidth/2+'px'; cur.style.top = event.clientY-cur.clientHeight/2+'px'; }); }; }; title = document.getElementById('firstHeading'); if(title.innerText == "Main Page"){ subtitle = document.getElementsByClassName("MainpageHeading")[0]; title.innerHTML = subtitle.innerHTML; subtitle.outerHTML = ""; };