Add local generator function to account for revert of r93063 in r96236.
authorKrinkle <krinkle@users.mediawiki.org>
Sun, 4 Sep 2011 17:04:09 +0000 (17:04 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Sun, 4 Sep 2011 17:04:09 +0000 (17:04 +0000)
resources/mediawiki.page/mediawiki.page.ajaxCategories.js

index b7fe3c2..916ec6b 100644 (file)
                return '';
        }
 
+       /**
+       * Generates a random id out of 62 alpha-numeric characters.
+       *
+       * @param {Number} Length of id (optional, defaults to 32)
+       * @return {String}
+       */
+       function generateRandomId( idLength ) {
+               idLength = typeof idLength === 'number' ? idLength : 32;
+               var     seed = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
+                       id = '';
+               for ( var r, i = 0; i < idLength; i++ ) {
+                       r = Math.floor( Math.random() * seed.length );
+                       id += seed.substring( r, r + 1 );
+               }
+               return id;
+       }
+
        /**
         * Helper function for $.fn.suggestions
         *
@@ -872,7 +889,7 @@ mw.ajaxCategories.prototype = {
                                        var     token = data.edittoken,
                                                timestamp = data.revisions[0].timestamp,
                                                oldText = data.revisions[0]['*'],
-                                               nowikiKey = mw.user.generateId(), // Unique ID for nowiki replacement
+                                               nowikiKey = generateRandomId(), // Unique ID for nowiki replacement
                                                nowikiFragments = []; // Nowiki fragments will be stored here during the changes
 
                                        // Replace all nowiki parts with unique keys..