Created
March 16, 2011 13:46
-
-
Save lukegalea/872514 to your computer and use it in GitHub Desktop.
Panopticon JS
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
// The Panopticon is a type of prison building designed by English philosopher and social theorist Jeremy Bentham in 1785. | |
// The concept of the design is to allow an observer to observe (-opticon) all (pan-) prisoners without the incarcerated being able to tell whether they are being watched, | |
// thereby conveying what one architect has called the "sentiment of an invisible omniscience." | |
// Bentham himself described the Panopticon as "a new mode of obtaining power of mind over mind, in a quantity hitherto without example." | |
var lastAction = new Date(), | |
timeoutMins = 2, | |
keepAliveMins = 1, | |
timeoutEvent, | |
keepAliveEvent, | |
debugLog = function(msg) { | |
$('<p>' + msg + '</p>').appendTo($('div#debug')); | |
}, | |
updateTimeouts = function() { | |
if (timeoutEvent) { | |
clearTimeout(timeoutEvent); | |
} | |
timeoutEvent = setTimeout(noAction, timeoutMins * 60 * 1000); | |
if (!keepAliveEvent) { | |
debugLog("Activating Keep Alive"); | |
// Quickly fire off one right now so they don't have to wait | |
doKeepAlive(); | |
keepAliveEvent = setTimeout(doKeepAlive, keepAliveMins * 60 * 1000); | |
} | |
}, | |
updateLastAction = function(e) { | |
lastAction = new Date(); | |
updateTimeouts(); | |
}, | |
// This means they haven't moved in a while, shut 'em down | |
noAction = function() { | |
clearInterval(keepAliveEvent); | |
keepAliveEvent = null; | |
debugLog("Timeout"); | |
}, | |
doKeepAlive = function() { | |
debugLog("Keeping Alive"); | |
}, | |
panopticonWatch = function() { | |
debugLog("Starting up"); | |
$(window.document).mousemove(updateLastAction); | |
$(window.document).keypress(updateLastAction); | |
updateTimeouts(); | |
}; | |
$(document).ready(panopticonWatch); |
Author
lukegalea
commented
Mar 16, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment