User:Blue-Haired Lawyer/vector.js
Jump to navigation
Jump to search
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the central discussion page, Scriptorium. The code will be executed when previewing this page under some skins, including Monobook. You can in the interim if you wish to refresh the content sooner under another skin. |
The accompanying .css page for this skin is at User:Blue-Haired Lawyer/vector.css. |
// To make this script work you need to add the following to you style sheet (vector.css):
// +--------------------------------------------------------------------+
// | #mw-panel { visibility: hidden !important; } |
// | #mw-head-base { margin-left: 0 !important; } |
// | #content { margin-left: 0 !important; } |
// | #left-navigation { margin-left: 1em !important; } |
// | #footer { margin-left: 0 !important; } |
// +--------------------------------------------------------------------+
// ie or firefox
var whichText = document.body.textContent ? 'textContent' : 'innerText';
if ( mw.config.get( 'skin' ) == 'vector' ) {
if (document.readyState === "complete") { initWideSkin(); }
else { $( initWideSkin ); }
}
// set viewport for mobile devices
myView = document.createElement("meta");
myView.setAttribute("name", "viewport");
myView.setAttribute("content", "width=device-width, initial-scale=1.0, minimal-scale=1.0, maximal-scale=1.0");
document.getElementsByTagName("head")[0].appendChild(myView);
// Insert head banner
myDiv = document.createElement("DIV");
myLink = document.createElement("A");
myDiv.appendChild(myLink);
myDiv.id = 'myNewBanner';
myDiv.setAttribute("style", "position: absolute; top: 5px; left: 15px; font: 31pt Times; font-variant: small-caps; z-index: 999999;");
myDiv.className = 'noprint';
myLink.href = mw.config.get( 'wgArticlePath' ).replace('$1', '');
myLink.setAttribute("style", "color: black; text-decoration: none;");
var siteName = mw.config.get( 'wgSiteName' );
if(siteName == 'Wikipedia') { siteName = 'WikipediA'; }
myLink.innerHTML = siteName;
document.getElementById("mw-head").appendChild(myDiv);
function initWideSkin() {
// place certain (less used) links in the footer
transferChildren("#t-permalink A, #t-cite A, #p-coll-print_export A", "#footer-places");
// move toolbox to drop down menu
// do this before creating icon menu
transferChildren("#p-tb LI A", "#p-cactions ul");
// Make visible
document.getElementById("p-cactions").style.display = 'block';
// language links
var langChildren = document.querySelectorAll("#p-lang UL A");
if(langChildren !== null && langChildren.length > 0) {
var addLinks = document.querySelector('.wbc-editpage > a');
if(addLinks !== null) {
addLinks.innerHTML = 'Add language links';
}
//list
var langList = document.createElement("UL");
langList.id = 'langList';
langList.style.fontSize = "0.8em";
// interwiki list
transferChildren(langChildren, langList);
// language banner
var lbanner = document.createElement("DIV");
lbanner.id = "lbanner";
lbanner.className = "catlinks noprint";
lbanner.appendChild(langList);
document.getElementById("content").appendChild(lbanner);
}
// Create a wiki menu for navigation and interaction links
// node.cloneNode(true) doesn't copy css stuff properly
var vectorMenu = document.getElementById('p-cactions');
var newMenu = document.createElement("NAV");
newMenu.id = 'faviconMenu';
newMenu.innerHTML = vectorMenu.innerHTML;
newMenu.className = vectorMenu.className;
// Change ids and clear content
newMenu.querySelector('h3').id = 'p-favicon-label';
newMenu.querySelector('span').innerHTML = 'W';
newMenu.querySelector('ul').innerHTML = '';
// Insert newMenu
var vectorMenu = document.getElementById('p-cactions');
document.getElementById('right-navigation').insertBefore(newMenu, vectorMenu);
// add menu items (except help)
transferChildren("#mw-panel .portal LI:not(#n-help) A", "#faviconMenu ul");
// Place help at end of icon menu
transferChildren("#n-help A", "#faviconMenu ul");
// set some css for good and featured articles
var style = document.createElement('style');
var head = document.getElementsByTagName('head')[0];
var css = document.createTextNode( "#lbanner .GA:before { content: url('//upload.wikimedia.org/wikipedia/commons/4/42/Monobook-bullet-ga.png') ' '; } " );
css.appendData( "#lbanner .FA:before { content: url('//upload.wikimedia.org/wikipedia/en/d/d4/Monobook-bullet-star.png') ' '; }" );
style.appendChild(css);
head.appendChild(style);
}
function transferChildren(from, to) {
if(typeof from == 'string') {
from = document.querySelectorAll(from);
}
if(typeof to == 'string') {
to = document.querySelector(to);
}
var eles = [];
for(var i = from.length - 1; i > -1; i--) {
var a = from[i].parentNode.removeChild(from[i]);
var li = document.createElement("LI");
li.className = 'noprint';
li.appendChild(a);
eles.unshift(li);
}
while(eles.length > 0) {
to.appendChild(eles.shift());
}
}