Skip to content

Commit 8d5d323

Browse files
committed
Replace null by NaN in JSON data to avoid error in remote interface.
1 parent 093e723 commit 8d5d323

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎index.html‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,15 @@
242242
forceFull = false;
243243
}
244244

245+
function nullToNaN(array) {
246+
for (var i = 0; i < array.length; i++) {
247+
if (array[i] == null) {
248+
array[i] = NaN;
249+
}
250+
}
251+
return array;
252+
}
253+
245254
function updateData() {
246255
updateUsedVarStr();
247256
ajax("get?" + usedVarStr,
@@ -252,13 +261,13 @@
252261
data[index]["changed"] = false;
253262
continue;
254263
}
255-
data[index]["data"] = data[index]["data"].concat(jsonData["buffer"][index]["buffer"]);
264+
data[index]["data"] = data[index]["data"].concat(nullToNaN(jsonData["buffer"][index]["buffer"]));
256265
if (jsonData["buffer"][index]["size"] > 0)
257266
data[index]["data"].splice(0, data[index]["data"].length - jsonData["buffer"][index]["size"]);
258267
data[index]["changed"] = true;
259268
} else {
260269
data[index] = {};
261-
data[index]["data"] = jsonData["buffer"][index]["buffer"];
270+
data[index]["data"] = nullToNaN(jsonData["buffer"][index]["buffer"]);
262271
data[index]["changed"] = true;
263272
}
264273
}

0 commit comments

Comments
 (0)