Skip to content

Instantly share code, notes, and snippets.

@jsrath
jsrath / telecom.js
Last active November 3, 2018 11:16
const mainNav = document.querySelector('.main-nav');
const menu = document.querySelector('#menu');
toggleMenu = () => {
mainNav.classList.toggle('isDisplayed');
if (menu.getAttribute('src') === './images/menu.svg') {
menu.setAttribute('src', './images/menu-purple.svg');
} else {
menu.setAttribute('src', './images/menu.svg');
updateExpiry = () => {
let today = new Date();
const options = { day: 'numeric', month: 'long', year: 'numeric' };
today.setDate(today.getDate() + this.state.daysLeft);
today = today.toLocaleDateString('en-GB', options);
this.setState({ expiry: today });
};
Promise.all([
fetch('/api/movies', {
headers: new Headers({
'ApiKey': 'USER_KEY_2',
}),
}),
fetch('/api/series', {
headers: new Headers({
'ApiKey': 'USER_KEY_2',
}),
getCartQuantity = () => {
this.getTotalPrice();
const updatedCart = [...this.state.cart];
let quant = [];
updatedCart.forEach(element => {
quant.push(element.quantity);
});
sortLetters() {
this.dataService.contacts[0].forEach(contact => {
this.letters.push(contact.name.toUpperCase().slice(0, 1));
});
this.letters = this.letters.filter( (elem, index, self) => index === self.indexOf(elem));
}
async function getCurrencies(url) {
await fetch(url)
.then(result => result.json())
.then(result => sortCurrencies(result))
.then(result => setOptions(result));
}
for (let i = 0; i < placeLinks.length; i++) {
placeLinks[i].addEventListener('click', function (event) {
let li = document.createElement('li');
li.innerHTML = event.target.innerHTML;
selectedOptions.appendChild(li);
});
selectedOptions.style.left = `${search.getBoundingClientRect().left + 5}px`;
selectedOptions.style.top = `${search.getBoundingClientRect().bottom - 40 + this.pageYOffset}px`;
selectedOptions.style.width = `${search.getBoundingClientRect().width - 2}px`;
}
function removeTags() {
const tags = document.querySelectorAll('.css-viz');
tags.forEach((element) => {
element.parentNode.removeChild(element)
});
const all = document.querySelectorAll('*');
all.forEach((element, index) => {
async function getData(event) {
event.preventDefault();
document.querySelector('.output').classList.add('visible');
let createdDate;
let data = [];
const user = document.getElementById('username').value;
await fetch(`https://api.github.com/users/${user}`)
.then(response => response.json())