משתמש:Realmgic/monobook.js

מתוך ויקיפדיה, האנציקלופדיה החופשית

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

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
  • אופרה: ללחוץ על Ctrl-F5.
// This function is used to include scripts from other Wikipedia pages in mine.  I got it from [[:en:User:Omegatron/monobook.js]] who got it from [[:en:User:Quarl/monobook.js]].
function winc(s) {
    s = s.replace(/^\[\[/, '').replace(/\]\]$/, '');
    document.write('<scr' + 'ipt type="text/javascript" src="' 
             + 'http://he.wikipedia.org/w/index.php?title=' + s
             + '&action=raw&ctype=text/javascript&dontcountme=s"></scr' 
             + 'ipt>');
}

// Revert tools by Lorian
function getElementsByClass(searchClass,node,tag) {
  // Function from http://www.dustindiaz.com/getelementsbyclass/
  var classElements = new Array();
  if ( node == null )
    node = document;
  if ( tag == null )
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if ( pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

// _GET code from NoGray JS Library http://www.nogray.com/new_site/
var _GET = new Array();
var _uri = location.href;

var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");

var _temp_get_arr_1 = new Array();

for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){
  _temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("=");
  _GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]);
}

delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;

function getMessage (where, user1, user2) {
  var message = prompt ('איזו הודעה ברצונך להשאיר?', '');
  window.location = 'http://he.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
}

$(function (){
  if (location.href.match(/diff=/)) {
    // Get username of submitter
    var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
    var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;
    document.getElementById('contentSub').innerHTML = '(<a href="http://he.wikipedia.org/w/index.php?title=' + wgPageName + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">שחזר</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">הודעה</a>) (<a href="http://he.wikipedia.org/w/index.php?title=' + wgPageName + '&action=edit&oldid=' + _GET['oldid'] + '&vandalism=1&user1='+user1+'&user2='+user2+'">ונדליזם</a> / <a href="javascript:var message = getMessage(\'vandalism\', \''+user1+'\', \''+user2+'\');">הודעה</a>) (אזהרה: <a href="http://he.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=1">אזהרה</a> / <a href="http://he.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=2">ניסויים</a> / <a href="http://he.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=3">תודה</a>)';
  } else if (location.href.match(/revert=1/)) {
    document.getElementById('wpSummary').value = 'שוחזר מעריכה של [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] לגרסה ' + _GET['oldid']+' של [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
    document.getElementById('editform').submit();
  } else if (location.href.match(/revert=2/)) {
    document.getElementById('wpSummary').value = 'שוחזר מעריכה של [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] לגרסה ' + _GET['oldid']+' של [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
    document.getElementById('editform').submit();
  } else if (location.href.match(/vandalism=1/)) {
    document.getElementById('wpSummary').value = 'שחזור השחתה של[[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] לגרסה ' + _GET['oldid']+' של [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
    document.getElementById('editform').submit();
  } else if (location.href.match(/vandalism=2/)) {
    document.getElementById('wpSummary').value = 'שחזור השחתה של [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] לגרסה ' + _GET['oldid']+' של [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=1/)) {
    document.getElementById('wpSummary').value = 'אזהרת השחתה';
    document.getElementById('wpTextbox1').value = '{{אזהרה}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=2/)) {
    document.getElementById('wpSummary').value = 'ניסויי עריכה';
    document.getElementById('wpTextbox1').value = '{{ניסויים}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=3/)) {
    document.getElementById('wpSummary').value = 'תודה על תרומתך לוויקיפדיתנו!';
    document.getElementById('wpTextbox1').value = '{{תודה}} ~~'+'~~';
    document.getElementById('editform').submit();
  }
});

//Made by Eran 
function addDeleteOption() {
  ta['del'] = ['', 'מחק דף זה'];
  if (!document.getElementById) return;
  var reqDel=wgPageName;
  x = document.getElementById('ca-move');
  if(!x) return;
  y = document.createElement('li');
  y.id = 'ca-move';
  z = document.createElement('a');
    z.href = 'http://he.wikipedia.org/w/index.php?title=ויקיפדיה:בקשות_ממפעילים&action=edit&section=2&pleasedelete=yes&pagefordel='+reqDel;
  if (x.children) {
    z.appendChild(document.createTextNode('מחק'));
    y.appendChild(z);
    document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling);
  } else {
    z.appendChild(document.createTextNode('מחק'));
    y.appendChild(z);
    document.getElementById('p-cactions').childNodes[3].insertBefore(y,null);
  }
}

$(function (){
if(location.href.match(/pleasedelete=yes/)) {
    txtLoc=location.href;
    reqDel=decodeURI(txtLoc.substring(txtLoc.indexOf('pagefordel=')+11,txtLoc.length));
    document.getElementById('wpSummary').value = '[[' + reqDel + ']]';
    document.getElementById('wpTextbox1').value = document.getElementById('wpTextbox1').value + '\n*[['+reqDel+']] ~~'+'~~';
    document.getElementById('editform').submit();
}
});

  addOnloadHook(addDeleteOption);

/* קוד להגבלת מספר המילים בתקציר האוטומטי של דף חדש ל7 */
function pacmanHatesAutoComments(){
if (wgPageName=='מיוחד:Newpages' || wgPageName=='מיוחד:Recentchanges'){
 var spans = document.getElementsByTagName("span");
 for (i = 0; i < spans.length; i++){
   if (spans[i].className == "comment"){
   var comm=spans[i].innerHTML;
   if (comm.indexOf('דף חדש:')!=-1){
     a=comm.indexOf(' ',0);
     for (j=0;j<8;j++){
     if(comm.indexOf(' ',a+1)>a) a=comm.indexOf(' ',a+1);
     }
     spans[i].innerHTML=comm.substring(0,a)+'...)';
    }
   }
  }
 }
}
$(pacmanHatesAutoComments);

/**** move edit sections- taken from [[:de:MediaWiki:Monobook.js]] ****/
function moveEditsection() {
    if (typeof oldEditsectionLinks == 'undefined' || oldEditsectionLinks == false) {
        var spans = document.getElementsByTagName("span");
        for(var i = 0; i < spans.length; i++) {
            if(spans[i].className == "editsection") {
                spans[i].style.fontSize = "x-small";
                spans[i].style.fontWeight = "normal";
                spans[i].style.cssFloat = "none";
                spans[i].style.marginRight = "0px";
                spans[i].parentNode.appendChild(document.createTextNode(" "));
                spans[i].parentNode.appendChild(spans[i]);
            }
        }
    }
}
// onload
$(moveEditsection);

