User:ST77/TScripts/Tabs1/monobook.js

/* */

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

// ========== Cleanup ========== function doCleanupTag(isSpeedy) { document.body.style.cursor = 'wait'; text = document.editform.wpTextbox1.value;

if(text.indexOf("nocleanup") >= 0) { alert("You may not cleanup this page as it is not expected you to do it."); return; }

//Format text = text.replace(/ |/gi, " "); text = text.replace(/([^\[]|^)\[([^\[^\]]*?)\]\]/gm, "$1$2"); text = text.replace(/\[\[([^\[^\]].*?)[$[^\]]?]/gm, "$1"); text = text.replace(/\[\[ ?([^\]\|]*?) \s*([\|\s|\]\]])/g, "[[$1$2"); text = text.replace(/^([\*#]+) /gm, "$1"); text = text.replace(/^([\*#]+)/gm, "$1 "); text = text.replace(/^= ?([^=].*?) ?=/gm,"== $1 =="); text = text.replace(/^(={1,5}) *(.*?) ?(={1,5}) *$/gm, "$1 $2 $3"); text = text.replace(/&prime;/g, "'"); text = text.replace(/&amp;/g, "&"); text = text.replace(/&minus;/g, "−"); text = text.replace(/&times;/g, "×"); text = text.replace(/&mdash;/g, "—"); text = text.replace(/–/g, "-"); text = text.replace(/(.[^\s\[\(])\(/g,"$1 ("); text = text.replace(/\)(.[^\s\[\(])/g,") $1"); text = text.replace(/\* ? ?(.*?)\r?\n/g,"* $2 $1\n"); text = text.replace(/ ? ?([^\r]*?) ?<\/ref>/g,"$3 $2 "); text = text.replace(/ *\|(?!-) *\r?\n *([^=\*<|{}]*?) ?=(?!=) *([^\|={}]*?)/g,"\n| $1 = $2"); text = text.replace(/\n *\|(?!-) *([^={}\*].*?) ?= *([^<={}]*?) \| ?( *}} *\r?\n| *\r?\n *}} *\r?\n)/g, "\n| $1 = $2\n}}\n") text = text.replace(/\n *\|(?!-) *([^=\|'"{}]*?) ?= *([^=]*?) *\r/g,"\n| $1 = $2"); text = text.replace(/(A\.D\.|AD\.)(\d{1,4})/g,"A.D. $2");

//Spellings if(text.indexOf("nofixbot") == -1) { text = text.replace(/recieve/g,"receive"); }

