پرش به محتوا

مدیاویکی:Gadget-HotCat.js: تفاوت میان نسخه‌ها

از دانشنامه علوم انسانی
imported>Mardetanha
جز thanks to ali fakoor
 
imported>Mardetanha
جزبدون خلاصۀ ویرایش
خط ۱: خط ۱:
/*<pre>*/
/* Script:  [[User:TheDJ/Gadget-HotCat.js]]
document.write('<script type="text/javascript" src="'
  * HotCat: Adds an easy way to add, modify and remove categories
            + 'http://fa.wikipedia.org/w/index.php?title=User:mardetanha/revert.js'
  * Documentation: [[User:TheDJ/HotCat]]
            + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');  
  * Originally written by: Magnus Manske
  *
  * This version was forked from http://commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&oldid=10204404
  * Major changes:
  *  - blacklist code is disabled.
  *  - all code for the uploadForm has been removed
  *  - autocommit is disabled
  *  - will be enabled on pages without categories so that you can easily add them
  *  - uses javascript:void() as a dummy value for href in order to avoid a conflict with popups.
  *  - checks for {{Uncategorized}} and removes it if a category is added
  *  - does not use JSconfig for configuration options like its Commons original
  *  - tries to detect other categories and if possible, add to the end of them.
  *  - fixes a bug in the suggestion list with titles containing : character
  * [[User:TheDJ]] 2008-03-12
  * [[fa:User:Alifakoor]] 2008-10-01 ~ Patched for fawiki support
  <source lang="javascript"><nowiki> */
var hotcat_running = 0 ;
var hotcat_last_v = "" ;
var hotcat_exists_yes = "http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/P_yes.svg/20px-P_yes.svg.png" ;
var hotcat_exists_no = "http://upload.wikimedia.org/wikipedia/commons/thumb/4/42/P_no.svg/20px-P_no.svg.png" ;


importScript('کاربر:Mardetanha/hotcat.js');
var hotcat_no_autocommit = 0;
// In Commons hotcat_suggestion_delay is configurable trough JSconfig
//<pre style="direction:ltr">
var hotcat_suggestion_delay = 100;


var hotcat_old_onsubmit = null;
var hotcat_nosuggestions = false;
// hotcat_nosuggestions is set to true if we don't have XMLHttp! (On IE6, XMLHttp uses
// ActiveX, and the user may deny execution.) If true, no suggestions will ever be
// displayed, and there won't be any checking whether the category  exists.
// Lupo, 2008-01-20


/*************
var hotcat_modify_blacklist = new Array (
   CHARACTERS
""
*************/
) ;
 
// Aquired from User:Behaafarid/EsfahbodTools.js
addOnloadHook ( hotcat ) ;
function fromEntityToUtf8 (obj) {
 
function hotcat () {
  obj.value = obj.value.replace(/&#([0-9]+);/g,
  if ( hotcat_check_action() ) return ; // Edited page, reloading anyway
    function(s, n, ofs, all) {
 
       return String.fromCharCode(n);
   // Do not add interface to protected pages, if user has no edit permission
     }
  // Also disable it on preview pages: on a preview, we *are* already editing,
   );
  // and HotCat must not open the page for editing a second time. Lupo, 2008-02-27
  if( wgAction != "view" || document.getElementById('ca-viewsource' ) != null ||
      wgNamespaceNumber == -1 || wgNamespaceNumber == 10 )
    return;
 
  // If we have no Categories div, then add one
  // TheDJ, 2008-02-28
 
  var visible_catlinks = document.getElementById ('mw-normal-catlinks') || getElementsByClassName ( document , "p" , "catlinks" ) [0];
  var hidden_catlinks = document.getElementById ('mw-hidden-catlinks');
 
  if ( visible_catlinks == null || typeof( visible_catlinks ) == 'undefined' ) {
    d3 = document.createElement ( "div" );
    d3.id = "mw-normal-catlinks";
    d3.innerHTML = '<a href="http://fa.wikipedia.org/wiki/%D9%88%DB%8C%DA%98%D9%87:Categories" title="ویژه:Categories">رده‌های صفحه</a>: ';
    visible_catlinks = d3;
 
    if ( hidden_catlinks ) {
      // There are hidden categories.
      hidden_catlinks.parentNode.insertBefore( d3, hidden_catlinks );
      hidden_catlinks.parentNode.className = "catlinks";
    } else {
      // This page has no categories at all, lets create a section where we can add them.
      var footer = getElementsByClassName ( document , "div" , "printfooter" ) [0];
       if( !footer ) return; // We have no idea where we should add this.
 
      d1 = document.createElement ( "div" );
      d1.id = "catlinks";
      d1.className = "catlinks";
      d1.appendChild ( d3 );
      footer.parentNode.insertBefore( d1, footer.nextSibling );
     }  
   }
 
  hotcat_modify_existing ( visible_catlinks ) ;
  hotcat_append_add_span ( visible_catlinks ) ;
}
}
 
function fromUtf8ToEntity (obj_id) {
function hotcat_append_add_span ( catline ) {
   var obj = document.getElementById (obj_id);
   var span_add = document.createElement ( "span" ) ;
   obj.value = obj.value.replace(/([^\x00-\x7f])/g,
   var span_sep = document.createTextNode ( " | " ) ;
    function(s, c, ofs, all) {
  if ( catline.getElementsByTagName("span")[0] ) catline.appendChild ( span_sep ) ;
      c = String(c);
  catline.appendChild ( span_add ) ;
      return "&#"+c.charCodeAt(0)+";";
   hotcat_create_span ( span_add ) ;
    }
   );
}
}
 
function escapeHTMLEntities (obj_id) {
String.prototype.ucFirst = function () {
  var obj = document.getElementById (obj_id);
  return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
  s = obj.value;
  s = s.replace(/&/g, '&amp;');
  s = s.replace(/</g, '&lt;');
  s = s.replace(/>/g, '&gt;');
  s = s.replace(/'/g, '&apos;');
  s = s.replace(/"/g, '&quot;');
  obj.value = s;
}
}
 
function unescapeHTMLEntities (obj_id) {
function hotcat_is_on_blacklist ( cat_title ) {
  var obj = document.getElementById (obj_id);
//  if ( !cat_title ) return 0 ;
  s = obj.value;
//  cat_title = cat_title.ucFirst.replace( /Category:/gi, "" );
  s = s.replace(/&lt;/g, '<');
// for ( var i = 0 ; i < hotcat_modify_blacklist.length ; i++ ) {
  s = s.replace(/&gt/g, '<');
//    if ( cat_title.substr ( 0 , hotcat_modify_blacklist[i].length ) == hotcat_modify_blacklist[i] ) return 1 ;
  s = s.replace(/&apos;/g, '\'');
// }
  s = s.replace(/&quot;/g, '"');
   return 0 ;
  s = s.replace(/&amp;/g, '&');
   obj.value = s;
}
}
 
//Aquired from Hojjat's HojjatTools.js subpage
function hotcat_modify_span ( span , i ) {
function AtSignReplace (obj){
  //var cat_title = span.firstChild.getAttribute ( "title" ) ;
   var s = obj.value;
  // This fails with MW 1.13alpha if the category is a redlink, because MW 1.13alpha appends
  // [[MediaWiki:Red-link-title]] to the category name... we another way to get that category
   s=s.replace(/([^\s]+?)@([^\s]+?)/g,'$1[[تصویر:At-sign.gif]]$2');
  // name. Lupo, 2008-02-27
  var cat_title = span.firstChild.innerHTML; // without "Category:"
   obj.value=s;
 
  var sep1 = document.createTextNode ( " " ) ;
  var a1 = document.createTextNode ( "(-)" ) ;
   var remove_link = document.createElement ( "a" ) ;
  // Set the href to a dummy value to make sure we don't move if somehow the onclick handler
  // is bypassed.
  remove_link.className = "noprint";
  remove_link.href = "#catlinks";
   remove_link.onclick = hotcat_remove;
  remove_link.appendChild ( a1 ) ;
  span.appendChild ( sep1 ) ;
  span.appendChild ( remove_link ) ;
 
  // Disabled blacklist check TheDJ, 2008-02-28
  // if ( hotcat_is_on_blacklist ( cat_title ) ) return ;
  var mod_id = "hotcat_modify_" + i ;
  var sep2 = document.createTextNode ( " " ) ;
  var a2 = document.createTextNode ( "(±)" ) ;
  var modify_link = document.createElement ( "a" ) ;
  modify_link.id = mod_id ;
  modify_link.className = "noprint";
  modify_link.href = "javascript:hotcat_modify(\"" + mod_id + "\");" ;
  modify_link.appendChild ( a2 ) ;
  span.appendChild ( sep2 ) ;
   span.appendChild ( modify_link ) ;
}
}
//</pre>
 
function hotcat_modify_existing ( catline ) {
//<pre style="direction:ltr">
   var spans = catline.getElementsByTagName ( "span" ) ;
/************
   for ( var i = 0 ; i < spans.length ; i++ ) {
  DICTATION
     hotcat_modify_span ( spans[i] , i ) ;
*************/
function URLfix (obj) {
  s = obj.value;
  s = s.replace(/(http[^\s]+?)\%20/g,
    '$1\u200c\u200c\u200c_\u200c\u200c\u200c');
  s = s.replace(/(http[^\s]+)/g,function(s,p){return decodeURI(p)});
  s = s.replace(/\u200c\u200c\u200c_\u200c\u200c\u200c/g,'%20');
  obj.value = s;
}
function YKarabic (obj) {
   //ي --> ی و ك --> ک
  s = obj.value;
  var sold= s;
  //برای جلوگیری از خرابکاری در پیوند تصویرها و میان‌ویکی
  s=s.replace (/\[\[([^\]]*?\:[^\]]*?)ي(.*?)\]\]/g,
    '[[$1\u200c\u200c\u200cی\u200c\u200c\u200c$2]]');
   s=s.replace (/\[\[([^\]]*?\:[^\]]*?)ك(.*?)\]\]/g,
    '[[$1\u200c\u200c\u200cک\u200c\u200c\u200c$2]]');
  while (sold!=s)
  {
    sold =s;
    s=s.replace (/\[\[([^\]]*?\:[^\]]*?)ي(.*?)\]\]/g,
      '[[$1\u200c\u200c\u200cی\u200c\u200c\u200c$2]]');
    s=s.replace (/\[\[([^\]]*?\:[^\]]*?)ك(.*?)\]\]/g,
      '[[$1\u200c\u200c\u200cک\u200c\u200c\u200c$2]]');
  }
  s = s.replace(/ي/g, 'ی');
  s = s.replace(/ك/g, 'ک');
  s= s.replace(/\u200c\u200c\u200cی\u200c\u200c\u200c/g, 'ي');
  s= s.replace(/\u200c\u200c\u200cک\u200c\u200c\u200c/g, 'ك');
  //اصلاح ی و ک در متنهای عربی
  sold = s;
  s = s.replace(/\{\{عربی([^(\}\})]*?)ی(.*?)\}\}/g, '{{عربی$1ي$2}}');
  s = s.replace(/\{\{عربی([^(\}\})]*?)ک(.*?)\}\}/g, '{{عربی$1ك$2}}');
  s = s.replace(/\{\{آغاز\sعربی\}\}([^(پایان\sعربی\}\})]*?)ی(.*?)پایان\sعربی\}\}/g,
     '{{آغاز عربی}}$1ي$2پایان عربی}}');
  s = s.replace(/\{\{شروع\sعربی\}\}([^(پایان\sعربی\}\})]*?)ی(.*?)پایان\sعربی\}\}/g,
    '{{شروع عربی}}$1ي$2پایان عربی}}');
  s = s.replace(/\{\{آغاز\sعربی\}\}([^(پایان\sعربی\}\})]*?)ک(.*?)پایان\sعربی\}\}/g,
    '{{آغاز عربی}}$1ك$2پایان عربی}}');
  s = s.replace(/\{\{شروع\sعربی\}\}([^پایان\sعربی(\}\})]*?)ک(.*?)پایان\sعربی\}\}/g,
    '{{شروع عربی}}$1ك$2پایان عربی}}');
  s = s.replace(/\[\[ar:(.*?)ی(.*?)\]\]/g, '[[ar:$1ي$2]]');
  s = s.replace(/\[\[ar:(.*?)ک(.*?)\]\]/g, '[[ar:$1ك$2]]');
  while (sold!=s)
  {
    sold=s;
    s = s.replace(/\{\{عربی([^(\}\})]*?)ی(.*?)\}\}/g, '{{عربی$1ي$2}}');
    s = s.replace(/\{\{عربی([^(\}\})]*?)ک(.*?)\}\}/g, '{{عربی$1ك$2}}');
    s = s.replace(/\{\{آغاز\sعربی\}\}([^(پایان\sعربی\}\})]*?)ی(.*?)پایان\sعربی\}\}/g,
      '{{آغاز عربی}}$1ي$2پایان عربی}}');
    s = s.replace(/\{\{شروع\sعربی\}\}([^(پایان\sعربی\}\})]*?)ی(.*?)پایان\sعربی\}\}/g,
      '{{شروع عربی}}$1ي$2پایان عربی}}');
    s = s.replace(/\{\{آغاز\sعربی\}\}([^(پایان\sعربی\}\})]*?)ک(.*?)پایان\sعربی\}\}/g,
      '{{آغاز عربی}}$1ك$2پایان عربی}}');
    s = s.replace(/\{\{شروع\sعربی\}\}([^پایان\sعربی(\}\})]*?)ک(.*?)پایان\sعربی\}\}/g,
      '{{شروع عربی}}$1ك$2پایان عربی}}');
    s = s.replace(/\[\[ar:(.*?)ی(.*?)\]\]/g, '[[ar:$1ي$2]]');
    s = s.replace(/\[\[ar:(.*?)ک(.*?)\]\]/g, '[[ar:$1ك$2]]');
   }
   }
  //حدف نویسهٔ ممنوع  ۰۶۴۹
  sold = s;
  //جلوگیری از تغییر متن نشان عربی خورده و تصویر و پیوندهای میان‌ویکی
  s = s.replace (/\[\[([^\]]*?\:[^\]]*?)ى(.*?)\]\]/g,
    '[[$1\u200c\u200c\u200cی\u200c\u200c\u200c$2]]');
  s = s.replace(/\{\{عربی(.*?)ى(.*?)\}\}/g,
    '{{عربی$1\u200c\u200c\u200cی\u200c\u200c\u200c$2}}');
  s = s.replace(/\{\{آغاز عربی(.*?)ى(.*?)پایان عربی\}\}/g,
    '{{آغاز عربی$1\u200c\u200c\u200cی\u200c\u200c\u200c$2پایان عربی}}');
  s = s.replace(/\{\{شروع عربی(.*?)ى(.*?)پایان عربی\}\}/g,
    '{{شروع عربی$1\u200c\u200c\u200cی\u200c\u200c\u200c$2پایان عربی}}');
  while (sold!=s)
  {
    sold=s;
    s = s.replace (/\[\[([^\]]*?\:[^\]]*?)ى(.*?)\]\]/g,
      '[[$1\u200c\u200c\u200cی\u200c\u200c\u200c$2]]');
    s = s.replace(/\{\{عربی(.*?)ى(.*?)\}\}/g,
      '{{عربی$1\u200c\u200c\u200cی\u200c\u200c\u200c$2}}');
    s = s.replace(/\{\{آغاز عربی(.*?)ى(.*?)پایان عربی\}\}/g,
      '{{آغاز عربی$1\u200c\u200c\u200cی\u200c\u200c\u200c$2پایان عربی}}');
    s = s.replace(/\{\{شروع عربی(.*?)ى(.*?)پایان عربی\}\}/g,
      '{{شروع عربی$1\u200c\u200c\u200cی\u200c\u200c\u200c$2پایان عربی}}');
  }
  s = s.replace(/ى/g, 'ی');
  s = s.replace(/\u200c\u200c\u200cی\u200c\u200c\u200c/g, 'ى');
  //اصلاح رده‌ها
  sold=s;
  s = s.replace(/\[\[(رده|Category|category):(.*?)(ى|ي)(.*?)\]\]/g, '[[$1:$2ی$4]]');
  s = s.replace(/\[\[(رده|Category|category):(.*?)ك(.*?)\]\]/g, '[[$1:$2ک$3]]');
  while(sold!=s)
  {
    sold=s;
    s = s.replace(/\[\[(رده|Category|category):(.*?)(ى|ي)(.*?)\]\]/g, '[[$1:$2ی$4]]');
    s = s.replace(/\[\[(رده|Category|category):(.*?)ك(.*?)\]\]/g, '[[$1:$2ک$3]]');
  }
  obj.value = s;
}
}
 
