-
Notifications
You must be signed in to change notification settings - Fork 0
adding files #1
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
Open
Noormasarwa
wants to merge
4
commits into
review
Choose a base branch
from
master
base: review
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
adding files #1
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| node_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
|
|
||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" | ||
| integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous"> | ||
| <link rel="stylesheet" href="style.css"> | ||
| <title> | ||
| Whethear App | ||
| </title> | ||
| </head> | ||
|
|
||
| <body> | ||
|
|
||
| <script id="weather-template" type="text/x-handlebars-template"> | ||
| {{#each cities}} | ||
| <div class="card"> | ||
| <div class="city">{{name}}</div> | ||
| <div class="temperature">{{temperature}}<span>℃</span></div> | ||
| <div class="condition">{{condition}}</div> | ||
| <img src="http://openweathermap.org/img/wn/{{conditionPic}}@2x.png"> | ||
| </div> | ||
| {{/each}} | ||
| </script> | ||
|
|
||
| <div id="container"> | ||
| <div id="inputSearchBar"> | ||
| <input type="text" id ="textLine"> | ||
| <i class="fas fa-search" id="searchBtn"></i> | ||
| </div> | ||
| <div id="weatherContainer"></div> | ||
|
|
||
|
|
||
| </div> | ||
| <script src="https://code.jquery.com/jquery-3.3.1.js" crossorigin="anonymous"></script> | ||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.4/handlebars.js"></script> | ||
| <script src="Model.js"></script> | ||
| <script src="View.js"></script> | ||
| <script src="main.js"></script> | ||
|
|
||
| </body> | ||
|
|
||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| const model = new Model() | ||
| const view = new View() | ||
|
|
||
| $(`#searchBtn`).on('click',function(){ | ||
| const cityName = $('#textLine').val() | ||
| if(!cityName) | ||
| return | ||
| model.getCityData(cityName).then(val => view.renderer(val)) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| class Model{ | ||
| constructor(){ | ||
| this.cityData = [] | ||
|
|
||
| } | ||
|
|
||
| async getDataFromDB(){ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would call this instead |
||
| const data = await $.get('/cities') | ||
| return data | ||
| } | ||
|
|
||
| async getCityData(cityName){ | ||
| const data = await $.get(`/city/${cityName}`) | ||
|
|
||
| this.cityData.push({ | ||
| name:data.name, | ||
| temperature:(data.main.temp - 273.15).toFixed(2), | ||
| condition:data.weather[0].main, | ||
| conditionPic:data.weather[0].icon | ||
| }) | ||
| return this.cityData | ||
| } | ||
|
|
||
| async saveCity(cityObj){ | ||
| return $.post('/city',cityObj,function(response){ | ||
| console.log(response) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use async await here. Keep things consistent |
||
| }) | ||
|
|
||
| } | ||
|
|
||
| async removeCity(cityName){ | ||
| return $.ajax({ | ||
| url: `/city/${cityName}`, | ||
| type: 'DELETE', | ||
| success: function(result) { | ||
| console.log(result) | ||
| return this.getDataFromDB() | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
|
|
||
| #container{ | ||
| width : 100%; | ||
| display:grid; | ||
| grid-template-rows: auto auto; | ||
| grid-gap:10%; | ||
| } | ||
|
|
||
| #inputSearchBar{ | ||
| width:100%; | ||
| display:grid; | ||
| grid-template-columns: 10fr 2fr; | ||
| grid-gap:10%; | ||
| } | ||
|
|
||
|
|
||
| #weatherContainer{ | ||
| width:100%; | ||
| display:grid; | ||
| grid-gap:10%; | ||
| size:300%; | ||
| } | ||
|
|
||
| .card{ | ||
| width:100%; | ||
| height: 100%; | ||
| display:grid; | ||
| grid-template-columns: auto auto auto auto; | ||
| background: #1995AD; | ||
| border-radius: 1ch; | ||
| box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); | ||
| justify-items: center; | ||
| align-items: center; | ||
|
|
||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| class View{ | ||
| constructor(){ | ||
| //handlebars init | ||
| this.weatherTemplate = $(`#weather-template`).html() | ||
| this.weatherSelector = Handlebars.compile(this.weatherTemplate); | ||
| } | ||
| renderer(cities){ | ||
| const newHTML = this.weatherSelector({ cities }); | ||
| $('#weatherContainer').empty().append(newHTML); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to use async await if you are using it in the rest of the code