diff options
Diffstat (limited to 'app.js')
-rw-r--r-- | app.js | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -2,7 +2,7 @@ var screen = h('div', {id: 'screen'}) document.body.appendChild(screen) -var header = h('div', {classList: 'message'}) +//var header = h('div', {classList: 'message'}) var keys = getKeys() @@ -129,12 +129,6 @@ function route () { clientLog.log = [] } - /*if (localSTorage['log']) { - var publicLog = localStorage['log'] - } else { - var publicLog = [] - }*/ - ws.onopen = function () { ws.send(JSON.stringify(clientLog)) } @@ -142,7 +136,17 @@ function route () { ws.onmessage = function (ev) { var serverData = JSON.parse(ev.data) if (serverData.log.length > clientLog.log.length) { + + // update the log of the id localStorage[src] = JSON.stringify(serverData.log) + + // contact new items from the log onto the client's log of everything + var num = serverData.log.length - clientLog.log.length + var diff = serverData.log.slice(0, num) + var oldLog = JSON.parse(localStorage['log']) + var newLog = diff.concat(oldLog) + localStorage['log'] = JSON.stringify(newLog) + location.reload() } } |