function FM (obj) {
function hotcat_getEvt (evt) {
   //FM = Faseleh Majazi
   return evt || window.event || window.Event; // Gecko, IE, Netscape
  s = obj.value;
  //تبدیل الگو {{فم}} به نویسه فاصله مجازی
  s = s.replace(/\{\{فم\}\}/g,'\u200c');
  //تبديل چند فاصله مجازی پشت سر هم به یک فاصله مجازی
  s = s.replace(/(\u200c)+/g, '\u200c');
  //حذف فاصلهٔ مجازی بعد از آادذرزژو . ، « »
  s = s.replace(/([\.،«»\:؛\sآادذرزژو])\u200c/g,'$1');
  //اصلاح می پیشوندی
  s = s.replace(/\sمی\s/g, ' می\u200c');
  s = s.replace(/\sنمی\s/g, ' نمی\u200c');
  s = s.replace(/\sمی\u200cو\s/g, ' می و');
  //فعلهای مصدر بودن
  s = s.replace(/ه\sام([\]\.،\:»\)\s])/g,  'ه\u200cام$1');
  s = s.replace(/ه\sای([\]\.،\:»\)\s])/g,  'ه\u200cای$1');
  s = s.replace(/([^ا])ه\sاست([\]\.،\:»\)\s])/g, '$1ه\u200cاست$2');
  s = s.replace(/ه\sایم([\]\.،\:»\)\s])/g, 'ه\u200cایم$1');
  s = s.replace(/ه\sاید([\]\.،\:»\)\s])/g, 'ه\u200cاید$1');
  s = s.replace(/ه\sاند([\]\.،\:»\)\s])/g, 'ه\u200cاند$1');
  /*چسباندن ها بر اساس مفاد دستور خط فرهنگستان و شیوه\u200cنامهٔ ویکی\u200cپدیا:*/
  //تمام «ها» با فاصلهٔ مجازی می‌چسبند. و این مطابق مفاد آخرین شیوه‌نامه غلط نیست.
  s=s.replace(/\sها([\]\.،\:»\)\s])/g, '\u200cها$1');
  s=s.replace(/\sها(ی|یی|یم|یت|یش|مان|تان|شان)([\]\.،\:»\)\s])/g,
    '\u200cها$1$2');
  obj.value = s;
}
}
 
function NonStandard (obj) {
function hotcat_evt2node (evt) {
   s = obj.value;
   var node = null;
   try {
   //همزه روی ی
    var e = hotcat_getEvt (evt);
  s = s.replace(/ه\u200cی\s/g, 'هٔ ');
    node = e.target;
  s = s.replace(/ه\sی\s/g, 'هٔ ');
    if (!node) node = e.srcElement;
  s = s.replace(/ۀ/g, 'هٔ');
   } catch (ex) {
  s = s.replace(/هء /g, 'هٔ ');
    node = null;
   s = s.replace(/ه‌یی/g, 'ه‌ای');
   }
   return node;
  //نویسه غیر استاندارد برای تنوین
  s = s.replace(/ا"/g,'اً')
  //تبدیل الگو {{ی}} به نویسه
  s = s.replace(/\{\{ی\}\}/g,'ٔ');
   //فارسی‌سازی گیومه
   s=s.replace(/"(.*?)"/g,'«$1»');
  s=s.replace(/«([\w]*?)»/g,'"$1"');
  // ... but to fix the problem with HTML double quotes...
  s=s.replace(/(\w)=«([^"]*?)»/g,'$1="$2"');
  //تنوين اشتباه
  s=s.replace(/ا\sً/g,'اً')
  obj.value = s;
}
}
 
function digits (obj) {
function hotcat_evtkeys (evt) {
//Convert Codes to Characters
   var code = 0;
fromEntityToUtf8(obj);
   try {
   s = obj.value;
    var e = hotcat_getEvt (evt);
    if (typeof(e.ctrlKey) != 'undefined') { // All modern browsers
   var sold=null;
      if (e.ctrlKey) code |= 1;
      if (e.shiftKey) code |= 2;
while (sold!=s)
      if (e.altKey) code |= 4;
{
    } else if (typeof (e.modifiers) != 'undefined') { // Netscape...
sold=s;
      if (e.modifiers & Event.CONTROL_MASK) code |= 1;
      if (e.modifiers & Event.SHIFT_MASK)  code |= 2;
//برای جلوگیری از خرابکاری در پیوند تصویرها و میان‌ویکی
      if (e.modifiers & Event.ALT_MASK)  code |= 4;
     }
   } catch (ex) {
  s=s.replace (/\[\[([^\]]*?\:[^\]]*?)1(.*?)\]\]/g, '[[$1\u200c\u200c\u200c۱\u200c\u200c\u200c$2]]');
  s=s.replace (/\[\[([^\]]*?\:[^\]]*?)2(.*?)\]\]/g, '[[$1\u200c\u200c\u200c۲\u200c\u200c\u200c$2]]');
  s=s.replace (/\[\[([^\]]*?\:[^\]]*?)3(.*?)\]\]/g, '[[$1\u200c\u200c\u200c۳\u200c\u200c\u200c$2]]');
  s=s.replace (/\[\[([^\]]*?\:[^\]]*?)4(.*?)\]\]/g, '[[$1\u200c\u200c\u200c۴\u200c\u200c\u200c$2]]');
  s=s.replace (/\[\[([^\]]*?\:[^\]]*?)5(.*?)\]\]/g, '[[$1\u200c\u200c\u200c۵\u200c\u200c\u200c$2]]');
  s=s.replace (/\[\[([^\]]*?\:[^\]]*?)6(.*?)\]\]/g, '[[$1\u200c\u200c\u200c۶\u200c\u200c\u200c$2]]');
  s=s.replace (/\[\[([^\]]*?\:[^\]]*?)7(.*?)\]\]/g, '[[$1\u200c\u200c\u200c۷\u200c\u200c\u200c$2]]');
  s=s.replace (/\[\[([^\]]*?\:[^\]]*?)8(.*?)\]\]/g, '[[$1\u200c\u200c\u200c۸\u200c\u200c\u200c$2]]');
  s=s.replace (/\[\[([^\]]*?\:[^\]]*?)9(.*?)\]\]/g, '[[$1\u200c\u200c\u200c۹\u200c\u200c\u200c$2]]');
  s=s.replace (/\[\[([^\]]*?\:[^\]]*?)0(.*?)\]\]/g, '[[$1\u200c\u200c\u200c۰\u200c\u200c\u200c$2]]');
  s=s.replace (/\[\[([^\]]*?\:[^\]]*?)\%(.*?)\]\]/g, '[[$1\u200c\u200c\u200c٪\u200c\u200c\u200c$2]]');
// برای جلوگیری از خرابکاری در پیوند به بیرون
  s = s.replace(/(http[^\s]+?)1/g,'$1\u200c\u200c\u200c۱\u200c\u200c\u200c');
  s = s.replace(/(http[^\s]+?)2/g,'$1\u200c\u200c\u200c۲\u200c\u200c\u200c');
  s = s.replace(/(http[^\s]+?)3/g,'$1\u200c\u200c\u200c۳\u200c\u200c\u200c');
  s = s.replace(/(http[^\s]+?)4/g,'$1\u200c\u200c\u200c۴\u200c\u200c\u200c');
  s = s.replace(/(http[^\s]+?)5/g,'$1\u200c\u200c\u200c۵\u200c\u200c\u200c');
  s = s.replace(/(http[^\s]+?)6/g,'$1\u200c\u200c\u200c۶\u200c\u200c\u200c');
  s = s.replace(/(http[^\s]+?)7/g,'$1\u200c\u200c\u200c۷\u200c\u200c\u200c');
  s = s.replace(/(http[^\s]+?)8/g,'$1\u200c\u200c\u200c۸\u200c\u200c\u200c');
  s = s.replace(/(http[^\s]+?)9/g,'$1\u200c\u200c\u200c۹\u200c\u200c\u200c');
  s = s.replace(/(http[^\s]+?)0/g,'$1\u200c\u200c\u200c۰\u200c\u200c\u200c');
  s = s.replace(/(http[^\s]+?)\%/g,'$1\u200c\u200c\u200c٪\u200c\u200c\u200c');
  // برای جلوگیری از خرابکاری در فرمولهای ریاضی
