Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New pages #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions project/html/helpers/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@
<!-- then bootstrap -->
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

<script>var apiKey="<%= process.env.API_KEY %>";</script>

<!-- then our app's own js file -->
<script src="js/main.js"></script>
5 changes: 5 additions & 0 deletions project/html/helpers/navbar.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ul class="nav">
<li class="nav-item"><a class="nav-link" href="/">Home</a></li>
<li class="nav-item"><a class="nav-link" href="/album">Album</a></li>
<li class="nav-item"><a class="nav-link" href="/history">History</a></li>
</ul>
24 changes: 24 additions & 0 deletions project/html/pages/album.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<html lang="en">
<head>
<% include ../helpers/head %>
</head>

<body>
<!-- the classes 'page-header' and 'btn btn-dark' create bootstrap components. -->
<!-- Check out more components here: http://getbootstrap.com/components/ -->
<div class="page-header">
<% include ../helpers/navbar %>


<h1>Album of the Day</h1>
</div>

<p>Click on the button for a surprise.</p>

<button onClick="showPicture()" class="btn btn-dark">Click me</button>

<div id="image"></div>

</body>

</html>
27 changes: 27 additions & 0 deletions project/html/pages/history.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<html lang="en">
<head>
<% include ../helpers/head %>
</head>

<body>
<!-- the classes 'page-header' and 'btn btn-dark' create bootstrap components. -->
<!-- Check out more components here: http://getbootstrap.com/components/ -->
<div class="page-header">
<% include ../helpers/navbar %>

<h1>Scores History</h1>

</div>

<input class="search" type="text" placeholder="Search for a city">
<button type="button" onClick="searchWeather()">Search</button>

<div class="error-message"></div>

<div class ="city"></div>

<div class="temp"></div>

</body>

</html>
4 changes: 2 additions & 2 deletions project/html/pages/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<!-- the classes 'page-header' and 'btn btn-dark' create bootstrap components. -->
<!-- Check out more components here: http://getbootstrap.com/components/ -->
<div class="page-header">

<% include ../helpers/navbar %>

<h1>My Web App</h1>
<h1>Music Salon</h1>
</div>

<p>Click on the button for a surprise.</p>
Expand Down
27 changes: 27 additions & 0 deletions project/js/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
$(document).ready(function(){
getWeather();
})

function getWeather(searchQuery) {
// var url = "https://api.openweathermap.org/data/2.5/weather?q=Boston&APPID="+apiKey; // Need to figure out how to make sure Heroku is storing my API key

var url = "https://api.openweathermap.org/data/2.5/weather?q="+searchQuery+"&units=imperial&APPID=de7c147ddb0ac76a8ca839042b94c47a"

$(".city").text("");
$(".temp").text("");
$(".error-message").text("");

$.ajax(url,{success: function(data){
$(".city").text(data.name);
$(".temp").text(data.main.temp);
// console.log(data); // To view in the console log
}, error: function(error){
$(".error-message").text("An error occurred");
}})
}

function searchWeather() {
var searchQuery = $(".search").val();
getWeather(searchQuery);
}

function showPicture(){
// use jQuery ($ is shorthand) to find the div on the page and then change the html
// 'rounded-circle' is a bootstrap thing! Check out more here: http://getbootstrap.com/css/
Expand Down
9 changes: 9 additions & 0 deletions project/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ app.get('/', function(request, response) {
response.render('pages/index');
});

app.get('/album', function(request, response) {
response.render('pages/album');
});

app.get('/history', function(request, response) {
response.render('pages/history');
});


app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests==2.25.1