From: Alexander Ebert Date: Sat, 22 Jul 2017 19:55:44 +0000 (+0200) Subject: Moved `String.prototype.hashCode()` X-Git-Tag: 3.1.0_Alpha_1~223 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2fd40772aaea3ddbee0dac3dfaacd2723597bb0a;p=GitHub%2FWoltLab%2FWCF.git Moved `String.prototype.hashCode()` The dev tools indirectly require this method to be loaded a bit earlier. --- 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);