Skip to content

Commit

Permalink
Merge pull request #20 from eduard-deriv/eduard-deriv-footer-changes
Browse files Browse the repository at this point in the history
feat: move footer and hide/show login into github
  • Loading branch information
eduard-deriv authored Jun 25, 2024
2 parents a40f466 + aaabb2a commit 4a4071d
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 0 deletions.
84 changes: 84 additions & 0 deletions src/js/footer/footer/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
export const hideElems = [
{
id: 'appgallery',
selectors: [
'.footer_banner-badge.gallery.w-inline-block',
'.app-download_link-wrapper.appgallery.w-inline-block',
],
countries: [
"af", "al", "dz", "ad", "ao", "am", "bh", "bd", "bj", "bo", "ba", "bw", "br", "bn", "bf", "bi", "kh", "cm", "cv", "cf", "td", "km", "cg", "ck", "dj", "eg", "gq", "er", "et", "fo", "fj", "pf", "ga", "gm", "gh", "gi", "gl", "gn", "gw", "is", "in", "id", "iq", "jo", "ke", "kr", "kw", "lb", "ls", "lr", "ly", "li", "mo", "mg", "mw", "my", "mv", "ml", "mr", "mu", "yt", "mx", "md", "mc", "mn", "me", "ma", "mz", "mm", "na", "nr", "np", "nz", "ne", "ng", "no", "om", "pk", "ps", "pg", "pe", "ph", "qa", "re", "rw", "sm", "st", "sa", "sn", "rs", "sc", "sl", "sg", "sb", "so", "ss", "lk", "ch", "tw", "tj", "tz", "th", "tg", "to", "tn", "tr", "tm", "ug", "ua", "ae", "uz", "ye", "zm", "zw", "bt", "sz"
],
},
{
id: 'googlePlay',
selectors: [
'.footer_banner-badge.google.w-inline-block',
'.app-download_link-wrapper.google.w-inline-block',
],
countries: ["au", "at", "be", "bg", "ca", "hr", "cy", "cz", "dk", "ee", "fi", "fr", "de", "gi", "gr", "va", "hk", "hu", "is", "ir", "ie", "il", "it", "lv", "li", "lt", "lu", "mt", "mc", "nl", "nz", "pl", "pt", "ro", "sk", "si", "es", "se", "ch", "tr", "gb", "us", "vu"],
},
{
id: 'appstoreAndGallery',
selectors: [
'.footer_banner-badge.store.w-inline-block',
'.footer_banner-badge.gallery.w-inline-block',
'.app-download_link-wrapper.appstore.w-inline-block',
'.app-download_link-wrapper.appgallery.w-inline-block',
],
countries: ["aq", "bv", "io", "cx", "cc", "cw", "fk", "tf", "gg", "hm", "im", "je", "ki", "nu", "nf", "pn", "bq", "sh", "vc", "gs", "tl", "tk", "um", "eh"],
},
{
id: 'appstore',
selectors: [
'.footer_banner-badge.store.w-inline-block',
'.app-download_link-wrapper.appstore.w-inline-block',
],
countries: [
"au", "at", "be", "bg", "ca", "hr", "cy", "cz", "dk", "ee", "fi", "fr", "de", "gr", "hk", "hu", "ie", "il", "it", "jp", "la", "lv", "lt", "lu", "mt", "nl", "pl", "pt", "ro", "sk", "si", "es", "se", "gb", "us", "vu"
],
},
{
id: 'p2p',
selectors: [
'#p2payment.accordion_toggle-block',
'#p2component.section_dp2p',
'#card_block_p2p.help_category',
],
countries: [
"as", "au", "at", "be", "bg", "ca", "hr", "cy", "cz", "dk", "ee", "fi", "fr", "gr", "gu", "gg", "hk", "hu", "ir", "ie", "im", "il", "it", "je", "ng", "mm", "sy", "kp", "lv", "lt", "lu", "my", "mt", "nl", "nz", "mp", "py", "pl", "pt", "pr", "ro", "rw", "sk", "si", "es", "se", "ae", "gb", "us", "um", "vu", "vi", "ky", "cu", "de"]
},
{
id: 'w-dyn-item-p2p',
selectors: [
'div.w-dyn-item',
],
countries: [
"as", "au", "at", "be", "bg", "ca", "hr", "cy", "cz", "dk", "ee", "fi", "fr", "gr", "gu", "gg", "hk", "hu", "ir", "ie", "im", "il", "it", "je", "ng", "mm", "sy", "kp", "lv", "lt", "lu", "my", "mt", "nl", "nz", "mp", "py", "pl", "pt", "pr", "ro", "rw", "sk", "si", "es", "se", "ae", "gb", "us", "um", "vu", "vi", "ky", "cu", "de"]
},
{
id: 'hideRow',
selectors: [
'.footer_social-icons',
'.footer_text.w-richtext',
'.footer_risk-warning.w-richtext',
],
countries: ["br", "uy", "lk", "ch", "za", "ec"],
},
{
id: 'hideDiel',
selectors: [
'.diel',
],
countries: ["br", "uy", "lk", "ch", "za", "ec"],
},
];

export const showElems = [
{
id: 'showElems',
selectors: [
'.banner_disclaimer',
],
countries: ["br", "uy", "lk", "ch", "za", "ec"]
},
];
57 changes: 57 additions & 0 deletions src/js/footer/footer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { hideElems, showElems} from "./data.js";

hideElems.forEach(array => {
const shouldHide = array.id === 'hideDiel'
? !array.countries.includes(clientsCountry)
: array.countries.includes(clientsCountry);

if (array.id === 'hideDiel') {
document.querySelector('.footer_social-icons.diel').style.display = 'flex';
}

if (clientsCountry && shouldHide) {
array.selectors.forEach(selectorString => {
const selectors = document.querySelectorAll(selectorString);
selectors.forEach(selector => {
if (selector) {
if (array.id === 'w-dyn-item-p2p') {
const nestedElement = selector.querySelector('#card_block_p2p.help_category');
if (nestedElement) {
selector.style.display = "none";
}
} else {
selector.style.display = "none";
}
}
});
});
}
});
console.log('worked');
showElems.forEach(array => {
if (clientsCountry && array.countries.includes(clientsCountry)) {
array.selectors.forEach(selectorString => {
const selectors = document.querySelectorAll(selectorString);
selectors.forEach(selector => {
if (selector) {
if(selectorString === '.banner_disclaimer'){
selector.classList.remove('hide-element')
}
else {
selector.style.display = "block";
}
}
});
});
} else {
array.selectors.forEach(selectorString => {
const selectors = document.querySelectorAll(selectorString);
selectors.forEach(selector => {

if (selector) {
selectorString === '.banner_disclaimer' ? selector.classList.add('hide-element'): selector.style.display = "none";
}
});
});
}
});
1 change: 1 addition & 0 deletions src/js/footer/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// All the footer js files should be imported and exported from here
import './helper';
import './footer/index.js';

0 comments on commit 4a4071d

Please sign in to comment.