Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
chore: development fix
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitK-deriv committed Feb 29, 2024
1 parent 6c65036 commit 0a2c45c
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 105 deletions.
4 changes: 2 additions & 2 deletions gatsby-ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export const onRenderBody = ({ setHeadComponents }) => {
const hotjarId = process.env.GATSBY_HOTJAR_ID || ''

setHeadComponents([
<script async key="live-price-script" type="text/javascript" src="/live-price.js" />,

<link
key="preconnect-gstatic"
rel="preconnect"
Expand Down Expand Up @@ -87,5 +85,7 @@ export const onRenderBody = ({ setHeadComponents }) => {
}}
/>
),

<script async key="live-price-script" type="text/javascript" src="/live-price.js" />,
])
}
37 changes: 17 additions & 20 deletions src/features/components/templates/navigation/template/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,25 +191,23 @@ const NavTemplate = ({
}
/>
)}

<Link
url={
sectionItem.data
.url
}
className={
styles.section_title
}
>
<span
className={
styles.section_title
<Localize
translate_text={
sectionItem
.data
.title
}
>
<Localize
translate_text={
sectionItem
.data
.title
}
/>
</span>
/>
</Link>
</div>
),
Expand All @@ -228,14 +226,13 @@ const NavTemplate = ({
key={subItem.id}
className={styles.single_column_item}
>
<Link url={subItem.data.url}>
<span
className={styles.single_column_title}
>
<Localize
translate_text={subItem.data.title}
/>
</span>
<Link
url={subItem.data.url}
className={styles.single_column_title}
>
<Localize
translate_text={subItem.data.title}
/>
</Link>
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
top: 100%;
left: 0;
background-color: #fff;
padding: 10px;
padding: 20px 0 0 10px;
display: flex;
flex-direction: column;
}
Expand All @@ -68,6 +68,7 @@

.submenu_title,
.single_column_title {
inline-size: 100px;
font-weight: bold;
color: #333;
margin-right: 10px; /* add margin between title and icon */
Expand All @@ -94,6 +95,7 @@
}

.section_title {
inline-size: 100px;
font-weight: bold;
color: #333;
margin-right: 10px; /* add margin between title and icon */
Expand Down
164 changes: 82 additions & 82 deletions static/live-price.js
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
var hash = 'fx'

var onTabChange = (newHash) => {
document.getElementById('#' + hash).classList.remove('active-cards')
document.getElementById(hash).classList.remove('active-tab')
window.location.hash = newHash
hash = newHash
document.getElementById('#' + newHash).classList.add('active-cards')
document.getElementById(newHash).classList.add('active-tab')
}
var tabs = ['fx', 'der', 'etfs', 'stk', 'cry', 'com']
setTimeout(() => {
var hash = 'fx'

var onTabChange = (newHash) => {
document.getElementById('#' + hash).classList.remove('active-cards')
document.getElementById(hash).classList.remove('active-tab')
window.location.hash = newHash
hash = newHash
document.getElementById('#' + newHash).classList.add('active-cards')
document.getElementById(newHash).classList.add('active-tab')
}
var tabs = ['fx', 'der', 'etfs', 'stk', 'cry', 'com']
tabs.map((tabId) => {
document.getElementById(tabId).addEventListener('click', function () {
onTabChange(tabId)
})
})
document.getElementById(window.location.hash).classList.add('active-cards')
document.getElementById(window.location.hash.substring(1)).classList.add('active-tab')
}, 500)
document.getElementById('#' + hash).classList.add('active-cards')
document.getElementById(hash).classList.add('active-tab')

var upIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
upIcon.setAttribute('width', '24')
upIcon.setAttribute('height', '24')
upIcon.setAttribute('viewBox', '0 0 24 24')
upIcon.setAttribute('fill', '#00bb86')
upIcon.innerHTML = `<path d="M21.3125 4.34375C21.6875 4.53125 21.8438 4.96875 21.6562 5.34375L18.6562 11.3438C18.5312 11.5938 18.2812 11.75 17.9688 11.75H13.4375L9.65625 19.3438C9.46875 19.7188 9.03125 19.875 8.65625 19.6875L2.65625 16.6875C2.28125 16.5 2.125 16.0625 2.3125 15.6875C2.5 15.3125 2.9375 15.1562 3.3125 15.3438L8.65625 18L12.3125 10.6875C12.4375 10.4375 12.6875 10.25 13 10.25H17.5312L20.3125 4.6875C20.5 4.3125 20.9375 4.15625 21.3125 4.34375Z"/>`
var upIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
upIcon.setAttribute('width', '24')
upIcon.setAttribute('height', '24')
upIcon.setAttribute('viewBox', '0 0 24 24')
upIcon.setAttribute('fill', '#00bb86')
upIcon.innerHTML = `<path d="M21.3125 4.34375C21.6875 4.53125 21.8438 4.96875 21.6562 5.34375L18.6562 11.3438C18.5312 11.5938 18.2812 11.75 17.9688 11.75H13.4375L9.65625 19.3438C9.46875 19.7188 9.03125 19.875 8.65625 19.6875L2.65625 16.6875C2.28125 16.5 2.125 16.0625 2.3125 15.6875C2.5 15.3125 2.9375 15.1562 3.3125 15.3438L8.65625 18L12.3125 10.6875C12.4375 10.4375 12.6875 10.25 13 10.25H17.5312L20.3125 4.6875C20.5 4.3125 20.9375 4.15625 21.3125 4.34375Z"/>`

var downIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
downIcon.setAttribute('width', '24')
downIcon.setAttribute('height', '24')
downIcon.setAttribute('viewBox', '0 0 24 24')
downIcon.setAttribute('fill', '#DE0040')
downIcon.innerHTML = `<path d="M21.3125 19.6875C20.9375 19.875 20.5 19.7188 20.3125 19.3438L17.5312 13.75H13C12.6875 13.75 12.4375 13.5938 12.3125 13.3438L8.65625 6.03125L3.3125 8.6875C2.9375 8.875 2.5 8.71875 2.3125 8.34375C2.125 7.96875 2.28125 7.53125 2.65625 7.34375L8.65625 4.34375C9.03125 4.15625 9.46875 4.3125 9.65625 4.6875L13.4375 12.25H17.9688C18.2812 12.25 18.5312 12.4375 18.6562 12.6875L21.6562 18.6875C21.8438 19.0625 21.6875 19.5 21.3125 19.6875Z"/>`
var downIcon = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
downIcon.setAttribute('width', '24')
downIcon.setAttribute('height', '24')
downIcon.setAttribute('viewBox', '0 0 24 24')
downIcon.setAttribute('fill', '#DE0040')
downIcon.innerHTML = `<path d="M21.3125 19.6875C20.9375 19.875 20.5 19.7188 20.3125 19.3438L17.5312 13.75H13C12.6875 13.75 12.4375 13.5938 12.3125 13.3438L8.65625 6.03125L3.3125 8.6875C2.9375 8.875 2.5 8.71875 2.3125 8.34375C2.125 7.96875 2.28125 7.53125 2.65625 7.34375L8.65625 4.34375C9.03125 4.15625 9.46875 4.3125 9.65625 4.6875L13.4375 12.25H17.9688C18.2812 12.25 18.5312 12.4375 18.6562 12.6875L21.6562 18.6875C21.8438 19.0625 21.6875 19.5 21.3125 19.6875Z"/>`

function fetchData() {
fetch('https://deriv-static-pricingfeedv2.firebaseio.com/.json')
.then((response) => {
if (!response.ok) {
throw new Error('Network response was not ok')
}
return response.json()
})
.then((data) => {
const forexData = data.eu.mkt[hash]
if (!forexData) {
throw new Error('No data available')
}
var chngElements = document.querySelectorAll(`.percent-change.${hash}`)
var bidElements = document.querySelectorAll(`.bid.${hash}`)
var askElements = document.querySelectorAll(`.ask.${hash}`)
var sprdElements = document.querySelectorAll(`.spread.${hash}`)
function fetchData() {
fetch('https://deriv-static-pricingfeedv2.firebaseio.com/.json')
.then((response) => {
if (!response.ok) {
throw new Error('Network response was not ok')
}
return response.json()
})
.then((data) => {
const forexData = data.eu.mkt[hash]
if (!forexData) {
throw new Error('No data available')
}
var chngElements = document.querySelectorAll(`.percent-change.${hash}`)
var bidElements = document.querySelectorAll(`.bid.${hash}`)
var askElements = document.querySelectorAll(`.ask.${hash}`)
var sprdElements = document.querySelectorAll(`.spread.${hash}`)

var iconElements = document.querySelectorAll(`.content-top_change-image.${hash}`)
var iconElements = document.querySelectorAll(`.content-top_change-image.${hash}`)

var index = 0
for (const key in forexData) {
if (index >= 4) break
const currency = forexData[key]
console.log(currency)
var index = 0
for (const key in forexData) {
if (index >= 4) break
const currency = forexData[key]
console.log(currency)

chngElements[index].textContent = currency.chng
bidElements[index].textContent = currency.bid
askElements[index].textContent = currency.ask
chngElements[index].textContent = currency.chng
bidElements[index].textContent = currency.bid
askElements[index].textContent = currency.ask

var change = parseFloat(currency.chng)
if (change > 0) {
chngElements[index].style.color = '#00bb86'
bidElements[index].style.color = '#00bb86'
askElements[index].style.color = '#00bb86'
} else if (change < 0) {
chngElements[index].style.color = '#DE0040'
bidElements[index].style.color = '#DE0040'
askElements[index].style.color = '#DE0040'
} else {
chngElements[index].style.color = '#00bb86'
bidElements[index].style.color = '#00bb86'
askElements[index].style.color = '#00bb86'
}
var change = parseFloat(currency.chng)
if (change > 0) {
chngElements[index].style.color = '#00bb86'
bidElements[index].style.color = '#00bb86'
askElements[index].style.color = '#00bb86'
} else if (change < 0) {
chngElements[index].style.color = '#DE0040'
bidElements[index].style.color = '#DE0040'
askElements[index].style.color = '#DE0040'
} else {
chngElements[index].style.color = '#00bb86'
bidElements[index].style.color = '#00bb86'
askElements[index].style.color = '#00bb86'
}

sprdElements[index].textContent = currency.sprd
sprdElements[index].textContent = currency.sprd

if (index < iconElements.length) {
var icon = change === 0 ? 'remain' : change > 0 ? 'up' : 'down'
var selectedIcon =
icon === 'up' ? upIcon.cloneNode(true) : downIcon.cloneNode(true)
if (index < iconElements.length) {
var icon = change === 0 ? 'remain' : change > 0 ? 'up' : 'down'
var selectedIcon =
icon === 'up' ? upIcon.cloneNode(true) : downIcon.cloneNode(true)

iconElements[index].innerHTML = ''
iconElements[index].appendChild(selectedIcon)
}
iconElements[index].innerHTML = ''
iconElements[index].appendChild(selectedIcon)
}

index++
}
})
.catch((error) => {
console.error('error', error)
})
}
index++
}
})
.catch((error) => {
console.error('error', error)
})
}

setInterval(fetchData, 1000)
setInterval(fetchData, 1000)
}, 500)

0 comments on commit 0a2c45c

Please sign in to comment.