-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
file sys changes and extracted 3rd party code to ./lib
- Loading branch information
1 parent
c280cd3
commit dc5d32a
Showing
7 changed files
with
177 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,56 @@ | |||
|
|||
|
|||
/** | |||
* This is a copy of a .js timer made by @mrSpeaker for another HN bookmarklet | |||
* taken from this repo: https://github.com/mrspeaker/HackemUp | |||
* | |||
**/ | |||
|
|||
var hnutimer = { | |||
refreshTime: 2 * (60 * 1000), | |||
waitOnFocusTime: 1500, | |||
|
|||
timerId: null, | |||
lastCheck: null, | |||
focusedTime: null, | |||
|
|||
init: function(onTimerExpire) { | |||
$(window).bind({ | |||
"focus": function(){ hnutimer.onFocus(); }, | |||
"blur": function(){ hnutimer.onBlur(); } | |||
}); | |||
this.onTimerExpire = onTimerExpire; | |||
// Init onfocus to avoid first time load delay | |||
this.focusedTime = new Date().getTime() - this.waitOnFocusTime; | |||
this.update(); | |||
}, | |||
update: function() { | |||
var doFetch = true, | |||
refreshTime = this.refreshTime, | |||
previous = this.lastCheck, | |||
rightNow = new Date().getTime(), | |||
elapsed = previous ? rightNow - previous : refreshTime; | |||
|
|||
if (elapsed < refreshTime) { | |||
doFetch = false; | |||
refreshTime -= elapsed; | |||
} | |||
|
|||
if(doFetch) { | |||
if(rightNow - this.focusedTime >= this.waitOnFocusTime){ | |||
this.onTimerExpire && this.onTimerExpire(); | |||
this.lastCheck = rightNow; | |||
} else { | |||
refreshTime = this.waitOnFocusTime; | |||
} | |||
} | |||
this.timerId = setTimeout(function(){ hnutimer.update(); }, refreshTime); | |||
}, | |||
onFocus: function() { | |||
this.focusedTime = new Date().getTime(); | |||
this.update(); | |||
}, | |||
onBlur: function() { | |||
clearTimeout(this.timerId); | |||
} | |||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,72 @@ | |||
|
|||
/** | |||
* a Javascript implementation of Jenkins' hash copypasta'd from | |||
* http://stackoverflow.com/questions/4234499/javascript-implementation-of-jenkins-hash | |||
* | |||
**/ | |||
|
|||
|
|||
var Jenkins = { | |||
rot: function(x,k) { | |||
return (x<<k) | (x>>>(32-k)); | |||
}, | |||
|
|||
mix: function(a,b,c) { | |||
a = (a - c) | 0; a ^= Jenkins.rot(c, 4); c = (c + b) | 0; | |||
b = (b - a) | 0; b ^= Jenkins.rot(a, 6); a = (a + c) | 0; | |||
c = (c - b) | 0; c ^= Jenkins.rot(b, 8); b = (b + a) | 0; | |||
a = (a - c) | 0; a ^= Jenkins.rot(c,16); c = (c + b) | 0; | |||
b = (b - a) | 0; b ^= Jenkins.rot(a,19); a = (a + c) | 0; | |||
c = (c - b) | 0; c ^= Jenkins.rot(b, 4); b = (b + a) | 0; | |||
return {a : a, b : b, c : c}; | |||
}, | |||
|
|||
final: function(a,b,c) { | |||
c ^= b; c -= Jenkins.rot(b,14) | 0; | |||
a ^= c; a -= Jenkins.rot(c,11) | 0; | |||
b ^= a; b -= Jenkins.rot(a,25) | 0; | |||
c ^= b; c -= Jenkins.rot(b,16) | 0; | |||
a ^= c; a -= Jenkins.rot(c,4) | 0; | |||
b ^= a; b -= Jenkins.rot(a,14) | 0; | |||
c ^= b; c -= Jenkins.rot(b,24) | 0; | |||
return {a : a, b : b, c : c}; | |||
}, | |||
|
|||
hashlittle2: function(k, initval, initval2) { | |||
var length = k.length; | |||
a = b = c = 0xdeadbeef + length + initval; | |||
c += initval2; | |||
|
|||
offset = 0; | |||
while (length > 12) { | |||
a += (k.charCodeAt(offset+0) + (k.charCodeAt(offset+1)<<8) + (k.charCodeAt(offset+2)<<16) + (k.charCodeAt(offset+3)<<24)); a = a>>>0; | |||
b += (k.charCodeAt(offset+4) + (k.charCodeAt(offset+5)<<8) + (k.charCodeAt(offset+6)<<16) + (k.charCodeAt(offset+7)<<24)); b = b>>>0; | |||
c += (k.charCodeAt(offset+8) + (k.charCodeAt(offset+9)<<8) + (k.charCodeAt(offset+10)<<16) + (k.charCodeAt(offset+11)<<24)); c = c>>>0; | |||
o = Jenkins.mix(a,b,c); | |||
a = o.a; b = o.b; c = o.c; | |||
length -= 12; | |||
offset += 12; | |||
} | |||
|
|||
switch(length) { | |||
case 12: c += (k.charCodeAt(offset+8) + (k.charCodeAt(offset+9)<<8) + (k.charCodeAt(offset+10)<<16) + (k.charCodeAt(offset+11)<<24)); b += (k.charCodeAt(offset+4) + (k.charCodeAt(offset+5)<<8) + (k.charCodeAt(offset+6)<<16) + (k.charCodeAt(offset+7)<<24)); a += (k.charCodeAt(offset+0) + (k.charCodeAt(offset+1)<<8) + (k.charCodeAt(offset+2)<<16) + (k.charCodeAt(offset+3)<<24)); break; | |||
case 11: c += (k.charCodeAt(offset+8) + (k.charCodeAt(offset+9)<<8) + (k.charCodeAt(offset+10)<<16)); b += (k.charCodeAt(offset+4) + (k.charCodeAt(offset+5)<<8) + (k.charCodeAt(offset+6)<<16) + (k.charCodeAt(offset+7)<<24)); a += (k.charCodeAt(offset+0) + (k.charCodeAt(offset+1)<<8) + (k.charCodeAt(offset+2)<<16) + (k.charCodeAt(offset+3)<<24)); break; | |||
case 10: c += (k.charCodeAt(offset+8) + (k.charCodeAt(offset+9)<<8)); b += (k.charCodeAt(offset+4) + (k.charCodeAt(offset+5)<<8) + (k.charCodeAt(offset+6)<<16) + (k.charCodeAt(offset+7)<<24)); a += (k.charCodeAt(offset+0) + (k.charCodeAt(offset+1)<<8) + (k.charCodeAt(offset+2)<<16) + (k.charCodeAt(offset+3)<<24)); break; | |||
case 9: c += (k.charCodeAt(offset+8)); b += (k.charCodeAt(offset+4) + (k.charCodeAt(offset+5)<<8) + (k.charCodeAt(offset+6)<<16) + (k.charCodeAt(offset+7)<<24)); a += (k.charCodeAt(offset+0) + (k.charCodeAt(offset+1)<<8) + (k.charCodeAt(offset+2)<<16) + (k.charCodeAt(offset+3)<<24)); break; | |||
case 8: b += (k.charCodeAt(offset+4) + (k.charCodeAt(offset+5)<<8) + (k.charCodeAt(offset+6)<<16) + (k.charCodeAt(offset+7)<<24)); a += (k.charCodeAt(offset+0) + (k.charCodeAt(offset+1)<<8) + (k.charCodeAt(offset+2)<<16) + (k.charCodeAt(offset+3)<<24)); break; | |||
case 7: b += (k.charCodeAt(offset+4) + (k.charCodeAt(offset+5)<<8) + (k.charCodeAt(offset+6)<<16)); a += (k.charCodeAt(offset+0) + (k.charCodeAt(offset+1)<<8) + (k.charCodeAt(offset+2)<<16) + (k.charCodeAt(offset+3)<<24)); break; | |||
case 6: b += ((k.charCodeAt(offset+5)<<8) + k.charCodeAt(offset+4)); a += (k.charCodeAt(offset+0) + (k.charCodeAt(offset+1)<<8) + (k.charCodeAt(offset+2)<<16) + (k.charCodeAt(offset+3)<<24)); break; | |||
case 5: b += (k.charCodeAt(offset+4)); a += (k.charCodeAt(offset+0) + (k.charCodeAt(offset+1)<<8) + (k.charCodeAt(offset+2)<<16) + (k.charCodeAt(offset+3)<<24)); break; | |||
case 4: a += (k.charCodeAt(offset+0) + (k.charCodeAt(offset+1)<<8) + (k.charCodeAt(offset+2)<<16) + (k.charCodeAt(offset+3)<<24)); break; | |||
case 3: a += (k.charCodeAt(offset+0) + (k.charCodeAt(offset+1)<<8) + (k.charCodeAt(offset+2)<<16)); break; | |||
case 2: a += (k.charCodeAt(offset+0) + (k.charCodeAt(offset+1)<<8)); break; | |||
case 1: a += (k.charCodeAt(offset+0)); break; | |||
case 0: return {b : b, c : c}; | |||
} | |||
|
|||
o = Jenkins.final(a,b,c); | |||
a = o.a; b = o.b; c = o.c; | |||
|
|||
return {b : b>>>0, c : c>>>0}; | |||
} | |||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.