Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DTRA] Maryia/FEQ-1465/TrackJS error '404 : GET https://smarttrader.deriv.com/en/user/top_up_virtual_pop_up.html & dialog.html #611

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
4 changes: 2 additions & 2 deletions src/javascript/app/common/attach_dom/dialog.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const showPopup = require('./popup');
const elementInnerHtml = require('../../../_common/common_functions').elementInnerHtml;
const urlFor = require('../../../_common/url').urlFor;

// use this function if you need a simple popup with just a confirm or also a cancel button
// if you need to show a form with some validations, use showPopup() instead
const Dialog = (() => {
const baseDialog = (options, is_alert = false) => (
new Promise((resolve) => {
showPopup({
url : urlFor('dialog'),
// url : urlFor('dialog'), // Unused in pages.js.
// TODO: Uncomment/update popup logic when restoring Dialog feature.
popup_id : options.id,
form_id : '#frm_confirm',
content_id : '#dialog_content',
Expand Down
6 changes: 4 additions & 2 deletions src/javascript/app/common/attach_dom/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const showPopup = (options) => {
}
if (cache[options.url]) {
callback(options);
} else {
} else if (options.url) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how could options.url trigger since its commented out ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need this condition because we don't want the code below to get executed if there is no options.url (e.g. when it's commented out like in our case).

const xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState !== 4 || this.status !== 200) {
Expand All @@ -32,7 +32,9 @@ const showPopup = (options) => {
const callback = (options) => {
const div = createElement('div', { html: cache[options.url] });
const lightbox = createElement('div', { id: options.popup_id, class: 'lightbox' });
lightbox.appendChild(div.querySelector(options.content_id));
const content = div.querySelector(options.content_id);
if (!content) return;
lightbox.appendChild(content);
lightbox.addEventListener('DOMNodeRemoved', (e) => {
if (!popup_queue.length || e.target.className !== 'lightbox') return;
document.body.appendChild(popup_queue.pop()); // show popup in queue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ const TopUpVirtualPopup = (() => {
showPopup({
form_id,
popup_id,
url : urlFor('user/top_up_virtual_pop_up'),
// url : urlFor('user/top_up_virtual_pop_up'), // Unused in pages.js.
// TODO: Uncomment/update popup logic when restoring TopUpVirtualPopup. Removed JSX can be found in PR#592 (4f8e0ff)
content_id : '#top_up',
additionalFunction: () => {
if (message) {
Expand Down
Loading