Skip to content

Instantly share code, notes, and snippets.

@empirefx
Created December 19, 2014 21:18
Show Gist options
  • Save empirefx/92adc7f5cf92e9826ab8 to your computer and use it in GitHub Desktop.
Save empirefx/92adc7f5cf92e9826ab8 to your computer and use it in GitHub Desktop.
var socket = io.connect();
socket.on('info', function (data) {
console.log(data);
var state = JSON.parse(data.state);
for( i = 0; i < state.length; i++)
{
var body = document.getElementsByTagName("body")[0];
var wrapper = document.createElement("div");
wrapper.setAttribute("id", "wrapper");
for(var index in state[i])
{
if (typeof state[i][index] === "object")
{
continue;
};
var p = document.createElement("p");
var number = document.createElement("div");
number.setAttribute("id", "number");
number.appendChild(document.createTextNode(state[i][index]));
p.appendChild(number);
p.appendChild(document.createTextNode(index));
wrapper.appendChild(p);
}
body.appendChild(wrapper);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment