diff options
author | David Underwood <david.underwood@jadedpixel.com> | 2013-07-29 11:56:43 -0400 |
---|---|---|
committer | David Underwood <david.underwood@jadedpixel.com> | 2013-07-29 11:56:43 -0400 |
commit | ff467e28a14163f6257c260fdd570c0ccd95228c (patch) | |
tree | 44ec670aa78aa0c1b5f998d947662e5ed0251702 /javascripts/dashing.coffee | |
parent | c2fad09e3b3845f80fb6e60f7ceb7e64c60dd633 (diff) | |
parent | 60dcd73bac913afe0a49b6c6c07b709aa288fd7d (diff) |
Merge remote-tracking branch 'cjolly/cjolly-application-messages'
* cjolly/cjolly-application-messages:
only fire dashboard events when target is current dashboard
dashboard events - use SSE event names
Adding application messaging.
Conflicts:
test/app_test.rb
Diffstat (limited to 'javascripts/dashing.coffee')
-rw-r--r-- | javascripts/dashing.coffee | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/javascripts/dashing.coffee b/javascripts/dashing.coffee index ebf5c0a..5712e98 100644 --- a/javascripts/dashing.coffee +++ b/javascripts/dashing.coffee @@ -25,6 +25,9 @@ Batman.Filters.shortenedNumber = (num) -> num class window.Dashing extends Batman.App + @on 'reload', (data) -> + window.location.reload(true) + @root -> Dashing.params = Batman.URI.paramsFromQuery(window.location.search.slice(1)); @@ -98,7 +101,7 @@ source.addEventListener 'error', (e)-> if (e.readyState == EventSource.CLOSED) console.log("Connection closed") -source.addEventListener 'message', (e) => +source.addEventListener 'message', (e) -> data = JSON.parse(e.data) if lastEvents[data.id]?.updatedAt != data.updatedAt if Dashing.debugMode @@ -108,6 +111,12 @@ source.addEventListener 'message', (e) => for widget in widgets[data.id] widget.receiveData(data) +source.addEventListener 'dashboards', (e) -> + data = JSON.parse(e.data) + if Dashing.debugMode + console.log("Received data for dashboards", data) + if data.dashboard is '*' or window.location.pathname is "/#{data.dashboard}" + Dashing.fire data.event, data $(document).ready -> Dashing.run() |