ผู้ใช้:Pubat/monobook.js

จากวิกิพีเดีย สารานุกรมเสรี

หมายเหตุ: หลังเผยแพร่ คุณอาจต้องล้างแคชเว็บเบราว์เซอร์ของคุณเพื่อดูการเปลี่ยนแปลง

  • ไฟร์ฟอกซ์ / ซาฟารี: กด Shift ค้างขณะคลิก Reload หรือกด Ctrl-F5 หรือ Ctrl-R (⌘-R บนแมค)
  • กูเกิล โครม: กด Ctrl-Shift-R (⌘-Shift-R บนแมค)
  • อินเทอร์เน็ตเอกซ์พลอเรอร์ และ Edge: กด Ctrl ค้างขณะคลิก Refresh หรือกด Ctrl-F5
  • โอเปร่า: กด Ctrl-F5
/* <pre><nowiki> */

// ========== สคริปต์จัดให้ ตัวเลือกปรับแต่ง ==========
// == ให้รีเฟรชแคช (Ctrl+F5 สำหรับ IE) ที่หน้านี้หลังจากเปลี่ยนค่า ==

iScriptConfig = {
  gender : "male",
  useFullNames : true,
  useAjaxApi : true,
  useMyWelcome : false,
  usePreciseConversion : false,
  useOldTabsNavigation: false,
  userTalkPageMode : "blank",
  searchURL : "http://www.google.co.th/search?hl=th&q=",
  useEnhancedRollback : true,
  autoNotifyUploader : false,
  wikiProjectTabs : "all",
  bookmark1 : ["", ""],
  bookmark2 : ["", ""],
  bookmark3 : ["", ""],
  bookmark4 : ["", ""],
  bookmark5 : ["", ""],
  deluxeSummary1 : ["", ""],
  deluxeSummary2 : ["", ""],
  deluxeSummary3 : ["", ""]

};


// ========== สคริปต์จัดให้ สำหรับชาววิกิพีเดีย ==========
importScript('User:Jutiphan/iScript/main.js');

// ========== Quick Wikify ==========
function doQwikify() {
  document.editform.wpTextbox1.value = "{{ช่วยดูหน่อย}}\n\n" + document.editform.wpTextbox1.value;
  document.editform.wpSummary.value = "ช่วยดูหน่อย";
  document.editform.wpMinoredit.checked = true;
  document.editform.submit() ;
}

function addQwikify() {
  addTab("javascript:doQwikify() ", "ช่วย", "ca-wikify", "แจ้งว่าช่วยดูหน่อย", "") ;
  akeytt() ;
}

if (document.title.indexOf("แก้ไข ") == 0) {
  if (window.addEventListener) window.addEventListener("load", addQwikify, false) ;
  else if (window.attachEvent) window.attachEvent("onload", addQwikify) ;
}

