מדיה ויקי:Gadget-HotCat.js: הבדלים בין גרסאות בדף

מאין תקציר עריכה
Blacklist
שורה 2: שורה 2:


/*
/*
   HotCat V2.4
   HotCat V2.5


   Ajax-based simple Category manager. Allows adding/removing/changing categories on a page view.
   Ajax-based simple Category manager. Allows adding/removing/changing categories on a page view.
שורה 26: שורה 26:
           load translations from the Commons. Major/minor edit flag configurable; and fix a minor
           load translations from the Commons. Major/minor edit flag configurable; and fix a minor
           bug with the "Warn upon empty edit summary" user preference.
           bug with the "Warn upon empty edit summary" user preference.
    V2.5: Jan 2011: [[User:Lupo]]: blacklist


   License: Quadruple licensed GFDL, GPL, LGPL and Creative Commons Attribution 3.0 (CC-BY-3.0)
   License: Quadruple licensed GFDL, GPL, LGPL and Creative Commons Attribution 3.0 (CC-BY-3.0)
שורה 161: שורה 162:
  ,upload_disabled : false
  ,upload_disabled : false
   // If upload_disabled is true, HotCat will not be used on the Upload form.
   // If upload_disabled is true, HotCat will not be used on the Upload form.
,blacklist : null
  // Single regular expression matching blacklisted categories that cannot be changed or
  // added using HotCat. For instance /\bstubs?$/ (any category ending with the word "stub"
  // or "stubs"), or /(\bstubs?$)|\bmaintenance\b/ (stub categories and any category with the
  // word "maintenance" in its title.


   // Stuff changeable by users:
   // Stuff changeable by users:
שורה 679: שורה 685:
       }
       }
     }
     }
    if (changes == 0) return;
     // Fill in the form and submit it
     // Fill in the form and submit it
     commitForm.wpAutoSummary.value = 'd41d8cd98f00b204e9800998ecf8427e'; // MD5 hash of the empty string
     commitForm.wpAutoSummary.value = 'd41d8cd98f00b204e9800998ecf8427e'; // MD5 hash of the empty string
שורה 1,271: שורה 1,278:
       this.linkSpan.style.display = 'none';
       this.linkSpan.style.display = 'none';
       this.form.style.display = 'inline';
       this.form.style.display = 'inline';
      this.ok.disabled = false;
       CategoryEditor.makeActive (this);
       CategoryEditor.makeActive (this);
       // Kill the event before focussing, otherwise IE will kill the onfocus event!
       // Kill the event before focussing, otherwise IE will kill the onfocus event!
שורה 1,400: שורה 1,408:
         return false;
         return false;
       }
       }
       if (!dontCheck && wgNamespaceNumber == 14 && v == wgTitle) {
       if (!dontCheck
          && (  wgNamespaceNumber == 14 && v == wgTitle
              || HotCat.blacklist != null && HotCat.blacklist.test(v))
        ) {
         this.cancel ();
         this.cancel ();
         return false;
         return false;
שורה 1,495: שורה 1,506:
             )
             )
           || wgNamespaceNumber == 14 && this.currentCategory == wgTitle
           || wgNamespaceNumber == 14 && this.currentCategory == wgTitle
          || HotCat.blacklist != null && HotCat.blacklist.test (this.currentCategory)
         )
         )
       {
       {
שורה 1,648: שורה 1,660:
       // Hide all other lists
       // Hide all other lists
       CategoryEditor.makeActive (this);
       CategoryEditor.makeActive (this);
      if (noSuggestions) {
        // No Ajax: just make sure the list is hidden
        if (this.list) this.list.style.display = 'none';
        if (this.engineSelector) this.engineSelector.style.display = 'none';
        if (this.icon) this.icon.style.display = 'none';
        return;
      }
     
       // Get input value, omit sort key, if any
       // Get input value, omit sort key, if any
       this.sanitizeInput ();
       this.sanitizeInput ();
שורה 1,666: שורה 1,670:
       this.lastInput = v;
       this.lastInput = v;
       this.lastRealInput = v;
       this.lastRealInput = v;
      // Mark blacklisted inputs.
      this.ok.disabled = v.length > 0 && HotCat.blacklist != null && HotCat.blacklist.test (v);
      if (noSuggestions) {
        // No Ajax: just make sure the list is hidden
        if (this.list) this.list.style.display = 'none';
        if (this.engineSelector) this.engineSelector.style.display = 'none';
        if (this.icon) this.icon.style.display = 'none';
        return;
      }
     
       if (v.length == 0) { this.showSuggestions([]); return; }
       if (v.length == 0) { this.showSuggestions([]); return; }
       if (!sajax_init_object ()) {
       if (!sajax_init_object ()) {
שורה 1,724: שורה 1,740:
       if (titles) {
       if (titles) {
         var vLow = v.toLowerCase ();
         var vLow = v.toLowerCase ();
        // Strip blacklisted categories
        if (HotCat.blacklist != null) {
          for (var i = 0; i < titles.length; i++) {
            if (HotCat.blacklist.test (titles[i])) {
              titles.splice(i, 1);
              i--;
            }
          }
        }
         titles.sort (
         titles.sort (
           function (a, b) {
           function (a, b) {
שורה 2,213: שורה 2,238:
     if (!catTitle) return null;
     if (!catTitle) return null;
     catTitle = catTitle.substr (catTitle.indexOf (':') + 1).replace (/_/g, ' ');
     catTitle = catTitle.substr (catTitle.indexOf (':') + 1).replace (/_/g, ' ');
    if (HotCat.blacklist != null && HotCat.blacklist.test (catTitle)) return null;
     var result = { title : catTitle, match : ["", "", ""] };
     var result = { title : catTitle, match : ["", "", ""] };
     if (pageText === null) return result;
     if (pageText === null) return result;