Code Monkey home page Code Monkey logo

widget-weather-and-clock's Introduction

widget-weather-and-clock

About

Code developed for demo and educational purposes. Creates one or more widgets inside a web page showing information about the weather and the local time in any place of the world.

Code gets information making requests to third party APIs:

  • From api.openweathermap.org gets weather data, with requests commited via gc-info.herokuapp.com (custom server written in Flask/Python) to bypass Cross Origin blocks.
  • From tech.yandex.com/translate/ gets translated location names (via gc-info.herokuapp.com too).
  • From api.timezonedb.com gets local times (via gc-info.herokuapp.com too).
  • From ipapi.co gets location coordinates that corresponds to client IP, with requests straight from the client.

How to use

User should include in head section a tag like this:

<script src='widget-weather-and-clock.js'></script> 

and in body section one or more tags like this:

<script>new WeatherApiWidget({
  latitude:37.983810, 
  longitude:23.727539, 
  timeRefresh:600000, 
  width:180,
  border:'1px solid darkgreen', 
  background:'cyan', 
  color:'darkgreen'
});</script>

or even like this:

<script>new WeatherApiWidget();</script>

All arguments are optional:

  • Latitude and longitude represent location coordinates on the map, if ommitted the code automatically place them with coordinates that corresponds to client IP.
  • TimeRefresh (in milliseconds) define how frequent data refresh, if ommitted the default value is 900000 (15 minutes).
  • Width, border, background and color corresponds to CSS values (widget's styling is isolated from document general styling).

Live demo here https://giannisclipper.github.io/widget-weather-and-clock/

Athens 2 Feb 2019, Giannis Clipper

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.