summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/application/layout.js.coffee21
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