diff options
| author | Ev Bogue <ev@evbogue.com> | 2019-04-04 08:43:31 -0500 | 
|---|---|---|
| committer | Ev Bogue <ev@evbogue.com> | 2019-04-04 08:43:31 -0500 | 
| commit | 249f0a43fef58bab1a28fadbde74b0b073702f2d (patch) | |
| tree | 0625d6980df5287ef353b8aa528b6c8c7014f659 | |
| parent | 3986e1d4388c5484dd941b164337a196fc96439c (diff) | |
add new items to public log when syncing
| -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()        }      } | 
