diff options
author | Luke Shumaker <shumakl@purdue.edu> | 2014-04-28 00:04:47 -0400 |
---|---|---|
committer | Luke Shumaker <shumakl@purdue.edu> | 2014-04-28 00:04:47 -0400 |
commit | 6b66877bda4c0e4a33bb3109304636d5ada85904 (patch) | |
tree | 7065307802fec8452afc89c8a7b445fd2ceca772 /app/assets/javascripts/application | |
parent | 33fcf6de9feaaa6f90dfe5082e08d280c930dae1 (diff) | |
parent | 7a4832621f1a0bb2e4b86ee9f879a73df0188a3e (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app/assets/javascripts/application')
-rw-r--r-- | app/assets/javascripts/application/layout.js.coffee | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/assets/javascripts/application/layout.js.coffee b/app/assets/javascripts/application/layout.js.coffee new file mode 100644 index 0000000..da0bc67 --- /dev/null +++ b/app/assets/javascripts/application/layout.js.coffee @@ -0,0 +1,21 @@ +json_url = "/alerts.json" + +page_visited = false +starting_size = 0 +update = (alerts) -> + if !page_visited + starting_size = alerts.length + page_visited = true + + if alerts.length > starting_size + $("#alerts-ajax").css("display", "inline"); + return + + setTimeout (-> + $.ajax(url: json_url).done update + return + ), 2000 + +# Now kick off the whole process +window.onload = -> + $.ajax(url: json_url).done update
\ No newline at end of file |