לדלג לתוכן

מדיה ויקי:Gadget-CustomSideBarLinks.js: הבדלים בין גרסאות בדף

מתוך צפונות ויקי
תיקונים כדי שיעבוד טוב גם ב VECTOR + מוחק הערות לא רלוונטיות
מ שכתובון
שורה 40: שורה 40:
}
}


function initCustomNav()
$(document).ready(function(){
{
$.ajax({ url: mw.util.wikiScript('index'), data: {
    var a = sajax_init_object();
title: mw.util.wikiUrlencode('משתמש:'+mw.user.name()+'/הקישורים שלי'),
    a.open ('GET', wgServer + wgScript + '?title=%D7%9E%D7%A9%D7%AA%D7%9E%D7%A9:' + encodeURIComponent(wgUserName) + '/%D7%94%D7%A7%D7%99%D7%A9%D7%95%D7%A8%D7%99%D7%9D_%D7%A9%D7%9C%D7%99&action=render', true);
action: 'render'
    a.onreadystatechange = function()
}, success:
      {
function(data){createCustomNav(data);}
        if ( a.readyState != 4 ) return;
}
        createCustomNav ( a.responseText );
});
      };
    a.send (null);
}
 
addOnloadHook ( initCustomNav );

גרסה מ־08:02, 4 באוקטובר 2011

// הסקריפט מוסיף קישורים (שנבחרו על ידי המשתמש) לתיבה שממוקמת מעל לתיבת הקהילה.
// created by [[user:Yonidebest]] with some help from [[User:ערן]]

var CustomSideBarLinksShowDefualt = false; // he who wishes the side bar to be visibale by default, set this to true.

function navCustonToggle()
{
    var divBody = document.getElementById('p-customBody1');
    if ( divBody.style.display == 'none' ) divBody.style.display = 'block';  // show content
                                      else divBody.style.display = 'none';   // hide content
}

function createCustomNav(linkstext)
{
    var aLink1 = document.createElement('A');
    aLink1.appendChild(document.createTextNode('הקישורים שלי'));
    aLink1.href = 'javascript:navCustonToggle();';

    var h5CustonTitle = document.createElement('H5');
    h5CustonTitle.appendChild(aLink1);

    try { // for IE
       var divCustonBody = document.createElement('<DIV ID="p-customBody1"></DIV>');
    } catch (e) { // for FF
       var divCustonBody = document.createElement('DIV');
       divCustonBody.id = 'p-customBody1';
    };
    divCustonBody.innerHTML = linkstext;

    var navCustonMain = document.createElement('DIV');
    navCustonMain.appendChild(h5CustonTitle);
    navCustonMain.appendChild(divCustonBody);

    var pCom = document.getElementById('p-community');
    navCustonMain.className = pCom.className;
    divCustonBody.className = pCom.getElementsByTagName('DIV')[0].className;
    pCom.parentNode.insertBefore (navCustonMain, pCom);

    if ( !CustomSideBarLinksShowDefualt ) navCustonToggle();
}

$(document).ready(function(){
	$.ajax({ url: mw.util.wikiScript('index'), data: {
		title: mw.util.wikiUrlencode('משתמש:'+mw.user.name()+'/הקישורים שלי'),
		action: 'render'
	}, success: 
		function(data){createCustomNav(data);}
	}
});