diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-03-31 18:36:32 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-03-31 18:36:32 +0200 |
| commit | b9bf1b369aaef86d1f2d4dd2bf7f7fbe4bc1e9e8 (patch) | |
| tree | 0a61c694c9e0eb62995ed3f08c635c28518dafe8 | |
| parent | 89f3dcb22f20d6914e451d4a2c6caa20d8e4969e (diff) | |
better refresh
| -rw-r--r-- | lib/index.js | 2 | ||||
| -rw-r--r-- | public/assets/js/nav.js | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/index.js b/lib/index.js index d0f5e76..e87e4e6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -113,6 +113,8 @@ site.init = function(){ size: req.file.size, url, }) + }).catch(function(err){ + console.error("db error", err) }) } }) diff --git a/public/assets/js/nav.js b/public/assets/js/nav.js index 247ed05..d1d9083 100644 --- a/public/assets/js/nav.js +++ b/public/assets/js/nav.js @@ -1,3 +1,5 @@ +var deferTimeout + var NavView = View.extend({ el: "body", @@ -94,6 +96,11 @@ var NavView = View.extend({ this.fetching = true this.onLatest = false console.log('fetch ascii') + clearTimeout(deferTimeout) + deferTimeout = setTimeout(function(){ + this.fetchAscii() + }.bind(this), 45000) + $.get("/p/get/randomascii", function(data){ // console.log(data) var asciiData = { @@ -107,6 +114,7 @@ var NavView = View.extend({ if (loaded) return loaded = true this.display(asciiData) + clearTimeout(deferTimeout) setTimeout(this.fetchAscii.bind(this), 15000) }.bind(this) img.onerror = function(){ |
