User:Guycn2/common.js

From translatewiki.net
Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Add links to sidebar (A script from the Hebrew Wikipedia) */
$(function(){

	function createCustomNav(linkstext) {
        if (mw.config.get('skin') == 'vector') {
            var linksPortalName = 'myLinksPortal';
            var div = $('<div>', { id: linksPortalName } ).addClass('portal');
            $('#mw-panel > div.portal:eq(0)').after(div
                .append($('<h3>').text('הקישורים שלי'))
                .append($('<div>', {'class': 'body'}).html(linkstext))
            );
	        $( document ).trigger( 'new-portlet-link', [linksPortalName] );
            return;
        } // else...
        var aLink1 = $('<a href="#">הקישורים שלי</a>');
        aLink1.click(function(){
            $('#p-customBody1').toggle();
            return false;
        });
        var h3CustomTitle = $('<h3>').append(aLink1);
        var divCustomBody = $('<div>', { id: "p-customBody1"} ).toggle(!! window.customLinksOpen);
        divCustomBody.html(linkstext);
        var navCustomMain = $('<div>').append(h3CustomTitle).append(divCustomBody);
        var pCom = $('#p-navigation');
        navCustomMain.addClass(pCom.attr('class'));
        divCustomBody.addClass(pCom.find('div').attr('class'));
        navCustomMain.insertBefore(pCom);
	}
 
    $.ajax({
            url: mw.util.wikiScript('index'),
            data: {
                title: 'User:' + mw.config.get('wgUserName') + '/הקישורים שלי',
                action: 'render'
            },
            success: createCustomNav
    });
});
window.customLinksOpen = 1; // Keep the menu open