From 600d580f4f8d16c6c18b26e280ae0eb1466ef7d6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 19 May 2015 00:38:43 +0200 Subject: [PATCH] Add WoltLab/WCF/Core.getUUID() --- wcfsetup/install/files/js/WCF.js | 5 +---- wcfsetup/install/files/js/WoltLab/WCF/Core.js | 13 +++++++++++++ .../install/files/js/WoltLab/WCF/Event/Handler.js | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 2a7060bf3f..3ad13d7cb9 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -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) { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Core.js b/wcfsetup/install/files/js/WoltLab/WCF/Core.js index 2fb807aa83..6ef38d1e82 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Core.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Core.js @@ -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) { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Event/Handler.js b/wcfsetup/install/files/js/WoltLab/WCF/Event/Handler.js index 74720dbc02..aab7048367 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Event/Handler.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Event/Handler.js @@ -6,7 +6,7 @@ * @license GNU Lesser General Public License * @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; -- 2.20.1