User:Pecoes/global.js

var menu = [ ['JE Modding', 'http://jadeempire-modding.wikia.com/', ['Admin Dashboard', 'http://jadeempire-modding.wikia.com/wiki/Special:AdminDashboard'], ['Sandbox', 'http://jadeempire-modding.wikia.com/wiki/User:Pecoes/Sandbox'], ['Wikia.css', 'http://jadeempire-modding.wikia.com/wiki/MediaWiki:Wikia.css'], ['Common.js', 'http://jadeempire-modding.wikia.com/wiki/MediaWiki:Common.js'] ],   ['Community Central', 'http://community.wikia.com/', ['Admin Forum', 'http://community.wikia.com/wiki/Admin_Central:Forum'], ['Community Forum', 'http://community.wikia.com/wiki/Forum:Community_Central_Forum'], ['Global.js',, 'http://community.wikia.com/wiki/User:Pecoes/global.js'], ],   ['Dev', 'http://dev.wikia.com/', ['Cheatsheet', 'http://dev.wikia.com/wiki/JS_and_CSS_Cheatsheet'], ['JavaScript', 'http://dev.wikia.com/wiki/List_of_JavaScript_Enhancements'] ],   ['API', 'http://jadeempire-modding.wikia.com/api.php'] ];

function renderMenu (menu) { if (undefined == window.wgUserName) return ''; var html = ''; html += ''; html += ''; html += ''; if (undefined != menu && menu instanceof Array) { html += ''; for (var i = 0; i < menu.length; i++) { html += renderMenuLevelOne(menu[i]); }       html += ""; }   html += ''; return html; }

function renderMenuLevelOne (menu) { if (undefined == menu || !(menu instanceof Array)) return ' '; var url, title, html; title = typeof menu[0] == 'string' ? menu[0] : 'undefined'; url  = typeof menu[1] == 'string' ? menu[1] : 'undefined'; html = ''; html += '' + title; if (menu.length > 2) { html += ''; html += ''; html += ''; for (var i = 2; i < menu.length; i++) { html += renderMenuLevelTwo(menu[i]); }       html += ""; }   else html += ''; html += ''; return html; }

function renderMenuLevelTwo (menu) { var url, title, html; title = typeof menu[0] == 'string' ? menu[0] : 'undefined'; url  = typeof menu[1] == 'string' ? menu[1] : 'undefined'; html = '<a class="subnav-3a" href="' + url + '">' + title + '</a></li>'; return html; }

$('#WikiHeader nav ul:first').append(renderMenu(menu)); $('#WikiHeader > nav').css({ width: "580" }); var navWidth = 0;

$(function {

// adjust size of main navigation to make room for bookmark menu: var navWidth = 0; $('#WikiHeader > nav > ul > li').each(function { navWidth += $(this).width; }); if (560 < navWidth) $('#WikiHeader > nav > ul > li > a').css({ paddingLeft: "11px", paddingRight: "11px" });

// see w:c:dev:Fix_for_Special:WantedImages if ("Special" == wgCanonicalNamespace && "WantedFiles" == wgCanonicalSpecialPageName) { $('ol.special a.new').each(function {           var m = $(this).attr('href').match(/title=File:([^&]+)/);            if (m) {                $(this).attr({ href: '/wiki/Special:Upload?wpDestFile=' + m[1], title: 'Upload ' + m[1] });           }        });    }

// Sine: talkNameSpaces = [1,3,5,7,9,11,13,15,110,111,114,401,500,501,502,503]; if (-1 < $.inArray(wgNamespaceNumber, talkNameSpaces) && 'edit' == $.getUrlVar('action')) { appendSignature = function { if ($('input#wpMinoredit').is(':checked')) return; var sig = '' + String.fromCharCode(126) + '~'; switch (editorInstance.mode) { case 'wysiwyg': editorInstance.getEditbox.append(sig); break; case 'source': var content = editorInstance.getContent; if (!content.trim.length) return;                        // if there's no content abort var lines = content.split(/\r|\n|\r\n/).reverse;         // split into lines and start at the bottom var l = lines[0].trim; if (l.length) {                                            // is there content on the last line? if (sig == l.substr(-4)) return;                       // already signed var block = /^[*#]/.test(l) || /^(={2,6})[^=]+\1$/.test(l) || /(?:|<\/(?:blockquote|div|pre|code|nowiki)>)$/.test(l) sig = (block ? "\r\n" : " -- ") + sig;                 // if last line contains block element insert newline, else -- } else { for (var i = 1; i < lines.length; i++) {               // find out about indentation l = lines[i].trim; if (!l.length) continue; if (sig == l.substr(-4)) return;                   // already signed m = l.match(/^(\:+)/); if (m) sig = m[1] + sig; break; }                   }                    editorInstance.setContent(content + sig); break; }       }        $('input#wpSave').click(appendSignature); $('a#publish').click(appendSignature); } });