From 2fd40772aaea3ddbee0dac3dfaacd2723597bb0a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 22 Jul 2017 21:55:44 +0200 Subject: [PATCH] Moved `String.prototype.hashCode()` The dev tools indirectly require this method to be loaded a bit earlier. --- wcfsetup/install/files/js/WCF.js | 22 ------------------- wcfsetup/install/files/js/wcf.globalHelper.js | 20 +++++++++++++++++ 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 2da297143e..eb77a71006 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -76,28 +76,6 @@ } })(); - - -/** - * Provides a hashCode() method for strings, similar to Java's String.hashCode(). - * - * @see http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/ - */ -String.prototype.hashCode = function() { - var $char; - var $hash = 0; - - if (this.length) { - for (var $i = 0, $length = this.length; $i < $length; $i++) { - $char = this.charCodeAt($i); - $hash = (($hash << 5) - $hash) + $char; - $hash = $hash & $hash; // convert to 32bit integer - } - } - - return $hash; -}; - /** * Adds a Fisher-Yates shuffle algorithm for arrays. * diff --git a/wcfsetup/install/files/js/wcf.globalHelper.js b/wcfsetup/install/files/js/wcf.globalHelper.js index e18ffbcc5c..48fdc94474 100644 --- a/wcfsetup/install/files/js/wcf.globalHelper.js +++ b/wcfsetup/install/files/js/wcf.globalHelper.js @@ -246,4 +246,24 @@ } }); })(); + + /** + * Provides a hashCode() method for strings, similar to Java's String.hashCode(). + * + * @see http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/ + */ + window.String.prototype.hashCode = function() { + var $char; + var $hash = 0; + + if (this.length) { + for (var $i = 0, $length = this.length; $i < $length; $i++) { + $char = this.charCodeAt($i); + $hash = (($hash << 5) - $hash) + $char; + $hash = $hash & $hash; // convert to 32bit integer + } + } + + return $hash; + }; })(window, document); -- 2.20.1