// ========== สคริปต์จัดให้ สำหรับหน่วยเก็บกวาดเฉพาะกิจ ==========
// == ให้รีเฟรชแคช (Ctrl+F5 สำหรับ IE) ที่หน้านี้หลังจากแก้ไข หรือเพื่อรับรุ่นล่าสุด ==
 document.write('<script type="text/javascript" src="' 
    + 'http://th.wikipedia.org/w/index.php?title=User:Jutiphan/iScript/main.js' 
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

/*document.write('<script src="http://localhost/iScript/LocalMain.js" type="text/javascript"></script>');
*/

if(iScriptConfig.usingLocalMain == 'undefined') {
  document.write('<script type="text/javascript" src="' 
    + 'http://th.wikipedia.org/w/index.php?title=User:Jutiphan/iScript/main.js' 
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
}

if(iScriptConfig.enableTestScripts) {
  // ========== ความสามารถทดสอบ ==========
  document.write('<script type="text/javascript" src="'
    + 'http://localhost/iScript/debug.js'
    + '"></script>');
}

if(is_gecko) {
  importScript('mediawiki:Gadget-popups.js');
  importStylesheet('mediawiki:Gadget-navpop.css')
}

// ========== เก็บกวาดย่อย ==========
function doMClink() {
z = document.editform.wpTextbox1.value;
z = z.replace("[[ภาพ:","[[ไฟล์:");
z = z.replace("[[Image:","[[ไฟล์:");
z = z.replace("[[File:","[[ไฟล์:");
z = z.replace("[[Media:","[[ไฟล์:");
z = z.replace("[[สื่อ:","[[ไฟล์:");
z = z.replace("url=http://maps.google.com/maps?t=k&q=Thailand&ll=", "");
z = z.replace("ภาพถ่ายทางอากาศ","แผนที่-อาคาร");
z = z.replace("<references />","{{รายการอ้างอิง}}");
z = z.replace("<References />","{{รายการอ้างอิง}}");
z = z.replace("<references/>","{{รายการอ้างอิง}}");
z = z.replace("<References/>","{{รายการอ้างอิง}}");
z = z.replace("{{reflist}}","{{รายการอ้างอิง}}");
z = z.replace("{{Reflist}}","{{รายการอ้างอิง}}");


document.editform.wpTextbox1.value = z;
//  document.editform.submit();

}
function addMClink() {
  addTab("javascript:doMClink()", "กวาดย่อย", "ca-MClink", "กวาดย่อย", "");
  akeytt();
}
 
if (document.title.indexOf("แก้ไข ") == 0) {
  if (window.addEventListener) window.addEventListener("load", addMClink, false);
  else if (window.attachEvent) window.attachEvent("onload", addMClink);
}


// ========== ใส่กล่องจำแนกพันธุ์ ==========
function doBIlink() {
 z = document.editform.wpTextbox1.value;
z = z.replace("ตัวอย่างกล้วยไม้ในประเทศไทย","รายชื่อกล้วยไม้ในประเทศไทย");
// z = z.slice(z.indexOf("http"),200);
  document.editform.wpTextbox1.value = "{{ตารางจำแนกพันธุ์\n| name = \n| image = \n| image_caption = \n| regnum = [[พืช]] ([[Plantae]])\n| divisio = \n| classis = \n| ordo = \n| familia = \n| genus = \n| species = \n| binomial = \n| binomial_authority = \n}}\n\n" + z;
  document.editform.wpSummary.value = "[[WP:CLEAN2]]";
  document.editform.wpMinoredit.checked = true;
//  document.editform.submit();

}
function addBIlink() {
  addTab("javascript:doBIlink()", "ตารางจำแนก", "ca-BIlink", "ใส่ตารางจำแนก", "");
  akeytt();
}
 
if (document.title.indexOf("แก้ไข ") == 0) {
  if (window.addEventListener) window.addEventListener("load", addBIlink, false);
  else if (window.attachEvent) window.attachEvent("onload", addBIlink);
}


// ========== ใส่กล่องภาพ ==========
function doSTlink() {
 z = document.editform.wpTextbox1.value;
// z = z.slice(z.indexOf("http"),200);
  document.editform.wpTextbox1.value = "== คำอธิบายโดยย่อ ==\n{{nonfreeimage\n| คำอธิบายภาพ = \n| เจ้าของลิขสิทธิ์ = \n| เว็บไซต์ที่มา = \n| เหตุผลในการใช้ภาพ = \n}}\n\n" + z;
  document.editform.wpSummary.value = "[[WP:CLEAN2]]";
  document.editform.wpMinoredit.checked = true;
//  document.editform.submit();
}
function addSTlink() {
  addTab("javascript:doSTlink()", "กล่องภาพ", "ca-STlink", "ใส่กล่องภาพ", "");
  akeytt();
}
 
if (document.title.indexOf("แก้ไข ") == 0) {
  if (window.addEventListener) window.addEventListener("load", addSTlink, false);
  else if (window.attachEvent) window.attachEvent("onload", addSTlink);
}



// ========== ลบภาพประดับ ==========
function doCOlink() {
//    document.mw-img-deleteconfirm.wpReason.value = "[[WP:FAIR|ภาพละเมิดลิขสิทธิ์ประดับบทความ]]";
//    document.mw-img-deleteconfirm.mw-filedelete-submit();
}
function addCOlink() {
  addTab("javascript:doCOlink()", "ภาพประดับ", "ca-COlink", "ลบภาพประดับบทความ", "");
  akeytt();
}
 
if (document.title.indexOf("ลบ") == 0) {
  if (window.addEventListener) window.addEventListener("load", addCOlink, false);
  else if (window.attachEvent) window.attachEvent("onload", addCOlink);
}


// ========== แจ้งโฆษณา ==========
$(function() {
  //check if called from deletion request
  if(document.getElementById('ca-nstab-special')) {
    return;
  }

  if (document.title.indexOf("แก้ไข") != -1) {
    if (document.URL.lastIndexOf("&fakeaction=advert") == -1)
      return;

    document.editform.wpTextbox1.value = "{{โฆษณา}}\n\n" + document.editform.wpTextbox1.value;
    document.editform.wpSummary.value = "แจ้งโฆษณา";
    document.editform.submit() ;
    return;
  }
  addTab("javascript:doAdvert() ", "แจ้งโฆษณา", "ca-advert", "คำสั่งแจ้งโฆษณา", "") ;
}) ;
 
function doAdvert() {
  //edit page
  var title = document.title.substr(0, document.title.lastIndexOf(' - วิกิพีเดีย')) ;
  location.assign("/w/index.php?title=" + title + "&action=edit&fakeaction=advert") ;
}

//<nowiki>
// ========== แจ้งลบ ==========
$(function() {
  //check if called from deletion request
  if(document.getElementById('ca-nstab-special')) {
    return;
  }

  if (document.title.indexOf("แก้ไข") != -1) {
    if (document.URL.lastIndexOf("&fakeaction=speedydel") == -1)
      return;

    document.editform.wpTextbox1.value = "{{ลบ}}\n\n" + document.editform.wpTextbox1.value;
    document.editform.wpSummary.value = "แจ้งลบ";
    document.editform.submit() ;
    return;
  }
  addTab("javascript:doQsd() ", "แจ้งลบ", "ca-sd", "คำสั่งแจ้งลบ", "") ;
}) ;
 
function doQsd() {
  //edit page
  var title = document.title.substr(0, document.title.lastIndexOf(' - วิกิพีเดีย')) ;
  location.assign("/w/index.php?title=" + title + "&action=edit&fakeaction=speedydel") ;
}

// ========== แจ้งละเมิดลิขสิทธิ์ (รุ่นใส่เวลาไทย) ==========
function doCopyViolation() {
  var currentDay = new Date() ;
  var thaiDate = new Date(currentDay.getTime() + 25200000) ; //7*1000*60*60
  var month = thaiDate.getUTCMonth() +1;
  var year = thaiDate.getUTCFullYear() +543;

  document.editform.wpTextbox1.value = "{{ละเมิดลิขสิทธิ์ | url=  | วันที่=" + thaiDate.getUTCDate()
 + "/" + month + "/" + year + " | หมายเหตุ= }}"
  document.editform.wpSummary.value = "แจ้งละเมิดลิขสิทธิ์ ";
}
function addCopyViolation() {
  addTab("javascript:doCopyViolation() ", "ละเมิด", "ca-vio", "แจ้งละเมิดลิขสิทธิ์", "") ;
  akeytt() ;
}

if (document.title.indexOf("แก้ไข ") == 0) {
  if (window.addEventListener) window.addEventListener("load", addCopyViolation, false) ;
  else if (window.attachEvent) window.attachEvent("onload", addCopyViolation) ;
}
//</nowiki>

// ========== Replace string ==========
// Javascript from http://www.irt.org/script/242.htm
function replace(string,text,by) {
// Replaces text with by in string
    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;
}

// ========== Thai to Arabic Numbers ==========
// This script converts all Thai numbers (๑ ๒ ๓) to Arabic numbers (1 2 3)
function doConvertNumber() {
  text = document.editform.wpTextbox1.value;
  text = replace(text,'๑','1') ;
  text = replace(text,'๒','2') ;
  text = replace(text,'๓','3') ;
  text = replace(text,'๔','4') ;
  text = replace(text,'๕','5') ;
  text = replace(text,'๖','6') ;
  text = replace(text,'๗','7') ;
  text = replace(text,'๘','8') ;
  text = replace(text,'๙','9') ;
  text = replace(text,'๐','0') ;
  document.editform.wpTextbox1.value = text;
  document.editform.wpSummary.value = "เปลี่ยนเลขไทยเป็นอารบิก";
}

function addConvertNumber() {
  addTab("javascript:doConvertNumber() ", "๒ ->2", "ca-tanum", "เปลี่ยนเลขไทยเป็นอารบิก", "") ;
  akeytt() ;
}

if (document.title.indexOf("แก้ไข ") == 0) {
  if (window.addEventListener) window.addEventListener("load", addConvertNumber, false) ;
  else if (window.attachEvent) window.attachEvent("onload", addConvertNumber) ;
}

// ========== Arabic to Thai Numbers ==========
// This script converts all Arabic numbers (1 2 3) to Thai numbers (๑ ๒ ๓)
function doConvertToThaiNumber() {
  text = document.editform.wpTextbox1.value;
  text = replace(text,'1','๑') ;
  text = replace(text,'2','๒') ;
  text = replace(text,'3','๓') ;
  text = replace(text,'4','๔') ;
  text = replace(text,'5','๕') ;
  text = replace(text,'6','๖') ;
  text = replace(text,'7','๗') ;
  text = replace(text,'8','๘') ;
  text = replace(text,'9','๙') ;
  text = replace(text,'0','๐') ;
  document.editform.wpTextbox1.value = text;
  document.editform.wpSummary.value = "เปลี่ยนเลขอารบิกเป็นไทย";
}
function addConvertToThaiNumber() {
  addTab("javascript:doConvertToThaiNumber() ", "2 ->๒", "ca-atnum", "เปลี่ยนเลขอารบิกเป็นไทย", "") ;
  akeytt() ;
}

if (document.title.indexOf("แก้ไข ") == 0) {
  if (window.addEventListener) window.addEventListener("load", addConvertToThaiNumber, false) ;
  else if (window.attachEvent) window.attachEvent("onload", addConvertToThaiNumber) ;
}


// ========== Edit Section 0 ==========
function addEditSection0() {
  ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page'];
  if (!document.getElementById) return;
  x = document.getElementById('ca-edit') ;
  if(!x) return;
  y = document.createElement('LI') ;
  y.id = 'ca-edit-0';
  if (x.className == 'selected') {
    if (/&action=edit&section=0$/.test(window.location.href)) {
      x.className = 'istalk';
      y.className = 'selected';
    } else {
      x.className = 'selected istalk';
    }
  } else if (x.className == 'selected istalk') {
    if (/&action=edit&section=0$/.test(window.location.href)) {
      x.className = 'istalk';
      y.className = 'selected istalk';
    } else {
      y.className = 'istalk';
    }
  } else {
    y.className = x.className;
    x.className = 'istalk';
  }
  z = document.createElement('A') ;
  if (x.children) {
    z.href = x.children[0].href + '&section=0';
    z.appendChild(document.createTextNode('0')) ;
    y.appendChild(z) ;
    document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling) ;
  } else {
    z.href = x.childNodes[0].href + '&section=0';
    z.appendChild(document.createTextNode('0')) ;
    y.appendChild(z) ;
    document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling) ;
  }
}

if (document.title.indexOf("Editing ") == -1) {
  if (window.addEventListener) window.addEventListener("load", addEditSection0, false) ;
  else if (window.attachEvent) window.attachEvent("onload", addEditSection0) ;
}


// ========== ดูความแตกต่างล่าสุด (Last diff) ==========
var articleTitle = mw.config.get('wgPageName');

function doLastDiff() {
  var nurl="http://th.wikipedia.org/w/index.php?title=" + articleTitle + "&diff=cur&oldid=prev";
  document.location=nurl;
}

function addLastDiff() {
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul') [0];
    var l=addlilink(tabs, "javascript:doLastDiff() ", 'ล่าสุด', '') ;
    l.lastChild.title="ดูความแตกต่างล่าสุด";
}

if (document.title.indexOf("แก้ไข") == -1) {
  if(wgCanonicalNamespace.indexOf("Special") == -1) {
    if (window.addEventListener) window.addEventListener("load", addLastDiff, false) ;
    else if (window.attachEvent) window.attachEvent("onload", addLastDiff) ;
  }
}


/* <nowiki><pre> */