Skip to content

Commit

Permalink
add a hard-refresh option
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeraci committed Jan 22, 2017
1 parent ca5ea37 commit 7ad91a7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ project root. You'll also need to obtain a free api key for
# swap the css, js, or templates
VERSION = "0.000"

# how often the entire page should hard refresh (0 for no refreshing)
REFRESH_TIME = 10000

# your info for forecast.io
FORECASTIO_API_KEY = "<your api key>"
FORECASTIO_LAT_LONG = "40.676423,-73.980488"
Expand Down
2 changes: 2 additions & 0 deletions auto-hud.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# secret settings
from localsettings import VERSION
from localsettings import REFRESH_TIME
from localsettings import BIRTHDAYS
from localsettings import CHORES
from localsettings import FORECASTIO_API_KEY
Expand All @@ -23,6 +24,7 @@ def index_route(params={}):

return render_template('index.html', params = {
'version': VERSION,
'refreshTime': REFRESH_TIME,
'C': C,
'forecastioApiKey': FORECASTIO_API_KEY,
'forecastioLatLong': FORECASTIO_LAT_LONG,
Expand Down
12 changes: 12 additions & 0 deletions static/js/AutoHUD.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ window.AutoHUD = {
@controller.init()

@watchVersion(params)
@watchRefershTime(params.refreshTime)


# versioning
Expand Down Expand Up @@ -56,4 +57,15 @@ window.AutoHUD = {
# if the version has updated, refresh the page
if data.version != @version
window.location.reload()


# hard refresher
#############################################################################

watchRefershTime: (time) ->
return if !time

setTimeout(->
window.location.reload()
, time)
}
11 changes: 10 additions & 1 deletion static/js/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ window.AutoHUD = {
this.model.set(params);
this.view.init();
this.controller.init();
return this.watchVersion(params);
this.watchVersion(params);
return this.watchRefershTime(params.refreshTime);
},
watchVersion: function(params) {
if (params.version == null) {
Expand Down Expand Up @@ -55,6 +56,14 @@ window.AutoHUD = {
if (data.version !== this.version) {
return window.location.reload();
}
},
watchRefershTime: function(time) {
if (!time) {
return;
}
return setTimeout(function() {
return window.location.reload();
}, time);
}
};

Expand Down

0 comments on commit 7ad91a7

Please sign in to comment.