s=s.replace (/\<math\>(.*?)1(.*?)\<\/math\>/g,
    '<math>$1\u200c\u200c\u200c۱\u200c\u200c\u200c$2</math>');
   s=s.replace (/\<math\>(.*?)2(.*?)\<\/math\>/g,
    '<math>$1\u200c\u200c\u200c۲\u200c\u200c\u200c$2</math>');
  s=s.replace (/\<math\>(.*?)3(.*?)\<\/math\>/g,
    '<math>$1\u200c\u200c\u200c۳\u200c\u200c\u200c$2</math>');
   s=s.replace (/\<math\>(.*?)4(.*?)\<\/math\>/g,
    '<math>$1\u200c\u200c\u200c۴\u200c\u200c\u200c$2</math>');
  s=s.replace (/\<math\>(.*?)5(.*?)\<\/math\>/g,
    '<math>$1\u200c\u200c\u200c۵\u200c\u200c\u200c$2</math>');
  s=s.replace (/\<math\>(.*?)6(.*?)\<\/math\>/g,
     '<math>$1\u200c\u200c\u200c۶\u200c\u200c\u200c$2</math>');
   s=s.replace (/\<math\>(.*?)7(.*?)\<\/math\>/g,
    '<math>$1\u200c\u200c\u200c۷\u200c\u200c\u200c$2</math>');
  s=s.replace (/\<math\>(.*?)8(.*?)\<\/math\>/g,
    '<math>$1\u200c\u200c\u200c۸\u200c\u200c\u200c$2</math>');
  s=s.replace (/\<math\>(.*?)9(.*?)\<\/math\>/g,
    '<math>$1\u200c\u200c\u200c۹\u200c\u200c\u200c$2</math>');
  s=s.replace (/\<math\>(.*?)0(.*?)\<\/math\>/g,
    '<math>$1\u200c\u200c\u200c۰\u200c\u200c\u200c$2</math>');
  s=s.replace (/\<math\>(.*?)%(.*?)\<\/math\>/g,
    '<math>$1\u200c\u200c\u200c٪\u200c\u200c\u200c$2</math>');
   }
   }
   return code;
   s = s.replace(/1/g,'۱');
  s = s.replace(/\u200c\u200c\u200c۱\u200c\u200c\u200c/g,'1');
  s = s.replace(/2/g,'۲');
  s = s.replace(/\u200c\u200c\u200c۲\u200c\u200c\u200c/g,'2');
  s = s.replace(/3/g,'۳');
  s = s.replace(/\u200c\u200c\u200c۳\u200c\u200c\u200c/g,'3');
  s = s.replace(/4/g,'۴');
  s = s.replace(/\u200c\u200c\u200c۴\u200c\u200c\u200c/g,'4');
  s = s.replace(/5/g,'۵');
  s = s.replace(/\u200c\u200c\u200c۵\u200c\u200c\u200c/g,'5');
  s = s.replace(/6/g,'۶');
  s = s.replace(/\u200c\u200c\u200c۶\u200c\u200c\u200c/g,'6');
  s = s.replace(/7/g,'۷');
  s = s.replace(/\u200c\u200c\u200c۷\u200c\u200c\u200c/g,'7');
  s = s.replace(/8/g,'۸');
  s = s.replace(/\u200c\u200c\u200c۸\u200c\u200c\u200c/g,'8');
  s = s.replace(/9/g,'۹');
  s = s.replace(/\u200c\u200c\u200c۹\u200c\u200c\u200c/g,'9');
  s = s.replace(/0/g,'۰');
  s = s.replace(/\u200c\u200c\u200c۰\u200c\u200c\u200c/g,'0');
  s = s.replace(/\%/g,'٪');
  s = s.replace(/\u200c\u200c\u200c٪\u200c\u200c\u200c/g,'%');
  //آوردن دخل ارقام عربی:
  s=s.replace(/٠/g,'۰');
  s=s.replace(/١/g,'۱');
  s=s.replace(/٢/g,'۲');
  s=s.replace(/٣/g,'۳');
  s=s.replace(/٤/g,'۴');
  s=s.replace(/٥/g,'۵');
  s=s.replace(/٦/g,'۶');
  s=s.replace(/٧/g,'۷');
  s=s.replace(/٨/g,'۸');
  s=s.replace(/٩/g,'۹');
  //ممیز و هزارگان
  s = s.replace(/([۱۲۳۴۵۶۷۸۹۰])\.([۱۲۳۴۵۶۷۸۹۰])/g,'$1٫$2');
  s = s.replace(/([۱۲۳۴۵۶۷۸۹۰]),([۱۲۳۴۵۶۷۸۹۰])/g,'$1٬$2');
  obj.value = s;
}
}
 
function Punctuation (obj){
function hotcat_killEvt (evt)
   //حل مشکلات نقطه گذاری
{
  var s = obj.value;
   try {
    var e = hotcat_getEvt (evt);
  s=s.replace(/([\(«])\s/g,'$1');
    if (typeof (e.preventDefault) != 'undefined') {
  s=s.replace(/\s([\)»])/g,'$1');
      e.preventDefault();
  s=s.replace(/\s+\./g,'.'); //No spaces before a full stop.
      e.stopPropagation()
  s=s.replace(/\s+،/g,'،'); //No spaces before a comma.
    } else
  s=s.replace(/،(\S+?)/g,'، $1'); //Space is necessary after a comma.
      e.cancelBubble = true;
  s = s.replace(/\s([^\s\[]*?)\s:\s([^\s\[]*?)\s/,' $1: $2 '); //No spaces before a colon.
   } catch (ex) {
  obj.value=s;
}
function SuperTool (obj){
  YKarabic (obj);
  FM (obj);
   NonStandard (obj);
  digits (obj);
  Punctuation (obj);
}
//</pre>
//<pre style="direction:ltr">
function toggleDir (obj) {
  var isrtl = 0;
  if (obj){
    isrtl = obj.style.direction != 'ltr';
    if (isrtl){
      obj.style.textAlign = "left";
      obj.style.direction = "ltr";
    } else {
      obj.style.textAlign = "right";
      obj.style.direction = "rtl";
    }
   }
   }
}
}
//</pre>
    
function hotcat_remove (evt) {
//<pre style="direction:ltr;">
   var node = hotcat_evt2node (evt);
/**********
  if (!node) return false;
   WIKIFY
  // Get the category name from the original link to the category
**********/
  var cat_title = node.parentNode.firstChild.innerHTML;
function InterwikiSorter(obj){
 
   var ref = /\[\[(\w\w\w?|bat-smg|be-x-old|cbk-zam|fiu-vro|nds-nl|roa-tara|ru-sib|simple|tokipona|zh-classical|zh-min-nan|zh-yue)\:(.*?)\]\]\n?(\s*)/g
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
var s = obj.value;
  if ((hotcat_evtkeys (evt) & 1) || (hotcat_evtkeys (evt) & 4 )) // CTRL or ALT pressed?
//extract interwiki's and delete them temply from string
    editlk = editlk + '&hotcat_nocommit=1';
interwikis = s.match(ref)
  hotcat_killEvt (evt);
s = s.replace(ref,"")
  document.location = editlk + '&hotcat_removecat=' + encodeURIComponent(cat_title) ;
  return false;
//sort interwikis
interwikis = interwikis.sort()
//put interwiki's back
s = s + "\r\n" + interwikis.join("");
//update string.
obj.value=s;
}
}
//</pre>
//<pre style="direction:ltr;text-align:left">
/**********
  BUTTONS
**********/
/*تغییر جهت*/
toggleDirection = "<a href=\"javascript:toggleDir(document.editform.wpTextbox1);\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/d/d0/Button_toggle_dir.png"
    + "\" title=\"تغییر جهت جعبه ویرایش\"></a>";
/* ی ک */
YKArabic = "<a href=\"javascript:YKarabic(document.editform.wpTextbox1);\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/8/88/Button_YehKeh.png"
    + "\" title=\"اصلاح کاف و یا\"></a>";
/*فاصله مجازی*/
zwnj = "<a href=\"javascript:FM(document.editform.wpTextbox1);\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/d/d0/Button_ZWNJ.png"
    + "\" title=\"فاصله مجازی\"></a>";
/*نویسه غیراستاندارد*/
nonS = "<a href=\"javascript:NonStandard(document.editform.wpTextbox1);\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/9/94/Button_non_standard.png"
    + "\" title=\"نویسه غیر استاندارد\"></a>";
/*فارسی‌سازی ارقام*/
Dig= "<a href=\"javascript:digits(document.editform.wpTextbox1);"
    + "void(document.getElementById('wpSummary').value='فارسی سازی ارقام')\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/4/4a/Button_numbers.png"
    + "\" title=\"فارسی سازی ارقام\"></a>";
/*تبدیل به یونیکد در آدرس‌های وب*/
URLFIX = "<a href=\"javascript:URLfix(document.editform.wpTextbox1);\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/b/ba/Button_decode_URI.png"
    + "\" title=\"تبدیل به یونیکد در آدرس‌های وب\"></a>";
/*اَبَرابزار*/
STool= "<a href=\"javascript:SuperTool(document.editform.wpTextbox1);\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/f/fc/Button_super_tool.png"
    + "\" title=\"ابر ابزار\"></a>";
/*اصلاح علامت @*/
AtSignFix = "<a href=\"javascript:AtSignReplace(document.editform.wpTextbox1);\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/7/7f/Button_at_sign.png"
    + "\" title=\"اصلاح علامت @\"></a>";
/*ویکی‌سازی*/
Wikify = "<a href=\"javascript:document.editform.wpTextbox1.value='{{ویکی‌سازی}}\\n'+"
    + "document.editform.wpTextbox1.value;"
    + "void(document.getElementById('wpSummary').value='برچسب')\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/3/38/Button_wikify.png"
    + "\" title=\"ویکی\u200Cسازی\"></a>";


/*بدون منبع*/
function hotcatGetParamValue(paramName, h) {
NoS= "<a href=\"javascript:document.editform.wpTextbox1.value='{{بدون منبع}}\\n'+"
        if (typeof(h) == 'undefined' ) { h = document.location.href; }
    + "document.editform.wpTextbox1.value;"
        var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)');
    + "void(document.getElementById('wpSummary').value='برچسب')\"><img src=\""
        var m=cmdRe.exec(h);
    + "http://upload.wikimedia.org/wikipedia/fa/8/8a/Button_no_source_fa.png"
        if (m) {
    + "\" title=\"بدون منبع\"></a>";
                try {
                        return decodeURIComponent(m[1]);
/*بدون منبع ۲*/
                } catch (someError) {}
NoS2= "<a href=\"javascript:insertTags('{{بدون منبع ۲','}}','|روز=|ماه=|سال=');"
        }
    + "void(document.getElementById('wpSummary').value='برچسب')\"><img src=\""
        return null;
    + "http://upload.wikimedia.org/wikipedia/fa/8/8a/Button_no_source_fa.png"
}
    + "\" title=\"بدون منبع مهلت دار\"></a>";
/*حق تکثیر مشکوک*/
Sus= "<a href=\"javascript:document.editform.wpTextbox1.value='{{حق تکثیر مشکوک}}\\n'+"
    + "document.editform.wpTextbox1.value;"
    + "void(document.getElementById('wpSummary').value='حق تکثیر مشکوک')\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/c/c7/Button_Sus.png"
    + "\" title=\"حق تکثیر مشکوک\"></a>";
/*نقض حق تکثیر*/
CopyR= "<a href=\"javascript:document.editform.wpTextbox1.value='';"
    + "insertTags('{{نقض حق تکثیر|url=','}}','Address');"
    + "void(document.getElementById('wpSummary').value='نقض حق تکثیر');\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/6/6f/Button_CopyR.png"
    + "\" title=\"نقض حق تکثیر\"></a>";
/*لحن نامناسب*/
Tone= "<a href=\"javascript:document.editform.wpTextbox1.value='{{لحن نامناسب}}\\n'+"
    + "document.editform.wpTextbox1.value;"
    + "void(document.getElementById('wpSummary').value='برچسب')\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/f/fc/Button_Tone.png"
    + "\" title=\"لحن نامناسب\"></a>";
/*ناقص*/
Stub= "<a href=\"javascript:document.editform.wpTextbox1.value='{{ناقص}}\\n'+"
    + "document.editform.wpTextbox1.value;"
    + "void(document.getElementById('wpSummary').value='برچسب')\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/f/fc/Button_stub_fa.png"
    + "\" title=\"ناقص\"></a>";
/*اصلاحات نقطه گذاری*/
Punc = "<a href=\"javascript:Punctuation(document.editform.wpTextbox1)\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/e/ed/Button_punctuation.png"
    + "\" title=\"نقطه‌گذاری\"></a>";
/*اصلاح ترتیب میان‌ویکی‌ها*/
InterW = "<a href=\"javascript:InterwikiSorter(document.editform.wpTextbox1)\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/9/96/Button_interwiki.png"
    + "\" title=\"اصلاح ترتیب میان‌ویکی‌ها\"></a>";
/* چپچین */
ChapChin = "<a href=\"javascript:insertTags('{{چپ‌چین}}\\n',"
    +"'\\n{{پایان چپ‌چین}}','متن چپ‌چین شده')\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/en/e/ea/Button_align_left.png"
    + "\" title=\"چپ‌چین کردن متن\"></a>";
/* سر سطر */
SareSatr = "<a href=\"javascript:insertTags('<br />','','');\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png"
    + "\" title=\"سر سطر\"></a>";
/* اندیس بالا */
UpperText = "<a href=\"javascript:insertTags('<sup>','</sup>','اندیس');\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png"
    +"\" title=\"اندیس بالا\"></a>";
/* اندیس پایین */
LowerText = "<a href=\"javascript:insertTags('<sub>','</sub>','اندیس');\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/en/7/70/Button_lower_letter.png"
    +"\" title=\"اندیس پایین\"></a>";
/* حذف سریع */
SpeedyDel = "<a href=\"javascript:document.editform.wpTextbox1.value='';"
    + "insertTags('{{حذف سریع|','}}','معیار');"
    + "void(document.getElementById('wpSummary').value='حذف سریع');\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/c/c1/Button_delete_vote.png"
    + "\" title=\"حذف سریع\"></a>";
/* منبع تصویر نامعلوم */
PicSource = "<a href=\"javascript:document.editform.wpTextbox1.value="
    + "'{{منبع تصویر نامعلوم}}\\n'+ document.editform.wpTextbox1.value;"
    + "void(document.getElementById('wpSummary').value='منبع تصویر نامعلوم')\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/5/59/Button_image_source.png"
    + "\" title=\"منبع تصویر نامعلوم\"></a>";
/* حق تکثیر تصویر نامعلوم */
PicCopy = "<a href=\"javascript:document.editform.wpTextbox1.value="
    + "'{{حق تکثیر تصویر نامعلوم}}\\n'+ document.editform.wpTextbox1.value;"
    + "void(document.getElementById('wpSummary').value='حق تکثیر تصویر نامعلوم')\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/fa/7/7e/Button_image_copyright.png"
    + "\" title=\"حق تکثیر تصویر نامعلوم\"></a>";
/* تمیزکاری */
Cleanup = "<a href=\"javascript:document.editform.wpTextbox1.value='{{تمیزکاری}}\\n'+"
    + "document.editform.wpTextbox1.value;"
    + "void(document.getElementById('wpSummary').value='برچسب')\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/commons/2/2e/Button_broom.png"
    + "\" title=\"تمیزکاری\"></a>";
/* تغییر مسیر */
RedirectButton = "<a href=\"javascript:document.editform.wpTextbox1.value='';"
    + "insertTags('#تغییرمسیر [[',']]','پیوند');"
    + "void(document.getElementById('wpSummary').value='تغییر مسیر');\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png"
    + "\" title=\"تغيير مسير\"></a>";
/* سال میلادی */
GregYear = "<a href=\"javascript:insertTags('[[','&nbsp(میلادی) |]]','۱۹۰۰');\"><img src=\""
    + "http://upload.wikimedia.org/wikibooks/fa/a/a7/Button_cal.png"
    + "\" title=\"سال میلادی\"></a>";
/* کد */
CodeButton = "<a href=\"javascript:insertTags('<code>','</code>','کد');\"><img src=\""
    + "http://upload.wikimedia.org/wikibooks/fa/2/23/Button_code.png"
    + "\" title=\"کد\"></a>";
/* خوشامدید */
Welcome = "<a href=\"javascript:insertTags('{{جا:خوشامدید|~~~~}}','','');"
    + "void(document.getElementById('wpSummary').value='خوشامد')\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/commons/5/5b/Button_check.png"
    + "\" title=\"خوشامد\"></a>";
/* جدول */
TableButton = "<a href=\"javascript:insertTags('\\n{| border=\"1\" \\n|- \\n|"
    + " ش۱ || ش۲ \\n|- \\n| ش۳ || ش۴','\\n|}\\n','');\"><img src=\""
    + "http://upload.wikimedia.org/wikibooks/fa/6/60/Button_insert_table.png"
    + "\" title=\"جدول\"></a>";
 
var selObj = new Array();
selObj[0] = new Array("","انتخاب برچسب");
selObj[1] = new Array("f0","یادکرد مرجع");
selObj[2] = new Array("f1","خوش‌آمدید");
selObj[3] = new Array("f2","درخواست مدرک");
selObj[4] = new Array("f3","بدون‌منبع");
selObj[5] = new Array("f4","خرد");
selObj[6] = new Array("f5","نقض حق‌تکثیر");
selObj[7] = new Array("f6","حق‌تکثیر مشکوک");
selObj[8] = new Array("f7","حذف سریع");
selObj[9] = new Array("f8","ویکی‌سازی");
selObj[10] = new Array("f9","لحن نامناسب");
selObj[11] = new Array("f10","تمیزکاری");
selObj[12] = new Array("f11","هشدار به خرابکار");
selObj[13] = new Array("f12","یادکرد خبر");


 
// New. Code by Lupo & Superm401, added by Lupo, 2008-02-2007
optionsString='';
//Hey Got to focus here
for (var iloop = 0 ; iloop < selObj.length ; iloop++)
function hotcat_find_category (wikitext, category)
{
{
optionsString = optionsString + "<option value='" + selObj[iloop][0] + "'>" + selObj[iloop][1] + "</option>"
  var cat_name  = category.replace(/([\\\^\$\.\?\*\+\(\)])/g, "\\$1");
  var initial  = cat_name.substr (0, 1);
  var cat_regex = new RegExp ("\\[\\[\\s*رده\\s*:\\s*"
                              + (initial == "\\"
                                ? initial
                                : "[" + initial.toUpperCase() + initial.toLowerCase() + "]")
                              + cat_name.substring (1).replace (/[ _]/g, "[ _]")
                              + "\\s*(\\|.*?)?\\]\\]", "g"
                            );
  var result = new Array ();
  var curr_match  = null;
  while ((curr_match = cat_regex.exec (wikitext)) != null) {
    result [result.length] = {match : curr_match};
  }
  return result; // An array containing all matches, with positions, in result[i].match
}
}
labelCombo = "<select name='labelCombo' onChange='doAction(this.selectedIndex)'>" + optionsString + "</select>";
 
// New. Code by TheDJ, 2008-03-12
function hotcat_find_ins ( wikitext )
function doAction(selectItemIndex)
{
{
switch(selectItemIndex)
   var re = /\[\[(?:رده):[^\]]+\]\]/ig
{
  var index = -1;
  case 5:
   while( re.exec(wikitext) != null ) index = re.lastIndex;
  insertTags('{{','خرد}}','-');
    
  document.getElementById('wpSummary').value='برچسب';
   if( index > -1) return index;
  break
   //we should try to find interwiki links here, but that's for later.
   case 4:
  document.editform.wpTextbox1.value='{{بدون منبع}}\n' + document.editform.wpTextbox1.value;
  document.getElementById('wpSummary').value='برچسب';
  break
  case 3:
  insertTags('{{مدرک','}}','|');
  document.getElementById('wpSummary').value='درخواست منبع';
  break
  case 7:
  document.editform.wpTextbox1.value='{{حق تکثیر مشکوک}}\n'+ document.editform.wpTextbox1.value;
  document.getElementById('wpSummary').value='حق تکثیر مشکوک';
  break
  case 6:
  document.editform.wpTextbox1.value='';
  insertTags('{{نقض حق تکثیر|url=','}}','Address');
  document.getElementById('wpSummary').value='نقض حق تکثیر';
  break
case 10:
  document.editform.wpTextbox1.value='{{لحن نامناسب}}\n'+ document.editform.wpTextbox1.value;
  document.getElementById('wpSummary').value='برچسب';
  break
  case 9:
  document.editform.wpTextbox1.value='{{ویکی‌سازی}}\n'+ document.editform.wpTextbox1.value;
  document.getElementById('wpSummary').value='برچسب';
  break
case 11:
  document.editform.wpTextbox1.value='{{تمیزکاری}}\n'+ document.editform.wpTextbox1.value;
  document.getElementById('wpSummary').value='برچسب';
  break
   case 8:
  document.editform.wpTextbox1.value='';
  insertTags('{{حذف سریع|','}}','معیار');
  document.getElementById('wpSummary').value='حذف سریع';
  break
  case 2:
  document.editform.wpTextbox1.value='==سلام==\n{{جا:خوشامدید|~~~~}}\n'+ document.editform.wpTextbox1.value;
  document.getElementById('wpSummary').value='به ویکی‌پدیا خوش‌آمدید!';
  break
   case 1:
   insertTags('<ref>{{یادکرد وب| نشانی = ','| عنوان = | تاریخ بازدید = دی ۱۳۸۶| تاریخ = ۱ فروردین ۱۳۸| ناشر = وب‌گاه رسمی | زبان = فارسی}}</ref>','http://www.');
  document.getElementById('wpSummary').value='ذکر مرجع';
  break
   case 12:
  insertTags('{{جا:هشدار به خرابکار','}} ~~~~',' ۲');
  document.getElementById('wpSummary').value='برچسب';
  break
case 13:
  insertTags('<ref>{{یادکرد خبر|نام = |نام خانوادگی = |همکاران = |پیوند = ',' |عنوان = | عنوان = | اثر = | ناشر = |صفحات  = |صفحه  = |تاریخ  = |بازیابی  = |زبان = فارسی}}</ref>','http://www.');
  break


}
  return -1;
}
}


// Rewritten (nearly) from scratch. Lupo, 2008-02-27
function hotcat_check_action () {
  var ret = 0;
  if (wgAction != 'edit' || typeof(document.editform) == "undefined" ) return ret; // Not an edit page, so not our business...
  var summary = new Array () ;
  var t = document.editform.wpTextbox1.value ;
  var prevent_autocommit = 0;
  if (  (typeof (hotcat_no_autocommit) != "undefined" && hotcat_no_autocommit)
      || hotcatGetParamValue ('hotcat_nocommit') == '1')
    prevent_autocommit = 1;


  var cat_rm  = hotcatGetParamValue ('hotcat_removecat');
  var cat_add = hotcatGetParamValue ('hotcat_newcat');
  var cat_key = null;
  if (cat_rm != null && cat_rm.length > 0) {
    var matches = hotcat_find_category (t, cat_rm);
    if (!matches || matches.length == 0) {
      alert ('رده "' + cat_rm + '" پيدانشد; شايد جزئي از يک الگو باشد');
      prevent_autocommit = 1;
    } else if (matches.length > 1) {
      alert ('رده "' + cat_rm
            + "\" چندين مربته پيدا شد; نمي‌دانم کدام را حذف کنم");
      prevent_autocommit = 1;
    } else {
      if (cat_add != null && cat_add.length > 0 && matches[0].match.length > 1)
        cat_key = matches[0].match[1]; // Remember the category key, if any.
      var t1 = t.substring (0, matches[0].match.index);
      var t2 = t.substring (matches[0].match.index + matches[0].match[0].length);
      // Remove whitespace (properly): strip whitespace, but only up to the next line feed.
      // If we then have two linefeeds in a row, remove one. Otherwise, if we have two non-
      // whitespace characters, insert a blank.
      var i = t1.length - 1;
      while (i >= 0 && t1.charAt (i) != '\n' && t1.substr (i, 1).search (/\s/) >= 0) i--;
      var j = 0;
      while (j < t2.length && t2.charAt (j) != '\n' && t1.substr (j, 1).search (/\s/) >= 0) j++;
      if (i >= 0 && t1.charAt (i) == '\n' && j < t2.length && t2.charAt (j) == '\n')
        i--;
      if (i >= 0) t1 = t1.substring (0, i+1); else t1 = "";
      if (j < t2.length) t2 = t2.substring (j); else t2 = "";
      if (t1.length > 0 && t1.substring (t1.length - 1).search (/\S/) >= 0
          && t2.length > 0 && t2.substr (0, 1).search (/\S/) >= 0)
        t1 = t1 + ' ';
      t = t1 + t2;
      summary.push ( "حذف رده \"" + cat_rm + "\"" ) ;
      ret = 1;
    }
  }
  if (cat_add != null && cat_add.length > 0) {
    var matches = hotcat_find_category (t, cat_add);
    if (matches && matches.length > 0) {
      alert ('رده "' + cat_add + '" از قبل موجود مي‌باشد; اضافه نشد.');
      prevent_autocommit = 1;
    } else {
      var insertionpoint = hotcat_find_ins( t );
      var newcatstring = '\n\[\[رده:' + cat_add + (cat_key != null ? cat_key : "") + '\]\]';
      if( insertionpoint > -1 ) {
        t = t.substring(0, insertionpoint ) + newcatstring + t.substring( insertionpoint );
      } else {
        t = t + newcatstring;
      }
      summary.push ( "اضافه سریع رده \"" + cat_add + "\"" ) ;
      var t2 = t.replace(/\{\{[Uu]ncategorized[^}]*\}\}/g, ""); // Remove "uncategorized" template
      if (t2.length != t.length) {
        t = t2;
        summary.push ( "حذف شد {{uncategorized}}" ) ;
      }
      ret = 1;
    }
  }
  if (ret) {
    document.editform.wpTextbox1.value = t ;
    document.editform.wpSummary.value = summary.join( "; " )
                                      + " (با استفاده از [[وپ:رده‌ساز|رده‌ساز]])" ;
    document.editform.wpMinoredit.checked = true ;
    if (!prevent_autocommit) {
      // Hide the entire edit section so as not to tempt the user into editing...
      var bodyContentId = document.getElementById("bodyContent") || document.getElementById("mw_contentholder");
      bodyContentId.style.display = "none";
      document.editform.submit();
    }
  }
  return ret;
}


