Commit 181863db authored by Ricardo J. Mendez's avatar Ricardo J. Mendez

ClojureScript already implements hash-string

parent 95ce1dad
String.prototype.hashCode = function() {};
String.prototype.hashCode = function(){
var hash = 0;
if (this.length == 0) return hash;
for (var i = 0; i < this.length; i++) {
var char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
};
booklet.background.init();
String.prototype.hashCode = function(){
var hash = 0;
if (this.length == 0) return hash;
for (var i = 0; i < this.length; i++) {
var char = this.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
};
booklet.content.init();
\ No newline at end of file
......@@ -251,7 +251,7 @@
(fn [app-state [_ tab time]]
(let [url-times (or (get-in app-state url-time-path) {})
url (or (:url tab) "")
url-key (.hashCode url)
url-key (hash-string url)
url-time (or (get url-times url-key)
{:url (:url tab)
:time 0
......
......@@ -12,7 +12,7 @@
[database node]
(let [parent (.-parentNode node)
href (.-href parent)
id (.hashCode href)
id (hash-string href)
data (get database id)
time (:time data)
root-item (-> parent .-parentNode .-parentNode .-parentNode) ; Yeah, hacky as fuck
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment