Browse Source

fixed multiple object local json

visualizer
edoardoo 10 years ago
parent
commit
c9df78338e
2 changed files with 14 additions and 10 deletions
  1. +13
    -1
      public/scripts/functions.js
  2. +1
    -9
      public/scripts/socketSetup.js

+ 13
- 1
public/scripts/functions.js View File

@ -3,6 +3,18 @@ var totalRenders = 0;
function updateDimensions( dimension ){
less.modifyVars({"@sizeWidth":dimension+"px"});
}
function prePopulate(honeyCells){
var honeyCells = JSON.parse(honeyCells);
if( honeyCells.constructor === Array){
for (var i = 0; i < honeyCells.length; i++) {
populateHoneycomb( honeyCells[i], i );
};
}else{
populateHoneycomb( honeyCells , 0);
}
}
function populateHoneycomb( honeyCells , index){
@ -256,7 +268,7 @@ document.onkeydown = checkKey;
function sendJson(){
// console.log("sending mama some json.")
// socket.emit("jsonToParse", document.getElementById("sendHCJson").value);
populateHoneycomb( JSON.parse(document.getElementById("sendHCJson").value) , 0);
prePopulate( document.getElementById("sendHCJson").value);
}
function checkKey(e) {


+ 1
- 9
public/scripts/socketSetup.js View File

@ -9,15 +9,7 @@ socket.on("jsonHoneycomb",function(message){
be executed . The Callback function gets the dat sent from the server
*/
console.log("Message from the server arrived")
var honeyCells = JSON.parse(message);
if( honeyCells.constructor === Array){
for (var i = 0; i < honeyCells.length; i++) {
populateHoneycomb( honeyCells[i], i );
};
}else{
populateHoneycomb( honeyCells , 0);
}
prePopulate(message);
socket.emit('ackMessage', "true");
});


Loading…
Cancel
Save