Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gulp/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ gulp.task(
gulp.task(
'pull-blockly-translations',
gulp.series(done => {
const blocklyLanguages = ['en', 'id', 'it', 'vi', 'pl', 'ru', 'pt', 'es', 'fr', 'zh-hans', 'zh-hant'];
const blocklyLanguages = ['en', 'it', 'vi', 'pl', 'ru', 'pt', 'es', 'fr', 'zh-hans', 'zh-hant'];
remoteSrc(
blocklyLanguages.map(lang => `${lang}.js?_=${Date.now()}`),
{
Expand Down
2 changes: 0 additions & 2 deletions src/common/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import es from './translations/es_ES/i10n.json';
import fr from './translations/fr_FR/i10n.json';
import en from './translations/en/i10n.json';
import ach from './translations/ach_UG/i10n.json';
import id from './translations/id_ID/i10n.json';

export const supportedLanguages = {
zh_tw: zhTw,
Expand All @@ -25,7 +24,6 @@ export const supportedLanguages = {
fr,
en,
ach,
id,
};

const fallbackLang = en;
Expand Down
13 changes: 9 additions & 4 deletions src/common/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import BotLanding from '../indexPage/react-components/bot-landing';

const elements = ['#notification-banner', '#main', '#footer', '#header'];
export const getLanguage = () => {
const queryLang = parseQueryString().l;
const lang = queryLang in supportedLanguages ? queryLang : getStorage('lang') || 'en';
const queryLang = parseQueryString().l || 'en';
const checkIsSupported = queryLang in supportedLanguages;
// eslint-disable-next-line camelcase
const un_supported_languages = ['id', 'tr'];
const checkLanguageNotSupported = () =>
un_supported_languages.includes(queryLang) ? 'en' : getStorage('lang') || 'en';
const lang = checkIsSupported ? queryLang : checkLanguageNotSupported();
setStorage('lang', lang);
setCookieLanguage(lang);
return lang;
Expand All @@ -31,7 +36,6 @@ const addUiLang = () => {
export const load = () => {
if (typeof $ !== 'function') return; // Adding this check to skip unit test
const lang = getLanguage();

$('#select_language li:not(:first)').click(function click() {
const newLang = $(this).attr('class');
if (
Expand All @@ -43,7 +47,7 @@ export const load = () => {
render(<BotLanding />, document.getElementById('bot-landing'));
elements.map(elem => document.querySelector(elem).classList.add('hidden'));
document.getElementById('bot-landing').classList.remove('hidden');
document.getElementById('bot-main').classList.remove('hidden');
document.getElementById('bot-main').classList.add('hidden');
document.location.search = `l=${newLang}`;
$('.barspinner').hide();
} else {
Expand All @@ -68,6 +72,7 @@ export const load = () => {
script.src = `${document.location.protocol}//cdn.crowdin.com/jipt/jipt.js`;
$('body').append(script);
}
console.log(lang, 'dnashjdnajksdnajksdnakjsdnksajnkjs');

init(lang);

Expand Down
3 changes: 2 additions & 1 deletion src/common/utils/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const parseQueryString = () => {
str.replace(new RegExp('([^?=&]+)(=([^&]*))?', 'g'), (a0, a1, a2, a3) => {
objURL[a1] = a3;
});
return objURL;

return objURL || false;
};
export const generateURL = url => {
if (url.split('?').length !== null && url.split('?').length !== undefined) {
Expand Down
15 changes: 5 additions & 10 deletions src/indexPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isEuCountry, showHideEuElements } from '../common/footer-checks';
import GTM from '../common/gtm';
import { load as loadLang, showBanner } from '../common/lang';
import { moveToDeriv } from '../common/utils/utility';
import { get as getStorage, set as setStorage, remove, getTokenList } from '../common/utils/storageManager';
import { get as getStorage, remove, getTokenList } from '../common/utils/storageManager';
import { createUrl, isBinaryDomain, parseQueryString, serialize } from '../common/utils/tools';
import '../common/binary-ui/dropdown';
import BotLanding from './react-components/bot-landing';
Expand All @@ -21,7 +21,6 @@ const sevenDays = 7;
const oneMinute = 60;
const oneDay = 24;

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

Expand Down Expand Up @@ -72,7 +71,6 @@ export const setTimeOutBanner = route => {
(route === 'views' && checkifBotRunning() === true)
) {
remove('setDueDateForBanner');
setStorage('setDueDateForBanner', expirationDate());
return false;
}
}, calcSetTimeoutValueBanner);
Expand All @@ -82,12 +80,7 @@ export const renderBanner = () => {
if (window.location.pathname.indexOf('/bot') === -1 || window.location.pathname === '/movetoderiv.html') {
getComponent();
render(Component, document.getElementById(dynamicRoutePathanme));
if (dynamicRoutePathanme === 'bot-landing') {
setStorage('setDueDateForBanner', expirationDate());
}
elements.map(elem => document.querySelector(elem).classList.add('hidden'));
document.getElementById(dynamicRoutePathanme).classList.remove('hidden');
document.getElementById('bot-main').classList.remove('hidden');
document.getElementById('topbar').classList.remove('hidden');
$('.barspinner').hide();
}
Expand All @@ -103,11 +96,13 @@ const renderElements = () => {
if (!bannerToken) {
if (window.location.pathname.indexOf('/bot') === -1) {
renderBanner();
document.getElementById('bot-main').classList.add('hidden');
}
} else {
if (today > bannerToken) {
remove('setDueDateForBanner');
renderBanner();
document.getElementById('bot-main').classList.add('hidden');
return false;
}
if (window.location.pathname.indexOf('/bot') === -1) {
Expand All @@ -119,10 +114,9 @@ const renderElements = () => {
'href',
createUrl({ subdomain: 'shop', path: 'collections/strategies', isNonBotPage: true })
);
elements.map(elem => document.querySelector(elem).classList.remove('hidden'));
document.getElementById(dynamicRoutePathanme).classList.add('hidden');
}
document.getElementById('bot-main').classList.remove('hidden');

setTimeout(() => {
$('.barspinner').hide();
}, 2000);
Expand Down Expand Up @@ -152,6 +146,7 @@ const loginCheck = () => {
} else {
setTimeout(() => {
renderBanner();
document.getElementById('bot-main').classList.add('hidden');
}, 0);
}
};
Expand Down
5 changes: 1 addition & 4 deletions src/indexPage/react-components/bot-landing/Hero.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import { translate } from '../../../common/i18n';
import { generateURL } from '../../../common/utils/tools'

const Hero = () => (
<section className="hero">
Expand All @@ -15,9 +14,7 @@ const Hero = () => (
<a href="https://bot.deriv.com">
<button className="l-btn primary">{translate('Take me to Binary Bot on Deriv')}</button>
</a>
<a href={generateURL(window.location.href)}>
<button className="l-btn">{translate('Maybe later')}</button>
</a>

</div>
</div>
<div className="hero-inner__placeholder">
Expand Down
4 changes: 1 addition & 3 deletions src/indexPage/react-components/bot-landing/SwitchSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ const SwitchSection = () => (
<a href={getOAuthURLDeriv()}>
<button className="l-btn danger">{translate('Try it now')}</button>
</a>
<a href={generateURL(window.location.href)}>
<button className="l-btn transparent">{translate('Maybe later')}</button>
</a>

</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion static/css/_landing.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ $header-color : #333333;
margin: 0 auto;
max-width: 1400px;
}

.hero {
background: $hero-BG url(../image/BG-1.webp) no-repeat;
background-size: cover;
Expand Down
8 changes: 8 additions & 0 deletions static/css/bot.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ body {
font-size: 1em;
}

#bot-main{
background: $hero-BG url(../image/BG-1.webp) no-repeat !important;
background-size: cover !important;
position: absolute;
height: 100%;
z-index: -1;
}

#server-status .online {
background-color: green;
}
Expand Down
8 changes: 4 additions & 4 deletions templates/index.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</head>

<body>
<div id="bot-main" class="hidden" style="width: 100%; position: relative;">
<div id="bot-main" style="width: 100%; position: relative;">
{{> ../templates/partials/loading }}
</div>
<div id="topbar">
Expand All @@ -27,17 +27,17 @@
<div id="movetoderiv"></div>
<div id="bot-landing"></div>

<div id="header">
<div id="header" class="hidden">
<div class="wrapper">
<div class="logo-wrapper">
<div id="binary-logo"></div>
{{> ../templates/partials/bbot-to-deriv-banner }}
</div>
</div>
</div>
<div id="notification-banner"></div>
<div id="notification-banner" class="hidden"></div>
<div id="bot-landing-alert-popup" class="bot-landing-alert bot-landing-alert-popup"></div>
<div id="main">
<div id="main" class="hidden">
<div>
<div class="content show-on-load">
<h1 class="center" data-i18n-text="Binary Bot"></h1>
Expand Down
1 change: 0 additions & 1 deletion templates/partials/language.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
</li>
<li class="en">English</li>
<li class="fr">Français</li>
<li class="id">Indonesia</li>
<li class="pl">Polish</li>
<li class="pt">Português</li>
<li class="ru">Русский</li>
Expand Down