GithubHelp home page GithubHelp logo

lshillman / personal-weather-dashboard Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 18 KB

A page that fetches some weather information I care about from 3rd-party APIs.

Home Page: https://lshillman.github.io/personal-weather-dashboard/

CSS 4.22% JavaScript 60.86% HTML 34.92%

personal-weather-dashboard's Introduction

Personal Weather Dashboard

Check out the live dashboard

I like knowing the weather, and I dislike using Google (only half joking about that last part. A company with that much power shouldn't also control the WEATHER!). Anyway, I needed some practice with third-party APIs, so this seemed like a good idea at the time. Search for your city on the page, and your search history is saved in localStorage so you can easily come back to it later.

Technologies used:

  • HTML
  • CSS
  • JS
  • Bootstrap
  • OpenWeather geocoding and One Call APIs

Code snippet

This was maddening: I only wanted a new location to be added to the search history if the user had typed something into the search field and clicked 'search'. Clicking on search history items shouldn't re-add them to the search history! There must be a better way of doing this, but in the end I created a global variable called "clickedHistoryItem" and used that to keep track of user actions.

$('#currentHeader').html(locDisplayName + " (" + moment().format("MM/DD/YYYY") + ") <img id='currentIcon' src='https://openweathermap.org/img/wn/" + data.current.weather[0].icon + "@2x.png' />");

// only add stuff to the search history if the user typed something into the search field and clicked 'search'
if (!clickedHistoryItem) {
    searchHistory.push({name: locDisplayName, latitude: lat, longitude: lon});
    localStorage.setItem('searchHist', JSON.stringify(searchHistory));
    renderSearchHistory();
    citySearch.val("");
}

displayWeatherData(data);

In action

Here's a little clip of searching for locations and revisiting places in the search history:

weather-dashboard.mov

Credits

As always: https://www.w3.org/WAI/

And what would I have done without OpenWeather's API documentation:

License

You are hereby granted no rights. Talk to me if you want to use this for something. And don't use my API key!

personal-weather-dashboard's People

Contributors

lshillman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.