if(wgNamespaceNumber == 0 && wgPageName.indexOf("Wikipedia:") != 0) { text = text.replace(/-{0,2} ?\[\[User:.*/g,""); }

text = text.replace(/(== ?) ?(Websites|Website|Other Websites|Other Website|Links|Link|External Link) *==/g,'$1External Links ==');

if((wgNamespaceNumber == 0 || wgNamespaceNumber == 4 || wgNamespaceNumber == 14) && document.URL.indexOf("&section=") == -1 && text.indexOf("#REDIRECT") == -1 && text.indexOf("") == -1 && text.indexOf("") == -1 && text.indexOf("[[Category:") == -1 && text.indexOf("{{Disambiguation") == -1) {   text = "\n" + text;    if(document.editform.wpSummary.value.length == 0) {      document.editform.wpSummary.value = "Mark as uncategorized";    } else {      document.editform.wpSummary.value += " + Uncategorized";    }  }

document.editform.wpTextbox1.value = text; if(isSpeedy == 1) { if(document.editform.wpSummary.value.length == 0) { document.editform.wpSummary.value = "Speedy Cleanup article"; document.editform.wpMinoredit.checked = true; } else { document.editform.wpSummary.value += " + Speedy Cleaup article"; } } else { if(document.editform.wpSummary.value.indexOf("Cleanup article") == -1) { if(document.editform.wpSummary.value.length == 0) { document.editform.wpSummary.value = "Edit + Cleanup"; } else { var eIndex = document.editform.wpSummary.value.lastIndexOf("using tabs script"); if(eIndex != -1) { var strTmp = document.editform.wpSummary.value; document.editform.wpSummary.value = strTmp.substring(0,eIndex) + " + Cleanup"; } else { document.editform.wpSummary.value = document.editform.wpSummary.value + " + Cleanup article"; }     }    }  }  document.body.style.cursor = 'auto'; }

function getUploader { //NOTE: DOES NOT work in Edit page // Get uploader from first point in the list under "File history" // Uploader is stored in second A tag in UL tag under "File history" // Returns title of user page (without name space) in URL form var el = document.getElementById('filehistory') if (!el) { alert("getUploader: Cannot find filehistory ... exiting"); return null; } while (el.nextSibling) { el = el.nextSibling; if (el.tagName && el.tagName.toLowerCase == 'ul') break; } if (!el) { alert("getUploader: Cannot find UL tag ... exiting"); return null; }

var els = el.getElementsByTagName('li'); if (!els) { alert("getUploader: Cannot find LI tag ... exiting"); return null; } var uploaders = new Array; var re1 = new RegExp('http://' + (wgServer + '/wiki/').replace(/\./g, '\\.') + 'User:(.*)$'); var re2 = new RegExp('http://' + (wgServer + '/w/index.php').replace(/\./g, '\\.') + '\\?title=User:([^&]*)'); var re3 = /(User)?talk:(.*)$/; // this is for IE and handling Unicode characters

var m; var uploader; var uploaderList = ""; var count = 0; el = els[0]; do { var as = el.childNodes; for (var k=0; k 0) uploaderList += "; "; uploaderList += count + " - " + uploader; uploaders[uploaders.length] = uploader; count += 1; }   el = el.nextSibling; } while (el);

if (!uploaders || uploaders.length == 0) { alert("getUploader: Cannot find uploader ... exiting"); return null; } if (uploaders.length == 1) return uploaders[0];

var which = parseInt(window.prompt("Choose which uploader to notify: " + uploaderList)); if (isNaN(which) || which < 0 || which > uploaders.length) { alert("getUploader: Invalid selection ... exiting"); return null; } return uploaders[which]; }

