From b9bf1b369aaef86d1f2d4dd2bf7f7fbe4bc1e9e8 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 31 Mar 2018 18:36:32 +0200 Subject: better refresh --- public/assets/js/nav.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'public/assets/js') 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(){ -- cgit v1.2.3-70-g09d2