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

Commit 7bbd826

Browse files
authored
Merge pull request #3659 from rupato-deriv/translations-for-landing-page
Rupato / hot fixes for landing page
2 parents 35d28b1 + e573731 commit 7bbd826

File tree

8 files changed

+67
-24
lines changed

8 files changed

+67
-24
lines changed

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,
@@ -843,16 +843,15 @@ function renderErrorPage() {
843843
function renderReactComponents() {
844844
$('.barspinner').show();
845845
const bannerToken = getStorage('setDueDateForBanner');
846+
const qs = parseQueryString();
846847
if (new Date().getTime() > Number(bannerToken)) {
847848
remove('setDueDateForBanner');
848-
const getqueryParameter = document.location.search;
849-
const getDefaultPath = window.location.href.replace('/bot.html', getqueryParameter);
849+
const getDefaultPath = window.location.href.replace('/bot.html', serialize(qs));
850850
window.location.replace(getDefaultPath);
851851
return false;
852852
}
853853
if (bannerToken === null || bannerToken === undefined) {
854-
const getqueryParameter = document.location.search;
855-
const getDefaultPath = window.location.href.replace('/bot.html', getqueryParameter);
854+
const getDefaultPath = window.location.href.replace('/bot.html', serialize(qs));
856855
window.location.replace(getDefaultPath);
857856
document.getElementById('errorArea').remove();
858857
$('.barspinner').hide();
@@ -876,6 +875,7 @@ function renderReactComponents() {
876875
render(<TradeInfoPanel api={api} />, $('#summaryPanel')[0]);
877876
render(<LogTable />, $('#logTable')[0]);
878877
document.getElementById('bot-main').classList.remove('hidden');
878+
document.getElementById('toolbox').classList.remove('hidden');
879879
$('.barspinner').hide();
880880
}
881881
}

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: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +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

1616
const today = new Date().getTime();
1717
// eslint-disable-next-line one-var
1818
const oneMilliSec = 1000;
19-
// twentyOneDays = 21,
19+
// sevenDays = 7,
2020
// fiveMinutes = 300,
2121
// oneMinute = 60,
2222
// oneDay = 24;
2323

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

2828
// eslint-disable-next-line arrow-body-style
2929
export const expirationDate = () => {
30-
// return today + oneMilliSec * oneMinute * oneMinute * oneDay * twentyOneDays;
30+
// return today + oneMilliSec * oneMinute * oneMinute * oneDay * sevenDays;
3131
return today + oneMilliSec * 600;
3232
};
3333

@@ -45,14 +45,14 @@ const checkifBotRunning = () => {
4545

4646
export const setTimeOutBanner = route => {
4747
let bannerDisplayed;
48+
const qs = parseQueryString();
4849
// eslint-disable-next-line consistent-return
4950
timerForBanner = setTimeout(() => {
5051
if (
5152
(route === 'index' && !!bannerDisplayed === false) ||
5253
(route === 'views' && checkifBotRunning() === false)
5354
) {
54-
const getqueryParameter = document.location.search;
55-
const getDefaultPath = window.location.href.replace('/bot.html', getqueryParameter);
55+
const getDefaultPath = window.location.href.replace('/bot.html', serialize(qs));
5656
window.location.replace(getDefaultPath);
5757
renderBanner();
5858
} else if (
@@ -72,6 +72,7 @@ const renderBanner = () => {
7272
elements.map(elem => document.querySelector(elem).classList.add('hidden'));
7373
document.getElementById('bot-landing').classList.remove('hidden');
7474
document.getElementById('bot-main').classList.remove('hidden');
75+
document.getElementById('topbar').classList.remove('hidden');
7576
$('.barspinner').hide();
7677
};
7778

@@ -103,14 +104,18 @@ const renderElements = () => {
103104
document.getElementById('bot-landing').classList.add('hidden');
104105
}
105106
document.getElementById('bot-main').classList.remove('hidden');
106-
$('.barspinner').hide();
107+
setTimeout(() => {
108+
$('.barspinner').hide();
109+
}, 2000);
107110
}
108111
};
109112

110113
const loginCheck = () => {
111114
if (endpoint()) return;
112115
moveToDeriv();
113-
loadLang();
116+
if (window.location.href.indexOf('bot.html') === -1) {
117+
loadLang();
118+
}
114119
$('.show-on-load').show();
115120
if (bannerToken) {
116121
if (getTokenList().length) {
@@ -128,7 +133,7 @@ const loginCheck = () => {
128133
} else {
129134
setTimeout(() => {
130135
renderBanner();
131-
}, 2000);
136+
}, 0);
132137
}
133138
};
134139

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: 12 additions & 3 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;
@@ -530,7 +533,10 @@ $header-color : #333333;
530533
background-size: 65% 100%;
531534
min-height: 18.75rem;
532535
position: relative;
533-
536+
padding: 0 2rem;
537+
@include for-size(mobile) {
538+
padding: 0;
539+
}
534540
@include for-size(mobile) {
535541
min-height: 43.75rem;
536542
background-image: none;
@@ -590,7 +596,10 @@ $header-color : #333333;
590596
.about-trade-wrapper {
591597
background-color: #F8FAFB;
592598
padding: 0;
593-
599+
padding: 0 2rem;
600+
@include for-size(mobile) {
601+
padding: 0;
602+
}
594603
&-inner {
595604
padding: 3rem 0;
596605

templates/bot.mustache

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@
116116
</div>
117117

118118
</div>
119-
<div id="errorArea"></div>
119+
120120

121121

122-
<div id="toolbox" class="actions_menu show-on-load">
122+
<div id="toolbox" class="actions_menu show-on-load hidden">
123123
<button data-i18n-title="Reset the blocks to their initial state" id="resetButton"
124124
class="toolbox-button icon-reset"></button>
125125
<button data-i18n-title="Load new blocks (xml file)" id="load-xml" class="toolbox-button icon-browse"></button>
@@ -168,6 +168,7 @@
168168
</div>
169169

170170
</div>
171+
<div id="errorArea"></div>
171172
<div id="notification-banner"></div>
172173

173174
<ul id="toolbox-all-accounts" class="nav-menu main-nav" style="display: none;">

0 commit comments

Comments
 (0)