cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

<div class="container text-center">
  <!-- Change F/C and Search-->
  <div class="row" id="hed">
    <!--Button that change from C to F-->
    <div class="col">
      <button id="cel" class="btn btn-link">C</button>
    <!--Made by Ivan Ilievski-->
    <div class="col">
      <a href="http://www.ivanilievski.com/" target="_blank">by Ivan</a>
  <div id="title">
    <h1>Show The Local Weather</h1>
  <!--Wheather today-->
  <div id="tod">
    <h3 id="temp"></h3>


<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>

<!--Popper JS-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>

<!--Latest compiled JavaScript-->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
  color: #fff;

  color: #bdc3c7;

  margin-top: 20px;
  margin-bottom: 20px;
  font-family: sans-serif;

  margin-top: 20px;
  font-size: 30px !important;

  color:#fff !important;
  text-decoration:none !important;

              // Button selected 
var switchSF = document.getElementById("cel");
var itemContainer = document.getElementById("tod");
var currentForm = 'C';
var url = '';
var latitude = 0;
var longitude = 0;
var boolVar = false;
var handleTemp = 0;

//Getting geo location
navigator.geolocation.getCurrentPosition(function(position) {
  //Storing location into variables
  latitude = position.coords.latitude;
  longitude = position.coords.longitude;
  //Assigning the link with custom location
  url = 'https://fcc-weather-api.glitch.me/api/current?lat='+latitude+'&lon=' +longitude;
  //passing the url to AJAX call

// Celsius button
switchSF.addEventListener("click", function(){
  if(currentForm === 'C'){
    currentForm = 'F';
    boolVar = true;
  }else if(currentForm === 'F'){
    currentForm = 'C'; 
    boolVar = false;
  document.getElementById("cel").innerHTML = currentForm;
  document.getElementById("temp").innerHTML = getTemp(boolVar) + " " +  currentForm;

// Loading data just after the pge loading is done
// weatherMapApiRequest();

// Function that perform AJAX
function weatherMapApiRequest(link){
  // Establish connection with the url we specify and then we can send or receive data
  let weatherDataRequest = new XMLHttpRequest();

  //Tell the variable to do something
  // Use GET to specify that you recive data
  weatherDataRequest.open('GET', link);
  // Method where i specify what to happend when the data is loaded
  weatherDataRequest.onload = function(){
    // Save data in variable, but first change from string to json data
    let weatherDataSave = JSON.parse(weatherDataRequest.responseText);
    // Function where data is assigned to html elements
  // Send the request

// Function that assign data to variables and then to html elements
function displayWithHTML(data){
  let cityCountryName = '';
  let temperature = '';
  let description = '';
  let icon = '';
  handleTemp = data.main.temp;
  document.getElementById("temp").innerHTML = handleTemp + " C";
  cityCountryName = "<h3>" + data.name + ", " + data.sys.country + "</h3>";
  description = "<h3>" + data.weather[0].main + "</h3>";
  icon = '<img id="icon" src="' + data.weather[0].icon + '" />';
  itemContainer.insertAdjacentHTML("beforeend", cityCountryName);
  itemContainer.insertAdjacentHTML("beforeend", description);
  itemContainer.insertAdjacentHTML("beforeend", icon);

function getTemp(bVar){
      if(bVar === true){
        return (handleTemp * (9/5)) + 32;;
      }else if(bVar === false){
        return handleTemp;

Loading ..................