Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit e112fb8

Browse files
author
Aaron
authored
Merge pull request #2257 from aaron-binary/dbot-banner
aaron/Add DBot banner to Binary Bot
2 parents ce4ebfe + 58010b9 commit e112fb8

File tree

11 files changed

+154
-31
lines changed

11 files changed

+154
-31
lines changed

src/botPage/common/const.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ const config = {
235235
quick_strategies: ['martingale', 'dalembert'],
236236
};
237237

238-
export async function updateConfigCurrencies() {
239-
const api = generateLiveApiInstance();
238+
export async function updateConfigCurrencies(api = generateLiveApiInstance()) {
240239
try {
241240
const response = await api.getPayoutCurrencies();
242241
config.lists.CURRENCY = response.payout_currencies.map(c => [c, c]);

src/botPage/view/View.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
addTokenIfValid,
2929
} from '../../common/appId';
3030
import { translate } from '../../common/i18n';
31+
import { isEuCountry, showHideEuElements, hasEuAccount } from '../../common/footer-checks';
3132
import googleDrive from '../../common/integrations/GoogleDrive';
3233
import { getLanguage } from '../../common/lang';
3334
import { observer as globalObserver } from '../../common/utils/observer';
@@ -185,6 +186,9 @@ const updateTokenList = () => {
185186
loginButton.show();
186187
accountList.hide();
187188

189+
// If logged out, determine EU based on IP.
190+
isEuCountry(api).then(isEu => showHideEuElements(isEu));
191+
188192
$('.account-id')
189193
.removeAttr('value')
190194
.text('');
@@ -195,13 +199,17 @@ const updateTokenList = () => {
195199
} else {
196200
loginButton.hide();
197201
accountList.show();
202+
198203
const activeToken = getActiveToken(tokenList, getStorage(AppConstants.STORAGE_ACTIVE_TOKEN));
204+
showHideEuElements(hasEuAccount(tokenList));
199205
updateLogo(activeToken.token);
200206
addBalanceForToken(activeToken.token);
207+
201208
if (!('loginInfo' in activeToken)) {
202209
removeAllTokens();
203210
updateTokenList();
204211
}
212+
205213
tokenList.forEach(tokenInfo => {
206214
const prefix = isVirtual(tokenInfo) ? 'Virtual Account' : `${tokenInfo.loginInfo.currency} Account`;
207215
if (tokenInfo === activeToken) {
@@ -232,7 +240,7 @@ export default class View {
232240
constructor() {
233241
logHandler();
234242
this.initPromise = new Promise(resolve => {
235-
updateConfigCurrencies().then(() => {
243+
updateConfigCurrencies(api).then(() => {
236244
symbolPromise.then(() => {
237245
updateTokenList();
238246
this.blockly = new _Blockly();

src/common/footer-checks.js

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,45 @@
11
/* eslint-disable import/prefer-default-export */
22
import { generateLiveApiInstance } from './appId';
33

4-
export default async function isEuCountry() {
5-
const api = generateLiveApiInstance();
6-
const { website_status: { clients_country: clientsCountry } } = await api.send({ website_status: 1 });
7-
const { landing_company: { financial_company: financialCompany, gaming_company: gamingCompany } } = await api.send({
8-
landing_company: clientsCountry,
4+
export const showHideEuElements = isEu => {
5+
document.querySelectorAll('.eu-hide').forEach(el => {
6+
if (!isEu && el.classList.contains('invisible')) {
7+
// Keep original display type if invisible was specified.
8+
el.classList.remove('invisible');
9+
} else {
10+
// Default to setting display to block.
11+
el.setAttribute('display', `${!isEu ? 'block' : 'none'} !important`);
12+
}
913
});
14+
document.querySelectorAll('.eu-show', '.eu-only').forEach(el => {
15+
if (isEu && el.classList.contains('invisible')) {
16+
el.classList.remove('invisible');
17+
} else {
18+
el.setAttribute('display', `${isEu ? 'block' : 'none'} !important`);
19+
}
20+
});
21+
};
22+
23+
/* eslint-disable camelcase */
24+
export const isEuLandingCompany = landing_company => /^(maltainvest|malta|iom)$/.test(landing_company);
25+
26+
export const hasEuAccount = token_list =>
27+
token_list.some(token_obj => isEuLandingCompany(token_obj.loginInfo.landing_company_name));
28+
29+
export const isEuCountry = async (api = generateLiveApiInstance()) => {
30+
const { website_status } = await api.send({ website_status: 1 });
31+
const { clients_country } = website_status;
32+
const { landing_company } = await api.send({ landing_company: clients_country });
33+
const { financial_company, gaming_company } = landing_company;
1034

11-
const euShortcodeRegex = new RegExp('^(maltainvest|malta|iom)$');
12-
const euExcludedRegex = new RegExp('^mt$');
13-
const financialShortcode = financialCompany ? financialCompany.shortcode : false;
14-
const gamingShortcode = gamingCompany ? gamingCompany.shortcode : false;
35+
const eu_excluded_regexp = /^mt$/;
36+
const financial_shortcode = financial_company ? financial_company.shortcode : false;
37+
const gaming_shortcode = gaming_company ? gaming_company.shortcode : false;
1538

16-
api.disconnect();
39+
if (financial_shortcode || gaming_shortcode) {
40+
return isEuLandingCompany(financial_shortcode) || isEuLandingCompany(gaming_shortcode);
41+
}
1742

18-
return financialShortcode || gamingShortcode
19-
? euShortcodeRegex.test(financialShortcode) || euShortcodeRegex.test(gamingShortcode)
20-
: euExcludedRegex.test(clientsCountry);
21-
}
43+
return eu_excluded_regexp.test(clients_country);
44+
};
45+
/* eslint-enable */

src/indexPage/index.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,17 @@ import endpoint from './endpoint';
44
import Logo from './react-components/logo.jsx';
55
import Footer from './react-components/footer.jsx';
66
import { oauthLogin } from '../common/appId';
7-
import '../common/binary-ui/dropdown';
8-
import isEuCountry from '../common/footer-checks';
7+
import { isEuCountry, showHideEuElements } from '../common/footer-checks';
98
import GTM from '../common/gtm';
109
import { load as loadLang } from '../common/lang';
1110
import { getTokenList } from '../common/utils/storageManager';
1211
import { createUrl } from '../common/utils/tools';
12+
import '../common/binary-ui/dropdown';
1313

1414
const renderElements = () => {
15-
const showHideEuElements = isEu => {
16-
$('.eu-hide').attr('style', `display: ${isEu ? 'none' : 'block'} !important`);
17-
$('.eu-show, .eu-only').attr('style', `display: ${isEu ? 'block' : 'none'} !important`);
18-
};
1915
ReactDOM.render(<Logo />, document.getElementById('binary-logo'));
2016
ReactDOM.render(<Footer />, document.getElementById('footer'));
21-
isEuCountry().then(isEu => {
22-
showHideEuElements(isEu);
23-
});
17+
isEuCountry().then(isEu => showHideEuElements(isEu));
2418
$('#shop-url').attr('href', createUrl({ subdomain: 'shop', path: 'collections/strategies', isNonBotPage: true }));
2519
};
2620

static/css/_dbot-banner.scss

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
.dbot-banner {
2+
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@700&display=swap');
3+
font-family: 'IBM Plex Sans', sans-serif;
4+
-webkit-font-smoothing: antialiased;
5+
-moz-osx-font-smoothing: antialiased;
6+
align-items: center;
7+
align-self: center;
8+
display: flex;
9+
float: left;
10+
height: calc(100% - 20px);
11+
margin: 10px 0;
12+
13+
&__icon {
14+
margin-right: 8px;
15+
margin-left: 32px;
16+
}
17+
&__ad {
18+
color: #fff;
19+
margin-right: 16px;
20+
display: flex;
21+
justify-content: center;
22+
23+
&-text {
24+
font-size: 16px;
25+
font-weight: bold;
26+
line-height: 1.5;
27+
}
28+
}
29+
&__button {
30+
font-size: 14px;
31+
background-color: #ff444f;
32+
font-weight: bold;
33+
vertical-align: middle;
34+
align-items: center;
35+
justify-content: center;
36+
touch-action: manipulation;
37+
cursor: pointer;
38+
white-space: nowrap;
39+
padding: 0 16px;
40+
display: inline-flex;
41+
border: 0;
42+
height: 32px;
43+
border-radius: 4px;
44+
transition: all .2s cubic-bezier(.65,.05,.36,1);
45+
outline: 0;
46+
position: relative;
47+
text-decoration: none;
48+
text-transform: none!important;
49+
50+
&:hover {
51+
background: #eb3e48;
52+
}
53+
54+
&:focus {
55+
outline: none;
56+
}
57+
}
58+
&__separator {
59+
width: 2px;
60+
height: 36px;
61+
background-color: #17212c;
62+
}
63+
}
64+
65+
@media only screen and (max-width: 520px) {
66+
.dbot-banner {
67+
display: none;
68+
}
69+
}
70+
71+
@media only screen and (max-width: 700px) {
72+
.dbot-banner {
73+
&__separator {
74+
display: none;
75+
}
76+
}
77+
}

static/css/bot.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import 'color';
22
@import 'chart';
3+
@import 'dbot-banner';
34
@import 'fontello';
45
@import 'panel';
56
@import 'blockly-toolbox';
@@ -215,4 +216,4 @@ label {
215216

216217
.notifyjs-corner {
217218
z-index: 10001 !important;
218-
}
219+
}

static/css/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import 'color';
22
@import 'constants';
3+
@import 'dbot-banner';
34
@import 'footer';
45

56
html,

static/image/d-bot.svg

Lines changed: 1 addition & 0 deletions
Loading

templates/bot.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
</a>
7070
</div>
7171
</div>
72+
{{> ../templates/partials/dbot-banner }}
7273
<div class="right-header show-on-load">
7374
<div class="intro-login-logout">
7475
<div id="account-list">

templates/index.mustache

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
</div>
2020
<div id="header">
2121
<div class="wrapper">
22-
<div class="logo-wrapper">
23-
<div id="binary-logo"></div>
24-
</div>
25-
</div>
22+
<div class="logo-wrapper">
23+
<div id="binary-logo"></div>
24+
{{> ../templates/partials/dbot-banner }}
25+
</div>
26+
</div>
2627
</div>
2728
<div id="main">
2829
<div>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy