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
Show all changes
24 commits
Select commit Hold shift + click to select a range
6d7d5a1
Update footer text
Apr 8, 2019
5c0d91e
Merge branch 'dev' into update-costarica-footer
May 7, 2019
a9429b4
Allow for (slow) translation between languages
May 10, 2019
432de64
Export pushDataLayer
May 10, 2019
9a69a42
Override TreeNode onClick, push event to GTM
May 10, 2019
ff537b4
Track block deletion + creation, rename event name
May 10, 2019
14c91aa
Give connect + disconnect buttons unique id for passing to GTM
May 10, 2019
e2b6e6d
Add dataLayer as global var
May 13, 2019
32aafa4
Create init function for injecting GTM script tag
May 13, 2019
ca432a5
Call GTM.init(), re-order imports
May 13, 2019
eb54d13
Remove loading GTM in <head>
May 13, 2019
21648bd
Remove GTM tag from build vars, move to GTM class
May 13, 2019
2a12d94
Check if dataLayer is available, init instead of setVisitorId
May 13, 2019
22e9afc
Assign IDs to <span>-element
May 13, 2019
6395217
Remove .js extension
May 13, 2019
6ffa863
Merge branch 'dev' into track-gtm-events
May 14, 2019
3450524
Merge branch 'dev' into update-costarica-footer
May 14, 2019
2b7bd86
Update footer text
May 15, 2019
1937562
Revert #1494
May 17, 2019
8ff12c5
Merge pull request #1519 from aaron-binary/revert-files-element
ashkanx May 17, 2019
cfa7623
Merge branch 'dev' into update-costarica-footer
ashkanx May 17, 2019
4d6adec
Merge pull request #1409 from aaron-binary/update-costarica-footer
ashkanx May 17, 2019
03409db
Merge branch 'dev' into track-gtm-events
ashkanx May 20, 2019
ce7060a
Merge pull request #1493 from aaron-binary/track-gtm-events
ashkanx May 22, 2019
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
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"globals": {
"Blockly": false,
"trackJs": false,
"jest": false
"jest": false,
"dataLayer": false
},
"plugins": [
"react"
Expand Down
1 change: 0 additions & 1 deletion gulp/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const getConfig = prefix => ({
binary_style_img: 'image/binary-style',
elevio_script :
'<script>!function(e,l,v,i,o,n){e[i]||(e[i]={}),e[i].account_id=n;var g,h;g=l.createElement(v),g.type="text/javascript",g.async=1,g.src=o+n,h=l.getElementsByTagName(v)[0],h.parentNode.insertBefore(g,h);e[i].q=[];e[i].on=function(z,y){e[i].q.push([z,y])}}(window,document,"script","_elev","https://cdn.elev.io/sdk/bootloader/v4/elevio-bootloader.js?cid=","5bbc2de0b7365");</script>',
gtm_head : '<!-- Google Tag Manager --> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({\'gtm.start\': new Date().getTime(),event:\'gtm.js\'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src= \'https://www.googletagmanager.com/gtm.js?id=\'+i+dl;f.parentNode.insertBefore(j,f); })(window,document,\'script\',\'dataLayer\',\'GTM-P97C2DZ\');</script> <!-- End Google Tag Manager -->',
gtm_iframe:
'<!-- Google Tag Manager (noscript) --> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-P97C2DZ" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <!-- End Google Tag Manager (noscript) -->',
});
Expand Down
26 changes: 25 additions & 1 deletion src/botPage/view/blockly/customBlockly.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { translate } from '../../../common/utils/tools';
import GTM from '../../../common/gtm';
import { translate, translateLangToLang } from '../../../common/i18n';
import { getLanguage } from '../../../common/lang';

/* eslint-disable */
Blockly.WorkspaceAudio.prototype.preload = function() {};
Expand Down Expand Up @@ -334,3 +336,25 @@ Blockly.Input.prototype.attachShadowBlock = function(value, name, shadowBlockTyp
shadowBlock.initSvg();
shadowBlock.render();
};

/**
* Expand or collapse the node on mouse click.
* @param {!goog.events.BrowserEvent} _e The browser event.
* @override
*/
Blockly.Toolbox.TreeNode.prototype.onClick_ = function(_e) {
// eslint-disable-next-line no-underscore-dangle
const blocklyCategoryName = translateLangToLang(_e.target.innerText, getLanguage(), 'en');
GTM.pushDataLayer({ event: 'Click Block Category', blocklyCategoryName });

// Expand icon.
if (this.hasChildren() && this.isUserCollapsible_) {
this.toggle();
this.select();
} else if (this.isSelected()) {
this.getTree().setSelectedItem(null);
} else {
this.select();
}
this.updateRow();
};
26 changes: 26 additions & 0 deletions src/botPage/view/blockly/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { translate, xml as translateXml } from '../../../common/i18n';
import { getLanguage } from '../../../common/lang';
import { observer as globalObserver } from '../../../common/utils/observer';
import { showDialog } from '../../bot/tools';
import GTM from '../../../common/gtm';

const setBeforeUnload = off => {
if (off) {
Expand Down Expand Up @@ -232,6 +233,31 @@ export default class _Blockly {
},
trashcan: false,
});
workspace.addChangeListener(event => {
if (event.type === Blockly.Events.BLOCK_CREATE) {
event.ids.forEach(id => {
const block = workspace.getBlockById(id);
if (block) {
GTM.pushDataLayer({
event : 'Block Event',
blockEvent: event.type,
blockType : block.type,
});
}
});
} else if (event.type === Blockly.Events.BLOCK_DELETE) {
const dom = Blockly.Xml.textToDom(`<xml>${event.oldXml.outerHTML}</xml>`);
const blockNodes = dom.getElementsByTagName('block');
Array.from(blockNodes).forEach(blockNode => {
GTM.pushDataLayer({
event : 'Block Event',
blockEvent: event.type,
blockType : blockNode.getAttribute('type'),
});
});
}
});

const renderInstance = render(workspace);
window.addEventListener('resize', renderInstance, false);
renderInstance();
Expand Down
2 changes: 1 addition & 1 deletion src/botPage/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ view.initPromise.then(() => {
$('.barspinner').hide();
window.dispatchEvent(new Event('resize'));
Elevio.init();
GTM.setVisitorId();
GTM.init();
trackJs.configure({
userId: $('.account-id')
.first()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ export default class GoogleDriveIntegration extends PureComponent {
onClick={() => googleDrive.authorise()}
className={!googleDrive.isAuthorised ? 'button' : 'button-disabled'}
>
<span>{translate('Connect')}</span>
<span id="connect-google-drive">{translate('Connect')}</span>
</a>
<a
onClick={() => googleDrive.signOut()}
className={googleDrive.isAuthorised ? 'button' : 'button-disabled'}
>
<span>{translate('Disconnect')}</span>
<span id="disconnect-google-drive">{translate('Disconnect')}</span>
</a>
</div>
</div>
Expand Down
23 changes: 21 additions & 2 deletions src/common/gtm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,26 @@ import { getTokenList } from './utils/storageManager';
const GTM = (() => {
const isGtmApplicable = () => Object.values(AppIdMap).includes(`${getAppIdFallback()}`);

const pushDataLayer = data => {
const init = () => {
if (isGtmApplicable()) {
// eslint-disable-next-line no-undef
const gtmTag =
'(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({\'gtm.start\': new Date().getTime(),event:\'gtm.js\'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src= \'https://www.googletagmanager.com/gtm.js?id=\'+i+dl;f.parentNode.insertBefore(j,f); })(window,document,\'script\',\'dataLayer\',\'GTM-P97C2DZ\');';

const script = document.createElement('script');
script.innerHTML = gtmTag;
document.body.appendChild(script);

const interval = setInterval(() => {
if (dataLayer) {
setVisitorId();
clearInterval(interval);
}
}, 500);
}
};

const pushDataLayer = data => {
if (isGtmApplicable() && dataLayer) {
dataLayer.push({
...data,
});
Expand All @@ -24,6 +41,8 @@ const GTM = (() => {
};

return {
init,
pushDataLayer,
setVisitorId,
};
})();
Expand Down
14 changes: 14 additions & 0 deletions src/common/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ export const init = lang => {

export const translate = str => (str && t(sha1(str))) || str;

export const translateLangToLang = (str, fromLang, toLang) => {
if (supportedLanguages[fromLang]) {
const hashIndex = Object.values(supportedLanguages[fromLang]).findIndex(translatedStr => str === translatedStr);
if (hashIndex !== -1) {
const hash = Object.keys(supportedLanguages[fromLang])[hashIndex];
const translatedStr = supportedLanguages[toLang][hash];
if (translatedStr) {
return translatedStr;
}
}
}
return str;
};

export const xml = dom => {
const categories = Array.from(dom.getElementsByTagName('category') || []);
categories.forEach(child => {
Expand Down
10 changes: 6 additions & 4 deletions src/indexPage/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React from 'react';
import ReactDOM from 'react-dom';
import endpoint from './endpoint';
import Logo from './react-components/logo.jsx';
import Footer from './react-components/footer.jsx';
import { getTokenList } from '../common/utils/storageManager';
import { oauthLogin } from '../common/appId';
import { createUrl } from '../common/utils/tools';
import { load as loadLang } from '../common/lang';
import '../common/binary-ui/dropdown';
import endpoint from './endpoint';
import isEuCountry from '../common/footer-checks';
import GTM from '../common/gtm';
import { load as loadLang } from '../common/lang';
import { getTokenList } from '../common/utils/storageManager';
import { createUrl } from '../common/utils/tools';

const renderElements = () => {
const showHideEuElements = isEu => {
Expand All @@ -33,6 +34,7 @@ const loginCheck = () => {
$('.show-on-load').show();
$('.barspinner').hide();
renderElements();
GTM.init();
});
}
};
Expand Down
14 changes: 7 additions & 7 deletions src/indexPage/react-components/footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ const Footer = () => (
<div className='gr-row'>
<div className='gr-12'>
<p>
{translate(['In the EU, financial products are offered by Binary Investments (Europe) Ltd., Mompalao Building, Suite 2, Tower Road, Msida MSD1825, Malta, regulated as a Category 3 Investment Services provider by the Malta Financial Services Authority ([_1]licence no. IS/70156[_2]).', `<a href="${createUrl({ path: 'download/WS-Binary-Investments-Europe-Limited.pdf', isNonBotPage: true })}" target="_blank">`, '</a>'])}
{translate(['In the EU, financial products are offered by Binary Investments (Europe) Ltd., W Business Centre, Level 3, Triq Dun Karm, Birkirkara, BKR 9033, Malta, regulated as a Category 3 Investment Services provider by the Malta Financial Services Authority ([_1]licence no. IS/70156[_2]).', `<a href="${createUrl({ path: 'download/WS-Binary-Investments-Europe-Limited.pdf', isNonBotPage: true })}" target="_blank">`, '</a>'])}
</p>
<p>
{translate(['Outside the EU, financial products are offered by Binary (C.R.) S.A., 5th Floor, Building 6 Centro Ejecutivo La Sabana, Sabana Sur, San José, Costa Rica, Binary (V) Ltd, Govant Building, Port Vila, PO Box 1276, Vanuatu, regulated by the Vanuatu Financial Services Commission ([_1]view licence[_2]), Binary (BVI) Ltd, 2nd Floor, O’Neal Marketing Associates Building, Wickham’s Cay II, P.O. Box 3174, Road Town, Tortola VB1110, British Virgin Islands, regulated by the British Virgin Islands Financial Services Commission ([_3]licence no. SIBA/L/18/1114[_4]), and Binary (FX) Ltd., Lot No. F16, First Floor, Paragon Labuan, Jalan Tun Mustapha, 87000 Labuan, Malaysia, regulated by the Labuan Financial Services Authority to carry on a money-broking business ([_5]licence no. MB/18/0024[_6])',
{translate(['Outside the EU, financial products are offered by Binary (SVG) Ltd, Hinds Building, Kingstown, St. Vincent and the Grenadines; Binary (V) Ltd, Govant Building, Port Vila, PO Box 1276, Vanuatu, regulated by the Vanuatu Financial Services Commission ([_1]view licence[_2]); Binary (BVI) Ltd, Kingston Chambers, P.O. Box 173, Road Town, Tortola, British Virgin Islands, regulated by the British Virgin Islands Financial Services Commission ([_3]licence no. SIBA/L/18/1114[_4]); and Binary (FX) Ltd., Lot No. F16, First Floor, Paragon Labuan, Jalan Tun Mustapha, 87000 Labuan, Malaysia, regulated by the Labuan Financial Services Authority to carry on a money-broking business ([_5]licence no. MB/18/0024[_6]).',
'<a href="https://www.vfsc.vu/wp-content/uploads/2015/12/List-of-Licensees-under-Dealers-in-Securities-Licensing-Act-CAP-70-18.11.2016.pdf" target="_blank" rel="noopener noreferrer">', '</a>',
`<a href="${createUrl({ path: 'download/regulation/BVI_license.pdf', isNonBotPage: true })}" target="_blank">`, '</a>',
`<a href="${createUrl({ path: 'download/regulation/Labuan-license.pdf', isNonBotPage: true })}" target="_blank">`, '</a>'])}
</p>
<p>
{translate(['This websites services are not made available in certain countries such as the USA, Canada, Costa Rica, Hong Kong, Japan, or to persons under age 18.'])}
{translate(['This website\'s services are not made available in certain countries such as the USA, Canada, Hong Kong, Japan, or to persons under age 18.'])}
</p>
<fieldset className='fld-risk-warning'>
<legend>{translate(['Risk Warning'])}</legend>
<p>{translate(['The financial products offered via this website include binary options, contracts for difference ("CFDs") and other complex derivatives and financial products. Trading binary options may not be suitable for everyone. Trading CFDs carries a high level of risk since leverage can work both to your advantage and disadvantage. As a result, the products offered on this website may not be suitable for all investors because of the risk of losing all of your invested capital. You should never invest money that you cannot afford to lose, and never trade with borrowed money. Before trading in the complex financial products offered, please be sure to understand the risks involved and learn about [_1]Responsible Trading[_2].', `<a href="${createUrl({ path: 'responsible-trading', addLanguage: true, addHtmlExtension: true, isNonBotPage: true })}">`, '</a>'])}</p>
<p>{translate(['The products offered via this website include binary options, contracts for difference ("CFDs") and other complex derivatives. Trading binary options may not be suitable for everyone. Trading CFDs carries a high level of risk since leverage can work both to your advantage and disadvantage. As a result, the products offered on this website may not be suitable for all investors because of the risk of losing all of your invested capital. You should never invest money that you cannot afford to lose, and never trade with borrowed money. Before trading in the complex products offered, please be sure to understand the risks involved and learn about [_1]Responsible Trading[_2].', `<a href="${createUrl({ path: 'responsible-trading', addLanguage: true, addHtmlExtension: true, isNonBotPage: true })}">`, '</a>'])}</p>
</fieldset>
</div>
</div>
Expand Down Expand Up @@ -97,21 +97,21 @@ const Footer = () => (
<div className='gr-row'>
<div className='gr-12'>
<p>
{translate(['In the EU, financial products are offered by Binary Investments (Europe) Ltd., Mompalao Building, Suite 2, Tower Road, Msida MSD1825, Malta, licensed and regulated as a Category 3 Investment Services provider by the Malta Financial Services Authority (licence no. IS/70156).'])}
{translate(['In the EU, financial products are offered by Binary Investments (Europe) Ltd., W Business Centre, Level 3, Triq Dun Karm, Birkirkara, BKR 9033, Malta, licensed and regulated as a Category 3 Investment Services provider by the Malta Financial Services Authority (licence no. IS/70156).'])}
</p>
<p>
{translate(['In the Isle of Man and the UK, Volatility Indices are offered by Binary (IOM) Ltd., First Floor, Millennium House, Victoria Road, Douglas, IM2 4RW, Isle of Man, British Isles; licensed and regulated respectively by (1) the Gambling Supervision Commission in the Isle of Man (current licence issued on 31 August 2017) and by (2) the Gambling Commission in the UK (licence [_1]reference no: 39172[_2]).', '<a href="https://secure.gamblingcommission.gov.uk/PublicRegister/Search/Detail/39172" target="_blank" rel="noopener noreferrer">', '</a>'])}
</p>
<p>
{translate(['In the rest of the EU, Volatility Indices are offered by Binary (Europe) Ltd., Mompalao Building, Suite 2, Tower Road, Msida MSD1825, Malta; licensed and regulated by (1) the Malta Gaming Authority in Malta (licence no. MGA/B2C/102/2000 issued on 01 August 2018), for UK clients by (2) the UK Gambling Commission (licence [_1]reference no: 39495[_2]), and for Irish clients by (3) the Revenue Commissioners in Ireland (Remote Bookmaker\'s Licence no. 1010285 issued on 1 July 2017). View complete [_3]Regulatory Information[_2].', '<a href="https://secure.gamblingcommission.gov.uk/PublicRegister/Search/Detail/39495" target="_blank" rel="noopener noreferrer">', '</a>', `<a href="${createUrl({ path: 'regulation', addLanguage: true, addHtmlExtension: true, isNonBotPage: true })}">`])}
{translate(['In the rest of the EU, Volatility Indices are offered by Binary (Europe) Ltd., W Business Centre, Level 3, Triq Dun Karm, Birkirkara, BKR 9033, Malta; licensed and regulated by (1) the Malta Gaming Authority in Malta (licence no. MGA/B2C/102/2000 issued on 01 August 2018), for UK clients by (2) the UK Gambling Commission (licence [_1]reference no: 39495[_2]), and for Irish clients by (3) the Revenue Commissioners in Ireland (Remote Bookmaker\'s Licence no. 1010285 issued on 1 July 2017). View complete [_3]Regulatory Information[_2].', '<a href="https://secure.gamblingcommission.gov.uk/PublicRegister/Search/Detail/39495" target="_blank" rel="noopener noreferrer">', '</a>', `<a href="${createUrl({ path: 'regulation', addLanguage: true, addHtmlExtension: true, isNonBotPage: true })}">`])}
</p>
</div>
</div>
<div className='gr-row'>
<div className='gr-12'>
<div className='about-binary'>
<p>
{translate(['Binary.com is an award-winning online trading provider that helps its clients to trade on financial markets through binary options and CFDs. Trading binary options and CFDs on Volatility Indices is classified as a gambling activity. Remember that gambling can be addictive – please play responsibly. Learn more about [_1]Responsible Trading[_2]. Some products are not available in all countries. This websites services are not made available in certain countries such as the USA, Canada, Costa Rica, Hong Kong, or to persons under age 18.', `<a href="${createUrl({ path: 'responsible-trading', addLanguage: true, addHtmlExtension: true, isNonBotPage: true })}">`, '</a>'])}
{translate(['Binary.com is an award-winning online trading provider that helps its clients to trade on financial markets through binary options and CFDs. Trading binary options and CFDs on Volatility Indices is classified as a gambling activity. Remember that gambling can be addictive – please play responsibly. Learn more about [_1]Responsible Trading[_2]. Some products are not available in all countries. This website\'s services are not made available in certain countries such as the USA, Canada, Hong Kong, or to persons under age 18.', `<a href="${createUrl({ path: 'responsible-trading', addLanguage: true, addHtmlExtension: true, isNonBotPage: true })}">`, '</a>'])}
</p>
</div>
</div>
Expand Down
7 changes: 5 additions & 2 deletions templates/bot.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
{{> bundle_css }}
<link rel="stylesheet" href="css/binary.css">
{{> bot_css }}
{{> gtm_head }}
</head>

<body>
Expand Down Expand Up @@ -166,7 +165,11 @@

<div id="blocklyArea"></div>
<div id="blocklyDiv" style="position: absolute;"></div>


<form id="fileUploadForm" style="display: none;">
<input data-i18n-title="Open an already saved XML file and retrieve its blocks" type="file" id="files" accept=".xml"
multiple />
</form>
<div id="footer"></div>
<audio id="announcement" src="sound/announcement.ogg" autostart="false"></audio>
<audio id="earned-money" src="sound/coins.ogg" autostart="false"></audio>
Expand Down
Loading