function assignToEditForm(iScriptAction) { var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia')); location.assign("/w/index.php?title=" + title + "&action=edit&iScriptAction=" + iScriptAction); }

function assignToEditTalkForm(iScriptAction) { var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia')); title = title.replace("Talk:",""); location.assign("/w/index.php?title=Talk:" + title + "&action=edit&iScriptAction=" + iScriptAction); }

function doInvalidLicense { var pagename = encodeURIComponent(mw.config.get('wgPageName')); var uploader = getUploader; if (!uploader) { alert("Eror. Report this bug to User:ST77 : Message: Invalid License & GetUploader is unavailable. "); return; }

var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia')); location.assign("/w/index.php?title=" + title + "&action=edit&iScriptAction=invalidLicense&Uploader=" + uploader); }

function doNoLicense { var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia')); location.assign("/w/index.php?title=" + title + "&action=edit&iScriptAction=noLicense"); }

function notifyUploader { var pagename = encodeURIComponent(mw.config.get('wgPageName')); var uploader = getUploader; if (!uploader) return;

location.assign("/w/index.php?title=User_talk:" + uploader + "&action=edit&iScriptAction=warnNoImageLicense&target=" + pagename); //NOTE: This will be handled in userTabs/monobook.js module }

// ======================================================== // mainTabs // Main Load Function // // User:Jutiphan Created: 7/1/2007 Last Modified: 7/1/2007 // Replaced: lastdiff, cleanup, advert, speedydel // ======================================================== $( function {

//Add Cleanup Toolbar button var tooly = document.getElementById('toolbar'); if (tooly != null) { var cleanupButton = ""; tooly.innerHTML = tooly.innerHTML + cleanupButton; }

//Add SpeedyCleanup,lastDiff tabs if article, Add Advert, Qsd tabs if not in user namespace if(wgIsArticle) { addTab("javascript:assignToEditForm('speedyCleanup')", "★Clean", "ca-scleanup", "Speedy Cleanup", ""); if(wgNamespaceNumber != 2 && wgNamespaceNumber != 3 && wgNamespaceNumber != 6) { //If not user, user talk & image namespace addTab("javascript:assignToEditForm('needCleanup')", tNeedCleanup,"ca-ncleanup","แจ้งช่วยดูหน่อย",""); addTab("javascript:assignToEditForm('needCopyvioCheck')","↑ตรวจลิขสิทธิ์","ca-nCopyvioCheck","แจ้งต้องการตรวจลิขสิทธิ์",""); addTab("javascript:assignToEditForm('advert')", tAdvert, "ca-advert", "แจ้งโฆษณา", ""); if(iScriptConfig.enableTestScripts) { addTab("javascript:assignToEditForm('resume')", "↑เรซูเม", "ca-resume", "แจ้งเรซูเม", ""); }     addTab("javascript:assignToEditTalkForm('pThailand')", tPortalThailand, "ca-pThailand", "แจ้งอยู่ในโครงการวิกิประเทศไทย", ""); addTab("javascript:assignToEditTalkForm('doCele')","↑เฉลิม.","ca-Cele","แจ้งอยู่ในโครงการเฉลิมพระเกียรติ",""); }   if(wgNamespaceNumber == 6) { addTab("javascript:doInvalidLicense",tInvalidLicense,"ca-invalidLicense","แจ้งสัญญาอนุญาตไม่ถูกต้อง และเตือนผู้ใช้",""); if(iScriptConfig.enableTestScripts) { addTab("javascript:doNoLicense","แจ้งไม่ได้ระบุ","ca-noLicense","แจ้งไม่ได้ระบุ",""); addTab("javascript:notifyUploader","แจ้งผู้อัปโหลด","ca-notifyUploader","แจ้งผู้อัปโหลดภาพ",""); }   }    addTab("javascript:assignToEditForm('speedydel')", tDelete, "ca-sd", "แจ้งลบ", ""); addTab("javascript:doLastDiff","last","ca-ldff","Most recent diff",""); }

if (document.title.indexOf("Editing ") != -1 && document.URL.indexOf("&iScriptAction=") != -1) { if (wgNamespaceNumber == 0 && wgArticleId == 0) { alert("บทความนี้ได้ถูกลบโดยผู้ดูแลระบบไปแล้ว"); return; }

if (document.URL.lastIndexOf("&iScriptAction=speedyCleanup") != -1) { doCleanupTag(1); document.editform.submit; return;

} else if (document.URL.lastIndexOf("&iScriptAction=needCleanup") != -1) { text = document.editform.wpTextbox1.value; text = text.replace(//g,""); text = "\n" + text; document.editform.wpTextbox1.value = text; document.editform.wpSummary.value = "แจ้งต้องการเก็บกวาดด้วยสคริปต์จัดให้"; document.editform.submit; return;

} else if (document.URL.lastIndexOf("&iScriptAction=advert") != -1) { document.editform.wpTextbox1.value = "\n" + document.editform.wpTextbox1.value; document.editform.wpSummary.value = "แจ้งโฆษณาด้วยสคริปต์จัดให้"; document.editform.submit; return;

} else if (document.URL.lastIndexOf("&iScriptAction=resume") != -1) { document.editform.wpTextbox1.value = "\n" + document.editform.wpTextbox1.value; document.editform.wpSummary.value = "แจ้งอ่านเหมือนเรซูเมด้วยสคริปต์จัดให้"; document.editform.submit; return;

} else if (document.URL.lastIndexOf("&iScriptAction=needCopyvioCheck") != -1) { document.editform.wpTextbox1.value = "\n" + document.editform.wpTextbox1.value; document.editform.wpSummary.value = "แจ้งต้องการตรวจลิขสิทธิ์ด้วยสคริปต์จัดให้"; document.editform.submit; return;

} else if (document.URL.lastIndexOf("&iScriptAction=speedydel") != -1) { var textbox = document.editform.wpTextbox1.value; if(textbox.indexOf("{{ลบ") >= 0) { alert("บทความนี้ได้ถูกแจ้งลบไปก่อนหน้านี้แล้ว ยกเลิกการแจ้งลบเพื่อป้องกันการแจ้งซ้ำ"); return; }

if(wgCanonicalNamespace == "" && textbox.length < 500 && textbox.indexOf("#REDIRECT") != 0) { var qsdReason = ""; } else { var qsdReason = prompt("กรุณาระบุสาเหตุที่แจ้งลบ (เว้นว่างและคลิก OK หากจะไม่ระบุ):", "") if(qsdReason == undefined) { return; }     }

if(qsdReason.length == 0) { if(wgNamespaceNumber == 10) { document.editform.wpTextbox1.value = " {{ลบ}} " + document.editform.wpTextbox1.value; } else { document.editform.wpTextbox1.value = "{{ลบ}}\n\n" + document.editform.wpTextbox1.value; }       document.editform.wpSummary.value = "แจ้งลบด้วยสคริปต์จัดให้";

} else { if(wgNamespaceNumber == 10) { document.editform.wpTextbox1.value = " {{ลบ|" + qsdReason + "}} " + document.editform.wpTextbox1.value; } else { document.editform.wpTextbox1.value = "{{ลบ|" + qsdReason + "}}\n\n" + document.editform.wpTextbox1.value; }       document.editform.wpSummary.value = "แจ้งลบด้วยสคริปต์จัดให้: " + qsdReason; }     document.editform.submit; return;

} else if (document.URL.lastIndexOf("&iScriptAction=pThailand") != -1) { if(document.editform.wpTextbox1.value.indexOf("") != -1) { alert("บทความนี้ ได้รับแจ้งอยู่ในโครงการวิกิประเทศไทยไปแล้ว"); } else { document.editform.wpTextbox1.value = "\n" + document.editform.wpTextbox1.value; document.editform.wpSummary.value = "แจ้งอยู่ในโครงการวิกิประเทศไทยด้วยสคริปต์จัดให้"; document.editform.submit; }     return;

} else if (document.URL.lastIndexOf("&iScriptAction=doCele") != -1) { if(document.editform.wpTextbox1.value.indexOf("") != -1) { alert("บทความนี้ ได้รับแจ้งเป็นบทความในโครงการเฉลิมพระเกียรติไปแล้ว"); } else { var level = prompt("กรุณาระบุระดับของบทความนี้: คัดสรร คุณภาพ ดี พอใช้ โครง (เว้นว่างและคลิก OK หากจะไม่ระบุ)", "") if(level == undefined) { return; }       if(level.length == 0) { document.editform.wpTextbox1.value = "\n" + document.editform.wpTextbox1.value; document.editform.wpSummary.value = "แจ้งอยู่ในโครงการเฉลิมพระเกียรติด้วยสคริปต์จัดให้"; } else { document.editform.wpTextbox1.value = "\n" + document.editform.wpTextbox1.value; document.editform.wpSummary.value = "แจ้งอยู่ในโครงการเฉลิมพระเกียรติด้วยสคริปต์จัดให้: " + level; }       document.editform.submit; }     return;

} else if (document.URL.lastIndexOf("&iScriptAction=invalidLicense") != -1) { if(document.editform.wpTextbox1.value.indexOf("{{ภาพที่อาจจะละเมิดลิขสิทธิ์") != -1) { alert("ภาพนี้ ได้รับแจ้งเกี่ยวกับสัญญาอนุญาตไม่ถูกต้องไปแล้ว"); } else { var currentDay = new Date; var thaiDate = new Date(currentDay.getTime + 25200000); var year = thaiDate.getUTCFullYear+543; var month = thaiDate.getUTCMonth+1;

document.editform.wpTextbox1.value += "{{ภาพที่อาจจะละเมิดลิขสิทธิ์|" + thaiDate.getUTCDate + "/" + month + "/" + year + "}}"; document.editform.wpSummary.value = "แจ้งต้องการตรวจสอบสัญญาอนุญาต";

var pagename = encodeURIComponent(mw.config.get('wgPageName')); var uploader = getParamValue("Uploader"); if (uploader) { openInNewWindow(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?title=User_talk:" + uploader + "&action=edit&iScriptAction=warnInvalidImageLicense&target=" + pagename,'iScriptWarnWindow'); }       document.editform.submit; }     return;

} else if (document.URL.lastIndexOf("&iScriptAction=noLicense") != -1) { var currentDay = new Date; var thaiDate = new Date(currentDay.getTime + 25200000); var year = thaiDate.getUTCFullYear+543; var month = thaiDate.getUTCMonth+1;

document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(//g,""); document.editform.wpSummary.value = "แจ้งภาพไม่ได้ระบุ พร้อมใส่วันที่แจ้งด้วยสคริปต์จัดให้"; document.editform.submit; } } }); /*  */