MyIOTest / myiotest / static / test.html

The default branch has multiple heads

<html>
<script src="http://cdn.socket.io/stable/socket.io.js"></script>

<script>
var socket = new io.Socket(null, {rememberTransport: false,
                                  transports: ['websocket', 'xhr-multipart', 'xhr-polling', 'jsonp-polling']});
socket.on('message', function(obj){
  console.log("message:", JSON.stringify(obj));
  if ((obj.type == "memorized") || (obj.type == "forgot")) {
    // do some tihngs...
  }
  else if (obj.type == "new_content") {
    $("div.intr-timeline").append($(obj.insert_html));
  }
  else if (obj.type == "privacy_changed") {
    $("#privacy").val(obj.new_value);
  }
  else if (obj.type == "photos_sent") {
    $('#intrentry-post-photos div.upload').empty();
    new_upload_box();
  }
});
socket.on('error', function(obj) {
  console.log("error", obj);
});
socket.on('disconnect', function(obj) {
  console.log("disconnected", obj);
  socketio_notification("Disconnected", "There was a disconnection, either because of network or server failure");
  socketio_schedule_reconnect();
});
var connection_notification = null;
socket.on('connect', function() {
  console.log("connected");
  // Comment out if you don't use the auto-reconnect machinery:
  socketio_notification();
  socket.send({type: "connect", context: "interest", interest_id: "${intr['_id']}"});
});



// Use this:
alert('toto');
socket.connect(); 


// Or this is optional auto-reconnect machinery:

function socketio_schedule_reconnect() {
  setTimeout(function() { if (!socket.connected && !socket.connecting) { socketio_reconnect("reconnect");}}, 1000);
}
function socketio_reconnect(func) {
  console.log("connecting... ", socket);
  if (func == "connect") {
    socketio_notification("Connecting", "Connecting...");
  }
  if (func == "reconnect") {
    socketio_notification("Re-connecting", "Attempting to reconnect...");
    socketio_schedule_reconnect();
  }
  socket.connect();
}
function socketio_notification(title, msg) {
  if (connection_notification) {
    connection_notification.close();
    connection_notification = null;
  }
  if (title) {
    connection_notification = notify_default(title, msg);
  }
}
$(document).ready(function() {
  socketio_reconnect('connect');
});

</script>

<body>
   hello world
</body>
</html>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.