משתמש:ערן/monobook.js

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

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

  • באינטרנט אקספלורר, לחצו על מקש ה־Ctrl בעת לחיצתכם על רענן (Refresh), או הקישו על Ctrl+F5.
  • במוזילה, פיירפוקס או ספארי, לחצו על מקש ה־Shift בעת לחיצתכם על העלה מחדש (Reload), או הקישו Ctrl+Shift+R (או Cmd+Shift+R במקינטוש של אפל).
  • ב־Konqueror, לחצו על העלה מחדש (Reload), או הקישו על F5.
  • באופרה, ייתכן שתצטרכו להשתמש בכלים (Tools) > העדפות (Preferences) כדי לנקות לחלוטין את זכרון המטמון.
/* <div style="direction: ltr;"><pre> */
/* זהו דף הmonobook.js שלי- כאן אני מוסיף סקריפטים שונים. בדף זה מספר סקריפטים- כל אחד רשאי להעתיקם. */

/* הקוד מוסיף כפתור Html2Wiki שבלחיצה עליו אמור לשנות תגי HTML לויקי. כרגע הופך תגי b וi כמו שעשו בויקי הרוסית (רק בקצרה) וממיר טבלאות (ולפעמים גם מוסיף כל מיני רווחים מיותרים).
שימו לב! הפונקציה תחליף את כל הטקסט, גם אם הוא בתוך nowiki. עלולות להיות בעיות כשהקוד שגוי.
יש לבדוק שלא הורסים טקסט שצריך להשאר בhtml. ראו הוזהרתם */

function Html2Wiki()
{
txt = document.editform.wpTextbox1.value;

/* הפיכת התגיות b וstrong וi וem לתגי ויקי באמצעות החלפה. אזהרה: ההחלפה מתבצעת על כל הטקסט, גם אם רשום nowiki לפני */
txt = txt.replace(/\<\/?(b|strong)\>/g, "\'\'\'");
txt = txt.replace(/\<\/?(i|em)\>/g, "\'\'");

/* פונקציה להפיכת תגי table לתגי ויקי */
atab = txt.indexOf("<table",0);
while(atab!=-1){
btab = txt.indexOf(">",atab);
str1=txt.substring(0,btab);
str2=txt.substring(btab+1,txt.length);
txt=str1+str2;
atab = txt.indexOf("<table",btab);
if (btab==-1) atab=-1;
}
txt = txt.replace(/\<table/g, "\n{|");
txt = txt.replace(/\<\/table\>/g, "\n|}");

/* פונקציה להפיכת תגי tr לתגי ויקי */
atab = txt.indexOf("<tr",0);
while(atab!=-1){
btab = txt.indexOf(">",atab);
str1=txt.substring(0,btab);
str2=txt.substring(btab+1,txt.length);
txt=str1+"\n"+str2;
atab = txt.indexOf("<tr",btab);
if (btab==-1) atab=-1;
}
txt = txt.replace(/\<tr/g, "|-");
txt = txt.replace(/\<\/tr\>/g, "");

/* פונקציה להפיכת תגי td לתגי ויקי */
atab = txt.indexOf("<td",0);
while(atab!=-1){
btab = txt.indexOf(">",atab);
str1=txt.substring(0,btab);
str2=txt.substring(btab+1,txt.length);
txt=str1+"|"+str2;
atab = txt.indexOf("<td",btab);
if (btab==-1) atab=-1;
}
txt = txt.replace(/\<td/g, "|");
txt = txt.replace(/\<\/td\>/g, "");

/* פונקציה להפיכת תגי th לתגי ויקי */
atab = txt.indexOf("<th",0);
while(atab!=-1){
btab = txt.indexOf(">",atab);
str1=txt.substring(0,btab);
str2=txt.substring(btab+1,txt.length);
txt=str1+"|"+str2;
atab = txt.indexOf("<th",btab);
if (btab==-1) atab=-1;
}
txt = txt.replace(/\<th/g, "!");
txt = txt.replace(/\<\/th\>/g, "");

/* החלפת תוכן תיבת הקוד בקוד שעבר טיפול בפונקציה. */
document.editform.wpTextbox1.value = txt;
}

