From 8e2e335de614662656ed2d4d273cb32404d0a7b1 Mon Sep 17 00:00:00 2001 From: Dylan Graham Date: Sat, 7 Oct 2017 18:07:14 -0400 Subject: [PATCH 1/2] Inital commit --- css/style.css | 19 +++++++++++-------- index.html | 1 + js/app.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 js/app.js diff --git a/css/style.css b/css/style.css index 2a48093..bd99149 100644 --- a/css/style.css +++ b/css/style.css @@ -1,7 +1,7 @@ /* -Project Name: Blank Template -Client: Your Client -Author: Your Name +Project Name: Citipix +Client: FEWD +Author: Dylan Graham Developer @GA in NYC */ @@ -124,19 +124,22 @@ header { } .nyc { - background-image: url(../images/nyc.jpg) + background-image: url(../images/nyc.jpg); } .sf { - background-image: url(../images/sf.jpg) + background-image: url(../images/sf.jpg); } .la { - background-image: url(../images/la.jpg) + background-image: url(../images/la.jpg); } .austin { - background-image: url(../images/austin.jpg) + background-image: url(../images/austin.jpg); } .sydney { - background-image: url(../images/sydney.jpg) + background-image: url(../images/sydney.jpg); +} +.none { + background-image: none; } /****************************************** diff --git a/index.html b/index.html index d17eda2..a0d480b 100644 --- a/index.html +++ b/index.html @@ -27,5 +27,6 @@

CitiPix

+ diff --git a/js/app.js b/js/app.js new file mode 100644 index 0000000..97b4208 --- /dev/null +++ b/js/app.js @@ -0,0 +1,51 @@ +$(function () { + + // Listen for click + $("#submit-btn").click(searchForCity); + + // Searches given input + function searchForCity() { + // Get the input from the search bar + var city = $("#city-type").val(); + console.log("City: ", city); + getCityPic(city); + } + + // Helper function + function getCityPic(searchInput) { + var cleanedSearchInput = searchInput.trim().toLowerCase(); + console.log("seach: ", searchInput); + console.log("clean: ", cleanedSearchInput); + // "New York" or "New York City" or "NYC" make the background of the page nyc.jpg + if (cleanedSearchInput === "new york" || cleanedSearchInput === "new york city" || cleanedSearchInput === "nyc") { + $("body").attr('class', 'nyc'); + } + // "San Francisco" or "SF" or "Bay Area" make the background of the page sf.jpg + else if (cleanedSearchInput === "san francisco" || cleanedSearchInput === "sf" || cleanedSearchInput === "bay area") { + $("body").attr('class', 'sf'); + } + // "Los Angeles" or "LA" or "LAX" make the background of the page la.jpg + else if (cleanedSearchInput === "los angeles" || cleanedSearchInput === "la" || cleanedSearchInput === "lax") { + $("body").attr('class', 'la'); + } + // "Austin" or "ATX" make the background of the page austin.jpg + else if (cleanedSearchInput === "austin" || cleanedSearchInput === "atx") { + $("body").attr('class', 'austin'); + } + // "Sydney" or "SYD" make the background of the page sydney.jpg + else if (cleanedSearchInput === "sydney" || cleanedSearchInput === "syd") { + $("body").attr('class', 'sydney'); + } + // If no match, give an alert, remove background image, and clear the input + else { + alert("Sorry, we don't recognize input: " + searchInput + "\n Try again"); + $("body").removeAttr('class'); + clearInput(); + } + } + + function clearInput() { + $("#city-type").val(""); + } + +}); \ No newline at end of file From 2e8ad280cd1662c5115c4720bfab0b7484f589ef Mon Sep 17 00:00:00 2001 From: Dylan Graham Date: Sat, 7 Oct 2017 19:27:32 -0400 Subject: [PATCH 2/2] Remove none class --- css/style.css | 3 --- 1 file changed, 3 deletions(-) diff --git a/css/style.css b/css/style.css index bd99149..7f3e039 100644 --- a/css/style.css +++ b/css/style.css @@ -138,9 +138,6 @@ header { .sydney { background-image: url(../images/sydney.jpg); } -.none { - background-image: none; -} /****************************************** /* ADDITIONAL STYLES