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

Commit 729466f

Browse files
authored
Merge branch 'master' into binary-com-lp-new
2 parents 776cf2a + 312eb14 commit 729466f

File tree

10 files changed

+140
-31
lines changed

10 files changed

+140
-31
lines changed

.circleci/config.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,26 @@ commands:
130130
failure_message: "Release failed for binary bot with version *$(cat www/version)*"
131131
success_message: "Release succeeded for binary bot with version *$(cat www/version)*"
132132
webhook: ${SLACK_WEBHOOK}
133+
134+
135+
publish_to_pages_staging:
136+
description: "Publish to cloudflare pages"
137+
steps:
138+
- run:
139+
name: "Publish to cloudflare pages (staging)"
140+
command: |
141+
npx wrangler pages publish www/ --project-name=binary-bot-pages --branch=staging
142+
echo "New staging website - http://staging.cf-pages-binary-bot.deriv.com"
143+
144+
publish_to_pages_production:
145+
description: "Publish to cloudflare pages"
146+
steps:
147+
- run:
148+
name: "Publish to cloudflare pages (production)"
149+
command: |
150+
npx wrangler pages publish www/ --project-name=binary-bot-pages --branch=main
151+
echo "New website - http://cf-pages-binary-bot.deriv.com"
152+
133153
jobs:
134154
test:
135155
docker:
@@ -147,6 +167,10 @@ jobs:
147167
- npm_install
148168
- test
149169
- build
170+
- persist_to_workspace:
171+
root: www
172+
paths:
173+
- .
150174
- docker_build_push
151175
- deploy:
152176
target_branch: "staging"
@@ -160,6 +184,10 @@ jobs:
160184
- npm_install
161185
- test
162186
- build
187+
- persist_to_workspace:
188+
root: www
189+
paths:
190+
- .
163191
- docker_build_push:
164192
docker_latest_image_tag: latest
165193
docker_image_tag: ${CIRCLE_TAG}
@@ -170,6 +198,22 @@ jobs:
170198
k8s_namespace: "bot-binary-com-production"
171199
k8s_version: ${CIRCLE_TAG}
172200
- notify_slack
201+
202+
publish_cloudflare_staging:
203+
docker:
204+
- image: circleci/node:16.13.1-stretch
205+
steps:
206+
- attach_workspace:
207+
at: www
208+
- publish_to_pages_staging
209+
210+
publish_cloudflare_production:
211+
docker:
212+
- image: circleci/node:16.13.1-stretch
213+
steps:
214+
- attach_workspace:
215+
at: www
216+
- publish_to_pages_production
173217

174218
workflows:
175219
test:
@@ -184,10 +228,26 @@ workflows:
184228
filters:
185229
branches:
186230
only: /^master$/
231+
- publish_cloudflare_staging:
232+
requires:
233+
- release_staging
234+
filters:
235+
branches:
236+
only: /^master$/
237+
context: binary-frontend-artifact-upload
187238
- release_production:
188239
filters:
189240
branches:
190241
ignore: /.*/
191242
tags:
192243
only: /^production.*/
193244
context: binary-frontend-artifact-upload
245+
- publish_cloudflare_production:
246+
requires:
247+
- release_production
248+
filters:
249+
branches:
250+
ignore: /.*/
251+
tags:
252+
only: /^production.*/
253+
context: binary-frontend-artifact-upload

