From 7303c02cac5085411d67520340d512061ab5d902 Mon Sep 17 00:00:00 2001 From: hparfr Date: Mon, 11 Sep 2017 10:29:11 +0000 Subject: [PATCH] Lint --- .../static/src/js/switch_company_warning.js | 18 ++++++++++-------- .../src/js/switch_company_warning_worker.js | 8 +++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/web_switch_company_warning/static/src/js/switch_company_warning.js b/web_switch_company_warning/static/src/js/switch_company_warning.js index ababba27..b7af4c42 100644 --- a/web_switch_company_warning/static/src/js/switch_company_warning.js +++ b/web_switch_company_warning/static/src/js/switch_company_warning.js @@ -6,23 +6,25 @@ odoo.define('web_switch_company_warning.widget', function (require) { //Show a big banner in the top of the page if the company has been //changed in another tab or window (in the same browser) - if (!window.SharedWorker) - return; //not supported - + if (!window.SharedWorker) { + //not supported + return; + } var SwitchCompanyWarningWidget = Widget.extend({ template:'WarningWidget', init: function() { this._super(); var self = this; - var w = new SharedWorker('/web_switch_company_warning/static/src/js/switch_company_warning_worker.js'); + var w = new SharedWorker('/web_switch_company_warning/static/src/js/switch_company_warning_worker.js'); w.port.addEventListener('message', function (msg) { - if (msg.data.type !== 'newCtx') + if (msg.data.type !== 'newCtx') { return; - if(msg.data.newCtx != self.session.company_id) { - self.$el.show(); - } else { + } + if(msg.data.newCtx === self.session.company_id) { self.$el.hide(); + } else { + self.$el.show(); } }); w.port.start(); diff --git a/web_switch_company_warning/static/src/js/switch_company_warning_worker.js b/web_switch_company_warning/static/src/js/switch_company_warning_worker.js index d4b4fbe4..014fcfb3 100644 --- a/web_switch_company_warning/static/src/js/switch_company_warning_worker.js +++ b/web_switch_company_warning/static/src/js/switch_company_warning_worker.js @@ -3,8 +3,7 @@ //changed in another tab or window (in the same browser) var con = []; - -var lastCtx = null; +var lastCtx = null; addEventListener("connect", function(ee) { var port = ee.ports[0]; @@ -13,12 +12,11 @@ addEventListener("connect", function(ee) { port.onmessage = function (e) { //addEventListener doesnt seams to work well var newCtx = e.data; - if (lastCtx && newCtx != lastCtx) { + if (lastCtx && newCtx !== lastCtx) { con.map(function (eport) { - eport.postMessage({ type: "newCtx", "newCtx": newCtx, "lastCtx": lastCtx}); + eport.postMessage({type: "newCtx", "newCtx": newCtx, "lastCtx": lastCtx}); }); } lastCtx = newCtx; }; - }, false);