From c971f42005401f3cad0ae45a0443090214a91b57 Mon Sep 17 00:00:00 2001 From: "Glitch (hello-express)" Date: Mon, 19 Mar 2018 20:52:00 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=A2=F0=9F=95=8C=20Checkpoint=20./publi?= =?UTF-8?q?c/vanilla-client.js:96831/1671=20./public/client.js:96831/210?= =?UTF-8?q?=20./views/index.html:96831/514?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/vanilla-client.js | 51 ++++++++++++++++++++++++++++++++++++++++ views/index.html | 13 +++++----- 2 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 public/vanilla-client.js diff --git a/public/vanilla-client.js b/public/vanilla-client.js new file mode 100644 index 0000000..bdfe715 --- /dev/null +++ b/public/vanilla-client.js @@ -0,0 +1,51 @@ +// client-side js +// run by the browser each time your view template is loaded + +(function(){ + console.log('hello world :o'); + + const dreams = [ + 'Find and count some sheep', + 'Climb a really tall mountain', + 'Wash the dishes' + ]; + + const dreamsList = document.getElementById('dreams'); + const dreamsForm = document.forms[0]; + + dreams.forEach( function(dream) { + const newListItem = document.createElement('li'); + newListItem.innerHTML = dream; + dreamsList.appendChild(newListItem); + }); + + dreamsForm.onsubmit = function(event) { + event.preventDefault(); + + const dream = + }; + +})() + +/* +$(function() { + console.log('hello world :o'); + + $.get('/dreams', function(dreams) { + dreams.forEach(function(dream) { + $('
  • ').text(dream).appendTo('ul#dreams'); + }); + }); + + $('form').submit(function(event) { + event.preventDefault(); + var dream = $('input').val(); + $.post('/dreams?' + $.param({dream: dream}), function() { + $('
  • ').text(dream).appendTo('ul#dreams'); + $('input').val(''); + $('input').focus(); + }); + }); + +}); +*/ \ No newline at end of file diff --git a/views/index.html b/views/index.html index 51d7e5f..b2ba18c 100644 --- a/views/index.html +++ b/views/index.html @@ -29,7 +29,11 @@

    Oh hi,

    Tell me your hopes and dreams:

    - + + +
    @@ -44,11 +48,8 @@ - - - + +