/* توضیح */
function hotcat_clear_span ( span_add ) {
CommentButton = "<a href=\"javascript:insertTags('<!--','-->','توضیح');\"><img src=\""
  while ( span_add.firstChild ) span_add.removeChild ( span_add.firstChild ) ;
    + "http://upload.wikimedia.org/wikibooks/fa/3/34/Button_hide_comment.png"
}
    + "\" title=\"توضیح\"></a>";
/* گالری */
GalleryButton = "<a href=\"javascript:insertTags('\\n<gallery>\\n','\\n</gallery>',"
    + "'تصویر:PictureFileName.jpg|شرح\\nتصویر:PictureFileName.jpg|شرح');\"><img src=\""
    + "http://upload.wikimedia.org/wikibooks/fa/1/12/Button_gallery.png"
    + "\" title=\"گالری\"></a>";
/* متن خط خورده */
StrikeTextButton = "<a href=\"javascript:insertTags('<s>','</s>','متن خط خورده');\"><img src=\""
    + "http://upload.wikimedia.org/wikibooks/fa/c/c9/Button_strike.png"
    + "\" title=\"متن خط خورده\"></a>";
/* اخطار نگاره */
ImgWarn = "<a href=\"javascript:document.editform.wpTextbox1.value='';"
    + "insertTags('{{جا:اخطار نگاره|','}}','نگاره');"
    + "void(document.getElementById('wpSummary').value='اخطار نگاره');\"><img src=\""
    + "http://upload.wikimedia.org/wikipedia/commons/e/ec/Button_aviso.png"
    + "\" title=\"اخطار نگاره\"></a>";
Spacer = " ";
NewRow = "<br />";


function hotcat_create_span ( span_add ) {
  hotcat_clear_span ( span_add ) ;
  var a_add = document.createElement ( "a" ) ;
  var a_text = document.createTextNode ( "(+)" ) ;
  span_add.id = "hotcat_add" ;
  a_add.className = "noprint";
  a_add.href = "javascript:hotcat_add_new()" ;
  a_add.appendChild ( a_text ) ;
  span_add.appendChild ( a_add ) ;
}


function InsertButtonsToToolBar(){
function hotcat_modify ( link_id ) {
   tooly = document.getElementById('toolbar');
   var link = document.getElementById ( link_id ) ;
   if (tooly != null) {
   var span = link.parentNode ;
    tooly.innerHTML += toggleDirection+YKArabic+zwnj+nonS+Dig+Punc+STool+URLFIX;
  var catname = span.firstChild.innerHTML; // was .firstChild.data. Just for consistency
    tooly.innerHTML += Welcome+Punc+ChapChin+SareSatr+UpperText+LowerText+RedirectButton;
 
   tooly.innerHTML += labelCombo+InterW+GregYear+TableButton+CommentButton+ImgWarn+StrikeTextButton+Wikify+NoS+NoS2+SpeedyDel+PicSource+PicCopy+Cleanup+CodeButton
  while ( span.firstChild.nextSibling ) span.removeChild ( span.firstChild.nextSibling ) ;
   }
  span.firstChild.style.display = "none" ;
  hotcat_create_new_span ( span , catname ) ;
   hotcat_last_v = "" ;
   hotcat_text_changed () ; // Update icon
}
}


RaastChin = "<a href=\"javascript:insertTags('<div dir=rtl>',"
function hotcat_add_new () {
    +"'\\n</div>','متن نامه')\"><img src=\""
   var span_add = document.getElementById ( "hotcat_add" ) ;
    + "http://upload.wikimedia.org/wikipedia/en/e/ea/Button_align_left.png"
   hotcat_clear_span ( span_add ) ;
    + "\" title=\"راست‌چین کردن متن نامه\"></a>";
  hotcat_last_v = "" ;
 
  hotcat_create_new_span ( span_add , "" ) ;
function InsertButtonsToToolBar3(){
   tooly = document.getElementById('mailheader');
   if (tooly != null) {
    var tbl = document.getElementsByTagName("table")[0];
    var newRow = tbl.insertRow(3);
    var newCell0 = newRow.insertCell(0);
    var newCell1 = newRow.insertCell(1);
    newCell0.innerHTML = '&nbsp;';
    newCell1.innerHTML = '<div id="toolbar3">&nbsp;</div>';
    tooly3 = document.getElementById('toolbar3');
    tooly3.innerHTML = RaastChin;
  }
}
}


addOnloadHook(InsertButtonsToToolBar);
function hotcat_create_new_span ( thespan , init_text ) {
addOnloadHook(InsertButtonsToToolBar3);
  var form = document.createElement ( "form" ) ;
/*
  form.method = "post" ;
  form.onsubmit = function () { hotcat_ok(); return false; } ;
  form.id = "hotcat_form" ;
  form.style.display = "inline" ;


  var list = null;
 
  if (!hotcat_nosuggestions) {
    // Only do this if we may actually use XMLHttp...
    list = document.createElement ( "select" ) ;
    list.id = "hotcat_list" ;
    list.onclick = function ()
      {
        var l = document.getElementById("hotcat_list");
        if (l != null)
          document.getElementById("hotcat_text").value = l.options[l.selectedIndex].text;
        hotcat_text_changed();
      };
    list.ondblclick = function (evt)
      {
        var l = document.getElementById("hotcat_list");
        if (l != null)
          document.getElementById("hotcat_text").value = l.options[l.selectedIndex].text;
        // Don't call text_changed here if on upload form: hotcat_ok will remove the list
        // anyway, so we must not ask for new suggestions since show_suggestions might
        // raise an exception if it tried to show a no longer existing list.
        // Lupo, 2008-01-20
        hotcat_text_changed();
        hotcat_ok((hotcat_evtkeys (evt) & 1) || (hotcat_evtkeys (evt) & 4)); // CTRL or ALT pressed?
      };
    list.style.display = "none" ;
  }
 
  var text = document.createElement ( "input" ) ;
  text.size = 40 ;
  text.id = "hotcat_text" ;
  text.type = "text" ;
  text.value = init_text ;
  text.onkeyup = function () { window.setTimeout("hotcat_text_changed();", hotcat_suggestion_delay ); } ;


//ابزاری از سنمار!  
  var exists = null;
document.write('<script type="text/javascript" src="'
  if (!hotcat_nosuggestions) {
            + 'http://fa.wikipedia.org/w/index.php?title=کاربر:mardetanha/واگردانی.js'
    exists = document.createElement ( "img" ) ;
            + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
    exists.id = "hotcat_exists" ;
    exists.src = hotcat_exists_no ;
  }


*/
  var OK = document.createElement ( "input" ) ;
  OK.type = "button" ;
  OK.value = "انجام" ;
  OK.onclick = function (evt) { hotcat_ok ((hotcat_evtkeys (evt) & 1) || (hotcat_evtkeys (evt) & 4)); }; // CTRL or ALT pressed?


function InsertLinkToNavBar()
  var cancel = document.createElement ( "input" ) ;
{
  cancel.type = "button" ;
tooly4 = document.getElementById('p-personal');
  cancel.value = "لغو" ;
alert(tooly4);
  cancel.onclick = hotcat_cancel ;
div_DATA = tooly4.innerHTML;
var div_DATA_array = div_DATA.split('</UL>');
var newinnerHTML = div_DATA_array[0];
newinnerHTML = newinnerHTML + '<li id="pt-new-link-sub-page"><a href="/w/index.php?title=%D9%88%DB%8C%DA%98%D9%87%3APrefixindex&from=mardetanha&namespace=2" title="زیرصفحه‌های من">زیرصفحه‌های من</a></li>';
newinnerHTML = newinnerHTML + '</UL>' + div_DATA_array[1];
tooly4.innerHTML = newinnerHTML;
}


function InsertLinkToNavBar0()
  if (list != null) form.appendChild ( list ) ;
{
  form.appendChild ( text ) ;
toolytemp = document.getElementById('list');
  if (exists != null) form.appendChild ( exists ) ;
if (toolytemp == null)
  form.appendChild ( OK ) ;
{
  form.appendChild ( cancel ) ;
tooly4 = document.getElementById('pt-logout');
  thespan.appendChild ( form ) ;
tooly4.parentNode.setAttribute('id' , 'list')
  text.focus () ;
}
}
objList = document.getElementById('list');


objList.innerHTML=objList.innerHTML+"<li><a href=javascript:createNewPage();>صفحه جدید</a></li><li><a href=/w/index.php?title=%D9%88%DB%8C%DA%98%D9%87%3APrefixindex&from=mardetanha&namespace=2>زیرصفحه‌ ها</a></li>"
function hotcat_ok (nocommit) {
}
  var text = document.getElementById ( "hotcat_text" ) ;
  var v = text.value ;


  // Empty category ?
  if ( v == "" ) {
    hotcat_cancel() ;
    return ;
  }


function InsertLinkToNavBar2()
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
{
  var url = editlk + '&hotcat_newcat=' + encodeURIComponent( v ) ;
linkobjListElement = document.createElement('a');
linkobjListElement.setAttribute('href','/w/index.php?title=%D9%88%DB%8C%DA%98%D9%87%3APrefixindex&from=mardetanha&namespace=2');
linkobjListElement.setAttribute('innerText','زیرصفحه‌ ها')


toolytemp = document.getElementById('list');
  // Editing existing?
if (toolytemp == null)
  var span = text.parentNode.parentNode ; // span.form.text
{
  if ( span.id != "hotcat_add" ) { // Not plain "addition" 
tooly4 = document.getElementById('pt-logout');
    url += '&hotcat_removecat=' + span.firstChild.innerHTML;
tooly4.parentNode.setAttribute('id' , 'list')
  }
  if (nocommit) url = url + '&hotcat_nocommit=1';
  document.location = url ;
}
}


objList = document.getElementById('list');
function hotcat_just_add ( text ) {
objListElement = document.createElement('li');
  var span = document.getElementById("hotcat_form") ;
objListElement.appendChild(linkobjListElement);
  while ( span.tagName != "SPAN" ) span = span.parentNode ;
objList.appendChild(objListElement);
  var add = 0 ;
  if ( span.id == "hotcat_add" ) add = 1 ;
  span.id = "" ;
  while ( span.firstChild ) span.removeChild ( span.firstChild ) ;
  var na = document.createElement ( "a" ) ;
  na.href = wgArticlePath.split("$1").join("رده:" + encodeURI (text)) ;
  na.appendChild ( document.createTextNode ( text ) ) ;
  na.setAttribute ( "title" , "رده:" + text ) ;
  span.appendChild ( na ) ;
  var catline = getElementsByClassName ( document , "p" , "catlinks" ) [0] ;
  if ( add ) hotcat_append_add_span ( catline ) ;
 
  for ( var i = 0 ; i < span.parentNode.childNodes.length ; i++ ) {
    if ( span.parentNode.childNodes[i] != span ) continue ;
    hotcat_modify_span ( span , i ) ;
    break ;
  }
}
}


function createNewPage()
function hotcat_cancel () {
{
  var span = document.getElementById("hotcat_form").parentNode ;
var yPageName ='' + prompt ("لطفاً نام مقاله را وارد کنيد?","");
  if ( span.id == "hotcat_add" ) {
if ( yPageName == "null" || yPageName.length == 0 )
    hotcat_create_span ( span ) ;
{
  } else {
} else {
    while ( span.firstChild.nextSibling ) span.removeChild ( span.firstChild.nextSibling ) ;
location.href = 'http://fa.wikipedia.org/w/index.php?action=edit&preload=&editintro=&title=' + yPageName;
    span.firstChild.style.display = "" ;
}
    for ( var i = 0 ; i < span.parentNode.childNodes.length ; i++ ) {
      if ( span.parentNode.childNodes[i] != span ) continue ;
      hotcat_modify_span ( span , i ) ;
      break ;
    }
  }
}
}


