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')) { appendSine = function { if ($('input#wpMinoredit').is(':checked')) return; var sine = '' + String.fromCharCode(126) + '~'; switch (editorInstance.mode) { case 'wysiwyg': var wysiwyg = editorInstance.getEditbox; var textOnly = wysiwyg.text.trim; if (!textOnly.length || sine == textOnly.substr(-4)) return; var lastBlock = wysiwyg.find('> *:last-child'); if (lastBlock.is('p')) { if (lastBlock.text.trim.length) sine = ' -- ' + sine; var lastElement = lastBlock.find(':last-child'); lastElement[lastElement.is('br') ? 'before' : 'after'](sine); } else { while (!lastBlock.is('p') && lastBlock.prev.length) lastBlock = lastBlock.prev; $(' ' + sine + ' ').appendTo(wysiwyg).css({                           marginLeft: lastBlock.css('marginLeft')                        }); }               break; case 'source': var source = editorInstance.getContent; if (!source.trim.length) return; var lines = source.split(/\r\n|\r|\n/).reverse; var l = lines[0].trim; if (l.length) { if (sine == l.substr(-4)) return; var isBlock = /^[*#]/.test(l) || /^(={2,6})[^=]+\1$/.test(l) || /(?:|}}|<\/(?:blockquote|div|pre|code|nowiki)>)$/.test(l); sine = (isBlock ? "\r\n" : " -- ") + sine; } else { for (var i = 1; i < lines.length; i++) { l = lines[i].trim; if (!l.length) continue; if (sine == l.substr(-4)) return; m = l.match(/^(\:+)/); if (m) sine = m[1] + sine; break; }                   }                    editorInstance.setContent(source + sine); break; }       }        $('input#wpSave').click(appendSine); $('a#publish').click(appendSine); } });