Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/autonome/ipfs-stackbot. Bot for posting new StackOverflow questions tagged IPFS to IRC
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243// client-side js// run by the browser each time your view template is loaded
console.log('hello world :o');
// our default array of dreamsconst dreams = [ 'Find and count some sheep', 'Climb a really tall mountain', 'Wash the dishes'];
// define variables that reference elements on our pageconst dreamsList = document.getElementById('dreams');const dreamsForm = document.forms[0];const dreamInput = dreamsForm.elements['dream'];
// a helper function that creates a list item for a given dreamconst appendNewDream = function(dream) { const newListItem = document.createElement('li'); newListItem.innerHTML = dream; dreamsList.appendChild(newListItem);}
// iterate through every dream and add it to our pagedreams.forEach( function(dream) { appendNewDream(dream);});
// listen for the form to be submitted and add a new dream when it isdreamsForm.onsubmit = function(event) { // stop our form submission from refreshing the page event.preventDefault();
// get dream value and add it to the list dreams.push(dreamInput.value); appendNewDream(dreamInput.value);
// reset form dreamInput.value = ''; dreamInput.focus();};