src/botPage/view/View.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
getToken,
4242
remove,
4343
} from '../../common/utils/storageManager';
44-
import { isProduction } from '../../common/utils/tools';
44+
import { isProduction, parseQueryString, serialize } from '../../common/utils/tools';
4545
import GTM from '../../common/gtm';
4646
import {
4747
getMissingBlocksTypes,
@@ -851,16 +851,15 @@ function renderReactComponents() {
851851
}
852852
$('.barspinner').show();
853853
const bannerToken = getStorage('setDueDateForBanner');
854+
const qs = parseQueryString();
854855
if (new Date().getTime() > Number(bannerToken)) {
855856
remove('setDueDateForBanner');
856-
const getqueryParameter = document.location.search;
857-
const getDefaultPath = window.location.href.replace('/bot.html', getqueryParameter);
857+
const getDefaultPath = window.location.href.replace('/bot.html', serialize(qs));
858858
window.location.replace(getDefaultPath);
859859
return false;
860860
}
861861
if (bannerToken === null || bannerToken === undefined) {
862-
const getqueryParameter = document.location.search;
863-
const getDefaultPath = window.location.href.replace('/bot.html', getqueryParameter);
862+
const getDefaultPath = window.location.href.replace('/bot.html', serialize(qs));
864863
window.location.replace(getDefaultPath);
865864
document.getElementById('errorArea').remove();
866865
$('.barspinner').hide();
@@ -884,6 +883,7 @@ function renderReactComponents() {
884883
render(<TradeInfoPanel api={api} />, $('#summaryPanel')[0]);
885884
render(<LogTable />, $('#logTable')[0]);
886885
document.getElementById('bot-main').classList.remove('hidden');
886+
document.getElementById('toolbox').classList.remove('hidden');
887887
$('.barspinner').hide();
888888
}
889889
}

src/common/lang.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,18 @@ export const load = () => {
3434

3535
$('#select_language li:not(:first)').click(function click() {
3636
const newLang = $(this).attr('class');
37-
if (document.getElementById('bot-landing').classList.contains('hidden') === false) {
37+
if (
38+
document.getElementById('bot-landing') !== null &&
39+
document.getElementById('bot-landing') !== undefined &&
40+
document.getElementById('bot-landing').classList.contains('hidden') === false
41+
) {
3842
remove('setDueDateForBanner');
3943
render(<BotLanding />, document.getElementById('bot-landing'));
4044
elements.map(elem => document.querySelector(elem).classList.add('hidden'));
4145
document.getElementById('bot-landing').classList.remove('hidden');
4246
document.getElementById('bot-main').classList.remove('hidden');
43-
$('.barspinner').hide();
4447
document.location.search = `l=${newLang}`;
48+
$('.barspinner').hide();
4549
} else {
4650
document.location.search = `l=${newLang}`;
4751
}

src/common/utils/tools.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@ export const parseQueryString = () => {
1212
});
1313
return objURL;
1414
};
15+
export const generateURL = url => {
16+
if (url.split('?').length !== null && url.split('?').length !== undefined) {
17+
const baseUrl = url.split('?')[0];
18+
const queryParams = url.split('?')[1];
19+
return `${baseUrl}bot.html?${queryParams}`;
20+
}
21+
return `${url.replace(/\/+$/, '')}/bot.html`;
22+
23+
};
24+
25+
export const serialize = obj => {
26+
const str = [];
27+
Object.keys(obj).forEach(key => {
28+
// eslint-disable-next-line no-prototype-builtins
29+
if (obj.hasOwnProperty(obj[key])) {
30+
// eslint-disable-next-line prefer-template
31+
str.push(encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]));
32+
}
33+
});
34+
return str?.join('&');
35+
};
1536

1637
export const getObjectValue = obj => obj[Object.keys(obj)[0]];
1738

src/indexPage/index.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,25 @@ import GTM from '../common/gtm';
99
import { load as loadLang, showBanner } from '../common/lang';
1010
import { moveToDeriv } from '../common/utils/utility';
1111
import { get as getStorage, set as setStorage, remove, getTokenList } from '../common/utils/storageManager';
12-
import { createUrl } from '../common/utils/tools';
12+
import { createUrl, parseQueryString, serialize } from '../common/utils/tools';
1313
import '../common/binary-ui/dropdown';
1414
import BotLanding from './react-components/bot-landing';
1515
import BinaryLanding from './react-components/binary-landing';
1616

1717
const today = new Date().getTime();
1818
// eslint-disable-next-line one-var
1919
const oneMilliSec = 1000;
20-
// twentyOneDays = 21,
21-
// fiveMinutes = 300,
22-
// oneMinute = 60,
23-
// oneDay = 24;
20+
const sevenDays = 7;
21+
const oneMinute = 60;
22+
const oneDay = 24;
2423

25-
export const elements = ['#notification-banner', '#main', '#footer', '#header'];
24+
export const elements = ['#notification-banner', '#main', '#footer', '#header', '#topbar'];
2625
// eslint-disable-next-line one-var
2726
export const bannerToken = getStorage('setDueDateForBanner');
2827

2928
// eslint-disable-next-line arrow-body-style
3029
export const expirationDate = () => {
31-
// return today + oneMilliSec * oneMinute * oneMinute * oneDay * twentyOneDays;
32-
return today + oneMilliSec * 120;
30+
return today + oneMilliSec * oneMinute * oneMinute * oneDay * sevenDays;
3331
};
3432

3533
export const calcSetTimeoutValueBanner = expirationDate() - new Date().getTime();
@@ -46,14 +44,14 @@ const checkifBotRunning = () => {
4644

4745
export const setTimeOutBanner = route => {
4846
let bannerDisplayed;
47+
const qs = parseQueryString();
4948
// eslint-disable-next-line consistent-return
5049
timerForBanner = setTimeout(() => {
5150
if (
5251
(route === 'index' && !!bannerDisplayed === false) ||
5352
(route === 'views' && checkifBotRunning() === false)
5453
) {
55-
const getqueryParameter = document.location.search;
56-
const getDefaultPath = window.location.href.replace('/bot.html', getqueryParameter);
54+
const getDefaultPath = window.location.href.replace('/bot.html', serialize(qs));
5755
window.location.replace(getDefaultPath);
5856
renderBanner();
5957
} else if (
@@ -82,6 +80,7 @@ const renderBanner = () => {
8280
elements.map(elem => document.querySelector(elem).classList.add('hidden'));
8381
document.getElementById(dynamicVar).classList.remove('hidden');
8482
document.getElementById('bot-main').classList.remove('hidden');
83+
document.getElementById('topbar').classList.remove('hidden');
8584
$('.barspinner').hide();
8685
};
8786

@@ -121,14 +120,18 @@ const renderElements = () => {
121120
document.getElementById(dynamicVar).classList.add('hidden');
122121
}
123122
document.getElementById('bot-main').classList.remove('hidden');
124-
$('.barspinner').hide();
123+
setTimeout(() => {
124+
$('.barspinner').hide();
125+
}, 2000);
125126
}
126127
};
127128

128129
const loginCheck = () => {
129130
if (endpoint()) return;
130131
moveToDeriv();
131-
loadLang();
132+
if (window.location.href.indexOf('bot.html') === -1) {
133+
loadLang();
134+
}
132135
$('.show-on-load').show();
133136
if (bannerToken) {
134137
if (getTokenList().length) {
@@ -146,7 +149,7 @@ const loginCheck = () => {
146149
} else {
147150
setTimeout(() => {
148151
renderBanner();
149-
}, 2000);
152+
}, 0);
150153
}
151154
};
152155

src/indexPage/react-components/bot-landing/Carousel.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import Slider from 'react-slick';
3+
import { translate } from '../../../common/i18n';
34
import Translations from './Translations';
45
import { translate } from '../../../common/i18n';
56

@@ -45,7 +46,7 @@ const Carousel = () => {
4546
<h1>{translate(title)}</h1>
4647
<h2>{translate(content)}</h2>
4748
<a href="https://bot.deriv.com">
48-
<button className="l-btn danger">{action_text}</button>
49+
<button className="l-btn danger">{translate(action_text)}</button>
4950
</a>
5051
</div>
5152
<div className='landing_carousel_placeholder'>

src/indexPage/react-components/bot-landing/Hero.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react'
22
import { translate } from '../../../common/i18n';
3+
import { generateURL } from '../../../common/utils/tools'
34

45
const Hero = () => (
56
<section className="hero">
@@ -12,9 +13,9 @@ const Hero = () => (
1213
</h2>
1314
<div className="btn-group">
1415
<a href="https://bot.deriv.com">
15-
<button className="l-btn primary">{translate('Take me to Deriv')}</button>
16+
<button className="l-btn primary">{translate('Take me to Binary Bot on Deriv')}</button>
1617
</a>
17-
<a href={`${window.location.href.replace(/\/+$/, '')}/bot.html`}>
18+
<a href={generateURL(window.location.href)}>
1819
<button className="l-btn">{translate('Maybe later')}</button>
1920
</a>
2021
</div>

src/indexPage/react-components/bot-landing/SwitchSection.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22
import { translate } from '../../../common/i18n';
33
import { getOAuthURLDeriv } from '../../../common/appId';
4+
import { generateURL } from '../../../common/utils/tools'
5+
46

57
const SwitchSection = () => (
68
<section className="switch">
@@ -17,7 +19,7 @@ const SwitchSection = () => (
1719
<a href={getOAuthURLDeriv()}>
1820
<button className="l-btn danger">{translate('Try it now')}</button>
1921
</a>
20-
<a href={`${window.location.href.replace(/\/+$/, '')}/bot.html`}>
22+
<a href={generateURL(window.location.href)}>
2123
<button className="l-btn transparent">{translate('Maybe later')}</button>
2224
</a>
2325
</div>

static/css/_landing.scss

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ $header-color : #333333;
3030
.hero {
3131
background: $hero-BG url(../image/BG-1.webp) no-repeat;
3232
background-size: cover;
33-
33+
padding: 0 2rem;
34+
@include for-size(mobile) {
35+
padding: 0;
36+
}
3437
@include for-size(mobile) {
3538
background: $hero-BG url(../image/MBG1.png) no-repeat;
3639
background-size: cover;
@@ -126,7 +129,9 @@ $header-color : #333333;
126129
&.primary {
127130
background-color: #2E8836;
128131
color: $white;
129-
132+
@include for-size(mobile) {
133+
margin-bottom: 1rem;
134+
}
130135
&:hover {
131136
background-color: #246d2a;
132137
color: $white;
@@ -136,7 +141,9 @@ $header-color : #333333;
136141
&.danger {
137142
background: #FF444F;
138143
color: $white;
139-
144+
@include for-size(mobile) {
145+
margin-bottom: 1rem;
146+
}
140147
&:hover {
141148
background-color: #cd353e;
142149
color: $white;
@@ -300,6 +307,9 @@ $header-color : #333333;
300307

301308
&-inner {
302309
padding: 7.5rem 0;
310+
@include for-size(mobile) {
311+
padding: 2.5rem 0;
312+
}
303313
&-title {
304314
font: 700 2rem $font-IBM;
305315
color: #333;
@@ -523,7 +533,10 @@ $header-color : #333333;
523533
background-size: 65% 100%;
524534
min-height: 18.75rem;
525535
position: relative;
526-
536+
padding: 0 2rem;
537+
@include for-size(mobile) {
538+
padding: 0;
539+
}
527540
@include for-size(mobile) {
528541
min-height: 43.75rem;
529542
background-image: none;
@@ -583,7 +596,10 @@ $header-color : #333333;
583596
.about-trade-wrapper {
584597
background-color: #F8FAFB;
585598
padding: 0;
586-
599+
padding: 0 2rem;
600+
@include for-size(mobile) {
601+
padding: 0;
602+
}
587603
&-inner {
588604
padding: 3rem 0;
589605

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