Skip to content

Instantly share code, notes, and snippets.

View whatgoal.js
const tableContainer = document.getElementById('tableContainer');
let resultsTableBody = document.createElement('tbody');
for (let i = 0; i < allBoxes.length; i++) {
let row = document.createElement('tr');
for (let j = 0; j < 8; j++) {
let cell = document.createElement('td');
let cellText = document.createTextNode(goalArray[i][j]);
cell.appendChild(cellText);
row.appendChild(cell);
View gif-gallery.js
View ingatlan.js
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`;
}
View react-reel.js
Promise.all([
fetch('/api/movies', {
headers: new Headers({
'ApiKey': 'USER_KEY_2',
}),
}),
fetch('/api/series', {
headers: new Headers({
'ApiKey': 'USER_KEY_2',
}),
View cash-countdown.js
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 });
};
View github-birthday.js
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())
@jsrath
jsrath / telecom.js
Last active November 3, 2018 11:16
View telecom.js
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');
View visual-markup.js
function removeTags() {
const tags = document.querySelectorAll('.css-viz');
tags.forEach((element) => {
element.parentNode.removeChild(element)
});
const all = document.querySelectorAll('*');
all.forEach((element, index) => {
View contacts-keeper.js
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));
}
View budastat.js
const values = data.map(element => element[1]);
const scaleColors = getColor();
let color = d3.scaleLinear()
.domain([d3.min(values), d3.max(values)])
.range(scaleColors);