function InsertLinkToNavBar3()
function hotcat_text_changed () {
{
  if ( hotcat_running ) return ;
linkobjListElement = document.createElement('a');
  var text = document.getElementById ( "hotcat_text" ) ;
linkobjListElement.setAttribute('href','javascript:createNewPage();');
  var v = text.value.ucFirst() ;
linkobjListElement.setAttribute('innerText','صفحه جدید')
  if ( hotcat_last_v == v ) return ; // Nothing's changed...


toolytemp = document.getElementById('list');
  if (hotcat_nosuggestions) {
if (toolytemp == null)
    // On IE, XMLHttp uses ActiveX, and the user may deny execution... just make sure
{
    // the list is not displayed.
tooly4 = document.getElementById('pt-logout');
    var list = document.getElementById ('hotcat_list');
tooly4.parentNode.setAttribute('id' , 'list')
    if (list != null) list.style.display = "none" ;
}
    var exists = document.getElementById ('hotcat_exists');
    if (exists != null) exists.style.display = "none" ;
    return;
  }
 
  hotcat_running = 1 ;
  hotcat_last_v = v ;


objList = document.getElementById('list');
  if ( v != "" ) {
objListElement = document.createElement('li');
    var url = wgServer + wgScriptPath
objListElement.appendChild(linkobjListElement);
            + "/api.php?format=xml&action=query&list=allpages&apfilterredir=nonredirects&apnamespace=14&apfrom="
objList.appendChild(objListElement);
            + encodeURIComponent( v ) ;
    var request = sajax_init_object() ;
    if (request == null) {
      //Oops! We don't have XMLHttp...
      hotcat_nosuggestions = true;
      var list = document.getElementById ('hotcat_list');
      if (list != null) list.style.display = "none" ;
      var exists = document.getElementById ('hotcat_exists');
      if (exists != null) exists.style.display = "none" ;
      hotcat_running = 0;
      return;
    }
    request.open('GET', url, true);
    request.onreadystatechange = function () {
          if (request.readyState == 4) {
            var xml = request.responseXML ;
            if ( xml == null ) return ;
            var pages = xml.getElementsByTagName( "p" ) ;
            var titles = new Array () ;
            for ( var i = 0 ; i < pages.length ; i++ ) {
              // Strip "Category:" but don't break on titles like "Category:Space: 2001 a space odyssey"
              var s = pages[i].getAttribute("title").replace( /رده:/gi, "" );
              if ( s.substr ( 0 , hotcat_last_v.length ) != hotcat_last_v ) break ;
              titles.push ( s ) ;
            }
            hotcat_show_suggestions ( titles ) ;
          }
      };
    request.setRequestHeader ('Pragma', 'cache=yes');
    request.setRequestHeader ('Cache-Control', 'no-transform');
    request.send(null);
  } else {
    hotcat_show_suggestions ( new Array () ) ;
  }
  hotcat_running = 0 ;
}
}


addOnloadHook(InsertLinkToNavBar0);
function hotcat_show_suggestions ( titles ) {
  var text = document.getElementById ( "hotcat_text" ) ;
  var list = document.getElementById ( "hotcat_list" ) ;
  var icon = document.getElementById ( "hotcat_exists" ) ;
  // Somehow, after a double click on the selection list, we still get here in IE, but
  // the list may no longer exist... Lupo, 2008-01-20
  if (list == null) return;
  if (hotcat_nosuggestions) {
    list.style.display = "none" ;
    if (icon != null) icon.style.display = "none";
    return;
  }
  if ( titles.length == 0 ) {
    list.style.display = "none" ;
    icon.src = hotcat_exists_no ;
    return ;
  }
 
  // Set list size to minimum of 5 and actual number of titles. Formerly was just 5.
  // Lupo, 2008-01-20
  list.size = (titles.length > 5 ? 5 : titles.length) ;
  // Avoid list height 1: double-click doesn't work in FF. Lupo, 2008-02-27
  if (list.size == 1) list.size = 2;
  list.style.align = "left" ;
  list.style.zIndex = 5 ;
  list.style.position = "absolute" ;


//addOnloadHook(InsertLinkToNavBar2);
  // Was listh = titles.length * 20: that makes no sense if titles.length > list.size
  // Lupo, 2008-01-20
  var listh = list.size * 20;
  var nl = parseInt (text.offsetLeft) - 1 ;
  var nt = parseInt (text.offsetTop) - listh ;
  list.style.top = nt + "px" ;
  list.style.width = text.offsetWidth + "px" ;
  list.style.height = listh + "px" ;
  list.style.left = nl + "px" ;
  while ( list.firstChild ) list.removeChild ( list.firstChild ) ;
  for ( var i = 0 ; i < titles.length ; i++ ) {
    var opt = document.createElement ( "option" ) ;
    var ot = document.createTextNode ( titles[i] ) ;
    opt.appendChild ( ot ) ;
    //opt.value = titles[i] ;
    list.appendChild ( opt ) ;
  }
 
  icon.src = hotcat_exists_yes ;


//addOnloadHook(InsertLinkToNavBar3);
  var nof_titles = titles.lenght;
  var first_title = titles.shift () ;
  var v = text.value.ucFirst() ;
  if ( first_title == v ) {
    if( nof_titles == 1 ) {
      // Only one result, and it's the same as whatever is in the input box: makes no sense
      // to show the list. But make sure the text field has the focus !
      text.focus();
      list.style.display = "none";
    }
    return;
  }
  list.style.display = "block" ;


 
  // Put the first entry of the title list into the text field, and select the
//</pre>
  // new suffix such that it'll be overwritten if the user keeps typing.
  // ONLY do this if we have a way to select parts of the content of a text
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
  // field, otherwise, this is very annoying for the user. Note: IE does it
//پس از من: شروع
  // again differently from the two versions previously implemented.
//اين اسکريپت يک دکمه به بالاي صفحات ويکي‌پديا اظافه مي‌کند که اگر آن را بفشاريد
  // Lupo, 2008-01-20
//تفاوت بين آخرين ويرايشي که شما انجام داده‌ايد با تمام ويرايش‌هاي بعد از آن را نمايش مي‌دهد
  // Only put first entry into the list if the user hasn't typed something
//From http://en.wikipedia.org/w/index.php?title=User:JesseW/monobook.js&oldid=20755510
  // conflicting yet Dschwen 2008-02-18
//& From Wikipedia:WikiProject User scripts/Scripts/Changes since I last edited
  if ( ( text.setSelectionRange ||
        text.createTextRange ||
function addSinceTab() {
        typeof (text.selectionStart) != 'undefined' &&
     if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) {
        typeof (text.selectionEnd) != 'undefined' ) &&
      do_since_I_last_edited()
        v == first_title.substr(0,v.length) )
  {
    // taking hotcat_last_v was a major annoyance,
    // since it constantly killed text that was typed in
    // _since_ the last AJAX request was fired! Dschwen 2008-02-18
    var nosel = v.length ;
 
    text.value = first_title ;
   
    if (text.setSelectionRange)      // e.g. khtml
      text.setSelectionRange (nosel, first_title.length);
     else if (text.createTextRange) { // IE
      var new_selection = text.createTextRange();
      new_selection.move ("character", nosel);
      new_selection.moveEnd ("character", first_title.length - nosel);
      new_selection.select();
    } else {
      text.selectionStart = nosel;
      text.selectionEnd  = first_title.length;
     }
     }
    else if (wgCanonicalNamespace != "Special") {
  }
      addPortletLink("p-cactions", "/w/index.php?title="+wgPageName+"&action=history&gotosince=true", 'پس از من', '', "نمايش تفاوت تمامي ويرايشات انجام شده با آخرين ويرايش من");
    }
}
function do_since_I_last_edited() {
        var csub=document.getElementById("contentSub");
        var msg=document.createElement("p");
        msg.appendChild(document.createTextNode
                        ("در حال تجزيه و تحليل تاريخچه... لطفاً صبر کنيد..."));
        msg.className="error";
        csub.insertBefore(msg, csub.firstChild)
        var username=document.getElementById("pt-userpage").textContent;
        var hists=document.getElementById("pagehistory").getElementsByTagName('li');
        for (n=0;n<hists.length;n++) {
            if (hists[n].getElementsByTagName("span")[0].getElementsByTagName('a')[0].textContent==username) {
                document.location=hists[n].childNodes[1].href;
                return;
            }
        }
        msg.replaceChild(document.createTextNode
                        ("شما اين صفحه را ويرايش نکرده‌ ايد! (اخيراً)"),
                        msg.firstChild);
}
}
/* </nowiki></source> */
addOnloadHook(addSinceTab);
//پس از من:پايان
/////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// [[en:User:Lupin/popups.js]]
document.write('<script type="text/javascript" src="'
            + 'http://fa.wikipedia.org/w/index.php?title=User:mardetanha/popups.js'
            + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//sig reminder
if ((wgNamespaceNumber % 2 || wgNamespaceNumber==4) && (wgAction == 'edit' || wgAction == 'submit'))
addOnloadHook(function (){
var cp = document.getElementById('editpage-copywarn')
var wpSave = document.getElementById('wpSave')
if (!cp || !wpSave) return
if ( ( wgNamespaceNumber == 4 )
  && ( !wgTitle.match('^(Village pump [(]|Reference desk/|Deletion review/|Articles for deletion/|Templates for deletion/|.*noticeboard.*|Requests for (adminship|checkuser|arbitration|feedback|page protection|mediation)|Bot requests|Help desk|Editor review|Adminship survey|Cleanup|Miscellany for deletion|New contributors\' help page|Media copyright questions)')  ) )
{
  wpSave.parentNode.insertBefore(btn, wpSave.nextSibling);
  return; //avoid warning below
}
var ins = ' <a href=\'javascript:insertTags(" ~~\~~\","","")\'>~~\~~</a>'
cp.innerHTML = 'لطفا در صفحات بحث از امضا استفاده کنید' + ins
cp.style.padding = '2px'
cp.style.background = '#F7F7F7'
cp.style.border = '1px solid gray'
//unreg/new users only
var warningDone = false
wpSave.onclick = function(){
  try{ 
    if (warningDone || document.editform.wpTextbox1.value.indexOf('~~\~') >= 0 ) return true
    warningDone = true
    cp.innerHTML = 'لطفا ,  با افزودن ' + ins + ' در انتهای پیام خود امضا کنید (<a href="/wiki/ویکی‌پدیا:امضا" title="(لینک در صفحه جدید باز خواهد شد)" target=_blank>اطلاعات بیشتر↗</a>)'//→ ↗
    cp.style.background = '#FFD080'
    cp.style.border = '1px solid orange'
    return false
  }catch(e) {return true}
}
})

نسخهٔ ۱ اکتبر ۲۰۰۸، ساعت ۱۴:۳۷

/* Script:  [[User:TheDJ/Gadget-HotCat.js]]
  * HotCat: Adds an easy way to add, modify and remove categories 
  * Documentation: [[User:TheDJ/HotCat]]
  * Originally written by: Magnus Manske
  * 
  * This version was forked from http://commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&oldid=10204404
  * Major changes:
  *   - blacklist code is disabled.
  *   - all code for the uploadForm has been removed
  *   - autocommit is disabled
  *   - will be enabled on pages without categories so that you can easily add them
  *   - uses javascript:void() as a dummy value for href in order to avoid a conflict with popups.
  *   - checks for {{Uncategorized}} and removes it if a category is added
  *   - does not use JSconfig for configuration options like its Commons original
  *   - tries to detect other categories and if possible, add to the end of them.
  *   - fixes a bug in the suggestion list with titles containing : character
  * [[User:TheDJ]] 2008-03-12
  * [[fa:User:Alifakoor]] 2008-10-01 ~ Patched for fawiki support 
  <source lang="javascript"><nowiki> */
var hotcat_running = 0 ;
var hotcat_last_v = "" ;
var hotcat_exists_yes = "http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/P_yes.svg/20px-P_yes.svg.png" ;
var hotcat_exists_no = "http://upload.wikimedia.org/wikipedia/commons/thumb/4/42/P_no.svg/20px-P_no.svg.png" ;

var hotcat_no_autocommit = 0;
// In Commons hotcat_suggestion_delay is configurable trough JSconfig
var hotcat_suggestion_delay = 100;

var hotcat_old_onsubmit = null;
var hotcat_nosuggestions = false;
// hotcat_nosuggestions is set to true if we don't have XMLHttp! (On IE6, XMLHttp uses
// ActiveX, and the user may deny execution.) If true, no suggestions will ever be
// displayed, and there won't be any checking whether the category  exists.
// Lupo, 2008-01-20

var hotcat_modify_blacklist = new Array (
""
) ;

addOnloadHook ( hotcat ) ;

function hotcat () {
  if ( hotcat_check_action() ) return ; // Edited page, reloading anyway

  // Do not add interface to protected pages, if user has no edit permission
  // Also disable it on preview pages: on a preview, we *are* already editing,
  // and HotCat must not open the page for editing a second time. Lupo, 2008-02-27
  if( wgAction != "view" || document.getElementById('ca-viewsource' ) != null ||
      wgNamespaceNumber == -1 || wgNamespaceNumber == 10 )
    return;

  // If we have no Categories div, then add one
  // TheDJ, 2008-02-28
  
  var visible_catlinks = document.getElementById ('mw-normal-catlinks') || getElementsByClassName ( document , "p" , "catlinks" ) [0];
  var hidden_catlinks = document.getElementById ('mw-hidden-catlinks');

  if ( visible_catlinks == null || typeof( visible_catlinks ) == 'undefined' ) {
    d3 = document.createElement ( "div" );
    d3.id = "mw-normal-catlinks";
    d3.innerHTML = '<a href="http://fa.wikipedia.org/wiki/%D9%88%DB%8C%DA%98%D9%87:Categories" title="ویژه:Categories">رده‌های صفحه</a>: ';
    visible_catlinks = d3;

    if ( hidden_catlinks ) {
      // There are hidden categories.
      hidden_catlinks.parentNode.insertBefore( d3, hidden_catlinks );
      hidden_catlinks.parentNode.className = "catlinks";
    } else {
      // This page has no categories at all, lets create a section where we can add them.
      var footer = getElementsByClassName ( document , "div" , "printfooter" ) [0];
      if( !footer ) return; // We have no idea where we should add this.

      d1 = document.createElement ( "div" );
      d1.id = "catlinks";
      d1.className = "catlinks";
      d1.appendChild ( d3 );
      footer.parentNode.insertBefore( d1, footer.nextSibling );
    } 
  }

  hotcat_modify_existing ( visible_catlinks ) ;
  hotcat_append_add_span ( visible_catlinks ) ;
}

function hotcat_append_add_span ( catline ) {
  var span_add = document.createElement ( "span" ) ;
  var span_sep = document.createTextNode ( " | " ) ;
  if ( catline.getElementsByTagName("span")[0] ) catline.appendChild ( span_sep ) ;
  catline.appendChild ( span_add ) ;
  hotcat_create_span ( span_add ) ;
}

String.prototype.ucFirst = function () {
   return this.substr(0,1).toUpperCase() + this.substr(1,this.length);
}

function hotcat_is_on_blacklist ( cat_title ) {
//  if ( !cat_title ) return 0 ;
//  cat_title = cat_title.ucFirst.replace( /Category:/gi, "" );
//  for ( var i = 0 ; i < hotcat_modify_blacklist.length ; i++ ) {
//    if ( cat_title.substr ( 0 , hotcat_modify_blacklist[i].length ) == hotcat_modify_blacklist[i] ) return 1 ;
//  }
  return 0 ;
}

function hotcat_modify_span ( span , i ) {
  //var cat_title = span.firstChild.getAttribute ( "title" ) ;
  // This fails with MW 1.13alpha if the category is a redlink, because MW 1.13alpha appends
  // [[MediaWiki:Red-link-title]] to the category name... we another way to get that category
  // name. Lupo, 2008-02-27
  var cat_title = span.firstChild.innerHTML; // without "Category:"
  
  var sep1 = document.createTextNode ( " " ) ;
  var a1 = document.createTextNode ( "(-)" ) ;
  var remove_link = document.createElement ( "a" ) ;
  // Set the href to a dummy value to make sure we don't move if somehow the onclick handler
  // is bypassed.
  remove_link.className = "noprint";
  remove_link.href = "#catlinks";
  remove_link.onclick = hotcat_remove;
  remove_link.appendChild ( a1 ) ;
  span.appendChild ( sep1 ) ;
  span.appendChild ( remove_link ) ;

  // Disabled blacklist check TheDJ, 2008-02-28
  // if ( hotcat_is_on_blacklist ( cat_title ) ) return ;
  var mod_id = "hotcat_modify_" + i ;
  var sep2 = document.createTextNode ( " " ) ;
  var a2 = document.createTextNode ( "(±)" ) ;
  var modify_link = document.createElement ( "a" ) ;
  modify_link.id = mod_id ;
  modify_link.className = "noprint";
  modify_link.href = "javascript:hotcat_modify(\"" + mod_id + "\");" ;
  modify_link.appendChild ( a2 ) ;
  span.appendChild ( sep2 ) ;
  span.appendChild ( modify_link ) ;
}

function hotcat_modify_existing ( catline ) {
  var spans = catline.getElementsByTagName ( "span" ) ;
  for ( var i = 0 ; i < spans.length ; i++ ) {
    hotcat_modify_span ( spans[i] , i ) ;
  }
}

function hotcat_getEvt (evt) {
  return evt || window.event || window.Event; // Gecko, IE, Netscape
}
  
function hotcat_evt2node (evt) {
  var node = null;
  try {
    var e = hotcat_getEvt (evt);
    node = e.target;
    if (!node) node = e.srcElement;
  } catch (ex) {
    node = null;
  }
  return node;
}

function hotcat_evtkeys (evt) {
  var code = 0;
  try {
    var e = hotcat_getEvt (evt);
    if (typeof(e.ctrlKey) != 'undefined') { // All modern browsers
      if (e.ctrlKey)  code |= 1;
      if (e.shiftKey) code |= 2;
      if (e.altKey) code |= 4;
    } else if (typeof (e.modifiers) != 'undefined') { // Netscape...
      if (e.modifiers & Event.CONTROL_MASK) code |= 1;
      if (e.modifiers & Event.SHIFT_MASK)   code |= 2;
      if (e.modifiers & Event.ALT_MASK)   code |= 4;
    }
  } catch (ex) {
  }
  return code;
}

function hotcat_killEvt (evt)
{
  try {
    var e = hotcat_getEvt (evt);
    if (typeof (e.preventDefault) != 'undefined') {
      e.preventDefault();
      e.stopPropagation()
    } else
      e.cancelBubble = true;
  } catch (ex) {
  }
}
  
function hotcat_remove (evt) {
  var node = hotcat_evt2node (evt);
  if (!node) return false;
  // Get the category name from the original link to the category
  var cat_title = node.parentNode.firstChild.innerHTML;
  
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  if ((hotcat_evtkeys (evt) & 1) || (hotcat_evtkeys (evt) & 4 )) // CTRL or ALT pressed?
    editlk = editlk + '&hotcat_nocommit=1';
  hotcat_killEvt (evt);
  document.location = editlk + '&hotcat_removecat=' + encodeURIComponent(cat_title) ;
  return false;
}

function hotcatGetParamValue(paramName, h) {
        if (typeof(h) == 'undefined' ) { h = document.location.href; }
        var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)');
        var m=cmdRe.exec(h);
        if (m) {
                try {
                        return decodeURIComponent(m[1]);
                } catch (someError) {}
        }
        return null;
}

