From a5e7ac27066c020891acb065fd603faeb4c5a158 Mon Sep 17 00:00:00 2001 From: Amam Mustofa Date: Fri, 29 Mar 2019 17:06:36 +0800 Subject: [PATCH 1/8] add semicolon spaces and trailing comma --- src/navigation/navigation.es6 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/navigation/navigation.es6 b/src/navigation/navigation.es6 index 4755f01a41..abcec2718b 100644 --- a/src/navigation/navigation.es6 +++ b/src/navigation/navigation.es6 @@ -13,7 +13,7 @@ const menu_selectors = [ '.instruments', '.resources', '.workspace', -] +]; const getType = (acc) => { let id = acc.loginid || acc.id; @@ -22,13 +22,12 @@ const getType = (acc) => { MLT:"Gaming", MF:"Investment", VRTC:"Virtual", - REAL:(acc.currency || '').toUpperCase() || 'Real' + REAL:(acc.currency || '').toUpperCase() || 'Real', }; id = id.match(/^(MLT|MF|VRTC)/i) ? id.match(/^(MLT|MF|VRTC)/i)[0] : "REAL"; return type[id]+" Account"; }; - const initLoginButton = (root) => { const account_menu = root.find('.account-menu'); const time = root.find('span.time'); @@ -55,6 +54,7 @@ const initLoginButton = (root) => { window.open(financial_account_binary_url, '_blank') } }; + const destroy_windows = (data_attribute) => { $(`.webtrader-dialog[${data_attribute}]`).each((inx, elm) => { const dlg = $(elm); From 4921ba31d7935c29e77957d98e193ffb73120448 Mon Sep 17 00:00:00 2001 From: Amam Mustofa Date: Fri, 29 Mar 2019 17:07:39 +0800 Subject: [PATCH 2/8] spaces import --- src/navigation/navigation.es6 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/navigation/navigation.es6 b/src/navigation/navigation.es6 index abcec2718b..8591d80d14 100644 --- a/src/navigation/navigation.es6 +++ b/src/navigation/navigation.es6 @@ -1,9 +1,9 @@ -import $ from 'jquery'; -import moment from 'moment'; -import _ from 'lodash'; -import liveapi from '../websockets/binary_websockets'; -import rv from '../common/rivetsExtra'; -import $navHtml from 'text!./navigation.html'; +import $ from 'jquery'; +import moment from 'moment'; +import _ from 'lodash'; +import liveapi from '../websockets/binary_websockets'; +import rv from '../common/rivetsExtra'; +import $navHtml from 'text!./navigation.html'; import workspace from '../workspace/workspace.js'; import '../common/util'; import 'css!navigation/navigation.css'; @@ -41,7 +41,7 @@ const initLoginButton = (root) => { type:'', id:'', balance: '', - is_virtual:0 + is_virtual:0, }, show_submenu: false, show_new_account_link: false, From a8d5351f6abb060c16405021525d7b6ff5cc0833 Mon Sep 17 00:00:00 2001 From: Amam Mustofa Date: Fri, 29 Mar 2019 17:09:42 +0800 Subject: [PATCH 3/8] add spaces --- src/navigation/navigation.es6 | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/navigation/navigation.es6 b/src/navigation/navigation.es6 index 8591d80d14..11dd759ac9 100644 --- a/src/navigation/navigation.es6 +++ b/src/navigation/navigation.es6 @@ -24,7 +24,9 @@ const getType = (acc) => { VRTC:"Virtual", REAL:(acc.currency || '').toUpperCase() || 'Real', }; + id = id.match(/^(MLT|MF|VRTC)/i) ? id.match(/^(MLT|MF|VRTC)/i)[0] : "REAL"; + return type[id]+" Account"; }; @@ -55,15 +57,15 @@ const initLoginButton = (root) => { } }; -const destroy_windows = (data_attribute) => { - $(`.webtrader-dialog[${data_attribute}]`).each((inx, elm) => { - const dlg = $(elm); - dlg.dialog('close'); - dlg.one('dialogclose', () => { - _.defer(() => dlg.dialog('instance') && dlg.dialog('destroy') && dlg.remove()); - }); -}); -} + const destroy_windows = (data_attribute) => { + $(`.webtrader-dialog[${data_attribute}]`).each((inx, elm) => { + const dlg = $(elm); + dlg.dialog('close'); + dlg.one('dialogclose', () => { + _.defer(() => dlg.dialog('instance') && dlg.dialog('destroy') && dlg.remove()); + }); + }); + } state.oauth = local_storage.get('oauth') || []; state.oauth = state.oauth.map((e) => { @@ -93,7 +95,7 @@ const destroy_windows = (data_attribute) => { .catch((err) => { $.growl.error({message: err.message}); // logout user if he decided to self exclude himself. - if(err.code==="SelfExclusion"){ + if(err.code==="SelfExclusion") { console.log("logging out because of self exclude"); liveapi.invalidate(); } From 93c77ff036a97206a4eec5e4c1621ec3c17c66d7 Mon Sep 17 00:00:00 2001 From: Amam Mustofa Date: Fri, 29 Mar 2019 17:26:23 +0800 Subject: [PATCH 4/8] change double to single quote --- src/navigation/navigation.es6 | 39 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/navigation/navigation.es6 b/src/navigation/navigation.es6 index 11dd759ac9..1ed1ec2529 100644 --- a/src/navigation/navigation.es6 +++ b/src/navigation/navigation.es6 @@ -12,22 +12,22 @@ const menu_selectors = [ '.trade', '.instruments', '.resources', - '.workspace', + '.workspace' ]; const getType = (acc) => { let id = acc.loginid || acc.id; if(!acc || !id) return; const type = { - MLT:"Gaming", - MF:"Investment", - VRTC:"Virtual", + MLT:'Gaming', + MF:'Investment', + VRTC:'Virtual', REAL:(acc.currency || '').toUpperCase() || 'Real', }; - id = id.match(/^(MLT|MF|VRTC)/i) ? id.match(/^(MLT|MF|VRTC)/i)[0] : "REAL"; + id = id.match(/^(MLT|MF|VRTC)/i) ? id.match(/^(MLT|MF|VRTC)/i)[0] : 'REAL'; - return type[id]+" Account"; + return type[id]+' Account'; }; const initLoginButton = (root) => { @@ -95,8 +95,7 @@ const initLoginButton = (root) => { .catch((err) => { $.growl.error({message: err.message}); // logout user if he decided to self exclude himself. - if(err.code==="SelfExclusion") { - console.log("logging out because of self exclude"); + if (err.code === 'SelfExclusion') { liveapi.invalidate(); } }); @@ -107,8 +106,8 @@ const initLoginButton = (root) => { const update_balance = (data) => { if (!state.currency) { /* We're not going to set currency automatically, since the user might select a different currency */ - if (local_storage.get("currency")){ - state.currency = local_storage.get("currency"); + if (local_storage.get('currency')){ + state.currency = local_storage.get('currency'); } else return; } @@ -135,7 +134,7 @@ const initLoginButton = (root) => { state.account.type = ''; state.currency = ''; - local_storage.remove("currency"); + local_storage.remove('currency'); }); liveapi.events.on('login', (data) => { @@ -153,7 +152,7 @@ const initLoginButton = (root) => { state.account.type = getType(data.authorize); state.currency = data.authorize.currency; - local_storage.set("currency", state.currency); + local_storage.set('currency', state.currency); update_balance(data); const is_current_account_real = data.authorize.is_virtual === 0; @@ -172,7 +171,7 @@ const initLoginButton = (root) => { $.growl.error({ fixed: true, message:` - ${"Your account (%) is locked, please contact customer support for more info.".i18n().replace('%', lockedIds)} + ${'Your account (%) is locked, please contact customer support for more info.'.i18n().replace('%', lockedIds)} ` }); } @@ -180,8 +179,8 @@ const initLoginButton = (root) => { }); // Restore login-button in case of login-error - $('.login').on("login-error", (e) => { - console.log("Encountered login error"); + $('.login').on('login-error', (e) => { + console.log('Encountered login error'); state.show_login = true; }); @@ -300,7 +299,7 @@ export const getLandingCompany = () => { const financial = data.landing_company.financial_company; const gaming = data.landing_company.gaming_company; const loginIds = loginids(); - const curr_login = local_storage.get("oauth")[0]; + const curr_login = local_storage.get('oauth')[0]; curr_login.is_mlt = /MLT/.test(curr_login.id); if (gaming && financial && financial.shortcode === 'maltainvest') { // 1: if (_.some(loginIds, {is_mlt: true}) && (_.some(loginIds, {is_mf: true}) || !curr_login.is_mlt)) // 1-c @@ -321,7 +320,7 @@ export const getLandingCompany = () => { // 5: const cr_accts = _.filter(loginIds, {is_cr: true}); if( cr_accts.length && landing_company_details.legal_allowed_currencies) { - const currencies_config = local_storage.get("currencies_config") || {}; + const currencies_config = local_storage.get('currencies_config') || {}; const has_fiat = _.some(cr_accts, {type: 'fiat'}); const crypto_currencies = _.difference( landing_company_details.legal_allowed_currencies.filter((curr) => { @@ -345,7 +344,7 @@ export const getLandingCompany = () => { export const init = (callback) => { const root = $($navHtml).i18n(); - $("body").prepend(root); + $('body').prepend(root); initLoginButton(root); initLang(root); @@ -357,12 +356,12 @@ export const init = (callback) => { workspace.init($('#nav-menu .workspace')); if (callback) { - callback($("#nav-menu")); + callback($('#nav-menu')); } //Show config
  • if its production and not BETA if (is_beta()) { - root.find("a.config").closest('li').show(); + root.find('a.config').closest('li').show(); } // Handle click navigation to show menu dialog From fdb4a92e546101cd2455dba3a7d50a7beb69a5cf Mon Sep 17 00:00:00 2001 From: Amam Mustofa Date: Fri, 29 Mar 2019 17:27:54 +0800 Subject: [PATCH 5/8] add trailing and colon --- src/navigation/navigation.es6 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/navigation/navigation.es6 b/src/navigation/navigation.es6 index 1ed1ec2529..2476b0b1b9 100644 --- a/src/navigation/navigation.es6 +++ b/src/navigation/navigation.es6 @@ -371,12 +371,12 @@ export const init = (callback) => { const current_selector = `${nav_selector} ${selector}`; const visible = { 'visibility': 'visible', - 'opacity': 1 + 'opacity': 1, }; $(current_selector).click((e) => { $(dialog_selector).toggle('fast', () => { - $(dialog_selector).css(visible) + $(dialog_selector).css(visible); } ); }); From 7b087604efa43e7126483ad727de41432242b2a9 Mon Sep 17 00:00:00 2001 From: Amam Mustofa Date: Mon, 1 Apr 2019 11:32:47 +0800 Subject: [PATCH 6/8] add space --- src/navigation/navigation.es6 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/navigation/navigation.es6 b/src/navigation/navigation.es6 index 2476b0b1b9..9844c7ba6e 100644 --- a/src/navigation/navigation.es6 +++ b/src/navigation/navigation.es6 @@ -27,7 +27,7 @@ const getType = (acc) => { id = id.match(/^(MLT|MF|VRTC)/i) ? id.match(/^(MLT|MF|VRTC)/i)[0] : 'REAL'; - return type[id]+' Account'; + return type[id] + ' Account'; }; const initLoginButton = (root) => { From a027ce8e65af19c64def240c3e0e4e8f3f048db1 Mon Sep 17 00:00:00 2001 From: Amam Mustofa Date: Mon, 1 Apr 2019 11:38:45 +0800 Subject: [PATCH 7/8] follow code rules --- src/navigation/navigation.es6 | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/navigation/navigation.es6 b/src/navigation/navigation.es6 index 9844c7ba6e..0c2cbf3c08 100644 --- a/src/navigation/navigation.es6 +++ b/src/navigation/navigation.es6 @@ -39,11 +39,11 @@ const initLoginButton = (root) => { currency: '', logout_disabled: false, account: { - show:false, - type:'', - id:'', + show: false, + type: '', + id: '', balance: '', - is_virtual:0, + is_virtual: 0, }, show_submenu: false, show_new_account_link: false, @@ -53,7 +53,7 @@ const initLoginButton = (root) => { }, openFinancialAccountMF: () => { const financial_account_binary_url = getBinaryUrl('new_account/maltainvestws'); - window.open(financial_account_binary_url, '_blank') + window.open(financial_account_binary_url, '_blank'); } }; @@ -93,7 +93,7 @@ const initLoginButton = (root) => { destroy_windows('data-account-specific=true'); liveapi.switch_account(id) .catch((err) => { - $.growl.error({message: err.message}); + $.growl.error({ message: err.message }); // logout user if he decided to self exclude himself. if (err.code === 'SelfExclusion') { liveapi.invalidate(); @@ -160,14 +160,14 @@ const initLoginButton = (root) => { state.show_financial_link = (what_todo === 'upgrade-mf'); state.show_realaccount_link = (what_todo === 'upgrade-mlt'); const loginIds = loginids(); - state.has_real_account = _.some(loginIds, {is_real: true}); - state.has_mf_or_mlt = _.some(loginIds, {is_mf: true}) || _.some(loginIds, {is_mlt: true}); + state.has_real_account = _.some(loginIds, { is_real: true }); + state.has_mf_or_mlt = _.some(loginIds, { is_mf: true }) || _.some(loginIds, { is_mlt: true }); state.show_new_account_link = what_todo === 'new-account'; - state.has_disabled_account = _.some(loginIds, {is_disabled: true}); + state.has_disabled_account = _.some(loginIds, { is_disabled: true }); // https://trello.com/c/9PCHncnx/5146-8-raunak-accountlistordering // https://trello.com/c/fNZ1Zkbb/2529-negar-accountlistauthorize - if(_.some(oAuthLoginIds(), {is_disabled: true})) { - const lockedIds = _.filter(loginIds, {is_disabled:true}).map(acc => acc.id).join(','); + if(_.some(oAuthLoginIds(), { is_disabled: true })) { + const lockedIds = _.filter(loginIds, { s_disabled:true }).map(acc => acc.id).join(','); $.growl.error({ fixed: true, message:` @@ -219,11 +219,11 @@ const initLang = (root) => { state.onclick = (value) => { state.confirm.visible = false; - const lang = _.find(state.languages, {value: value}); + const lang = _.find(state.languages, { value: value }); if(lang && state.lang && lang.value == state.lang.value) return; - local_storage.set('i18n', {value: lang.value}); + local_storage.set('i18n', { value: lang.value }); window.location.reload(); }; @@ -231,8 +231,8 @@ const initLang = (root) => { state.confirm.visible = visible; } - const lang = (local_storage.get('i18n') || {value: 'en'}).value; - state.lang = _.find(state.languages, {value: lang}); // set the initial state. + const lang = (local_storage.get('i18n') || { value: 'en' }).value; + state.lang = _.find(state.languages, { value: lang }); // set the initial state. const contact_us_el = document.getElementById('contact-us'); const logo_container = document.getElementById('logo-container'); @@ -248,15 +248,14 @@ const initLang = (root) => { .send({website_status: 1}) .then((data) => { let supported_languages = (data.website_status || {}).supported_languages || []; - supported_languages = _.map(supported_languages, (m) => ({value: m.toLowerCase()})); + supported_languages = _.map(supported_languages, (m) => ({ value: m.toLowerCase() })); const newList = _.intersectionBy(state.languages, supported_languages, 'value') || []; state.languages.length = 0; newList.forEach( (e) => state.languages.push(e) ); }) - .catch(console.error) - + .catch(console.error); } /* From 95708dbc6f91a36a5209adfbbbb916d5b0852ad3 Mon Sep 17 00:00:00 2001 From: Amam Mustofa Date: Mon, 1 Apr 2019 11:43:48 +0800 Subject: [PATCH 8/8] add space --- src/navigation/navigation.es6 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/navigation/navigation.es6 b/src/navigation/navigation.es6 index 0c2cbf3c08..11a7e1a4e3 100644 --- a/src/navigation/navigation.es6 +++ b/src/navigation/navigation.es6 @@ -287,8 +287,8 @@ const initLang = (root) => { export const getLandingCompany = () => { return liveapi.cached.authorize().then((data) => { return Promise.all([ - liveapi.cached.send({landing_company: data.authorize.country }), - liveapi.cached.send({landing_company_details: data.authorize.landing_company_name}) + liveapi.cached.send({ landing_company: data.authorize.country }), + liveapi.cached.send({ landing_company_details: data.authorize.landing_company_name }) ]) .then((results) => { const data = results[0]; @@ -301,26 +301,26 @@ export const getLandingCompany = () => { const curr_login = local_storage.get('oauth')[0]; curr_login.is_mlt = /MLT/.test(curr_login.id); if (gaming && financial && financial.shortcode === 'maltainvest') { // 1: - if (_.some(loginIds, {is_mlt: true}) && (_.some(loginIds, {is_mf: true}) || !curr_login.is_mlt)) // 1-c + if (_.some(loginIds, { is_mlt: true }) && (_.some(loginIds, { is_mf: true }) || !curr_login.is_mlt)) // 1-c return 'do-nothing'; - if (_.some(loginIds, {is_mlt: true})) // 1-b + if (_.some(loginIds, { is_mlt: true })) // 1-b return 'upgrade-mf'; return 'upgrade-mlt'; // 1-a } if (financial && financial.shortcode === 'maltainvest' && !gaming) { // 2: - if (_.some(loginIds, {is_mf: true})) // 2-b + if (_.some(loginIds, { is_mf: true })) // 2-b return 'do-nothing'; return 'upgrade-mf'; // 2-a } // 3: - if (_.some(loginIds, {is_mlt: true}) || _.some(loginIds, {is_mx: true})) + if (_.some(loginIds, { is_mlt: true }) || _.some(loginIds, { is_mx: true })) return 'do-nothing'; // 3-b // 4: never happens, japan accounts are not able to log into webtrader. // 5: - const cr_accts = _.filter(loginIds, {is_cr: true}); + const cr_accts = _.filter(loginIds, { is_cr: true }); if( cr_accts.length && landing_company_details.legal_allowed_currencies) { const currencies_config = local_storage.get('currencies_config') || {}; - const has_fiat = _.some(cr_accts, {type: 'fiat'}); + const has_fiat = _.some(cr_accts, { type: 'fiat' }); const crypto_currencies = _.difference( landing_company_details.legal_allowed_currencies.filter((curr) => { return currencies_config[curr].type === 'crypto';