Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ <h1>CitiPix</h1>
</div>

<script src="js/jquery-2.1.4.js"></script>
<script src="js/app.js"></script>
</body>
</html>
46 changes: 46 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
$(function(){

// print background based on text entered.
// text must be the name of a city.
// city name has a class matching that city name in css.
// reset background with new submission.

// listen for user clicking 'submit'/submitting text
$("#submit-btn").click(changeBackground);

function changeBackground(event) {

event.preventDefault();

//text entry - basically tells js to read what is in the input box (class of 'city-type')
var city = $("#city-type").val();

//match entry with proper css class (name of city)

if(city === "NYC" || city === "new york city" || city === "new york" || city === "New York" || city === "New York City" || city === "nyc"){

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcooper8190 good look to cover the cover the lower and uppercased values on entry. You could have also used toUpperCase and toLowerCase to have the conditional case match the case of the the inputed values.

$("body").attr("class", "nyc");
}

else if(city === "SF" || city === "san francisco" || city === "bay area" || city === "Bay Area" || city === "San Francisco" || city === "sf"){
$("body").attr("class", "sf");
}

else if(city === "LA" || city === "los angeles" || city === "LAX" || city === "la" || city === "Los Angeles"){
$("body").attr("class", "la");
}

else if(city === "ATX" || city === "austin" || city === "Austin" || city === "atx"){
$("body").attr("class", "austin");
}

else if(city === "SYD" || city === "sydney" || city === "Sydney" || city === "syd"){
$("body").attr("class", "sydney");
}
// changes to default background images if input does not match any other city
else{
$("body").attr("class", "");
}


}
});