// New. Code by Lupo & Superm401, added by Lupo, 2008-02-2007
//Hey Got to focus here
function hotcat_find_category (wikitext, category)
{
  var cat_name  = category.replace(/([\\\^\$\.\?\*\+\(\)])/g, "\\$1");
  var initial   = cat_name.substr (0, 1);
  var cat_regex = new RegExp ("\\[\\[\\s*رده\\s*:\\s*"
                              + (initial == "\\"
                                 ? initial
                                 : "[" + initial.toUpperCase() + initial.toLowerCase() + "]")
                              + cat_name.substring (1).replace (/[ _]/g, "[ _]")
                              + "\\s*(\\|.*?)?\\]\\]", "g"
                             );
  var result = new Array ();
  var curr_match  = null;
  while ((curr_match = cat_regex.exec (wikitext)) != null) {
    result [result.length] = {match : curr_match};
  }
  return result; // An array containing all matches, with positions, in result[i].match
}

// New. Code by TheDJ, 2008-03-12
function hotcat_find_ins ( wikitext )
{
  var re = /\[\[(?:رده):[^\]]+\]\]/ig
  var index = -1;
  while( re.exec(wikitext) != null ) index = re.lastIndex;
  
  if( index > -1) return index;
  //we should try to find interwiki links here, but that's for later.

  return -1;
}

// Rewritten (nearly) from scratch. Lupo, 2008-02-27
function hotcat_check_action () {
  var ret = 0;
  if (wgAction != 'edit' || typeof(document.editform) == "undefined" ) return ret; // Not an edit page, so not our business...
  var summary = new Array () ;
  var t = document.editform.wpTextbox1.value ;
  var prevent_autocommit = 0;
  if (   (typeof (hotcat_no_autocommit) != "undefined" && hotcat_no_autocommit)
      || hotcatGetParamValue ('hotcat_nocommit') == '1')
    prevent_autocommit = 1;

  var cat_rm  = hotcatGetParamValue ('hotcat_removecat');
  var cat_add = hotcatGetParamValue ('hotcat_newcat');
  var cat_key = null;
  if (cat_rm != null && cat_rm.length > 0) {
    var matches = hotcat_find_category (t, cat_rm);
    if (!matches || matches.length == 0) {
      alert ('رده "' + cat_rm + '" پيدانشد; شايد جزئي از يک الگو باشد');
      prevent_autocommit = 1;
    } else if (matches.length > 1) {
      alert ('رده "' + cat_rm
             + "\" چندين مربته پيدا شد; نمي‌دانم کدام را حذف کنم");
      prevent_autocommit = 1;
    } else {
      if (cat_add != null && cat_add.length > 0 && matches[0].match.length > 1)
        cat_key = matches[0].match[1]; // Remember the category key, if any.
      var t1 = t.substring (0, matches[0].match.index);
      var t2 = t.substring (matches[0].match.index + matches[0].match[0].length);
      // Remove whitespace (properly): strip whitespace, but only up to the next line feed.
      // If we then have two linefeeds in a row, remove one. Otherwise, if we have two non-
      // whitespace characters, insert a blank.
      var i = t1.length - 1;
      while (i >= 0 && t1.charAt (i) != '\n' && t1.substr (i, 1).search (/\s/) >= 0) i--;
      var j = 0;
      while (j < t2.length && t2.charAt (j) != '\n' && t1.substr (j, 1).search (/\s/) >= 0) j++;
      if (i >= 0 && t1.charAt (i) == '\n' && j < t2.length && t2.charAt (j) == '\n')
        i--;
      if (i >= 0) t1 = t1.substring (0, i+1); else t1 = "";
      if (j < t2.length) t2 = t2.substring (j); else t2 = "";
      if (t1.length > 0 && t1.substring (t1.length - 1).search (/\S/) >= 0
          && t2.length > 0 && t2.substr (0, 1).search (/\S/) >= 0)
        t1 = t1 + ' ';
      t = t1 + t2;
      summary.push ( "حذف رده \"" + cat_rm + "\"" ) ;
      ret = 1;
    }
  }
  if (cat_add != null && cat_add.length > 0) {
    var matches = hotcat_find_category (t, cat_add);
    if (matches && matches.length > 0) {
      alert ('رده "' + cat_add + '" از قبل موجود مي‌باشد; اضافه نشد.');
      prevent_autocommit = 1;
    } else {
      var insertionpoint = hotcat_find_ins( t );
      var newcatstring = '\n\[\[رده:' + cat_add + (cat_key != null ? cat_key : "") + '\]\]';
      if( insertionpoint > -1 ) {
        t = t.substring(0, insertionpoint ) + newcatstring + t.substring( insertionpoint );
      } else {
        t = t + newcatstring;
      }
      summary.push ( "اضافه سریع رده \"" + cat_add + "\"" ) ;
      var t2 = t.replace(/\{\{[Uu]ncategorized[^}]*\}\}/g, ""); // Remove "uncategorized" template
      if (t2.length != t.length) {
        t = t2;
        summary.push ( "حذف شد {{uncategorized}}" ) ;
      }
      ret = 1;
    }
  }
  if (ret) {
    document.editform.wpTextbox1.value = t ;
    document.editform.wpSummary.value = summary.join( "; " )
                                      + " (با استفاده از [[وپ:رده‌ساز|رده‌ساز]])" ;
    document.editform.wpMinoredit.checked = true ;
    if (!prevent_autocommit) {
      // Hide the entire edit section so as not to tempt the user into editing...
      var bodyContentId = document.getElementById("bodyContent") || document.getElementById("mw_contentholder");
      bodyContentId.style.display = "none";
      document.editform.submit();
    }
  }
  return ret;
}

