aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/rocketchat/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/rocketchat/webview.js')
-rw-r--r--recipes/rocketchat/webview.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/recipes/rocketchat/webview.js b/recipes/rocketchat/webview.js
index 85b0c32..74556de 100644
--- a/recipes/rocketchat/webview.js
+++ b/recipes/rocketchat/webview.js
@@ -1,3 +1,8 @@
1function _interopRequireDefault(obj) {
2 return obj && obj.__esModule ? obj : { default: obj };
3}
4
5const _path = _interopRequireDefault(require('path'));
1 6
2module.exports = Ferdium => { 7module.exports = Ferdium => {
3 const getMessages = () => { 8 const getMessages = () => {
@@ -18,30 +23,34 @@ module.exports = Ferdium => {
18 23
19 Ferdium.loop(getMessages); 24 Ferdium.loop(getMessages);
20 25
26 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
27
21 const getTeamIcon = function getTeamIcon() { 28 const getTeamIcon = function getTeamIcon() {
22 const manifestElement = document.querySelector('link[rel="manifest"]'); 29 const manifestElement = document.querySelector('link[rel="manifest"]');
23 30
24 if (manifestElement == null) { 31 if (manifestElement === null) {
25 return; 32 return;
26 } 33 }
27 34
28 const manifestUrl = manifestElement.getAttribute('href'); 35 const manifestUrl = manifestElement.getAttribute('href');
29 36
30 if (manifestUrl == null) { 37 if (manifestUrl === null) {
31 return; 38 return;
32 } 39 }
33 40
34 const xmlhttp = new XMLHttpRequest(); 41 const xmlhttp = new XMLHttpRequest();
35 42
36 xmlhttp.addEventListener('readystatechange', function () { 43 xmlhttp.addEventListener('readystatechange', function () {
37 if (this.readyState != 4 || this.status != 200) { 44 if (this.readyState !== 4 || this.status !== 200) {
38 return; 45 return;
39 } 46 }
40 47
41 const response = JSON.parse(this.responseText); 48 const response = JSON.parse(this.responseText);
42 49
43 if (response.icons.length > 0) { 50 if (response.icons.length > 0) {
44 Ferdium.setAvatarImage(`${window.location.protocol}//${window.location.host}${response.icons[0].src}`); 51 Ferdium.setAvatarImage(
52 `${window.location.protocol}//${window.location.host}${response.icons[0].src}`,
53 );
45 } 54 }
46 }); 55 });
47 56