Add WoltLab/WCF/Core.getUUID()
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 18 May 2015 22:38:43 +0000 (00:38 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 18 May 2015 22:38:43 +0000 (00:38 +0200)
wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/js/WoltLab/WCF/Core.js
wcfsetup/install/files/js/WoltLab/WCF/Event/Handler.js

index 2a7060bf3ff75dfa7f643d5b1cee0f24e5312ec0..3ad13d7cb97658babf139c3d6a2938d88671203f 100755 (executable)
@@ -703,10 +703,7 @@ $.extend(WCF, {
        },
        
        /**
-        * Returns a RFC4122 version 4 compilant UUID.
-        * 
-        * @see         http://stackoverflow.com/a/2117523
-        * @return      string
+        * @deprecated Use WoltLab/WCF/Core.getUUID()
         */
        getUUID: function() {
                return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
index 2fb807aa8306ceada0451bd4f5757f03347cf7da..6ef38d1e824fb1c9cba3bdde0f7d74603075ecff 100644 (file)
@@ -44,6 +44,19 @@ define([], function() {
                        return out;
                },
                
+               /**
+                * Returns a RFC4122 version 4 compilant UUID.
+                * 
+                * @see         http://stackoverflow.com/a/2117523
+                * @return      {string}
+                */
+               getUUID: function() {
+                       return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+                               var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
+                               return v.toString(16);
+                       });
+               },
+               
                triggerEvent: function(el, eventName) {
                        var ev;
                        if (document.createEvent) {
index 74720dbc02b90b73e7cf8db754c4c2397698fc2f..aab704836769ee603ae7fa926b2dfecf4f35e75d 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/Event/Handler
  */
-define(['Dictionary'], function(Dictionary) {
+define(['Core', 'Dictionary'], function(Core, Dictionary) {
        "use strict";
        
        var _listeners = new Dictionary();
@@ -41,7 +41,7 @@ define(['Dictionary'], function(Dictionary) {
                                actions.set(action, callbacks);
                        }
                        
-                       var uuid = WCF.getUUID();
+                       var uuid = Core.getUUID();
                        callbacks.set(uuid, callback);
                        
                        return uuid;