diff options
author | Florent Gallaire <[email protected]> | 2013-11-11 02:16:50 +0100 |
---|---|---|
committer | Florent Gallaire <[email protected]> | 2014-02-20 00:05:29 +0100 |
commit | 148b6fe476e35e9e8db448d6dc73d57a3b23e800 (patch) | |
tree | af917b87e683ce638dc02bd50ac8bab38d9b4bc7 /examples/clock | |
parent | 5bf494144cf4f86e85cd80bfd8c7aa495a4e2209 (diff) | |
download | bullet-148b6fe476e35e9e8db448d6dc73d57a3b23e800.tar.gz bullet-148b6fe476e35e9e8db448d6dc73d57a3b23e800.tar.bz2 bullet-148b6fe476e35e9e8db448d6dc73d57a3b23e800.zip |
DRY url.replace().
Automatically disable WebSocket when the URL begins with 'http'.
Update the README with the new 'http' url syntax.
Update the clock example with the new 'http' url syntax.
Diffstat (limited to 'examples/clock')
-rw-r--r-- | examples/clock/src/toppage_handler.erl | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/examples/clock/src/toppage_handler.erl b/examples/clock/src/toppage_handler.erl index 71512d3..be52be2 100644 --- a/examples/clock/src/toppage_handler.erl +++ b/examples/clock/src/toppage_handler.erl @@ -24,6 +24,10 @@ handle(Req, State) -> Current time (best source): <span id=\"time_best\">unknown</span> <span></span><span id=\"status_best\">unknown</span> <button id=\"send_best\">Send Time</button></p> + <p><input type=\"checkbox\" checked=\"yes\" id=\"enable_best_nows\"></input> + Current time (best source non-websocket): <span id=\"time_best_nows\">unknown</span> + <span></span><span id=\"status_best_nows\">unknown</span> + <button id=\"send_best_nows\">Send Time</button></p> <p><input type=\"checkbox\" checked=\"yes\" id=\"enable_websocket\"></input> Current time (websocket only): <span id=\"time_websocket\">unknown</span> <span></span><span id=\"status_websocket\">unknown</span> @@ -44,10 +48,10 @@ handle(Req, State) -> <script type=\"text/javascript\"> // <![CDATA[ $(document).ready(function(){ - var start = function(name, options) { + var start = function(name, url, options) { var bullet; var open = function(){ - bullet = $.bullet('ws://localhost:8080/bullet', options); + bullet = $.bullet(url, options); bullet.onopen = function(){ $('#status_' + name).text('online'); }; @@ -81,12 +85,13 @@ $(document).ready(function(){ }); }; - start('best', {}); - start('websocket', {'disableEventSource': true, + start('best', 'ws://localhost:8080/bullet', {}); + start('best_nows', 'http://localhost:8080/bullet', {}); + start('websocket', 'ws://localhost:8080/bullet', {'disableEventSource': true, 'disableXHRPolling': true}); - start('eventsource', {'disableWebSocket': true, + start('eventsource', 'ws://localhost:8080/bullet', {'disableWebSocket': true, 'disableXHRPolling': true}); - start('polling', {'disableWebSocket': true, + start('polling', 'ws://localhost:8080/bullet', {'disableWebSocket': true, 'disableEventSource': true}); }); // ]]> |