Mercurial > piecrust2
comparison piecrust/admin/assets/js/foodtruck.js @ 929:cebeedfa034f
serve: Don't start the admin panel SSE until the window is ready.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 04 Oct 2017 09:08:31 -0700 |
parents | 628d639bb30b |
children |
comparison
equal
deleted
inserted
replaced
928:41db689d36b6 | 929:cebeedfa034f |
---|---|
24 | 24 |
25 var closePublogBtn = $('button', publogEl); | 25 var closePublogBtn = $('button', publogEl); |
26 closePublogBtn.on('click', function() { | 26 closePublogBtn.on('click', function() { |
27 publogEl.fadeOut(200); | 27 publogEl.fadeOut(200); |
28 }); | 28 }); |
29 | |
30 if (!!window.EventSource) { | |
31 // TODO: this only works when the Foodtruck blueprint is added under `/pc-admin`. | |
32 var source = new EventSource('/pc-admin/publish-log'); | |
33 source.onerror = function(e) { | |
34 console.log("Error with SSE, closing.", e); | |
35 source.close(); | |
36 }; | |
37 source.addEventListener('message', onPublishEvent); | |
38 } | |
29 }); | 39 }); |
30 | 40 |
31 var onPublishEvent = function(e) { | 41 var onPublishEvent = function(e) { |
32 | 42 |
33 var publogEl = $('#ft-publog'); | 43 var publogEl = $('#ft-publog'); |
53 publogEl.fadeIn(200); | 63 publogEl.fadeIn(200); |
54 } | 64 } |
55 containerEl.append(msgEl); | 65 containerEl.append(msgEl); |
56 }; | 66 }; |
57 | 67 |
58 if (!!window.EventSource) { | |
59 // TODO: this only works when the Foodtruck blueprint is added under `/pc-admin`. | |
60 var source = new EventSource('/pc-admin/publish-log'); | |
61 source.onerror = function(e) { | |
62 console.log("Error with SSE, closing.", e); | |
63 source.close(); | |
64 }; | |
65 source.addEventListener('message', onPublishEvent); | |
66 } | |
67 | |
68 |