Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/aphlict/behavior-aphlict-listen.js
| /** | /** | ||||
| * @provides javelin-behavior-aphlict-listen | * @provides javelin-behavior-aphlict-listen | ||||
| * @requires javelin-behavior | * @requires javelin-behavior | ||||
| * javelin-aphlict | * javelin-aphlict | ||||
| * javelin-stratcom | * javelin-stratcom | ||||
| * javelin-request | * javelin-request | ||||
| * javelin-uri | * javelin-uri | ||||
| * javelin-dom | * javelin-dom | ||||
| * javelin-json | * javelin-json | ||||
| * javelin-router | * javelin-router | ||||
| * javelin-util | |||||
| * phabricator-notification | * phabricator-notification | ||||
| */ | */ | ||||
| JX.behavior('aphlict-listen', function(config) { | JX.behavior('aphlict-listen', function(config) { | ||||
| var showing_reload = false; | var showing_reload = false; | ||||
| function onready() { | function onready() { | ||||
| Show All 30 Lines | JX.Stratcom.listen('aphlict-receive-message', null, function(e) { | ||||
| JX.Router.getInstance().queue(routable); | JX.Router.getInstance().queue(routable); | ||||
| }); | }); | ||||
| // Respond to a notification from the Aphlict notification server. We send | // Respond to a notification from the Aphlict notification server. We send | ||||
| // a request to Phabricator to get notification details. | // a request to Phabricator to get notification details. | ||||
| function onaphlictmessage(type, message) { | function onaphlictmessage(type, message) { | ||||
| switch (type) { | switch (type) { | ||||
| case 'error': | |||||
| new JX.Notification() | |||||
| .setContent('(Aphlict) ' + message) | |||||
| .alterClassName('jx-notification-error', true) | |||||
| .setDuration(0) | |||||
| .show(); | |||||
| break; | |||||
| case 'receive': | case 'receive': | ||||
| JX.Stratcom.invoke('aphlict-receive-message', null, message); | JX.Stratcom.invoke('aphlict-receive-message', null, message); | ||||
| break; | break; | ||||
| default: | default: | ||||
| if (__DEV__ && config.debug) { | case 'error': | ||||
| if (config.debug) { | |||||
| var details = message ? JX.JSON.stringify(message) : ''; | var details = message ? JX.JSON.stringify(message) : ''; | ||||
| JX.log('(Aphlict) [' + type + '] ' + details); | |||||
| new JX.Notification() | |||||
| .setContent('(Aphlict) [' + type + '] ' + details) | |||||
| .alterClassName('jx-notification-debug', true) | |||||
| .setDuration(3000) | |||||
| .show(); | |||||
| } | } | ||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| // Respond to a response from Phabricator about a specific notification. | // Respond to a response from Phabricator about a specific notification. | ||||
| function onnotification(response) { | function onnotification(response) { | ||||
| if (!response.pertinent) { | if (!response.pertinent) { | ||||
| return; | return; | ||||
| Show All 40 Lines | |||||