מדיה ויקי:Makor.js

מתוך ויקישיבה
קפיצה לניווט קפיצה לחיפוש

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

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
  • אופרה: ללחוץ על Ctrl-F5.
 /* כלי ליצירת מקורות המקושרים לפרוייקט השו"ת */
 /* גרסה 1.0 נכתב ע"י Yeshivaorgil */
 
 
 function generateMakor( cat, book, per, pas) {
 	var code = "";
 	if (book.substr(0,book.indexOf(" ")) != cat)
 		code += cat + ":" + book + " " + per + " " + pas;
 	else
 		code += cat + ":" + book.substr(book.indexOf(" ")+1) + " " + per + " " + pas;
 	insertTags( "{{מקור|", "}}", code );
 }
 
 function calPer(hak)
 {
 	a=hak*1;
 	a *= 0.27;
 	hak=Math.round((100*(a+1))/27);
 	return hak;
 	//popup.document.getElementById("percent").innerHTML=(100*(a+1))/27;
 }
  
 function popupMakor() {
 	var popup = window.open( "", "popup", "height=380,width=500" );
 	popup.document.open();
 	popup.document.write('<html><head><title>מקור מקושר</title>');
 	popup.document.write('<style type="text/css" media="screen,projection">/*<![CDATA[*/ @import "http://www.yeshiva.org.il/wiki/skins/monobook/main.css"; @import "http://www.yeshiva.org.il/wiki/skins/monobook/rtl.css"; /*]]>*/</style>');
 	popup.document.write('<style>select{font-family:arial;}.lst0{height:0px;width:0px;visibility:hidden;}.lst1{height:100px;width:300px;visiblility:visible;}</style>');
 	popup.document.write('<script language="javascript" src="http://www.yeshiva.org.il/wiki/extensions/makor/BD.js"></script>');
 	popup.document.write('<script type="text/javascript">function insertCode() {');
 	popup.document.write('var cat = document.paramForm.catList.options[document.paramForm.catList.selectedIndex].text; ');
 	popup.document.write('var book = document.paramForm.inputBook.value; ');
 	popup.document.write('var per = document.paramForm.inputPerek.value; ');
 	popup.document.write('var pas = document.paramForm.inputPasuk.value; ');
 	popup.document.write('window.opener.generateMakor( cat, book, per, pas); ');
 	popup.document.write('}\n');
 	popup.document.write('function getL()');
 	popup.document.write('{//alert(BrowserDetect.browser);\n');
 	popup.document.write('var xmlHttp;var num=document.paramForm.catList.selectedIndex;');
 	popup.document.write('try{// Firefox, Opera 8.0+, Safari\n');
 	popup.document.write('xmlHttp=new XMLHttpRequest();}\n');
 	popup.document.write('catch (e){// Internet Explorer\n');
 	popup.document.write('try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}\n');
 	popup.document.write('catch (e)');
 	popup.document.write('{');
 	popup.document.write('try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}\n');
 	popup.document.write('catch (e){');
 	popup.document.write('alert("Your browser does not support AJAX!");');
 	popup.document.write('return false;}\n');
 	popup.document.write('}\n');
 	popup.document.write('}\n');
 	popup.document.write('xmlHttp.onreadystatechange=function()');
 	popup.document.write('{');
 	popup.document.write('if(xmlHttp.readyState==4)');
 	popup.document.write('{alert(xmlHttp.responseText);');
 	popup.document.write('if(BrowserDetect.browser=="Explorer")');
 	popup.document.write('document.getElementById("select" + num).outerHTML="<textarea id=\\"select" + num + "\\" ondblclick=\\"autoVom(this);\\" onchange=\\"autoVom(this);\\" dir=\\"rtl\\" size=6>" + xmlHttp.responseText + "</textarea>";');
 	popup.document.write('else\n');
 	popup.document.write('document.getElementById("select" + num).innerHTML=xmlHttp.responseText;');
 	popup.document.write('}\n');
 	popup.document.write('}\n');
 	popup.document.write('if(BrowserDetect.browser!="Explorer")');
 	popup.document.write('xmlHttp.open("GET","http://www.yeshiva.org.il/extensions/makor/bl.php?sCat="+num,true);');
 	popup.document.write('else\n');
 	popup.document.write('xmlHttp.open("GET","http://www.yeshiva.org.il/extensions/makor/bl.php?sCat="+num,false);');
 	popup.document.write('xmlHttp.send(null);');
 	popup.document.write('}\n');
 	popup.document.write('function autoVom(selObj) {');
 	popup.document.write('paramForm.inputBook.value = selObj.options[selObj.selectedIndex].text;');
 	popup.document.write('}\n');
 	popup.document.write('function loadCat(selObj) {');
 	popup.document.write('getL();');
 	popup.document.write('for (i=0;i<document.getElementById("catList").length;i++)');
 	popup.document.write('{');
 	popup.document.write('var oJnf = document.getElementById("select" + i);');
 	popup.document.write('oJnf.style.visibility="hidden";oJnf.style.height=0;');
 	popup.document.write('oJnf.style.width=0;');
 	popup.document.write('}\n');
 	popup.document.write('var obj = document.getElementById("select" + selObj.selectedIndex);');
 	popup.document.write('obj.style.visibility="visible";obj.style.width=300;obj.style.height=100;');
 	popup.document.write('}\n');
 	popup.document.write('function FindDefinitionInList(UserSelection,objSelectBox)');
 	popup.document.write('{');
 	popup.document.write('var strSearchString, lngLenSearchString;');
 	popup.document.write('strSearchString = UserSelection.value;');
 	popup.document.write('lngLenSearchString = strSearchString.length;');
 	popup.document.write('for (i=0;i<objSelectBox.length;i++)');
 	popup.document.write('{');
 	popup.document.write('if (objSelectBox[i].text.substr(0,lngLenSearchString) == strSearchString){');
 	popup.document.write('objSelectBox.options[i].selected = true;');
 	popup.document.write('break;}');
 	popup.document.write('}\n');
 	popup.document.write('if(event.keyCode == 13) {');
 	popup.document.write('UserSelection.value = objSelectBox.options[i].text;}');
 	popup.document.write('}\n');
 	popup.document.write('</script>');
 	popup.document.write('</head><body>');
 	//alert(BrowserDetect.browser + " " + BrowserDetect.version + " " + BrowserDetect.OS);
 	//if(BrowserDetect.browser=="Explorer") popup.document.write('<div id="loading"><center><BR><BR>הדף נטען...&nbsp;<span id="percent">0</span>%<BR><img src="ajax-loader.gif"><BR><BR><BR></center></div>');
 	popup.document.write('<p>אנא הזן/י פרמטרים למקור : </p>');
 	popup.document.write('<form name="paramForm">');
 	popup.document.write('קטגוריה:<select id="catList" name="catList" onchange=\'loadCat(this);\'>');
 	popup.document.write('<option>תנ"ך</option><option>פרשנות-תנ"ך</option><option>משנה</option><option>תוספתא</option><option>מסכתות-קטנות</option><option>בבלי</option><option>ירושלמי</option><option>מדרשי-הלכה</option><option>מדרשי-אגדה</option><option>זוהר</option><option>גאונים</option><option>פרשנות-משנה</option><option>ראשונים</option><option>פוסקים</option><option>אחרונים</option><option>מנהגים</option><option>מצוות</option><option>מחשבה</option><option>רמב"ם</option><option>פרשנות-רמב"ם</option><option>טור</option><option>בית-יוסף</option><option>שולחן-ערוך</option><option>פרשנות-שו"ע</option><option>קיצור-שולחן-ערוך</option><option>חסידות</option><option>שות</option><option>כללים</option>');
 	popup.document.write('</select></div><BR>');
 	popup.document.write('ספר: <INPUT id="inputBook" name="inputBook" maxlength="70" onkeyup=\'FindDefinitionInList(getElementById("inputBook"),getElementById("select" + getElementById("catList").selectedIndex));\' style=\'FONT-FAMILY: arial; WIDTH: 100px;\' value=\'בראשית\'><BR>');
 	popup.document.write('רשימת ספרים:');
 		popup.document.write('<select id="select0" ondblclick="paramForm.inputBook.value = this.options[this.selectedIndex].text;" onchange=\"paramForm.inputBook.value = this.options[this.selectedIndex].text;\" dir=\"rtl\" size=6 class="lst1">');
 			popup.document.write('<option>בראשית</option>');
 			popup.document.write('<option>שמות</option>');
 			popup.document.write('<option>ויקרא</option>');
 			popup.document.write('<option>במדבר</option>');
 			popup.document.write('<option>דברים</option>');
 			popup.document.write('<option>יהושע</option>');
 			popup.document.write('<option>שופטים</option>');
 			popup.document.write('<option>שמואל א</option>');
 			popup.document.write('<option>שמואל ב</option>');
 			popup.document.write('<option>מלכים א</option>');
 			popup.document.write('<option>מלכים ב</option>');
 			popup.document.write('<option>ישעיהו</option>');
 			popup.document.write('<option>ירמיהו</option>');
 			popup.document.write('<option>יחזקאל</option>');
 			popup.document.write('<option>הושע</option>');
 			popup.document.write('<option>יואל</option>');
 			popup.document.write('<option>עמוס</option>');
 			popup.document.write('<option>עובדיה</option>');
 			popup.document.write('<option>יונה</option>');
 			popup.document.write('<option>מיכה</option>');
 			popup.document.write('<option>נחום</option>');
 			popup.document.write('<option>חבקוק</option>');
 			popup.document.write('<option>צפניה</option>');
 			popup.document.write('<option>חגי</option>');
 			popup.document.write('<option>זכריה</option>');
 			popup.document.write('<option>מלאכי</option>');
 			popup.document.write('<option>תהלים</option>');
 			popup.document.write('<option>משלי</option>');
 			popup.document.write('<option>איוב</option>');
 			popup.document.write('<option>שיר השירים</option>');
 			popup.document.write('<option>רות</option>');
 			popup.document.write('<option>איכה</option>');
 			popup.document.write('<option>קהלת</option>');
 			popup.document.write('<option>אסתר</option>');
 			popup.document.write('<option>דניאל</option>');
 			popup.document.write('<option>עזרא</option>');
 			popup.document.write('<option>נחמיה</option>');
 			popup.document.write('<option>דברי הימים א</option>');
 			popup.document.write('<option>דברי הימים ב</option>');
 		popup.document.write('</select>');
 
 		/*popup.document.write('<select id="select0" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst1">');
 		popup.document.write('<option>טוען רשימה...</option></select>');*/
 
 		popup.document.write('<select id="select1" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select2" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select3" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select4" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select5" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select6" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select7" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select8" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select9" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select10" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select11" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select12" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select13" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select14" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select15" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select16" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select17" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select18" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select19" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select20" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select21" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select22" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select23" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select24" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select25" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select26" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 		popup.document.write('<select id="select27" ondblclick="autoVom(this);" onchange="autoVom(this);" dir="rtl" size=6 class="lst0">');
 		popup.document.write('<option>טוען רשימה...</option></select>');
 
 	popup.document.write('<br>');
 	popup.document.write('חלק בספר (פרק, סימן וכד\'): <input type="text" name="inputPerek" maxlength="30" value="א" style=\"width:50px;\"><p>');
 	popup.document.write('חלק משנה (פסוק, סעיף וכד\') [לא חובה להזין]: <input type="text" name="inputPasuk" maxlength="30" value="א" style=\"width:50px;\"><p>');
 	popup.document.write('</form><br>');
 	popup.document.write('<p><a href="javascript:insertCode(); self.close();"> הוספת הקוד לחלון העריכה</a></p>');
 	popup.document.write('<p><a href="javascript:self.close()"> סגירה</a></p>');
 	popup.document.write('</body></html>');
 	popup.document.close();
 }
 
 /* הוספת כפתור מקורות לסרגל הכלים */
 
 function makorButton()
 {
 	if( document.getElementById("toolbar") )
 	{
 		var makorButton = document.createElement("img");
 		makorButton.width = 23;
 		makorButton.height = 22;
 		makorButton.src = "images/4/44/Button_makor.PNG";
 		makorButton.border = 0;
 		makorButton.alt = "הוספת מקור";
 		makorButton.title = "הוספת מקור";
 		makorButton.style.cursor = "pointer";
 		makorButton.onclick = popupMakor;
 		document.getElementById("toolbar").appendChild( makorButton );
 	}
 }
  
 hookEvent("load", makorButton);