User:Ch1902/monobook.js

/* */

CustomLinks = {  ns: '', menu : null, links: [ {ns: 'all', url: 'http://en.wikipedia.org/wiki/Category:Images_that_should_be_in_SVG_format', text: 'WP:SVG'}, {ns: 'all', url: 'http://commons.wikimedia.org/wiki/User:Ch1902', text: 'COM:Ch1902'}, {ns: 'all', url: 'http://commons.wikimedia.org/wiki/Special:Watchlist', text: 'COM:Watchlist'}, {ns: 'all', url: 'http://commons.wikimedia.org/wiki/Commons:Upload', text: 'COM:Upload'}, {ns: 'all', url: 'http://commons.wikimedia.org/wiki/Commons:Graphic_Lab/Images_to_improve', text: 'COM:GL'}, {ns: 'all', url: 'http://commons.wikimedia.org/wiki/Category:Images_that_should_use_vector_graphics', text: 'COM:SVG'} ],  init: function {     this.get_ns; for (var i = 0; link = this.links[i]; i++) {        if (link.ns == 'all' || link.ns == this.ns) this.add_item(link.url, link.text); }  },   add_item : function (href, text) {     if (this.menu == null) {        el = document.getElementById('p-personal'); el = el.getElementsByTagName('UL')[0]; el = el.parentNode; var ul = document.createElement('UL'); ul.className = 'extra-personal'; el.appendChild(ul); this.menu = ul; }

text = this.magicw(text); href = this.magicw(href); var li = document.createElement('LI'); var a = document.createElement('A'); a.href = href; a.innerHTML = text; li.appendChild(a); this.menu.appendChild(li); },  get_ns : function {     switch (wgNamespaceNumber) { case -1: this.ns = 'special'; break; case 0: case 1: this.ns = 'main'; break; // main & talk case 2: case 3: this.ns = 'user'; break; // user & talk case 4: case 5: this.ns = 'project'; break; // project & talk case 6: case 7: this.ns = 'image'; break; // image & talk case 8: case 9: this.ns = 'mediawiki'; break; // mediawiki & talk case 10: case 11: this.ns = 'template'; break; // template & talk case 12: case 13: this.ns = 'help'; break; // help & talk case 14: case 15: this.ns = 'category'; break; // category & talk default: this.ns = ''; }  },

magicw : function (s) {     s = s.replace(/%w/g, wgServer).replace(/%p/g, wgPageName);

return s;  } }; $ (function (e) { CustomLinks.init; });

function TopAndBottom (e) {  var doc = document && document.documentElement;

if (doc.offsetHeight > window.innerHeight * 2) {     var content = document.getElementById('bodyContent'); var div = document.createElement('DIV'); var s1 = document.createElement('SMALL'); var s2 = document.createElement('SMALL'); var a1 = document.createElement('A'); var a2 = document.createElement('A');

div.className = 'boilerplate metadata plainlinks'; div.style.position = 'fixed'; div.style.right = '0.3em'; div.style.border = '1px solid #a9a9a9'; div.style.background = '#FFFFFF'; div.style.padding = '2px'; div.style.zIndex = '1001'; div.style.width = '90px'; div.style.textAlign = 'center';

var top = div.cloneNode(true); top.style.top = '3.2em'; top.id = 'jump-top';

var bottom = div.cloneNode(true); bottom.style.bottom = '0.3em'; bottom.id = 'jump-bottom';

a1.title = 'Go to bottom'; a1.innerHTML = 'Go to bottom'; a1.href = '#'; a1.onclick = function (e) { doc.scrollTop = doc.scrollHeight; return false; };

a2.title = 'Go to top'; a2.innerHTML = 'Go to top'; a2.href = '#'; a2.onclick = function (e) { doc.scrollTop = 0; return false; };

s1.appendChild(a1); top.appendChild(s1); s2.appendChild(a2); bottom.appendChild(s2);

content.appendChild(top); content.appendChild(bottom);

hookEvent('scroll', function (e) {        if (doc.scrollTop < 35)            top.style.top = '3.2em';         else            top.style.top = '0.3em';      }); } }

$ (TopAndBottom);

function imageSizes { if (wgNamespaceNumber != 6 || wgAction != 'view') return; var imgSizes = ['100px', '200px', '300px', '400px', '500px', '600px', '800px', '1000px']; var wgThumb = (getElementsByClassName(document.getElementById('bodyContent'), 'DIV', 'sharedUploadNotice').length ? 'http://commons.wikimedia.org' : wgServer) + wgScriptPath + '/thumb.php?f=' + wgTitle + '&width='; var div = document.createElement('DIV'); div.className = 'extraMedia'; div.appendChild(document.createTextNode('Other sizes: ')); for (var i = 0; i < imgSizes.length; i++) { var a = document.createElement('A'); a.href = wgThumb + imgSizes[i]; a.appendChild(document.createTextNode(imgSizes[i])); div.appendChild(a);

if (i != imgSizes.length - 1) div.appendChild(document.createTextNode(' | ')); }  document.getElementById('file').appendChild(div); };

$(imageSizes);

/* */