Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html lang="en" >
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- Angular Material style sheet -->
  <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.12/angular-material.min.css">
  <link href="https://fonts.googleapis.com/css?family=Cute+Font" rel="stylesheet">
</head>
<body ng-app="weatherApp" ng-controller="WeatherController" data-ng-init="getLocation()">
  
  <!--------  Today's theme --------->
  <div layout="row" class="theme" layout-align="center center">Day 37: Local Weather App, Day38: Calendar</div>
  
  <!--------  Working area --------->
  <div class="working-area">
      <div ng-click="changeUnit()">
        <h2 layout="row" layout-align="center center">{{ temp }}°{{ unit }} </h2>
      </div>
      <h3 layout="row" layout-align="center center">{{ condition }} </h3>
      <h3 layout="row" layout-align="center center">{{ location }}</h3>
      <h2 layout="row" layout-align="center center">{{ date | date:'EEE d-MMM'}}</h2> 
  </div>
  
  <!--------  Footer --------->
  <div id="footer_container">
    <div layout="row" layout-align="center center"><h3>Youtube tutorial <a href="https://youtu.be/T45Ui4xRzSU" target="_blank"> here!</a></h3></div><br>
    <div layout="row" layout-align="center center">Created by Eleftheria</div>
    <div layout="row" layout-align="center center" class="footer">

        <!-- Linkedin -->
        <a href="https://www.linkedin.com/in/eleftheriabatsou/" target="_blank"><img src="https://image.flaticon.com/icons/svg/39/39714.svg" class="footer_image" alt="linkedin" title="linkedin"></a> ~
        <!-- Codepen -->
        <a href="https://codepen.io/EleftheriaBatsou" target="_blank"><img src="https://image.flaticon.com/icons/svg/51/51767.svg" class="footer_image" alt="codepen" title="codepen"></a> ~
        <!-- Youtube -->
        <a href="https://www.youtube.com/c/EleftheriaBatsou" target="_blank"><img src="https://image.flaticon.com/icons/svg/733/733646.svg" class="footer_image" alt="youtube" title="youtube"></a> ~
        <!-- Twitter -->
        <a href="https://twitter.com/BatsouElef" target="_blank"><img src="https://image.flaticon.com/icons/svg/8/8800.svg" class="footer_image" alt="twitter" title="twitter"></a> ~
        <!-- Github -->
        <a href="https://github.com/EleftheriaBatsou" target="_blank"><img src="https://image.flaticon.com/icons/svg/25/25231.svg" class="footer_image" alt="github" title="github"></a> ~ 
        <!-- Instagram -->
        <a href="https://www.instagram.com/eleftheriabatsou/" target="_blank"><img src="https://image.flaticon.com/icons/svg/69/69366.svg" class="footer_image" alt="instagram" title="instagram"></a> ~
      <!-- Website -->
        <a href="http://www.eleftheriabatsou.com" target="_blank"><img src="https://image.flaticon.com/icons/svg/484/484101.svg" class="footer_image" alt="website" title="website"></a>
   </div>
   </div>

</body>
</html>


              
            
!

CSS

              
                body {
 background-image: linear-gradient(to right bottom, #dc1767, #ac3086, #6f428f, #31457f, #003e60);
  color: white !important;
  font-family: 'Pacifico', cursive; 
}

.theme {
  padding: 32px 0;
  font-family: 'Pacifico', cursive; 
}

h2 {
  color: #ac3086;
  padding: 8px;
}

h3 {
  color: lightcyan;
  padding: 16px;
}

.working-area {
  width: 350px;
  height: 300px;
  margin: 0 auto;
  background-image: linear-gradient(to right bottom, #ff7cb1, #e69ae3, #c3b7ff, #aacfff, #abe1ff);
  padding: 16px;
  border-radius: 8px;
}

#footer_container {
  font-family: 'Pacifico', cursive; 
}
.footer .footer_image {
  height: 24px;
  width:24px;
  text-align: center;
  padding: 4px;
 }

.footer .footer_image:hover,
#footer_container a:hover {
  background-color: lightblue;
}
#footer_container a:link,
#footer_container a:active{
  color: #dc1767;
}

              
            
!

JS

              
                angular.module('weatherApp', ['ngMaterial', 'ngMessages'])

.controller('WeatherController', function($scope, $http, $interval) {
  $scope.unit = "c";
  $scope.condition = "Requires location tracking to load";
  $scope.currentC = 0;
  $scope.currentF = 0;
  $scope.loadedTemp = false;
  
  $scope.getLocation = function() {
    $scope.loadedTemp = false;
      if (navigator.geolocation) {
        const options = {
          enableHighAccuracy: false,
          timeout: 8000,
          maximumAge: 0
        };
        navigator.geolocation.getCurrentPosition($scope.getWeather, handleErrors, options); 
      } else { 
        console.log("Geolocation is not supported by this browser.");
        $scope.condition = "Geolocation is not supported by this browser.";
      }
  }
  
  $scope.getWeather = function(position) {
    const lat = position.coords.latitude;
    const lon = position.coords.longitude;
    $http({
      method : "GET",
      url : "https://api.apixu.com/v1/current.json?key=7a30e71728c84f77b6c152439172608&q=" + lat + ", " + lon
    }).then(function success(response) {
      setTemp(response.data);
      setLocation(response.data);
    });
  }

  function setLocation(data) {
    $scope.condition = data.current.condition.text;
    $scope.date = Date.now();
    $scope.location = data.location.name;
  }

  function setTemp(data) {
    $scope.loadedTemp = true;
    setF(data);
    setC(data);
  }

  function setC(data) {
    const resultC = Math.round(data.current.temp_c,2);
    $scope.temp = resultC;
    $scope.currentC = resultC;
  }

  function setF(data) {
    const resultF = Math.round(data.current.temp_f,2);
    $scope.temp = resultF;
    $scope.currentF = resultF;
  }

  $scope.changeUnit = function() {
    $scope.temp = " ";
    if($scope.unit === "c") {
      $scope.unit = "f";
      $scope.temp = $scope.currentF;
    } else {
      $scope.unit = "c";
      $scope.temp = $scope.currentC;
    }
  }

  $interval($scope.getLocation, 20000);

  function showError(error) {
    console.log(error);
    $scope.condition = error;
  }

  function handleErrors(error) {
    switch(error.code) {
      case error.PERMISSION_DENIED:
        showError("User denied the request for Geolocation.");
        break;
      case error.POSITION_UNAVAILABLE:
        showError("Location information is unavailable.");
        break;
      case error.TIMEOUT:
        showError("The request to get user location timed out.");
        break;
      case error.UNKNOWN_ERROR:
        showError("An unknown error occurred.");
        break;
    }
  }
});

// PLease note that the Javascript code is NOT written by me, 
//but it can be found here: https://codepen.io/danhearn/pen/RVVbQv?editors=0100
              
            
!
999px

Console