ميدياويكي:Gadget-easy db.js

ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات.

//[[en:user:Where/easy db]]

$(function()
{
  //check if called from deletion request
  if (document.title.indexOf("تحرير ") != -1)
  {
    if (document.URL.lastIndexOf("&fakeaction=huff") == -1)
      return;
    // does the page exist?
    if (mw.config.get('wgCurRevisionId') == false)
    {
      alert("قد حذفت الصفحة من قبل");
      return;
    }
    if (document.URL.lastIndexOf("&reason=off") != -1)
    {
      var type = prompt("اكتب رمز معيار الحذف السريع\n(a1, g3...)");
      if (type == null)
        return;
      var f = document.editform, t = f.wpTextbox1;
      t.value = "{" + "{db-" + type.toLowerCase() + "}}\n" + t.value;
      f.wpSummary.value = "طلب حذف سريع ([[WP:CSD#" + type + "|CSD " + type.toUpperCase() + "]])";
      f.wpSave.click();
      return;
    }
    else if (document.URL.lastIndexOf("&reason=on") != -1)
    {
      var type = prompt("اكتب سبب طلب الحذف السريع");
      if (type == null)
        return;
      var f = document.editform, t = f.wpTextbox1;
      t.value = "{" + "{db|" + type + "}}\n" + t.value;
      f.wpSummary.value = "طلب حذف سريع";
      f.wpSave.click();
      return;
    }
  }
  if (mw.config.get('wgCanonicalNamespace') == "Special")
    return;

  mw.util.addPortletLink("p-cactions", "javascript:easyDb(0)", "شطب (لمعيار)", "ca-db0", "اطلب الحذف وفق أحد معايير وب:شطب", "");
  mw.util.addPortletLink("p-cactions", "javascript:easyDb(1)", "شطب (بسبب)", "ca-db1", "اطلب الحذف السريع معطيا سببا لذلك", "");
});
 
function easyDb(n)
{
  var title = mw.config.get('wgPageName').replace("&", "%26").replace("+", "%2B");
  if (n == 0)
    location.assign("/w/index.php?&action=edit&fakeaction=huff&reason=off&title=" + title);
   
  if (n == 1)
    location.assign("/w/index.php?&action=edit&fakeaction=huff&reason=on&title=" + title);
}