diff --git a/src/javascript/app/common/currency.js b/src/javascript/app/common/currency.js
index 4ae093004c6..035404c19ee 100644
--- a/src/javascript/app/common/currency.js
+++ b/src/javascript/app/common/currency.js
@@ -23,9 +23,9 @@ const getCurrencyList = (currencies) => {
currency_list.fiat.push({ value: currency, text: currency_name });
}
});
- dataManager.set({
+ dataManager.setTrade({
currency_list,
- }, 'trade');
+ });
return $currencies.append($fiat_currencies.children().length ? $fiat_currencies : '').append($cryptocurrencies.children().length ? $cryptocurrencies : '');
};
diff --git a/src/javascript/app/common/data_manager.js b/src/javascript/app/common/data_manager.js
index 8c5a40e1585..5729f1ec916 100644
--- a/src/javascript/app/common/data_manager.js
+++ b/src/javascript/app/common/data_manager.js
@@ -37,28 +37,30 @@ class DataManager {
window.dispatchEvent(new CustomEvent(changeTypeMap[data_type], {
detail: { oldValues, newValues },
}));
- if (optional_trigger === 'barrier') {
- triggerBarrierChange();
- } else if (optional_trigger === 'time') {
- triggerTimeChange();
- } else {
- switch (data_type) {
- case 'trade':
+
+ switch (data_type) {
+ case 'trade':
+ if (optional_trigger === 'barrier') {
+ triggerBarrierChange();
+ } else if (optional_trigger === 'time') {
+ triggerTimeChange();
+ } else {
triggerTradeChange();
- break;
-
- case 'purchase':
- triggerPurchaseChange();
- break;
-
- case 'contract':
- triggerContractChange();
- break;
-
- default:
- break;
- }
+ }
+ break;
+
+ case 'purchase':
+ triggerPurchaseChange();
+ break;
+
+ case 'contract':
+ triggerContractChange();
+ break;
+
+ default:
+ break;
}
+
}
}
}
@@ -92,6 +94,70 @@ class DataManager {
has(key, data_type) {
return Object.prototype.hasOwnProperty.call(this.data[data_type], key);
}
+
+ // methods for trade
+ setTrade(data, optional_trigger) {
+ this.set(data, 'trade', optional_trigger);
+ }
+
+ getTrade(key) {
+ return this.get(key, 'trade');
+ }
+
+ getAllTrades() {
+ return this.getAll('trade');
+ }
+
+ clearTrades() {
+ this.clear('trade');
+ }
+
+ hasTrade(key) {
+ return this.has(key, 'trade');
+ }
+
+ // methods for purchase
+ setPurchase(data) {
+ this.set(data, 'purchase');
+ }
+
+ getPurchase(key) {
+ return this.get(key, 'purchase');
+ }
+
+ getAllPurchases() {
+ return this.getAll('purchase');
+ }
+
+ clearPurchases() {
+ this.clear('purchase');
+ }
+
+ hasPurchase(key) {
+ return this.has(key, 'purchase');
+ }
+
+ // methods for contract
+ setContract(data) {
+ this.set(data, 'contract');
+ }
+
+ getContract(key) {
+ return this.get(key, 'contract');
+ }
+
+ getAllContracts() {
+ return this.getAll('contract');
+ }
+
+ clearContracts() {
+ this.clear('contract');
+ }
+
+ hasContract(key) {
+ return this.has(key, 'contract');
+ }
+
}
const dataManager = new DataManager();
diff --git a/src/javascript/app/common/helpers.js b/src/javascript/app/common/helpers.js
index 510c6571e61..ae59297e28c 100644
--- a/src/javascript/app/common/helpers.js
+++ b/src/javascript/app/common/helpers.js
@@ -99,10 +99,10 @@ const setMinMaxTimeObj = (options) => {
}
}
- dataManager.set({
+ dataManager.setTrade({
starttime_obj,
expirytime_obj,
- }, 'trade', 'time');
+ }, 'time');
};
export {
diff --git a/src/javascript/app/components/loading-spinner.js b/src/javascript/app/components/loading-spinner.js
index dea8ed8cd9b..368790f2109 100644
--- a/src/javascript/app/components/loading-spinner.js
+++ b/src/javascript/app/components/loading-spinner.js
@@ -28,9 +28,9 @@ export const show = (content_id) => {
* @param content_id
*/
export const hide = (content_id) => {
- dataManager.set({
+ dataManager.setContract({
hidePageLoader: true,
- }, 'contract');
+ });
assertContainerExists(content_id);
const $container = $(`#${content_id}`);
diff --git a/src/javascript/app/pages/bottom/explanation.jsx b/src/javascript/app/pages/bottom/explanation.jsx
index e108e292f38..d069d64a9ad 100644
--- a/src/javascript/app/pages/bottom/explanation.jsx
+++ b/src/javascript/app/pages/bottom/explanation.jsx
@@ -15,7 +15,7 @@ export const Explanation = ({ explanationOnly = false }) => {
const hasContractChanges = useContractChange();
useEffect(() => {
- const actualFormName = dataManager.get('explanationFormName', 'contract');
+ const actualFormName = dataManager.getContract('explanationFormName');
setFormName(null);
setTimeout(() => {
diff --git a/src/javascript/app/pages/bottom/tabs.jsx b/src/javascript/app/pages/bottom/tabs.jsx
index f4292eedee2..58319fb3fca 100644
--- a/src/javascript/app/pages/bottom/tabs.jsx
+++ b/src/javascript/app/pages/bottom/tabs.jsx
@@ -69,7 +69,7 @@ const BottomTabs = () => {
: tabs;
useEffect(() => {
- setFormName(dataManager.get('explanationFormName', 'contract'));
+ setFormName(dataManager.getContract('explanationFormName'));
}, [hasContractChange, hasMarketChange]);
useEffect(() => {
diff --git a/src/javascript/app/pages/form/barrier-fields.jsx b/src/javascript/app/pages/form/barrier-fields.jsx
index ab259959b4f..aa5d10b7f83 100644
--- a/src/javascript/app/pages/form/barrier-fields.jsx
+++ b/src/javascript/app/pages/form/barrier-fields.jsx
@@ -21,7 +21,7 @@ const BarrierFields = ({ formName, handleAmountChange }) => {
useEffect(() => {
setBarrierData((oldData) => ({
...oldData,
- ...dataManager.getAll('trade'),
+ ...dataManager.getAllTrades(),
}));
}, [hasBarrierChange]);
diff --git a/src/javascript/app/pages/form/form-component.jsx b/src/javascript/app/pages/form/form-component.jsx
index d8337262953..fa0d8dcdf7a 100644
--- a/src/javascript/app/pages/form/form-component.jsx
+++ b/src/javascript/app/pages/form/form-component.jsx
@@ -32,7 +32,7 @@ export const FormComponent = () => {
useEffect(() => {
setTradeData((oldData) => ({
...oldData,
- ...dataManager.getAll('trade'),
+ ...dataManager.getAllTrades(),
}));
}, [hasTradeChange, hasSessionChange]);
diff --git a/src/javascript/app/pages/form/time-selection.jsx b/src/javascript/app/pages/form/time-selection.jsx
index bfb13d9f8b4..c4147e20b47 100644
--- a/src/javascript/app/pages/form/time-selection.jsx
+++ b/src/javascript/app/pages/form/time-selection.jsx
@@ -12,8 +12,8 @@ const TimeContent = ({ time, onUpdate, elementId }) => {
const { close } = useDropdown();
useEffect(() => {
- setStartTimeData(dataManager.get('starttime_obj', 'trade'));
- setExpiryTimeData(dataManager.get('expirytime_obj', 'trade'));
+ setStartTimeData(dataManager.getTrade('starttime_obj'));
+ setExpiryTimeData(dataManager.getTrade('expirytime_obj'));
}, [hasTimeChange]);
const formatTime = (timeObj) => {
diff --git a/src/javascript/app/pages/loader.jsx b/src/javascript/app/pages/loader.jsx
index 7da5bf409f1..d68996fcb80 100644
--- a/src/javascript/app/pages/loader.jsx
+++ b/src/javascript/app/pages/loader.jsx
@@ -45,7 +45,7 @@ const Loader = () => {
const page = getPageType().name;
useEffect(() => {
- const hidePageLoader = dataManager.get('hidePageLoader', 'contract');
+ const hidePageLoader = dataManager.getContract('hidePageLoader');
if (hidePageLoader){
setLoading(false);
diff --git a/src/javascript/app/pages/trade/analysis.js b/src/javascript/app/pages/trade/analysis.js
index c2fab72b9da..58180200df0 100644
--- a/src/javascript/app/pages/trade/analysis.js
+++ b/src/javascript/app/pages/trade/analysis.js
@@ -36,10 +36,10 @@ const TradingAnalysis = (() => {
const tab_form_name = tab_obj[form_name] || form_name;
form_name = map_obj[form_name] || form_name;
- dataManager.set({
+ dataManager.setContract({
actualFormName : form_name,
explanationFormName: tab_form_name,
- }, 'contract');
+ });
$('#tab_last_digit').setVisibility(/digits|overunder|evenodd/.test(tab_form_name));
diff --git a/src/javascript/app/pages/trade/barriers.js b/src/javascript/app/pages/trade/barriers.js
index 223493ff19e..19d15d05955 100644
--- a/src/javascript/app/pages/trade/barriers.js
+++ b/src/javascript/app/pages/trade/barriers.js
@@ -87,9 +87,9 @@ const Barriers = (() => {
showHideRelativeTip(barrier.barrier, [tooltip, span]);
barrier_data.show_barrier = true;
barrier_data.show_barrier_highlow = false;
- dataManager.set({
+ dataManager.setTrade({
barrier_data,
- }, 'trade', 'barrier');
+ }, 'barrier');
return;
} else if (barrier.count === 2) {
getElementById('barrier_row').style.display = 'none';
@@ -170,9 +170,9 @@ const Barriers = (() => {
Defaults.set(BARRIER_LOW, low_elm.value);
barrier_data.show_barrier = false;
barrier_data.show_barrier_highlow = true;
- dataManager.set({
+ dataManager.setTrade({
barrier_data,
- }, 'trade', 'barrier');
+ }, 'barrier');
return;
}
}
@@ -215,9 +215,9 @@ const Barriers = (() => {
}
}
- dataManager.set({
+ dataManager.setTrade({
barrier_error,
- }, 'trade', 'barrier');
+ }, 'barrier');
};
const showHideRelativeTip = (barrier, arr_el) => {
diff --git a/src/javascript/app/pages/trade/common.js b/src/javascript/app/pages/trade/common.js
index 8417a218dd1..ee807098644 100644
--- a/src/javascript/app/pages/trade/common.js
+++ b/src/javascript/app/pages/trade/common.js
@@ -42,8 +42,6 @@ const commonTrading = (() => {
UNDERLYING,
} = Defaults.PARAM_NAMES;
- const type_purchase = 'purchase';
-
const displayContractForms = (id, elements, selected) => {
if (!id || !elements || !selected) return;
@@ -53,12 +51,12 @@ const commonTrading = (() => {
const contract_to_show = /^(callputequal)$/.test(selected) ? 'risefall' : selected;
if (!contracts_element) {
- dataManager.set({
+ dataManager.setContract({
contractsTree : contracts_tree,
contracts : all_contracts,
formName : selected || Defaults.get('formname'),
contractElement: getElementById('contract'),
- }, 'contract');
+ });
} else { // Update the component.
contracts_element.updater.enqueueSetState(contracts_element, {
contracts_tree,
@@ -159,9 +157,9 @@ const commonTrading = (() => {
showHideOverlay('contract_confirmation_container', 'none');
showHideOverlay('contracts_list', 'flex');
$('.purchase_button').text(localize('Purchase'));
- dataManager.set({
+ dataManager.setPurchase({
showPurchaseResults: false,
- }, type_purchase);
+ });
};
const getContractCategoryTree = (elements) => {
@@ -255,9 +253,9 @@ const commonTrading = (() => {
} else {
node.show();
elementInnerHtml(node, comment);
- dataManager.set({
+ dataManager.setPurchase({
[`${position}Comment`]: comment,
- }, type_purchase);
+ });
}
}
};
@@ -477,15 +475,15 @@ const commonTrading = (() => {
requireHighstock,
showPriceOverlay: () => {
showHideOverlay('loading_container2', 'block');
- dataManager.set({
+ dataManager.setPurchase({
isPurchaseFormDisabled: true,
- }, type_purchase);
+ });
},
hidePriceOverlay: () => {
showHideOverlay('loading_container2', 'none');
- dataManager.set({
+ dataManager.setPurchase({
isPurchaseFormDisabled: false,
- }, type_purchase);
+ });
},
hideFormOverlay: () => { showHideOverlay('loading_container3', 'none'); },
showFormOverlay: () => { showHideOverlay('loading_container3', 'block'); },
diff --git a/src/javascript/app/pages/trade/common_independent.js b/src/javascript/app/pages/trade/common_independent.js
index 730a4bd09c7..7583939ce28 100644
--- a/src/javascript/app/pages/trade/common_independent.js
+++ b/src/javascript/app/pages/trade/common_independent.js
@@ -4,7 +4,6 @@ const dataManager = require('../../common/data_manager').default;
const getElementById = require('../../../_common/common_functions').getElementById;
const getPropertyValue = require('../../../_common/utility').getPropertyValue;
-const type_purchase = 'purchase';
/*
* Display price/spot movement variation to depict price moved up or down
*/
@@ -12,22 +11,22 @@ const displayPriceMovement = (element, old_value, current_value, data_key) => {
element.classList.remove('price_moved_down');
element.classList.remove('price_moved_up');
- dataManager.set({
+ dataManager.setPurchase({
[data_key]: '',
- }, type_purchase);
+ });
if (parseFloat(current_value) > parseFloat(old_value)) {
element.classList.remove('price_moved_down');
element.classList.add('price_moved_up');
- dataManager.set({
+ dataManager.setPurchase({
[data_key]: 'price_moved_up',
- }, type_purchase);
+ });
} else if (parseFloat(current_value) < parseFloat(old_value)) {
element.classList.remove('price_moved_up');
element.classList.add('price_moved_down');
- dataManager.set({
+ dataManager.setPurchase({
[data_key]: 'price_moved_down',
- }, type_purchase);
+ });
}
};
diff --git a/src/javascript/app/pages/trade/duration.js b/src/javascript/app/pages/trade/duration.js
index f3343af8b4f..7125bb36423 100644
--- a/src/javascript/app/pages/trade/duration.js
+++ b/src/javascript/app/pages/trade/duration.js
@@ -44,7 +44,6 @@ const Durations = (() => {
FORM_NAME,
TIME_START,
} = Defaults.PARAM_NAMES;
- const type_trade = 'trade';
const displayDurations = (time_start_val) => {
let date_time_start = moment(Defaults.get(DATE_START) * 1000);
@@ -154,9 +153,9 @@ const Durations = (() => {
Object.values(list).forEach(option => {
duration_options.push({ text: duration_list[option].text, value: option });
});
- dataManager.set({
+ dataManager.setTrade({
duration_options,
- }, type_trade);
+ });
smallest_duration = {
amount: duration_list[list[0]].dataset.minimum,
@@ -453,9 +452,9 @@ const Durations = (() => {
requested = selectEndDate(selected_date);
}
}
- dataManager.set({
+ dataManager.setTrade({
endtime_data,
- }, type_trade);
+ });
return requested;
};
@@ -508,9 +507,9 @@ const Durations = (() => {
fragment.appendChild(option);
}
target.appendChild(fragment);
- dataManager.set({
+ dataManager.setTrade({
expiry_type_options,
- }, type_trade);
+ });
};
const isNow = date_start => (date_start ? date_start === 'now' : (!State.get('is_start_dates_displayed') || CommonFunctions.getElementById('date_start').value === 'now'));
@@ -687,9 +686,9 @@ const Durations = (() => {
duration_data.message = `${localize('Minimum:')} ${duration_data.min}`;
}
}
- dataManager.set({
+ dataManager.setTrade({
duration_data,
- }, type_trade);
+ });
};
const onStartDateChange = (value) => {
diff --git a/src/javascript/app/pages/trade/markets/contracts-dropdown.jsx b/src/javascript/app/pages/trade/markets/contracts-dropdown.jsx
index 506bbe08c34..4791e07f1c8 100644
--- a/src/javascript/app/pages/trade/markets/contracts-dropdown.jsx
+++ b/src/javascript/app/pages/trade/markets/contracts-dropdown.jsx
@@ -7,7 +7,7 @@ import Defaults, { PARAM_NAMES } from '../defaults';
export const ContractDropdown = () => {
const { close } = useDropdown();
const hasContractChange = useContractChange();
- const [data, setData] = useState(dataManager.getAll('contract'));
+ const [data, setData] = useState(dataManager.getAllContracts());
const selectedRef = useRef(null);
const containerRef = useRef(null);
@@ -24,9 +24,9 @@ export const ContractDropdown = () => {
Defaults.set(PARAM_NAMES.FORM_NAME,formName);
- dataManager.set({
+ dataManager.setContract({
formName,
- }, 'contract');
+ });
triggerContractChange();
@@ -39,7 +39,7 @@ export const ContractDropdown = () => {
useEffect(() => {
setData(oldData => ({
...oldData,
- ...dataManager.getAll('contract'),
+ ...dataManager.getAllContracts(),
}));
}, [hasContractChange]);
diff --git a/src/javascript/app/pages/trade/markets/markets-dropdown.jsx b/src/javascript/app/pages/trade/markets/markets-dropdown.jsx
index bc7b5370325..75c352439d0 100644
--- a/src/javascript/app/pages/trade/markets/markets-dropdown.jsx
+++ b/src/javascript/app/pages/trade/markets/markets-dropdown.jsx
@@ -39,7 +39,7 @@ export const getMarketName = () => {
};
export const getContractName = () => {
- const data = dataManager.getAll('contract');
+ const data = dataManager.getAllContracts('contract');
let name = '';
// eslint-disable-next-line consistent-return
data?.contractsTree?.forEach((contract) => {
diff --git a/src/javascript/app/pages/trade/not-available.jsx b/src/javascript/app/pages/trade/not-available.jsx
index 833cd7232ef..130f9a3c599 100644
--- a/src/javascript/app/pages/trade/not-available.jsx
+++ b/src/javascript/app/pages/trade/not-available.jsx
@@ -29,9 +29,9 @@ const NotAvailable = ({ title, body }) => (
);
export const init = ({ ...props }) => {
- dataManager.set({
+ dataManager.setContract({
hidePageLoader: true,
- }, 'contract');
+ });
ReactDOM.render(, getElementById('content'));
};
diff --git a/src/javascript/app/pages/trade/price.js b/src/javascript/app/pages/trade/price.js
index 6d77a2ac05d..2cfea0227f1 100644
--- a/src/javascript/app/pages/trade/price.js
+++ b/src/javascript/app/pages/trade/price.js
@@ -34,7 +34,6 @@ const Price = (() => {
let form_id = 0;
let is_resubscribing = false;
const { DURATION_AMOUNT, DURATION_UNITS, EXPIRY_TIME, FORM_NAME } = Defaults.PARAM_NAMES;
- const type_purchase = 'purchase';
const createProposal = (type_of_contract) => {
const proposal = {
@@ -215,10 +214,10 @@ const Price = (() => {
h4.setAttribute('class', `contract_heading ${type}`);
CommonFunctions.elementTextContent(h4, display_text);
- dataManager.set({
+ dataManager.setPurchase({
[`${position}DisplayText`] : display_text,
[`${position}ContractType`]: type,
- }, type_purchase);
+ });
}
@@ -227,18 +226,18 @@ const Price = (() => {
if (!data.display_value) {
amount.classList.remove('price_moved_up', 'price_moved_down');
- dataManager.set({
+ dataManager.setPurchase({
[`${position}AmountClassname`]: '',
- }, type_purchase);
+ });
}
CommonFunctions.elementTextContent(stake, `${localize('Stake')}: `);
CommonFunctions.elementInnerHtml(amount, data.display_value ? formatMoney(currentCurrency, data.display_value) : '-');
if (!data.payout) {
amount.classList.remove('price_moved_up', 'price_moved_down');
- dataManager.set({
+ dataManager.setPurchase({
[`${position}AmountClassname`]: '',
- }, type_purchase);
+ });
}
CommonFunctions.elementTextContent(payout, `${localize('Payout')}: `);
CommonFunctions.elementInnerHtml(payout_amount, data.payout ? formatMoney(currentCurrency, data.payout) : '-');
@@ -246,24 +245,24 @@ const Price = (() => {
CommonFunctions.elementTextContent(multiplier, `${localize('Multiplier')}: `);
CommonFunctions.elementInnerHtml(contract_multiplier, data.multiplier ? formatMoney(currentCurrency, data.multiplier, false, 0, 2) : '-');
- dataManager.set({
+ dataManager.setPurchase({
[`${position}Amount`] : data.display_value ? formatMoney(currentCurrency, data.display_value,true) : '-',
[`${position}PayoutAmount`]: data.payout ? formatMoney(currentCurrency, data.payout,true) : '-',
[`${position}Multiplier`] : data.multiplier ? formatMoney(currentCurrency, data.multiplier, true, 0, 2) : '-',
currency : getCurrencyDisplayCode(currentCurrency),
- }, type_purchase);
+ });
if (data.longcode && window.innerWidth > 500) {
- dataManager.set({
+ dataManager.setPurchase({
[`${position}Description`]: data.longcode,
- }, type_purchase);
+ });
if (description) description.setAttribute('data-balloon', data.longcode);
if (longcode) CommonFunctions.elementTextContent(longcode, data.longcode);
} else {
- dataManager.set({
+ dataManager.setPurchase({
[`${position}Description`]: '',
- }, type_purchase);
+ });
if (description) description.removeAttribute('data-balloon');
if (longcode) CommonFunctions.elementTextContent(longcode, '');
@@ -271,9 +270,9 @@ const Price = (() => {
};
const setPurchaseStatus = (enable) => {
- dataManager.set({
+ dataManager.setPurchase({
[`${position}PurchaseDisabled`]: !enable,
- }, type_purchase);
+ });
purchase.parentNode.classList[enable ? 'remove' : 'add']('button-disabled');
};
@@ -283,9 +282,9 @@ const Price = (() => {
setData();
error.show();
CommonFunctions.elementTextContent(error, details.error.message);
- dataManager.set({
+ dataManager.setPurchase({
[`${position}Comment`]: details.error.message,
- }, type_purchase);
+ });
} else {
setData(proposal);
if ($('#websocket_form').find('.error-field:visible').length > 0) {
@@ -298,9 +297,9 @@ const Price = (() => {
if (isLookback(type)) {
const multiplier_value = formatMoney(Client.get('currency'), proposal.multiplier, false, 3, 2);
CommonFunctions.elementInnerHtml(comment, `${localize('Payout')}: ${getLookBackFormula(type, multiplier_value)}`);
- dataManager.set({
+ dataManager.setPurchase({
[`${position}Comment`]: `${localize('Payout')}: ${getLookBackFormula(type, multiplier_value)}`,
- }, type_purchase);
+ });
} else {
commonTrading.displayCommentPrice(comment, (currency.value || currency.getAttribute('value')), proposal.display_value, proposal.payout,position);
}
@@ -463,16 +462,16 @@ const Price = (() => {
const container = CommonFunctions.getElementById(`price_container_${position}`);
if (position_is_visible[position]) {
if (position === 'middle'){
- dataManager.set({
+ dataManager.setPurchase({
showMidPurchase: true,
- }, type_purchase);
+ });
}
$(container).fadeIn(0);
} else {
if (position === 'middle'){
- dataManager.set({
+ dataManager.setPurchase({
showMidPurchase: false,
- }, type_purchase);
+ });
}
$(container).fadeOut(0);
}
diff --git a/src/javascript/app/pages/trade/process.js b/src/javascript/app/pages/trade/process.js
index 0592aa95418..c697e654e97 100644
--- a/src/javascript/app/pages/trade/process.js
+++ b/src/javascript/app/pages/trade/process.js
@@ -46,9 +46,6 @@ const Process = (() => {
UNDERLYING,
} = Defaults.PARAM_NAMES;
- const type_purchase = 'purchase';
- const type_trade = 'trade';
-
/*
* This function processes the active symbols to get markets
* and underlying list
@@ -131,9 +128,9 @@ const Process = (() => {
getElementById('trading_socket_container').classList.add('show');
const init_logo = getElementById('trading_init_progress');
- dataManager.set({
+ dataManager.setContract({
hidePageLoader: true,
- }, 'contract');
+ });
if (init_logo && init_logo.style.display !== 'none') {
init_logo.style.display = 'none';
@@ -155,9 +152,9 @@ const Process = (() => {
const processContract = (contracts) => {
if (getPropertyValue(contracts, ['error', 'code']) === 'InvalidSymbol') {
Price.processForgetProposals();
- dataManager.set({
+ dataManager.setPurchase({
showPurchaseResults: true,
- }, type_purchase);
+ });
getElementById('contract_confirmation_container').style.display = 'block';
getElementById('contracts_list').style.display = 'none';
getElementById('confirmation_message').hide();
@@ -307,14 +304,14 @@ const Process = (() => {
el_equals.checked = true;
}
el_equals.parentElement.setVisibility(1);
- dataManager.set({
+ dataManager.setTrade({
show_allow_equals: true,
- }, type_trade);
+ });
} else {
el_equals.parentElement.setVisibility(0);
- dataManager.set({
+ dataManager.setTrade({
show_allow_equals: false,
- }, type_trade);
+ });
}
};
diff --git a/src/javascript/app/pages/trade/purchase.js b/src/javascript/app/pages/trade/purchase.js
index 4b42b4e0ba2..b5ce0910cc3 100644
--- a/src/javascript/app/pages/trade/purchase.js
+++ b/src/javascript/app/pages/trade/purchase.js
@@ -28,7 +28,6 @@ const getPropertyValue = require('../../../_common/utility').getProperty
* contract purchase response
*/
const Purchase = (() => {
- const type_purchase = 'purchase';
const adjustment = 5;
let payout_value,
@@ -94,7 +93,7 @@ const Purchase = (() => {
processPriceRequest();
TopUpVirtualPopup.show(error.message);
- dataManager.set({
+ dataManager.setPurchase({
error: {
showPurchaseResults: true,
...error,
@@ -102,13 +101,13 @@ const Purchase = (() => {
title : localize('Top up Virtual Account?'),
isCustom : true,
},
- }, type_purchase);
+ });
} else {
contracts_list.style.display = 'none';
container.style.display = 'block';
- dataManager.set({
+ dataManager.setPurchase({
showPurchaseResults: true,
- }, type_purchase);
+ });
message_container.hide();
if (/AuthorizationRequired/.test(error.code)) {
@@ -121,14 +120,14 @@ const Purchase = (() => {
const signup_url = `${Url.getStaticUrl()}/signup/`;
authorization_error_btn_signup.href = signup_url;
- dataManager.set({
+ dataManager.setPurchase({
error: {
...error,
signupUrl: signup_url,
title : localize('Ready to trade?'),
isCustom : true,
},
- }, type_purchase);
+ });
} else {
BinarySocket.wait('get_account_status').then(response => {
@@ -171,9 +170,9 @@ const Purchase = (() => {
}
}
- dataManager.set({
+ dataManager.setPurchase({
error: { ...error,message },
- }, type_purchase);
+ });
CommonFunctions.elementInnerHtml(confirmation_error, message);
});
@@ -185,22 +184,22 @@ const Purchase = (() => {
message_container.show();
authorization_error.setVisibility(0);
confirmation_error.setVisibility(0);
- dataManager.set({
+ dataManager.setPurchase({
error: null,
- }, type_purchase);
+ });
CommonFunctions.elementTextContent(heading, localize('Contract Confirmation'));
CommonFunctions.elementTextContent(descr, receipt.longcode);
CommonFunctions.elementTextContent(barrier_element, '');
CommonFunctions.elementTextContent(reference, `${localize('Your transaction reference is')} ${receipt.transaction_id}`);
- dataManager.set({
+ dataManager.setPurchase({
showPurchaseResults: true,
pr_heading : localize('Contract Confirmation'),
pr_description : receipt.longcode,
pr_barrier : '',
pr_reference : `${localize('Your transaction reference is')} ${receipt.transaction_id}`,
- }, type_purchase);
+ });
const currency = Client.get('currency');
let formula, multiplier;
@@ -216,31 +215,31 @@ const Purchase = (() => {
const potential_profit_value = payout_value ? formatMoney(currency, payout_value - cost_value) : undefined;
CommonFunctions.elementInnerHtml(cost, `${localize('Total Cost')}
${formatMoney(currency, cost_value)}
`);
- dataManager.set({
+ dataManager.setPurchase({
pr_tableCost : localize('Total Cost'),
pr_tableCostValue: formatMoney(currency, cost_value),
- }, type_purchase);
+ });
if (isLookback(contract_type)) {
CommonFunctions.elementInnerHtml(payout, `${localize('Potential Payout')} ${formula}
`);
- dataManager.set({
+ dataManager.setPurchase({
pr_tablePayout : localize('Potential Payout'),
pr_tablePayoutValue: formula,
pr_showTableProfit : false,
- }, type_purchase);
+ });
profit.setVisibility(0);
} else {
profit.setVisibility(1);
CommonFunctions.elementInnerHtml(payout, `${localize('Potential Payout')} ${formatMoney(currency, payout_value)}
`);
CommonFunctions.elementInnerHtml(profit, `${localize('Potential Profit')} ${potential_profit_value}
`);
- dataManager.set({
+ dataManager.setPurchase({
pr_tablePayout : localize('Potential Payout'),
pr_tablePayoutValue: formatMoney(currency, payout_value),
pr_tableProfit : localize('Potential Profit'),
pr_tableProfitValue: potential_profit_value,
pr_showTableProfit : true,
- }, type_purchase);
+ });
}
updateValues.updateContractBalance(receipt.balance_after);
@@ -264,15 +263,15 @@ const Purchase = (() => {
CommonFunctions.elementTextContent(button, localize('View'));
button.setAttribute('contract_id', receipt.contract_id);
button.show();
- dataManager.set({
+ dataManager.setPurchase({
pr_showBtn: true,
- }, type_purchase);
+ });
$('#confirmation_message_container .open_contract_details').attr('contract_id', receipt.contract_id).setVisibility(1);
} else {
button.hide();
- dataManager.set({
+ dataManager.setPurchase({
pr_showBtn: false,
- }, type_purchase);
+ });
$('#confirmation_message_container .open_contract_details').setVisibility(0);
}
}
diff --git a/src/javascript/app/pages/trade/purchase/contract-details.jsx b/src/javascript/app/pages/trade/purchase/contract-details.jsx
index 0247db612ce..745ae9cae2f 100644
--- a/src/javascript/app/pages/trade/purchase/contract-details.jsx
+++ b/src/javascript/app/pages/trade/purchase/contract-details.jsx
@@ -10,8 +10,6 @@ import { localize } from '../../../../_common/localize';
import { Explanation } from '../../bottom/explanation';
import { TimeTooltipWrapper, triggerClick } from '../../../common/helpers';
-const type_purchase = 'purchase';
-
const AuditSection = ({ data }) => {
const auditData = {
start: {
@@ -37,9 +35,9 @@ const AuditSection = ({ data }) => {
icon={}
color='black'
onClick={() => {
- dataManager.set({
+ dataManager.setPurchase({
cd_showAudit: false,
- }, type_purchase);
+ });
triggerClick('#contract_purchase_button');
}}
/>
@@ -130,9 +128,9 @@ const DetailsSection = ({ data }) => (
icon={}
color='black'
onClick={() => {
- dataManager.set({
+ dataManager.setPurchase({
showContractDetailsPopup: false,
- }, type_purchase);
+ });
}}
/>
@@ -177,9 +175,9 @@ const ContractDetails = () => {
useEffect(() => {
const handleKeyDown = (event) => {
if (event.key === 'Escape') {
- dataManager.set({
+ dataManager.setPurchase({
showContractDetailsPopup: false,
- }, type_purchase);
+ });
}
};
@@ -191,7 +189,7 @@ const ContractDetails = () => {
}, [hasPurchaseChange]);
useEffect(() => {
- const newData = dataManager.getAll(type_purchase);
+ const newData = dataManager.getAllPurchases();
setData((oldData) => ({
...oldData,
diff --git a/src/javascript/app/pages/trade/purchase/purchase.jsx b/src/javascript/app/pages/trade/purchase/purchase.jsx
index db0ad82c1f8..e23e65c9d13 100644
--- a/src/javascript/app/pages/trade/purchase/purchase.jsx
+++ b/src/javascript/app/pages/trade/purchase/purchase.jsx
@@ -14,7 +14,6 @@ import { localize } from '../../../../_common/localize';
import { parseData, triggerClick } from '../../../common/helpers';
const Purchase = () => {
- const type_purchase = 'purchase';
const hasPurchaseChange = usePurchaseChange();
const hasContractChange = useContractChange();
@@ -25,16 +24,16 @@ const Purchase = () => {
const isloading = () => !data?.topAmount && !data?.middleAmount && !data?.bottomAmount;
const hidePurchaseResults = () =>
- dataManager.set({
+ dataManager.setPurchase({
showPurchaseResults: false,
error : null,
cd_errorMsg : null,
cd_showAuditBtn : false,
cd_infoMsg : null,
- }, type_purchase);
+ });
useEffect(() => {
- const newData = dataManager.getAll(type_purchase);
+ const newData = dataManager.getAllPurchases();
setShowPopup(!!newData?.showContractDetailsPopup);
diff --git a/src/javascript/app/pages/trade/reset.js b/src/javascript/app/pages/trade/reset.js
index d3cd869d426..cd4ae8df566 100644
--- a/src/javascript/app/pages/trade/reset.js
+++ b/src/javascript/app/pages/trade/reset.js
@@ -36,9 +36,9 @@ const Reset = (() => {
CommonFunctions.getElementById('reset_time')
.html(localize('The reset time is [_1]', reset_time_str))
.setAttribute('style', '');
- dataManager.set({
+ dataManager.setTrade({
reset_message: localize('The reset time is [_1]', reset_time_str),
- }, 'trade');
+ });
};
const DurationMap = (() => {
@@ -63,9 +63,9 @@ const Reset = (() => {
const hideResetTime = () => {
CommonFunctions.getElementById('reset_time').style.display = 'none';
- dataManager.set({
+ dataManager.setTrade({
reset_message: null,
- }, 'trade');
+ });
};
const isNewBarrier = (entry_barrier, current_barrier) => (
diff --git a/src/javascript/app/pages/trade/starttime.js b/src/javascript/app/pages/trade/starttime.js
index a897c97564a..81e0374b724 100644
--- a/src/javascript/app/pages/trade/starttime.js
+++ b/src/javascript/app/pages/trade/starttime.js
@@ -110,9 +110,9 @@ const StartDates = (() => {
Dropdown('#date_start');
Defaults.set(DATE_START, target.value);
$('#time_start_row').setVisibility(target.value !== 'now');
- dataManager.set({
+ dataManager.setTrade({
start_dates: start_dates_data,
- }, 'trade');
+ });
}
State.set('is_start_dates_displayed', true);
if (first) {
diff --git a/src/javascript/app/pages/trade/tick.js b/src/javascript/app/pages/trade/tick.js
index 2265fa6344e..f7dbf2c8233 100644
--- a/src/javascript/app/pages/trade/tick.js
+++ b/src/javascript/app/pages/trade/tick.js
@@ -114,16 +114,16 @@ const Tick = (() => {
indicative_barrier_tooltip.textContent =
addComma((parseFloat(current_tick) + barrier_value), decimal_places);
- dataManager.set({
+ dataManager.setTrade({
barrier_indicator: addComma((parseFloat(current_tick) + barrier_value), decimal_places),
- }, 'trade', 'barrier');
+ }, 'barrier');
tooltip.style.display = 'inherit';
span.style.display = 'none';
} else {
elementTextContent(indicative_barrier_tooltip, '');
- dataManager.set({
+ dataManager.setTrade({
barrier_indicator: null,
- }, 'trade', 'barrier');
+ }, 'barrier');
tooltip.style.display = 'none';
span.style.display = 'inherit';
}
@@ -133,16 +133,16 @@ const Tick = (() => {
value = isNaN(value) ? 0 : value;
indicative_high_barrier_tooltip.textContent =
(parseFloat(current_tick) + value).toFixed(decimal_places);
- dataManager.set({
+ dataManager.setTrade({
barrier_indicator_high: (parseFloat(current_tick) + value).toFixed(decimal_places),
- }, 'trade', 'barrier');
+ }, 'barrier');
high_tooltip.style.display = 'inherit';
high_span.style.display = 'none';
} else {
elementTextContent(indicative_high_barrier_tooltip, '');
- dataManager.set({
+ dataManager.setTrade({
barrier_indicator_high: null,
- }, 'trade', 'barrier');
+ }, 'barrier');
high_tooltip.style.display = 'none';
high_span.style.display = 'inherit';
}
@@ -151,16 +151,16 @@ const Tick = (() => {
value = parseFloat(low_barrier_element.value);
value = isNaN(value) ? 0 : value;
indicative_low_barrier_tooltip.textContent = (parseFloat(current_tick) + value).toFixed(decimal_places);
- dataManager.set({
+ dataManager.setTrade({
barrier_indicator_low: (parseFloat(current_tick) + value).toFixed(decimal_places),
- }, 'trade', 'barrier');
+ }, 'barrier');
low_tooltip.style.display = 'inherit';
low_span.style.display = 'none';
} else {
elementTextContent(indicative_low_barrier_tooltip, '');
- dataManager.set({
+ dataManager.setTrade({
barrier_indicator_low: null,
- }, 'trade', 'barrier');
+ }, 'barrier');
low_tooltip.style.display = 'none';
low_span.style.display = 'inherit';
}
@@ -168,11 +168,11 @@ const Tick = (() => {
elementTextContent(indicative_barrier_tooltip, '');
elementTextContent(indicative_high_barrier_tooltip, '');
elementTextContent(indicative_low_barrier_tooltip, '');
- dataManager.set({
+ dataManager.setTrade({
barrier_indicator : null,
barrier_indicator_high: null,
barrier_indicator_low : null,
- }, 'trade', 'barrier');
+ }, 'barrier');
}
};
diff --git a/src/javascript/app/pages/trade/tick_trade.js b/src/javascript/app/pages/trade/tick_trade.js
index 155043387b9..30ee82564bd 100644
--- a/src/javascript/app/pages/trade/tick_trade.js
+++ b/src/javascript/app/pages/trade/tick_trade.js
@@ -167,9 +167,9 @@ const TickDisplay = (() => {
const setBarrierValue = (lbl_barrier) => {
CommonFunctions.elementInnerHtml(CommonFunctions.getElementById('contract_purchase_barrier'), `${lbl_barrier}: ${addComma(contract.barrier, display_decimals)}`);
- dataManager.set({
+ dataManager.setPurchase({
pr_barrier: `${lbl_barrier}: ${addComma(contract.barrier, display_decimals)}`,
- }, 'purchase');
+ });
};
const evaluateContractOutcome = () => {
diff --git a/src/javascript/app/pages/trade/update_values.js b/src/javascript/app/pages/trade/update_values.js
index 7fbdd1ef8ef..b9f8a168920 100644
--- a/src/javascript/app/pages/trade/update_values.js
+++ b/src/javascript/app/pages/trade/update_values.js
@@ -3,8 +3,6 @@ const dataManager = require('../../common/data_manager').default;
const formatMoney = require('../../common/currency').formatMoney;
const localize = require('../../../_common/localize').localize;
-const type_purchase = 'purchase';
-
const updatePurchaseStatus = (final_price, pnl, profit, localized_contract_status) => {
$('#contract_purchase_heading').text(localized_contract_status);
const $payout = $('#contract_purchase_payout');
@@ -14,37 +12,37 @@ const updatePurchaseStatus = (final_price, pnl, profit, localized_contract_statu
$payout.html($('
', { text: localize('Buy price') }).append($('
', { html: formatMoney(currency, Math.abs(pnl)) })));
$cost.html($('
', { text: localize('Final price') }).append($('
', { html: formatMoney(currency, final_price) })));
- dataManager.set({
+ dataManager.setPurchase({
pr_heading : localized_contract_status,
pr_tablePayout : localize('Buy price') ,
pr_tablePayoutValue: formatMoney(currency, Math.abs(pnl)),
pr_tableCost : localize('Final price'),
pr_tableCostValue : formatMoney(currency, final_price),
- }, type_purchase);
+ });
if (!final_price) {
$profit.html($('
', { text: localize('Loss') }).append($('
', { html: formatMoney(currency, pnl) })));
- dataManager.set({
+ dataManager.setPurchase({
pr_tableProfit : localize('Loss'),
pr_tableProfitValue: formatMoney(currency, pnl),
- }, type_purchase);
+ });
} else {
$profit.html($('
', { text: localize('Profit') }).append($('
', { html: formatMoney(currency, profit) })));
updateContractBalance(Client.get('balance'));
- dataManager.set({
+ dataManager.setPurchase({
pr_tableProfit : localize('Profit'),
pr_tableProfitValue: formatMoney(currency, profit),
- }, type_purchase);
+ });
}
};
const updateContractBalance = (balance) => {
$('#contract_purchase_balance').html(localize('Account balance:')).append($('
', { html: formatMoney(Client.get('currency'), balance) }));
- dataManager.set({
+ dataManager.setPurchase({
pr_balance : localize('Account balance:'),
pr_balanceValue: formatMoney(Client.get('currency'), balance),
- }, type_purchase);
+ });
};
module.exports = {
diff --git a/src/javascript/app/pages/user/view_popup/view_popup.js b/src/javascript/app/pages/user/view_popup/view_popup.js
index 7cc396d3373..ea3847b48da 100644
--- a/src/javascript/app/pages/user/view_popup/view_popup.js
+++ b/src/javascript/app/pages/user/view_popup/view_popup.js
@@ -36,7 +36,6 @@ const ViewPopup = (() => {
const wrapper_id = 'sell_content_wrapper';
const hidden_class = 'invisible';
const id_tick_chart = 'tick_chart';
- const type_purchase = 'purchase';
const init = (button, onClose) => {
btn_view = button;
@@ -64,10 +63,10 @@ const ViewPopup = (() => {
getContract();
- dataManager.set({
+ dataManager.setPurchase({
showContractDetailsPopup: true,
cd_description : null,
- }, type_purchase);
+ });
};
const responseContract = (response) => {
@@ -147,21 +146,21 @@ const ViewPopup = (() => {
containerSetText('trade_details_multiplier', formatMoney(contract.currency, multiplier, false, 3, 2));
if (Lookback.isLookback(contract.contract_type)) {
containerSetText('trade_details_payout', Lookback.getFormula(contract.contract_type, formatMoney(contract.currency, multiplier, false, 3, 2)));
- dataManager.set({
+ dataManager.setPurchase({
cd_payout: Lookback.getFormula(contract.contract_type,
formatMoney(contract.currency, multiplier, false, 3, 2)),
- }, type_purchase);
+ });
} else {
containerSetText('trade_details_payout', formatMoney(contract.currency, contract.payout));
- dataManager.set({
+ dataManager.setPurchase({
cd_payout: formatMoney(contract.currency, contract.payout),
- }, type_purchase);
+ });
}
Clock.setExternalTimer(updateTimers);
update();
ViewPopupUI.repositionConfirmation();
- dataManager.set({
+ dataManager.setPurchase({
cd_contractType : ContractTypeDisplay()[contract.contract_type],
cd_purchasePrice: formatMoney(contract.currency, contract.buy_price),
cd_multiplier : formatMoney(contract.currency, multiplier, false, 3, 2),
@@ -170,7 +169,7 @@ const ViewPopup = (() => {
formatMoney(contract.currency, multiplier, false, 3, 2))
: formatMoney(contract.currency, contract.payout),
- }, type_purchase);
+ });
};
const update = async () => {
@@ -181,17 +180,17 @@ const ViewPopup = (() => {
if (is_sold_before_start) {
$('#trade_details_start_date').parent().setVisibility(0);
containerSetText('trade_details_purchase_time', epochToDateTime(contract.purchase_time), '', true);
- dataManager.set({
+ dataManager.setPurchase({
cd_purchaseTime: epochToDateTime(contract.purchase_time),
soldBeforeStart: true,
- }, type_purchase);
+ });
} else {
$('#trade_details_purchase_time').parent().setVisibility(0);
containerSetText('trade_details_start_date', epochToDateTime(contract.date_start), '', true);
- dataManager.set({
+ dataManager.setPurchase({
cd_startTime : epochToDateTime(contract.date_start),
soldBeforeStart: false,
- }, type_purchase);
+ });
}
if (Callputspread.isCallputspread(contract.contract_type)) {
@@ -201,10 +200,10 @@ const ViewPopup = (() => {
if (contract.barrier_count > 1) {
containerSetText('trade_details_barrier', is_sold_before_start ? '-' : addComma(contract.high_barrier), '', true);
containerSetText('trade_details_barrier_low', is_sold_before_start ? '-' : addComma(contract.low_barrier), '', true);
- dataManager.set({
+ dataManager.setPurchase({
cd_barrier : is_sold_before_start ? '-' : addComma(contract.high_barrier),
cd_barrierLow: is_sold_before_start ? '-' : addComma(contract.low_barrier),
- }, type_purchase);
+ });
} else if (contract.barrier) {
const formatted_barrier = addComma(contract.barrier);
const mapping = {
@@ -220,9 +219,9 @@ const ViewPopup = (() => {
'',
true);
- dataManager.set({
+ dataManager.setPurchase({
cd_barrier: contract.entry_tick_time && is_sold_before_start ? '-' : (barrier_prefix + formatted_barrier),
- }, type_purchase);
+ });
if (Reset.isReset(contract.contract_type) && Reset.isNewBarrier(contract.entry_spot, contract.barrier)) {
containerSetText(
@@ -236,10 +235,10 @@ const ViewPopup = (() => {
'',
true);
- dataManager.set({
+ dataManager.setPurchase({
cd_barrier : is_sold_before_start ? '-' : contract.entry_spot_display_value,
cd_barrierReset: contract.entry_tick_time && is_sold_before_start ? '-' : (barrier_prefix + formatted_barrier),
- }, type_purchase);
+ });
}
}
@@ -252,17 +251,17 @@ const ViewPopup = (() => {
if (current_spot) {
containerSetText('trade_details_current_spot > span', current_spot);
- dataManager.set({
+ dataManager.setPurchase({
cd_currentSpot : current_spot,
cd_showCurrentSpot: true,
- }, type_purchase);
+ });
$('#trade_details_current_spot').parent().setVisibility(1);
} else {
$('#trade_details_current_spot').parent().setVisibility(0);
- dataManager.set({
+ dataManager.setPurchase({
cd_showCurrentSpot: false,
- }, type_purchase);
+ });
}
if (current_spot_time) {
@@ -272,9 +271,9 @@ const ViewPopup = (() => {
updateTimers();
}
containerSetText('trade_details_current_date', epochToDateTime(current_spot_time));
- dataManager.set({
+ dataManager.setPurchase({
cd_currentDate: epochToDateTime(current_spot_time),
- }, type_purchase);
+ });
$('#trade_details_current_date').parent().setVisibility(1);
} else {
$('#trade_details_current_date').parent().setVisibility(0);
@@ -283,32 +282,32 @@ const ViewPopup = (() => {
containerSetText('trade_details_ref_id', `${contract.transaction_ids.buy} (${localize('Buy')}) ${contract.transaction_ids.sell ? `
${contract.transaction_ids.sell} (${localize('Sell')})` : ''}`);
containerSetText('trade_details_indicative_price', indicative_price ? formatMoney(contract.currency, indicative_price) : '-');
- dataManager.set({
+ dataManager.setPurchase({
cd_transaction_ids: contract.transaction_ids,
cd_indicativePrice: indicative_price ? formatMoney(contract.currency, indicative_price) : '-',
- }, type_purchase);
+ });
if (is_ended && !contract.sell_price) {
containerSetText('trade_details_profit_loss', localize('Waiting for contract settlement.'), { class: 'pending' });
- dataManager.set({
+ dataManager.setPurchase({
cd_profitLoss : localize('Waiting for contract settlement.'),
cd_profitLossClass: 'pending',
- }, type_purchase);
+ });
} else if (contract.sell_price || contract.bid_price) {
containerSetText('trade_details_profit_loss',
`${formatMoney(contract.currency, contract.profit)}
(${(contract.profit_percentage > 0 ? '+' : '')}${addComma(contract.profit_percentage, 2)}%)`,
{ class: (contract.profit >= 0 ? 'profit' : 'loss') }
);
- dataManager.set({
+ dataManager.setPurchase({
cd_profitLoss : `${formatMoney(contract.currency, contract.profit)}
(${(contract.profit_percentage > 0 ? '+' : '')}${addComma(contract.profit_percentage, 2)}%)`,
cd_profitLossClass: (contract.profit >= 0 ? 'profit' : 'loss'),
- }, type_purchase);
+ });
} else {
containerSetText('trade_details_profit_loss', '-', { class: 'loss' });
- dataManager.set({
+ dataManager.setPurchase({
cd_profitLoss : '-',
cd_profitLossClass: 'loss',
- }, type_purchase);
+ });
}
if (is_multiplier_contract) {
@@ -330,22 +329,22 @@ const ViewPopup = (() => {
if (!is_started) {
containerSetText('trade_details_entry_spot > span', '-');
containerSetText('trade_details_message', localize('Contract has not started yet'));
- dataManager.set({
+ dataManager.setPurchase({
cd_entrySpot: '-',
cd_infoMsg : localize('Contract has not started yet'),
- }, type_purchase);
+ });
} else {
if (contract.entry_spot > 0) {
// only show entry spot if available and contract was not sold before start time
containerSetText('trade_details_entry_spot > span', is_sold_before_start ? '-' : contract.entry_spot_display_value);
- dataManager.set({
+ dataManager.setPurchase({
cd_entrySpot: is_sold_before_start ? '-' : contract.entry_spot_display_value,
- }, type_purchase);
+ });
}
containerSetText('trade_details_message', contract.validation_error && !is_unsupported_contract ? contract.validation_error : ' ');
- dataManager.set({
+ dataManager.setPurchase({
cd_infoMsg: contract.validation_error && !is_unsupported_contract ? contract.validation_error : null,
- }, type_purchase);
+ });
if (is_unsupported_contract) {
const redirect = `
`;
const redirect_close = '';
@@ -404,9 +403,9 @@ const ViewPopup = (() => {
containerSetText('trade_details_live_remaining', '-');
Clock.setExternalTimer(); // stop timer
- dataManager.set({
+ dataManager.setPurchase({
cd_remainingTime: '-',
- }, type_purchase);
+ });
} else {
$container.find('#notice_ongoing').setVisibility(1);
}
@@ -427,18 +426,18 @@ const ViewPopup = (() => {
const updateTimers = () => {
const now = Math.max(Math.floor((window.time || 0) / 1000), contract.current_spot_time || 0);
containerSetText('trade_details_live_date', epochToDateTime(now));
- dataManager.set({
+ dataManager.setPurchase({
cd_currentTime: epochToDateTime(now),
- }, type_purchase);
+ });
Clock.showLocalTimeOnHover('#trade_details_live_date');
const is_started = !contract.is_forward_starting || contract.current_spot_time > contract.date_start;
let remained = contract.date_expiry - now;
if (!is_started || contract.status !== 'open' || remained < 0) {
containerSetText('trade_details_live_remaining', '-');
- dataManager.set({
+ dataManager.setPurchase({
cd_remainingTime: '-',
- }, type_purchase);
+ });
} else {
let days = 0;
const day_seconds = 24 * 60 * 60;
@@ -449,10 +448,10 @@ const ViewPopup = (() => {
containerSetText('trade_details_live_remaining',
(days > 0 ? `${days} ${days > 1 ? localize('days') : localize('day')}, ` : '') + moment((remained) * 1000).utc().format('HH:mm:ss'));
- dataManager.set({
+ dataManager.setPurchase({
cd_remainingTime: (days > 0 ? `${days} ${days > 1 ? localize('days') : localize('day')}, ` : '') + moment((remained) * 1000).utc().format('HH:mm:ss'),
cd_contractEnded: false,
- }, type_purchase);
+ });
}
};
@@ -466,35 +465,35 @@ const ViewPopup = (() => {
containerSetText('trade_details_indicative_label', localize('Payout'));
containerSetText('trade_details_profit_loss_label', localize('Profit/loss'));
- dataManager.set({
+ dataManager.setPurchase({
cd_currentLabel : localize('Contract result'),
cd_indicativeLabel: localize('Payout'),
cd_profitLossLabel: localize('Profit/loss'),
cd_contractEnded : true,
- }, type_purchase);
+ });
if (contract.status === 'sold') {
containerSetText('trade_details_end_label', localize('Exit time'));
containerSetText('trade_details_end_date', epochToDateTime(contract.sell_time), '', true);
- dataManager.set({
+ dataManager.setPurchase({
cd_endLabel: localize('Exit time'),
cd_endDate : epochToDateTime(contract.sell_time),
- }, type_purchase);
+ });
}
if (Lookback.isLookback(contract.contract_type)) {
containerSetText('trade_details_spot_label', localize('Close'));
containerSetText('trade_details_spottime_label', localize('Close time'));
- dataManager.set({
+ dataManager.setPurchase({
cd_spotLabel : localize('Close'),
cd_spotTimeLabel: localize('Close time'),
- }, type_purchase);
+ });
} else {
containerSetText('trade_details_spot_label', localize('Exit spot'));
containerSetText('trade_details_spottime_label', localize('Exit spot time'));
- dataManager.set({
+ dataManager.setPurchase({
cd_spotLabel : localize('Exit spot'),
cd_spotTimeLabel: localize('Exit spot time'),
- }, type_purchase);
+ });
}
// show validation error if contract is not settled yet
@@ -540,14 +539,14 @@ const ViewPopup = (() => {
if (document.getElementById('sell_details_audit')) {
if (show) {
setAuditVisibility(1);
- dataManager.set({
+ dataManager.setPurchase({
cd_showAudit: true,
- }, type_purchase);
+ });
} else {
setAuditButtonsVisibility(1);
- dataManager.set({
+ dataManager.setPurchase({
cd_showAudit: false,
- }, type_purchase);
+ });
}
return;
}
@@ -648,9 +647,9 @@ const ViewPopup = (() => {
});
});
- dataManager.set({
+ dataManager.setPurchase({
[`auditData${type}`]: auditData,
- }, type_purchase);
+ });
resolve();
})
@@ -724,9 +723,9 @@ const ViewPopup = (() => {
if (contract.audit_details.contract_start) {
createAuditHeader(contract_starts.table);
appendAuditLink('trade_details_entry_spot');
- dataManager.set({
+ dataManager.setPurchase({
cd_showAuditBtn: true,
- }, type_purchase);
+ });
} else {
contract_starts.div.remove();
}
@@ -737,9 +736,9 @@ const ViewPopup = (() => {
if (contract.audit_details.contract_end) {
createAuditHeader(contract_ends.table);
appendAuditLink('trade_details_current_spot');
- dataManager.set({
+ dataManager.setPurchase({
cd_showAuditBtn: true,
- }, type_purchase);
+ });
} else {
contract_ends.div.remove();
}
@@ -756,9 +755,9 @@ const ViewPopup = (() => {
createAuditHeader(contract_details.table);
appendAuditLink('trade_details_entry_spot');
appendAuditLink('trade_details_current_spot');
- dataManager.set({
+ dataManager.setPurchase({
cd_showAuditBtn: true,
- }, type_purchase);
+ });
} else {
contract_details.div.remove();
}
@@ -838,7 +837,7 @@ const ViewPopup = (() => {
ViewPopupUI.showInpagePopup(``, '', '#sell_bet_desc');
// Pass all contract details to new quill contract detail popup
// cd_ prefix is Contract Details
- dataManager.set({
+ dataManager.setPurchase({
cd_description : longcode,
cd_showEntrySpot : should_show_entry_spot,
cd_showBarrier : should_show_barrier,
@@ -853,7 +852,7 @@ const ViewPopup = (() => {
cd_spotTimeLabel : localize('Spot time'),
cd_indicativeLabel : localize('Indicative'),
cd_profitLossLabel : localize('Potential profit/loss'),
- }, type_purchase);
+ });
return $(`#${wrapper_id}`);
};
@@ -885,9 +884,9 @@ const ViewPopup = (() => {
$loading.show();
}
} else if ($loading){
- dataManager.set({
+ dataManager.setContract({
hidePageLoader: true,
- }, 'contract');
+ });
if ($loading.length) {
$loading.hide();
@@ -921,17 +920,17 @@ const ViewPopup = (() => {
if (show) {
const is_started = !contract.is_forward_starting || contract.current_spot_time > contract.date_start;
const $sell_wrapper = $container.find('#contract_sell_wrapper');
- dataManager.set({
+ dataManager.setPurchase({
cd_showSell: true,
- }, type_purchase);
+ });
if (is_exist) {
if (!sell_text_updated && is_started) {
addSellNote($sell_wrapper);
$sell_wrapper.find(`#${sell_button_id}`).text(localize('Sell at market'));
- dataManager.set({
+ dataManager.setPurchase({
cd_sellLabel: localize('Sell at market'),
- }, type_purchase);
+ });
}
return;
}
@@ -943,9 +942,9 @@ const ViewPopup = (() => {
addSellNote($sell_wrapper);
}
- dataManager.set({
+ dataManager.setPurchase({
cd_sellLabel: is_started ? localize('Sell at market') : localize('Sell'),
- }, type_purchase);
+ });
$container.find(`#${sell_button_id}`).unbind('click').click((e) => {
e.preventDefault();
@@ -958,9 +957,9 @@ const ViewPopup = (() => {
});
});
} else {
- dataManager.set({
+ dataManager.setPurchase({
cd_showSell: false,
- }, type_purchase);
+ });
if (!is_exist) return;
$container.find(`#${sell_button_id}`).unbind('click');
@@ -974,10 +973,10 @@ const ViewPopup = (() => {
.append($('
', { text: `${localize('Note')}: ` }))
.append($('
', { text: localize('Contract will be sold at the prevailing market price when the request is received by our servers. This price may differ from the indicated price.') })));
- dataManager.set({
+ dataManager.setPurchase({
cd_sellInfo: `
${localize('Note')}: ${localize('Contract will be sold at the prevailing market price when the request is received by our servers. This price may differ from the indicated price.')}`,
cd_showSell: true,
- }, type_purchase);
+ });
};
// ===== Requests & Responses =====
@@ -1001,9 +1000,9 @@ const ViewPopup = (() => {
getContract();
} else {
$container.find('#errMsg').text(response.error.message).setVisibility(1);
- dataManager.set({
+ dataManager.setPurchase({
cd_errorMsg: response.error.message,
- }, type_purchase);
+ });
}
sellSetVisibility(true);
is_sell_clicked = false;
@@ -1018,11 +1017,11 @@ const ViewPopup = (() => {
`${localize('You have sold this contract at [_1] [_2]', [formatted_sell_price, getCurrencyDisplayCode(contract.currency)])}
${localize('Your transaction reference number is [_1]', response.sell.transaction_id)}`);
- dataManager.set({
+ dataManager.setPurchase({
cd_sellMsg: `${localize('You have sold this contract at [_1] [_2]', [formatted_sell_price, getCurrencyDisplayCode(contract.currency)])}
${localize('Your transaction reference number is [_1]', response.sell.transaction_id)}`,
- }, type_purchase);
+ });
}
getContract('no-subscribe');
};