From 51ce1fbc5ecd7d4934f7666c6971fcba460e0256 Mon Sep 17 00:00:00 2001 From: Anny Ng Date: Fri, 17 Jun 2016 19:13:21 -0400 Subject: [PATCH 1/2] HW 4 --- js/app.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 js/app.js diff --git a/js/app.js b/js/app.js new file mode 100644 index 0000000..a6d6c89 --- /dev/null +++ b/js/app.js @@ -0,0 +1,39 @@ +$(function(){ + + $("#submit-btn").click(checkSubmit); + + function checkSubmit(){ + var city = $("#city-type").val(); + handleSubmit(city); + } + + function handleSubmit(city) { + //if(!city.trim()) + + event.preventDefault(); + + if(city === "NYC" || city === "New York City" || city === "New York"){ + $("body").attr("class", "nyc"); + } + + else if (city === "San Francisco" || city === "SF" || city === "Bay Area"){ + $("body").attr("class", "sf"); + } + + else if (city === "Los Angeles" || city === "LA" || city === "LAX"){ + $("body").attr("class", "la"); + } + + else if (city === "Austin" || city === "ATX"){ + $("body").attr("class", "austin"); + } + + else if (city === "Sydney" || city === "SYD"){ + $("body").attr("class", "sydney"); + } + + else + alert("Must enter a valid city!"); + } + +}); \ No newline at end of file From bd9dbb3d30ec156f2ee1fa5fcb4834e85daf1d47 Mon Sep 17 00:00:00 2001 From: Anny Ng Date: Fri, 17 Jun 2016 19:40:38 -0400 Subject: [PATCH 2/2] HW4 take2 --- index.html | 1 + js/app.js | 11 +++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 9582524..4514d6f 100644 --- a/index.html +++ b/index.html @@ -26,5 +26,6 @@

CitiPix

+ \ No newline at end of file diff --git a/js/app.js b/js/app.js index a6d6c89..a8a096b 100644 --- a/js/app.js +++ b/js/app.js @@ -1,15 +1,10 @@ $(function(){ - $("#submit-btn").click(checkSubmit); - - function checkSubmit(){ + $("#submit-btn").click(function(event){ + var city = $("#city-type").val(); - handleSubmit(city); - } - function handleSubmit(city) { //if(!city.trim()) - event.preventDefault(); if(city === "NYC" || city === "New York City" || city === "New York"){ @@ -34,6 +29,6 @@ $(function(){ else alert("Must enter a valid city!"); - } + }); }); \ No newline at end of file