לדלג לתוכן

מדיה ויקי:Gadget-CustomSideBarLinks.js

מתוך צפונות ויקי

הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
// הסקריפט מוסיף קישורים (שנבחרו על ידי המשתמש) לתיבה שממוקמת מעל לתיבת הקהילה.
// 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
}

$(document).ready(function(){
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();
}

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