Permalink
Browse files

Proper client-side disconnection handling

  • Loading branch information...
1 parent 4fb0218 commit dd6293d1529992ea8ff83eb6470f694f25e79436 @suttree committed Apr 19, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 lib/occupy.js
View
@@ -12,12 +12,14 @@ socket.on('connect', function() {
});
socket.on('connect_failed', function () {
+ $('#occupy').html(slogan());
socket.reconnectionDelay = socket.reconnectionDelay / 2;
window.location.href = '/';
});
socket.on('disconnect', function() {
+ $('#occupy').html(slogan());
socket.reconnectionDelay = socket.reconnectionDelay / 2;
$('#log').html(ajax_loader_icon());
@@ -30,10 +32,12 @@ socket.on('reconnect', function(evt) {
});
socket.on('reconnecting', function(evt) {
+ $('#occupy').html(slogan());
$('#log').html(ajax_loader_icon());
});
socket.on('reconnect_failed', function() {
+ $('#occupy').html(slogan());
window.location.href = '/';
$('#log').html(ajax_loader_icon());
@@ -44,6 +48,7 @@ socket.on('message', function(evt) {
});
socket.on('error', function() {
+ $('#occupy').html(slogan());
log("eep");
});
@@ -72,6 +77,10 @@ function disconnected_icon() {
return "<img src='/images/icons/switch--minus.png' height='16' width='16' id='status' />"
}
+function slogan() {
+ return "There are 2,267,233,742 people with access to the internet.<br/><br/><b>You are the 77%</b><br/><a href='http://troisen.com/occupy-offline.html'>Huh?</a>"
+}
+
window.onload = function() {
socket.connect();
}

0 comments on commit dd6293d

Please sign in to comment.