ผู้ใช้:Bpitk/monobook.js
จาก วิกิซอร์ซ
คำแนะนำ: หลังจากบันทึกผลแล้ว คุณอาจจะต้องล้างแคชเว็บเบราว์เซอร์ของคุณเพื่อดูผลการเปลี่ยนแปลง
มอซิลลา / ไฟร์ฟอกซ์ / ซาฟารี: กดปุ่ม Shift ค้างไว้ขณะกดปุ่ม รีโหลด หรือกด Ctrl-F5 หรือกด Ctrl-R (Command-R สำหรับเครื่องแมคอินทอช);
คองเคอเรอร์: กดปุ่ม รีโหลด หรือกด F5;
โอเปร่า: อาจต้องล้างแคชทั้งหมดผ่านเมนู Tools → Preferences;
อินเทอร์เน็ตเอกซ์พลอเรอร์: กด Ctrl ค้างไว้ขณะที่กดปุ่ม รีเฟรช หรือกด Ctrl-F5;
/* from ผู้ใช้:Bpitk/monobook.js */ function addlilink(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); tabs.appendChild(li); na.accesskey = key; var pref = 'alt-'; if(((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1)) || navigator.userAgent.toLowerCase().indexOf( 'mac' ) != -1 ) pref = 'control-'; if(clientPC.indexOf('opera')!=-1) pref = 'shift-esc-'; if(key && title) na.title = title + ' [' + pref + key + ']'; else if(title) na.title = title; else if(key) na.title = '[' + pref + key + ']'; return li; } function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; addlilink(tabs, url, name, id, title, key); } function getPname() { z=document.getElementById("content").childNodes; for (var n=0;n<z.length;n++) { if (z[n].className=="firstHeading") return z[n].textContent; }; } // ========== Replace string ========== // Javascript from http://www.irt.org/script/242.htm function replace(string,text,by) { var strLength = string.length, txtLength = text.length; if ((strLength == 0) || (txtLength == 0)) return string; var i = string.indexOf(text); if ((!i) && (text != string.substring(0,txtLength))) return string; if (i == -1) return string; var newstr = string.substring(0,i) + by; if (i+txtLength < strLength) newstr += replace(string.substring(i+txtLength,strLength),text,by); return newstr; } // ========== {{พระสูตรและอรรถกถา}} ========== function doAddHead() { text = document.editform.wpTextbox1.value; text = "{{พระสูตรและอรรถกถา}}"+'\n'+text; document.editform.wpTextbox1.value = text; } function addHead() { addTab("javascript:doAddHead()", "{{", "Add Head", "Add Head", "Add Head"); akeytt(); } if (document.title.indexOf("กำลังแก้ไข") == 0) { if (window.addEventListener) window.addEventListener("load", addHead, false); else if (window.attachEvent) window.attachEvent("onload", addHead); } // ========== ดูเพิ่ม ========== function doAddLink() { text = document.editform.wpTextbox1.value; text = text+'\n'+"==ดูเพิ่ม=="+'\n'+"*[["+document.editform.wpSummary.value+"]]"; document.editform.wpTextbox1.value = text; } function addLink() { addTab("javascript:doAddLink()", "=+=", "Add Link", "Add Link", "Add Link"); akeytt(); } if (document.title.indexOf("กำลังแก้ไข") == 0) { if (window.addEventListener) window.addEventListener("load", addLink, false); else if (window.attachEvent) window.attachEvent("onload", addLink); } // ========== เว้นบรรทัด ========== function doConvertNumber() { text = document.editform.wpTextbox1.value; text = replace(text,'\n','\n\n'); document.editform.wpTextbox1.value = text; } function addConvertNumber() { addTab("javascript:doConvertNumber()", "+ บรรทัด", "Double Line", "Double Line", "Double Line"); akeytt(); } if (document.title.indexOf("กำลังแก้ไข") == 0) { if (window.addEventListener) window.addEventListener("load", addConvertNumber, false); else if (window.attachEvent) window.attachEvent("onload", addConvertNumber); } // ========== แทนอักษรบาลี ========== function doConvertAph() { text = document.editform.wpTextbox1.value; text = replace(text,'',''); text = replace(text,'','ํ'); text = replace(text,'','ญ'); text = replace(text,'','ฐ'); text = replace(text,'','ํ'); text = replace(text,'','ญ'); text = replace(text,'','ฐ'); text = replace(text,'แก้อรรถ',"'''แก้อรรถ'''"); document.editform.wpTextbox1.value = text; } function addConvertAph() { addTab("javascript:doConvertAph()", "[๐]", "Alphabet replace", "Alphabet replace", "Alphabet replace"); akeytt(); } if (document.title.indexOf("กำลังแก้ไข") == 0) { if (window.addEventListener) window.addEventListener("load", addConvertAph, false); else if (window.attachEvent) window.attachEvent("onload", addConvertAph); } // ========== จัดย่อหน้า ========== function doConvertNewLine() { text = document.editform.wpTextbox1.value; text = replace(text,'\t',' '); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n:'); text = replace(text,'\n ','\n'); document.editform.wpTextbox1.value = text; } function addConvertNewLine() { addTab("javascript:doConvertNewLine()", "ย่อหน้า", "Convert NewLine", "Convert NewLine", "Convert NewLine"); akeytt(); } if (document.title.indexOf("กำลังแก้ไข") == 0) { if (window.addEventListener) window.addEventListener("load", addConvertNewLine, false); else if (window.attachEvent) window.attachEvent("onload", addConvertNewLine); }