/* הוספת כפתור שמבצע החלפות שונות ומתריע על בעיות סגנון שונות */
function CheckTy()
{
 txt = document.editform.wpTextbox1.value;
 txt = txt.replace(/\ היתה/g, " הייתה");
 txt = txt.replace(/\איזור/g, "אזור");
 txt = txt.replace(/\אירגון/g, "ארגון");
 txt = txt.replace(/\גיאוגרפיה/g, "גאוגרפיה");
 txt = txt.replace(/\גיאולוגיה/g, "גאולוגיה");
 txt = txt.replace(/\דוגמא /g, "דוגמה ");
 txt = txt.replace(/\ ישוב /g, " יישוב ");
 txt = txt.replace(/\כנסיה/g, "כנסייה");
 txt = txt.replace(/\מוסיקה/g, "מוזיקה");
 txt = txt.replace(/\פיסיולוגיה/g, "פיזיולוגיה");
 txt = txt.replace(/\פיסיקה/g, "פיזיקה");
 txt = txt.replace(/\צלסיוס/g, "צלזיוס");
 txt = txt.replace(/\ שניה /g, " שנייה ");
 txt = txt.replace(/\תיאוריה/g, "תאוריה");
 txt = txt.replace(/\[Category:/gi, "[קטגוריה:");
 txt = txt.replace(/\[Image:/gi, "[תמונה:");
 txt = txt.replace(/\|thumb\|/gi, "|ממוזער|");
 txt = txt.replace(/\|right\|/gi, "|ימין|");
 txt = txt.replace(/\|left\|/gi, "|שמאל|");
 txt = txt.replace(/ראה גם/g, "ראו גם");
 txt = txt.replace(/\במידה ו/g, "במידה ש");
txt = txt.replace(/עויין/g, "עוין");
txt = txt.replace(/מצויין/g, "מצוין");
txt = txt.replace(/(ב-|ב )([1-9])?([1-9])( ל)(ינואר|פברואר|מרץ|אפריל|מאי|יוני|יולי|אוגוסט|ספטמבר|אוקטובר|נובמבר|דצמבר)/g, "ב-$2$3 ב$5");
txt = txt.replace(/\t/g, " ");
txt = txt.replace(/(\n\n)\n+/g, "$1");
txt = txt.replace(/== ? ?\n\n==/g, "==\n==");
txt = txt.replace(/^ ? ? \n/gm, "\n");
txt = txt.replace(/[ \t][ \t]+/g, " ");
 txt = txt.replace(/\  /g, " ");
 document.editform.wpTextbox1.value = txt;
comstr="";
 if(txt.indexOf("בגלל ש",0)!=-1) comstr=comstr+"\nיתכן שבערך מופיע הצירוף בגלל ש. אם מופיע מומלץ להחליפו בכיוון ש, משום ש, מאחר ש או מפני ש (מידע נוסף ב ויקיפדיה:לשון)";
 if(txt.indexOf("שוב פעם",0)!=-1) comstr=comstr+"\nיתכן שבערך מופיע הצירוף שוב פעם. אם מופיע מומלץ להחליפו עוד פעם או שוב (מידע נוסף ב ויקיפדיה:לשון)";
 if(txt.indexOf("עובדה מעניינת היא",0)!=-1 || txt.indexOf("יש לציין",0)!=-1){
   comstr=comstr+"\nאל תעיד אל עיסתך! מומלץ להימנע מהביטוים עובדה מעניינת היא או יש לציין. יש לתת לקורא להחליט אם העובדה ראויה לציון. (מידע נוסף ב ויקיפדיה:לשון)";
 }
 if(txt.indexOf("למרות ש",0)!=-1) comstr=comstr+"\nיתכן שבערך מופיע הצירוף למרות ש. אם מופיע מומלץ להחליפו באף על פי ש או אף ש או על אף ש או לעיתים הגם ש(מידע נוסף ב ויקיפדיה:לשון)";
if(txt.indexOf("כמובן ש",0)!=-1) comstr=comstr+"\nיתכן שבערך מופיע הצירוף כמובן ש. אם מופיע מומלץ להחליפו במובן ש או בכמובן(מידע נוסף ב ויקיפדיה:לשון)";
 if(txt.indexOf("כנראה ש",0)!=-1) comstr += "\nבערך מופיע הצירוף כנראה ש. רצוי להחליפו בנראה ש או בכנראה";
 if(txt.indexOf("להיכן",0)!=-1 || txt.indexOf("לאיפה",0)!=-1 || txt.indexOf("מהיכן",0)!=-1 || txt.indexOf("מאיפה",0)!=-1) comstr += "\nבערך מופיע בכל\"ם בצמוד לאיפה או להיכן. רצוי להחליף במקרים אלו מומלץ להחליף למילית שאלה אין - לאן או מאין";
 if(txt.indexOf("הכי טוב",0)!=-1){
   comstr=comstr+"\nבערך זה מופיע הצירוף הכי טוב, יתכן שכדאי להחליפו לטוב ביותר (מידע נוסף ב ויקיפדיה:שגיאות תרגום נפוצות)";
 }
 if(txt.indexOf("נפלא",0)!=-1 || txt.indexOf("מחריד",0)!=-1 || txt.indexOf("מקסימה",0)!=-1 || txt.indexOf("מקסימים",0)!=-1 || txt.indexOf("מקסימות",0)!=-1 || txt.indexOf("מקסים",0)!=-1 || txt.indexOf("מדהימ",0)!=-1 || txt.indexOf("מדהים",0)!=-1 || txt.indexOf("נהדר",0)!=-1) comstr=comstr+"\nיתכן שהערך כולל סופרלטיבים מיותרים; נפלא, מחריד, מקסים, מדהים, נהדר (וצורות הרבים והנקבה של הללו)";
 if(txt.indexOf(" יכל",0)!=-1) comstr=comstr+"\nבערך מופיע יכל רצוי להחליפו להיה יכול";
 if(txt.indexOf(" ז\"ל ",0)!=-1) comstr=comstr+"\nאין להצמיד לאדם את התואר ז\"ל או זצ\"ל (מידע נוסף ב ויקיפדיה:עקרונות מיוחדים לשפה העברית)";
 if(comstr!=""){
  alert(comstr);
 }
}

/* סקריפט להוספת רשימת תבניות פניה/אזהרה כשעורכים דף שיחה של משתמש אנונימי */
function talkIPTool()
{
  var title = (document.title.substr(0, document.title.lastIndexOf(" - ")));
  templatesList=document.getElementById('edit-templates');
  if(templatesList!=null && title.indexOf('.')!=title.lastIndexOf('.')){
   warList='אזהרות: <select onchange="document.editform.wpSummary.value+=this[selectedIndex].title; document.editform.wpTextbox1.value += \'{{ס:\' + this[selectedIndex].title + \'}} ~~\' + \'~~\';document.getElementById(\'editform\').submit();">';
   warList += '<option title="">בחרו מהרשימה כדי להוסיף</option>'
   warList += '<option title="אזהרה">אזהרה</option>'
   warList += '<option title="הבל">הבל</option>'
   warList += '<option title="הזמנה">הזמנה</option>'
   warList += '<option title="ניסויים">ניסויים</option>'
   warList += '<option title="תודה">תודה</option>'
   warList += '<option title="ויקיזציה">ויקיזציה</option>'
   warList += '<option title="לך">לך</option>'
   warList += '<option title="תלונה">תלונה</option>'
   warList += '<option title="טעות">טעות</option>'
   warList += '<option title="נייטרליות">נייטרליות</option>'
   warList += '<option title="נחסמת">נחסמת</option>'
   warList += '<option title="מילון">מילון</option>'
   warList += '<option title="כבר קיים">כבר קיים</option>'
   warList += '<option title="שגיאה" >שגיאה</option>'
   warList += '<option title="העתקה">העתקה</option>'
   warList += '<option title="פרסומת">פרסומת</option>'
   warList += '<option title="נמחק">נמחק</option>'
   warList += '<option title="הסבר">הסבר</option>'
   warList += '<option title="בוטל">בוטל</option>'
   warList += '<option title="סגנון">סגנון</option>'
   warList += '</select>'
   templatesList.innerHTML=warList+templatesList.innerHTML;
 }
}

/* הוספת כפתורים אישיים: כפתור הפיכת קוד html לוויקי (בעיקר טבלאות), כפתור לביצוע בדיקות שונות וכפתור מיקוף */
function eButtons(){
 if (document.getElementById('edit-templates')!=null){
  for(var i=0; a = document.getElementsByTagName("div")[i]; i++) {
  if(a.className == "editButtons") {
   mCusButtons = '<br/><div style="border-bottom:2px dashed #eeeeee">כפתורים נוספים:</div><input type="button" value="בדיקה" onclick="CheckTy();" />';

   a.innerHTML += mCusButtons;
   }
  }
 }
}
$(eButtons);
addLoadEvent(talkIPTool);


//
// סקריפט 8: לקוח מ[[ויקיפדיה:סקריפטים/8]]
// fix numbered lists in firefox
// written by Dekel [dekelb(at)(no-spam)gmail.com]
//
function fixOl() {
	if(clientPC.indexOf('firefox/') == -1) {
		return;
	}
	olList = document.getElementsByTagName('ol');
	for(i = 0; i < olList.length; ++i) {
		d = document.createElement('div');
		d.setAttribute('style', 'margin-left: 2em; display: table;');
		o = document.createElement('ol');
		o.innerHTML = olList[i].innerHTML;
		olList[i].parentNode.insertBefore(d, olList[i]);
		olList[i].parentNode.removeChild(olList[i]);
		d.appendChild(o);
	}
}
$(fixOl);
// עד כאן סקריפט 8

//
// סקריפט 12: לקוח מ[[ויקיפדיה:סקריפטים/12]]
// הקוד מוסיף אפשרות לערוך את ההקדמה של הערך
//
function addEditSection0() {
  x = document.getElementById('ca-edit');
  if (!x) return;
  ta['ca-edit-0'] = ['', 'ערוך את ההקדמה'];
  y = document.createElement('LI');
  y.id = 'ca-edit-0';
  
  // if is edit page and is section 0, then mark "0" as seleted and mark "עריכה" as unseleted
  var isSelected = (x.className.indexOf('selected') != -1);
  var isTalk = (x.className.indexOf('istalk') != -1);
  var isSection0 = (/&action=edit&section=0$/.test(window.location.href));
  //alert(isSelected + " " + isTalk + " " + isSection0);
  if (isSelected) {
    if (isSection0) {
      y.className = x.className;
      x.className = (isTalk) ? 'istalk' : '';
    } else {
      if (isTalk) y.className = 'istalk';
    }
  }

  // add the "0" li element
  var z = document.createElement('A');
  z.href = x.childNodes[0].href + '&section=0';
  z.appendChild(document.createTextNode('0'));
  y.appendChild(z);
  x.parentNode.insertBefore(y,x.nextSibling);

  // add summary if editing section 0
  if ( isSection0 )
    document.getElementById("wpSummary").value = "/* עריכת ההקדמה */ ";
}
$(addEditSection0);
// עד כאן סקריפט 12