/* הוספת כפתור שמבצע החלפות שונות ומתריע על בעיות סגנון שונות */
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, " ");
 document.editform.wpTextbox1.value = txt;
comstr="";
 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 += "\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) 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;
 }
}

/* תמונות ליד קישורים חיצוניים. */
function externalLIcons(e) 
{
    e = (e) ? e : event;
    var links = document.getElementsByTagName("a");
    var i;
    for (i = 1; i <= links.length; i++)
    {
        if (links[i - 1].className == "external text")
        {
    var extrImg=document.createElement("img");
    if(links[i-1].href.match(".pdf")){
    extrImg.src= 'http://upload.wikimedia.org/wikipedia/commons/thumb/2/23/Icons-mini-file_acrobat.gif/15px-Icons-mini-file_acrobat.gif';
    } else if(links[i-1].href.match(/.(doc|rtf)/)){
    extrImg.src= 'http://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/Noia_64_mimetypes_wordprocessing.png/16px-Noia_64_mimetypes_wordprocessing.png';
    } else {
    extrImg.src= 'http://upload.wikimedia.org/wikipedia/he/thumb/0/01/External2.png/10px-External2.png';
    }
         links[i-1].appendChild(extrImg);
        }
    }
}

/* הוספת כפתורים אישיים: כפתור הפיכת קוד 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="Html2Wiki" onclick="Html2Wiki();" /><input type="button" value="בדיקה" onclick="CheckTy();" />';

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

/* </div></pre> */

function imageCRV(){
if (wgNamespaceNumber==6 && wgIsArticle){
 filelinksH=document.getElementById('content').getElementsByTagName('ul')[3];
 if(filelinksH==null) return;
 var useLinks = filelinksH.getElementsByTagName("li");
 for (i = 0; i <useLinks.length ; i++){
  remLink = document.createElement("a");
  useLinks[i].appendChild(document.createTextNode(" | "));
  useLinks[i].appendChild(remLink);
  remLink.appendChild(document.createTextNode("הסר"));
  articleUseName=useLinks[i].getElementsByTagName("a")[0].href;
  remLink.href = '/w/index.php?title=' + articleUseName.substring(29,articleUseName.length) + '&action=edit&removeImage='+wgTitle;
 }
}

if(location.href.match('&action=edit&removeImage=')){
loc=location.href;
imageforDel=loc.substring(loc.indexOf('&removeImage=')+13,loc.length);
imageforDel=imageforDel.replace(/\%20/g," ");
imageforDelB=imageforDel.replace(/\ /g,"_");
txt = document.editform.wpTextbox1.value;
atab = txt.indexOf('[[תמונה:'+imageforDel);
if(atab==-1) atab = txt.indexOf('[[Image:'+imageforDel);
if(atab==-1) atab=txt.indexOf('[[Image:'+imageforDelB);
if(atab==-1) atab=txt.indexOf('[[תמונה:'+imageforDelB);
if(atab==-1) {
alert('error1');
return;
}

btab = txt.indexOf(']]',atab);
if (txt.indexOf('[[',atab+2)<btab){
 alert('error2');
 return;
}
document.editform.wpTextbox1.value=txt.substring(0,atab)+txt.substring(btab+2,txt.length);
document.editform.wpSummary.value+='הסרת תמונה חשודה';
}
}
addLoadEvent(imageCRV);

function FACarch(){
divFAC=document.getElementById('FACarchive');
if(divFAC!=null){
 divFAC.innerHTML+='<a href=\"http://he.wikipedia.org/w/index.php?title=' + wgPageName + '/הצעת_הוספה_למומלצים&action=edit&FAarhcive=yes\">לארכב!!</a>';
}
if(location.href.indexOf("action=edit&FAarhcive=yes") > -1) document.editform.wpTextbox1.value+='הועבר מ[[ויקיפדיה:ערכים מומלצים/הוספה למומלצים]] ~~' + '~~'+'~';
}

addLoadEvent(FACarch);