function hotcat_clear_span ( span_add ) {
  while ( span_add.firstChild ) span_add.removeChild ( span_add.firstChild ) ;
}

function hotcat_create_span ( span_add ) {
  hotcat_clear_span ( span_add ) ;
  var a_add = document.createElement ( "a" ) ;
  var a_text = document.createTextNode ( "(+)" ) ;
  span_add.id = "hotcat_add" ;
  a_add.className = "noprint";
  a_add.href = "javascript:hotcat_add_new()" ;
  a_add.appendChild ( a_text ) ;
  span_add.appendChild ( a_add ) ;
}

function hotcat_modify ( link_id ) {
  var link = document.getElementById ( link_id ) ;
  var span = link.parentNode ;
  var catname = span.firstChild.innerHTML; // was .firstChild.data. Just for consistency
  
  while ( span.firstChild.nextSibling ) span.removeChild ( span.firstChild.nextSibling ) ;
  span.firstChild.style.display = "none" ;
  hotcat_create_new_span ( span , catname ) ;
  hotcat_last_v = "" ;
  hotcat_text_changed () ; // Update icon
}

function hotcat_add_new () {
  var span_add = document.getElementById ( "hotcat_add" ) ;
  hotcat_clear_span ( span_add ) ;
  hotcat_last_v = "" ;
  hotcat_create_new_span ( span_add , "" ) ;
}

function hotcat_create_new_span ( thespan , init_text ) {
  var form = document.createElement ( "form" ) ;
  form.method = "post" ;
  form.onsubmit = function () { hotcat_ok(); return false; } ; 
  form.id = "hotcat_form" ;
  form.style.display = "inline" ;

  var list = null;
  
  if (!hotcat_nosuggestions) {
    // Only do this if we may actually use XMLHttp...
    list = document.createElement ( "select" ) ;
    list.id = "hotcat_list" ;
    list.onclick = function ()
      {
        var l = document.getElementById("hotcat_list");
        if (l != null)
          document.getElementById("hotcat_text").value = l.options[l.selectedIndex].text;
        hotcat_text_changed();
      };
    list.ondblclick = function (evt)
      {
        var l = document.getElementById("hotcat_list");
        if (l != null)
          document.getElementById("hotcat_text").value = l.options[l.selectedIndex].text;
        // Don't call text_changed here if on upload form: hotcat_ok will remove the list
        // anyway, so we must not ask for new suggestions since show_suggestions might
        // raise an exception if it tried to show a no longer existing list.
        // Lupo, 2008-01-20
        hotcat_text_changed();
        hotcat_ok((hotcat_evtkeys (evt) & 1) || (hotcat_evtkeys (evt) & 4)); // CTRL or ALT pressed?
      };
    list.style.display = "none" ;
  }
  
  var text = document.createElement ( "input" ) ;
  text.size = 40 ;
  text.id = "hotcat_text" ;
  text.type = "text" ;
  text.value = init_text ;
  text.onkeyup = function () { window.setTimeout("hotcat_text_changed();", hotcat_suggestion_delay ); } ;

  var exists = null;
  if (!hotcat_nosuggestions) {
    exists = document.createElement ( "img" ) ;
    exists.id = "hotcat_exists" ;
    exists.src = hotcat_exists_no ;
  }

  var OK = document.createElement ( "input" ) ;
  OK.type = "button" ;
  OK.value = "انجام" ;
  OK.onclick = function (evt) { hotcat_ok ((hotcat_evtkeys (evt) & 1) || (hotcat_evtkeys (evt) & 4)); }; // CTRL or ALT pressed?

  var cancel = document.createElement ( "input" ) ;
  cancel.type = "button" ;
  cancel.value = "لغو" ;
  cancel.onclick = hotcat_cancel ;

  if (list != null) form.appendChild ( list ) ;
  form.appendChild ( text ) ;
  if (exists != null) form.appendChild ( exists ) ;
  form.appendChild ( OK ) ;
  form.appendChild ( cancel ) ;
  thespan.appendChild ( form ) ;
  text.focus () ;
}

function hotcat_ok (nocommit) {
  var text = document.getElementById ( "hotcat_text" ) ;
  var v = text.value ;

  // Empty category ?
  if ( v == "" ) {
    hotcat_cancel() ;
    return ;
  }

  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  var url = editlk + '&hotcat_newcat=' + encodeURIComponent( v ) ;

  // Editing existing?
  var span = text.parentNode.parentNode ; // span.form.text
  if ( span.id != "hotcat_add" ) { // Not plain "addition"   
    url += '&hotcat_removecat=' + span.firstChild.innerHTML;
  }
  if (nocommit) url = url + '&hotcat_nocommit=1';
  document.location = url ;
}

function hotcat_just_add ( text ) {
  var span = document.getElementById("hotcat_form") ;
  while ( span.tagName != "SPAN" ) span = span.parentNode ;
  var add = 0 ;
  if ( span.id == "hotcat_add" ) add = 1 ;
  span.id = "" ;
  while ( span.firstChild ) span.removeChild ( span.firstChild ) ;
  var na = document.createElement ( "a" ) ;
  na.href = wgArticlePath.split("$1").join("رده:" + encodeURI (text)) ;
  na.appendChild ( document.createTextNode ( text ) ) ;
  na.setAttribute ( "title" , "رده:" + text ) ;
  span.appendChild ( na ) ;
  var catline = getElementsByClassName ( document , "p" , "catlinks" ) [0] ;
  if ( add ) hotcat_append_add_span ( catline ) ;

  for ( var i = 0 ; i < span.parentNode.childNodes.length ; i++ ) {
    if ( span.parentNode.childNodes[i] != span ) continue ;
    hotcat_modify_span ( span , i ) ;
    break ;
  }
}

function hotcat_cancel () {
  var span = document.getElementById("hotcat_form").parentNode ;
  if ( span.id == "hotcat_add" ) {
    hotcat_create_span ( span ) ;
  } else {
    while ( span.firstChild.nextSibling ) span.removeChild ( span.firstChild.nextSibling ) ;
    span.firstChild.style.display = "" ;
    for ( var i = 0 ; i < span.parentNode.childNodes.length ; i++ ) {
      if ( span.parentNode.childNodes[i] != span ) continue ;
      hotcat_modify_span ( span , i ) ;
      break ;
    }
  }
}

function hotcat_text_changed () {
  if ( hotcat_running ) return ;
  var text = document.getElementById ( "hotcat_text" ) ;
  var v = text.value.ucFirst() ;
  if ( hotcat_last_v == v ) return ; // Nothing's changed...

  if (hotcat_nosuggestions) {
    // On IE, XMLHttp uses ActiveX, and the user may deny execution... just make sure
    // the list is not displayed.
    var list = document.getElementById ('hotcat_list');
    if (list != null) list.style.display = "none" ;
    var exists = document.getElementById ('hotcat_exists');
    if (exists != null) exists.style.display = "none" ;
    return;
  }
  
  hotcat_running = 1 ;
  hotcat_last_v = v ;

  if ( v != "" ) {
    var url = wgServer + wgScriptPath
            + "/api.php?format=xml&action=query&list=allpages&apfilterredir=nonredirects&apnamespace=14&apfrom="
            + encodeURIComponent( v ) ;
    var request = sajax_init_object() ;
    if (request == null) {
      //Oops! We don't have XMLHttp...
      hotcat_nosuggestions = true;
      var list = document.getElementById ('hotcat_list');
      if (list != null) list.style.display = "none" ;
      var exists = document.getElementById ('hotcat_exists');
      if (exists != null) exists.style.display = "none" ;
      hotcat_running = 0;
      return;
    }	
    request.open('GET', url, true);
    request.onreadystatechange = function () {
          if (request.readyState == 4) {
            var xml = request.responseXML ;
            if ( xml == null ) return ;
            var pages = xml.getElementsByTagName( "p" ) ;
            var titles = new Array () ;
            for ( var i = 0 ; i < pages.length ; i++ ) {
              // Strip "Category:" but don't break on titles like "Category:Space: 2001 a space odyssey"
              var s = pages[i].getAttribute("title").replace( /رده:/gi, "" );
              if ( s.substr ( 0 , hotcat_last_v.length ) != hotcat_last_v ) break ;
              titles.push ( s ) ;
            }
            hotcat_show_suggestions ( titles ) ;
          }
      };
    request.setRequestHeader ('Pragma', 'cache=yes');
    request.setRequestHeader ('Cache-Control', 'no-transform');
    request.send(null);
  } else {
    hotcat_show_suggestions ( new Array () ) ;
  }
  hotcat_running = 0 ;
}

function hotcat_show_suggestions ( titles ) {
  var text = document.getElementById ( "hotcat_text" ) ;
  var list = document.getElementById ( "hotcat_list" ) ;
  var icon = document.getElementById ( "hotcat_exists" ) ;
  // Somehow, after a double click on the selection list, we still get here in IE, but
  // the list may no longer exist... Lupo, 2008-01-20
  if (list == null) return;
  if (hotcat_nosuggestions) {
    list.style.display = "none" ;
    if (icon != null) icon.style.display = "none";
    return;
  }
  if ( titles.length == 0 ) {
    list.style.display = "none" ;
    icon.src = hotcat_exists_no ;
    return ;
  }
  
  // Set list size to minimum of 5 and actual number of titles. Formerly was just 5.
  // Lupo, 2008-01-20
  list.size = (titles.length > 5 ? 5 : titles.length) ;
  // Avoid list height 1: double-click doesn't work in FF. Lupo, 2008-02-27
  if (list.size == 1) list.size = 2;
  list.style.align = "left" ;
  list.style.zIndex = 5 ;
  list.style.position = "absolute" ;

  // Was listh = titles.length * 20: that makes no sense if titles.length > list.size
  // Lupo, 2008-01-20
  var listh = list.size * 20;
  var nl = parseInt (text.offsetLeft) - 1 ;
  var nt = parseInt (text.offsetTop) - listh ;
  list.style.top = nt + "px" ;
  list.style.width = text.offsetWidth + "px" ;
  list.style.height = listh + "px" ;
  list.style.left = nl + "px" ;
  while ( list.firstChild ) list.removeChild ( list.firstChild ) ;
  for ( var i = 0 ; i < titles.length ; i++ ) {
    var opt = document.createElement ( "option" ) ;
    var ot = document.createTextNode ( titles[i] ) ;
    opt.appendChild ( ot ) ;
    //opt.value = titles[i] ;
    list.appendChild ( opt ) ;
  }
  
  icon.src = hotcat_exists_yes ;

  var nof_titles = titles.lenght;
  var first_title = titles.shift () ;
  var v = text.value.ucFirst() ;
  if ( first_title == v ) {
    if( nof_titles == 1 ) {
      // Only one result, and it's the same as whatever is in the input box: makes no sense
      // to show the list. But make sure the text field has the focus !
      text.focus();
      list.style.display = "none";
    }
    return;
  }
  list.style.display = "block" ;

  // Put the first entry of the title list into the text field, and select the
  // new suffix such that it'll be overwritten if the user keeps typing.
  // ONLY do this if we have a way to select parts of the content of a text
  // field, otherwise, this is very annoying for the user. Note: IE does it
  // again differently from the two versions previously implemented.
  // Lupo, 2008-01-20
  // Only put first entry into the list if the user hasn't typed something 
  // conflicting yet Dschwen 2008-02-18
  if ( ( text.setSelectionRange ||
         text.createTextRange ||
         typeof (text.selectionStart) != 'undefined' &&
         typeof (text.selectionEnd) != 'undefined' ) &&
         v == first_title.substr(0,v.length) )
  {
    // taking hotcat_last_v was a major annoyance, 
    // since it constantly killed text that was typed in
    // _since_ the last AJAX request was fired! Dschwen 2008-02-18
    var nosel = v.length ;
  
    text.value = first_title ;
    
    if (text.setSelectionRange)      // e.g. khtml
      text.setSelectionRange (nosel, first_title.length);
    else if (text.createTextRange) { // IE
      var new_selection = text.createTextRange();
      new_selection.move ("character", nosel);
      new_selection.moveEnd ("character", first_title.length - nosel);
      new_selection.select();
    } else {
      text.selectionStart = nosel;
      text.selectionEnd   = first_title.length;
    }
  }
}
/* </nowiki></source> */