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

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.

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

              
                        <div class="container box-temperature">
            <div class=" displayed-data">
                <p class="temperature"></p>
                <p class="cityg"></p>
            </div>
            <canvas id="particle"></canvas>
            <div class="box-btn">
                <button type="button" id="brick-btn" class="btn"></button>
            </div>
            <button type="button" id="mario-btn" class="btn"></button>
        </div>
        <div class="container box-footer">
            <footer><p>© 2016 ErreC • All Rights Reserved</p></footer>
        </div>
              
            
!

CSS

              
                @import 'https://fonts.googleapis.com/css?family=Press+Start+2P';

html, body {
  height: 100%;
  margin: 0 auto ;
  padding: 0;
  width: 100%;
}

body {
  align-items: center;
  background-color: #F4C52F;
  background-image: url('https://res.cloudinary.com/dt4qeehms/image/upload/v1476716211/weather%20machine/background-transp.png');
  display: flex;
  flex-direction: column;
  background-size: auto 300px;
  background-repeat: repeat-x;
  background-position: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  animation: animatedBackground 75s linear infinite;
}

@keyframes animatedBackground {
  from { background-position: 0; }
  to { background-position: 2250px; }
}

.box-temperature {
  background-size: 100%;
  outline: 4px solid black;
  box-shadow: 18px 22px 35px -6px rgba(0,0,0,0.75);
  min-height: 460px;
  overflow: hidden;
  position: relative;
  height: 460px;
  width: 380px;
  animation-duration: 8s;
  animation-iteration-count: infinite;
  animation-delay: 4s;
}

.box-footer {
  display: block;
  font-size: 80%;
  padding: 25px 0 0 0;
  text-align: end;
}

#brick-btn {
  background-size: 100%;
  margin: 60px 0 0 17px;
  width: 40px !important; /* !important: Fix Jquey effect() resize bug */
  height: 40px !important; /* !important: Fix Jquey effect() bug */
  border-radius: 0;
  position: absolute;
  left: 14px;
  bottom: 245px;
  background-color: transparent;
}

#mario-btn {
  background-size: 100%;
  margin: 60px 0 0 17px;
  width: 35px !important; /* !important: Fix Jquey effect() resize bug */
  height: 67px !important; /* !important: Fix Jquey effect() resize bug */
  border-radius: 0;
  background-image: url('https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/mario-stand.png');
  background-repeat: no-repeat;
  background-color: transparent;
  position: absolute;
  left: 17px;
  bottom: 160px;
}

@media screen and (max-width: 480px) {
  body {
    background-size: auto 200px;
    background-repeat: repeat;
    animation: 0s;
  }

  .box-temperature {
    min-height: calc(0.8*460px);
    height: calc(0.8*460px);
    width: calc(0.8*380px);
  }

  #brick-btn {
    left: calc(0.8*14px);
    bottom: calc(0.8*245px);
    width: calc(0.8*40px) !important; /* !important: Fix Jquey effect() resize bug */
    height: calc(0.8*40px) !important; /* !important: Fix Jquey effect() bug */
  }

  #mario-btn {
    left: calc(0.8*17px);
    bottom: calc(0.8*160px);
    width: calc(0.8*35px) !important; /* !important: Fix Jquey effect() resize bug */
    height: calc(0.8*67px) !important; /* !important: Fix Jquey effect() resize bug */
  }
}


.btn:focus {
  outline: none;
}

.displayed-data {
  font-family: 'Press Start 2P', cursive;
  margin: 10px 0 0 5px;
  position: absolute;
  z-index: 20;
}

.cityg {
  font-size: 20px;
  margin-left: 5px;
  margin-top: -20px;
  max-width: 60%;
  text-shadow: 0 1px #FFF;
  word-spacing: -10px;
}

.temperature {
  font-size: 50px;
  letter-spacing: -2px;
  text-shadow: 2px 1px #FFF;
}

.sun-inner {
  width: 70px;
  height: 70px;
  background-color: transparent;
  animation-name: suntopmov, sunleftmov;
  animation-duration: 1.5s, 1.5s;
  animation-timing-function: linear, linear;
  animation-iteration-count: infinite, infinite;
  animation-direction: alternate;
  position: absolute;
  z-index: 10;
}

@keyframes suntopmov {
  0% {top: 50px; animation-timing-function: ease-out;}
  50% {top: 160px; animation-timing-function: ease-in;}
  100% {top: 50px;}
}

@keyframes sunleftmov {
  0% {left: 25px;}
  100% {left: calc(100% - 70px)}
}

.sun-inner img {
width: 100%;
}

.star {
  width: 40px;
  height: 40px;
  position: absolute;
  right: 60px;
  top: 70px;
}
.star img {
width: 100%;
}

.cloud-rain {
  width: 315px;
  height: 35px;
}

.cloud-rain img {
  width: 100%;
}

#cloud-rain-1 {
  position: absolute;
  right: 40px;
  top: 25px;
  animation-duration: 65s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-name: cloudrainrighttoleft;
}

#cloud-rain-2 {
  position: absolute;
  right: 40px;
  top: 5px;
  animation-duration: 20s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-name: cloudrainlefttoright;
}

#cloud-rain-3 {
  position: absolute;
  right: 40px;
  top: 65px;
  animation-duration: 40s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-name: cloudrainlefttoright;
}

#cloud-rain-4 {
  position: absolute;
  right: 40px;
  top: -15px;
  animation-duration: 15s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-name: cloudrainrighttoleft;
}

@keyframes cloudrainlefttoright {
  0% {left: -315px;}
  100% {left: 100%}
}

@keyframes cloudrainrighttoleft {
  0% {left: 100%}
  100% {left: -315px;}
}

.cloud-double {
  width: 125px;
  height: 60px;
}

.cloud-double img {
  width: 100%;
}

#cloud-double-1 {
  position: absolute;
  right: 40px;
  top: 95px;
  animation-duration: 55s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
    animation-name: clouddoublerighttoleft;
}

#cloud-double-2 {
  position: absolute;
  right: 40px;
  top: 5px;
  animation-duration: 190s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-name: clouddoublelefttoright;
}

#cloud-double-3 {
  position: absolute;
  right: 40px;
  top: 65px;
  animation-duration: 150s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-name: clouddoublelefttoright;
}

#cloud-double-4 {
  position: absolute;
  right: 40px;
  top: -15px;
  animation-duration: 105s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-name: clouddoublerighttoleft;
}

@keyframes clouddoublelefttoright {
  0% {left: -125px;}
  100% {left: 100%}
}

@keyframes clouddoublerighttoleft {
  0% {left: 100%}
  100% {left: -125px;}
}

.cloud-simple {
  width: 83px;
  height: 60px;
}

.cloud-simple img {
  width: 100%;
}

#cloud-simple-1 {
  position: absolute;
  right: 40px;
  top: 85px;
  animation-duration: 20s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-name: cloudsimplerighttoleft;
}

#cloud-simple-2 {
  position: absolute;
  right: 35px;
  top: 20px;
  animation-duration: 40s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-name: cloudsimplelefttoright;
}

@keyframes cloudsimplelefttoright {
  0% {left: -83px;}
  100% {left: 100%}
}

@keyframes cloudsimplerighttoleft {
  0% {left: 100%}
  100% {left: -83px;}
}

.leaf-green {
  width: 40px;
  height: 35px;
}

.leaf-green img {
  width: 100%;
}

#leaf-green-1 {
  position: absolute;
  bottom: 40px;
  animation-duration: 3s, 3s;
  animation-timing-function: linear, linear;
  animation-iteration-count: infinite, infinite;
  animation-name: leaflefttoright, leafbottomtop1;
}

#leaf-green-2 {
  position: absolute;
  bottom: 160px;
  animation-duration: 1.8s, 1.8s;
  animation-timing-function: linear, linear;
  animation-iteration-count: infinite, infinite;
    animation-name: leaflefttoright, leafbottomtop2;
}

#leaf-green-3 {
  position: absolute;
  bottom: 300px;
  animation-duration: 2s, 2s;
  animation-timing-function: linear, linear;
  animation-iteration-count: infinite, infinite;
    animation-name: leaflefttoright, leafbottomtop3;
}

#leaf-green-4 {
  position: absolute;
  bottom: 100px;
  animation-duration: 1.5s, 1.5s;
  animation-timing-function: linear, linear;
  animation-iteration-count: infinite, infinite;
    animation-name: leaflefttoright, leafbottomtop4;
}

@keyframes leaflefttoright {
  0% {left: -40px;}
  100% {left: 100%}
}

@keyframes leafbottomtop1 {
  0% {bottom: 30px; animation-timing-function: ease-out;}
  25% {bottom: 60px; animation-timing-function: ease-in;}
  100% {bottom: 30px; animation-timing-function: ease-out;}
}

@keyframes leafbottomtop2 {
  0% {bottom: 120px; animation-timing-function: ease-out;}
  25% {bottom: 160px; animation-timing-function: ease-in;}
  100% {bottom: 120px; animation-timing-function: ease-out;}
}

@keyframes leafbottomtop3 {
  0% {bottom: 300px; animation-timing-function: ease-out;}
  25% {bottom: 340px; animation-timing-function: ease-in;}
  100% {bottom: 250px; animation-timing-function: ease-out;}
}

@keyframes leafbottomtop4 {
  0% {bottom: 100px; animation-timing-function: ease-out;}
  25% {bottom: 140px; animation-timing-function: ease-in;}
  50% {bottom: 100px; animation-timing-function: ease-out;}
  75% {bottom: 90px; animation-timing-function: ease-in;}
  100% {bottom: 120px; animation-timing-function: ease-out;}
}

@keyframes thundernight {
  0% {background-color: #020514;}
  1% {background-color: white;}
  2% {background-color: #020514;}
  100% {background-color: #020514;}
}

@keyframes thunderday {
  0% {background-color: #1528A2;}
  1% {background-color: white;}
  2% {background-color: #1528A2;}
  100% {background-color: #1528A2;}
}

              
            
!

JS

              
                // Assets are property of Nintendo!
$(document).ready(function(){
  var latitude, longitude, cityNameG;
  var temperature, weatherDescription, cityNameW, sunriseTime, sunsetTime;
  var currentTime = new Date().getTime() / 1000;
  var dayOrNight;

  temperature = 298;
  weatherDescription = 'clear';
  cityNameG = 'New York';
  dayOrNight = true;
  setWeatherBackground(weatherDescription, dayOrNight);
  setTimeout(function() {
    marioJump();
    $("#brick-btn").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716211/weather%20machine/btn-temp-f.png\')');
  }, 500);

  var showCelsius = true;
  $('.btn').on('click', function(){
    marioJump();
    showCelsius = convertTemp(temperature, showCelsius);
  });
  $(".cityg").text(cityNameG);
  $(".temperature").text(Math.round(temperature - 273.15) + "°C");
 
//API call not working on Codepen: This request has been blocked; the content must be served over HTTPS.  

/*  $.getJSON("http://ip-api.com/json/?callback=?", function(data) {
    latitude = data.lat;
    longitude = data.lon;
    cityNameG = data.city;
    console.log("http://api.openweathermap.org/data/2.5/weather?lat=" + latitude + "&lon=" + longitude + "&appid=6521fda1207eae043017412fa964c906");
    $.getJSON("http://api.openweathermap.org/data/2.5/weather?lat=" + latitude + "&lon=" + longitude + "&appid=6521fda1207eae043017412fa964c906", function(data) {
        temperature = data.main.temp; // K
        weatherDescription = data.weather[0].main.toLowerCase();
        cityNameW = data.name;
        sunriseTime = data.sys.sunrise;
        sunsetTime = data.sys.sunset;
        dayOrNight = currentTime > sunriseTime && currentTime < sunsetTime; // day: true, night: false
        $(".temperature").text(Math.round(temperature - 273.15) + "°C");

        setWeatherBackground(weatherDescription, dayOrNight);
        setTimeout(function() {
          marioJump();
          $("#brick-btn").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716211/weather%20machine/btn-temp-f.png\')');
        }, 500);

        var showCelsius = true;
        $('.btn').on('click', function(){
          marioJump();
          showCelsius = convertTemp(temperature, showCelsius);
        });
        $(".cityg").text(cityNameG);
    });
  });
*/
});
  function marioJump() {
  $('#mario-btn').effect( "bounce", {times:1}, 350 );
  $("#mario-btn").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/mario-jump.png\')');
  setTimeout(function() {
    $("#mario-btn").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/mario-stand.png\')');
  }, 350);
  setTimeout(function() {
    $('#brick-btn').effect( "bounce", {times:1}, 350 ).delay(700);
  }, 100);
}

function convertTemp(temperature, showCelsius) {
  if(showCelsius === false) {
  $(".temperature").text(Math.round(temperature - 273.15) + "°C");
  $("#brick-btn").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716211/weather%20machine/btn-temp-f.png\')');
  showCelsius = true;
  }
  else {
    $(".temperature").text(Math.round(temperature * 9 / 5 - 459.67) + "°F");
      $("#brick-btn").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/btn-temp-c.png\')');
      showCelsius = false;
  }
  return showCelsius;
}

// modified from https://codepen.io/otsukatomoya/pen/gbDxF/
function makeSnow() {
  var w = window.innerWidth,
      h = window.innerHeight,
      canvas = document.getElementById('particle'),
      ctx = canvas.getContext('2d'),
      rate = 50,
      arc = 500,
      time,
      count,
      size = 2,
      speed = 10,
      lights = [],
      colors = ['#eee'];

  canvas.setAttribute('width',w);
  canvas.setAttribute('height',h);

  function init() {
    time = 0;
    count = 0;

    for(var i = 0; i < arc; i++) {
      lights[i] = {
        x: Math.ceil(Math.random() * w),
        y: Math.ceil(Math.random() * h),
        toX: Math.random() * 5 + 1,
        toY: Math.random() * 5 + 1,
        c: colors[Math.floor(Math.random()*colors.length)],
        size: Math.random() * size
      };
    }
  }

  function bubble() {
    ctx.clearRect(0,0,w,h);

    for(var i = 0; i < arc; i++) {
      var li = lights[i];

      ctx.beginPath();
      ctx.arc(li.x,li.y,li.size,0,Math.PI*2,false);
      ctx.fillStyle = li.c;
      ctx.fill();

      li.x = li.x + li.toX * (time * 0.05);
      li.y = li.y + li.toY * (time * 0.05);

      if(li.x > w) { li.x = 0; }
      if(li.y > h) { li.y = 0; }
      if(li.x < 0) { li.x = w; }
      if(li.y < 0) { li.y = h; }
    }
    if(time < speed) {
      time++;
    }
    timerID = setTimeout(bubble,1000/rate);
  }
  init();
  bubble();
}

// modified from https://codepen.io/amwill/pen/eNMWBp/
function makeRain(dropSizeFactor, interval) {
  var canvas = document.getElementById('particle');
  var ctx = canvas.getContext('2d');

  var W = window.innerWidth;
  var H = window.innerHeight;
  canvas.width = W;
  canvas.height = H;

  var num = 300;
  var arr = [];
  var speed = 5;

  for (var i = 0; i < num; i++) {
    arr.push({
      x: Math.random() * W,
      y: Math.random() * H,
      w: 1,
      h: Math.random() * dropSizeFactor,
      s: Math.random() * 10 + 3
    });
  }

  function raindrops() {
    ctx.clearRect(0,0,W,H);
    for(var i = 0; i < num; i++) {
      ctx.fillStyle = 'rgba(158, 202, 255, 1.0)';
      ctx.fillRect(arr[i].x, arr[i].y, arr[i].w, arr[i].h);
    }
    makeItRain();
  }

  function makeItRain() {
    for(var i = 0; i< num; i++){
     arr[i].y += arr[i].s;
     if(arr[i].y >= H){
      arr[i].y =- arr[i].h;
     }
    }
  }
  setInterval(raindrops, interval);
}

function setWeatherBackground(description, dayOrNight) {
  switch(description){
    case "thunderstorm":
    cardThunderstorm(dayOrNight);
    break;

    case "drizzle":
    cardDrizzle(dayOrNight);
    break;

    case "rain":
    cardRain(dayOrNight);
    break;

    case "snow":
    cardSnow(dayOrNight);
    break;

    case "atmosphere":
    cardAtmosphere(dayOrNight);
    break;

    case "clear":
    cardClear(dayOrNight);
    break;

    case "clouds":
    cardClouds(dayOrNight);
    break;

    case "extreme":
    cardExtreme(dayOrNight);
    break;

    case "additional":
    cardAdditional(dayOrNight);
    break;
  }
}

function cardClear(dayOrNight) {
  $(".box-temperature").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/card-clear.png\')');
  if (dayOrNight == 1) {
    $(".box-temperature").css('background-color', '#5C94FC');
    $('.displayed-data').after('<div class="sun-wrapper"><div class="sun-inner"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716209/weather%20machine/sun-animated.gif\' ></div></div>');
  }
  else {
    $(".box-temperature").css('background-color', '#090F1B');
    $('.displayed-data').after('<div class="star"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716209/weather%20machine/star.png\' ></div>');
  }
}

function cardThunderstorm(dayOrNight) {
  $(".box-temperature").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/card-clear.png\')');
  $('.displayed-data')
  .after('<div id="cloud-rain-1" class="cloud-rain"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-rain.png\' ></div>',
         '<div id="cloud-rain-2" class="cloud-rain"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-rain.png\' ></div>',
         '<div id="cloud-rain-3" class="cloud-rain"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-rain.png\' ></div>',
         '<div id="cloud-rain-4" class="cloud-rain"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-rain.png\' ></div>');

  if (dayOrNight == 1) {
    $(".box-temperature").css('background-color', '#1528A2');
    $(".box-temperature").css('animation-name', 'thunderday');
  } else {
      $(".box-temperature").css('background-color', '#020514');
      $(".box-temperature").css('animation-name', 'thundernight');
    }

  makeRain(25,5);
}

function cardSnow(dayOrNight) {
  $(".box-temperature").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/card-snow.png\')');
  $('.displayed-data')
  .after('<div id="cloud-simple-1" class="cloud-simple"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-simple.png\' ></div>',
         '<div id="cloud-simple-2" class="cloud-simple"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-simple.png\' ></div>');

  if (dayOrNight == 1) {
    $(".box-temperature").css('background-color', '#2142FF');
  } else {
      $(".box-temperature").css('background-color', '#060E39');
          $('.displayed-data').after('<div class="star"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/star.png\' ></div>');
    }
  makeSnow();
}

function cardClouds(dayOrNight) {
  $(".box-temperature").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/card-clear.png\')');
  $('.displayed-data')
  .after('<div id="cloud-double-1" class="cloud-double"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-double.png\' ></div>',
         '<div id="cloud-double-2" class="cloud-double"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-double.png\' ></div>',
         '<div id="cloud-double-3" class="cloud-double"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-double.png\' ></div>',
         '<div id="cloud-double-4" class="cloud-double"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-double.png\' ></div>',
         '<div id="cloud-simple-1" class="cloud-simple"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-simple.png\' ></div>',
         '<div id="cloud-simple-2" class="cloud-simple"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-simple.png\' ></div>');

  if (dayOrNight == 1) {
    $(".box-temperature").css('background-color', '#5C94FC');
  } else {
      $(".box-temperature").css('background-color', '#090F1B');
    }
}

function cardDrizzle(dayOrNight) {
  $(".box-temperature").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/card-clear.png\')');
  $('.displayed-data').after('<div id="cloud-rain-2" class="cloud-rain"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-rain.png\' ></div>');

  if (dayOrNight == 1) {
    $(".box-temperature").css('background-color', '#1528A2');
  } else {
      $(".box-temperature").css('background-color', '#020514');
    }

  makeRain(5,15);
}

function cardRain(dayOrNight) {
  $(".box-temperature").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/card-clear.png\')');
  $('.displayed-data')
  .after('<div id="cloud-rain-1" class="cloud-rain"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-rain.png\' ></div>',
         '<div id="cloud-rain-2" class="cloud-rain"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-rain.png\' ></div>');

  if (dayOrNight == 1) {
    $(".box-temperature").css('background-color', '#1528A2');
  } else {
      $(".box-temperature").css('background-color', '#020514');
    }

  makeRain(20,10);
}

function cardExtreme(dayOrNight) {
  $(".box-temperature").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/card-clear.png\')');
  $('.displayed-data')
  .after('<div class="leaf-wrapper"><div id="leaf-green-1" class="leaf-green"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/leaf-green.png\' ></div></div>',
         '<div class="leaf-wrapper"><div id="leaf-green-2" class="leaf-green"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/leaf-green.png\' ></div></div>',
         '<div class="leaf-wrapper"><div id="leaf-green-3" class="leaf-green"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/leaf-green.png\' ></div></div>',
         '<div class="leaf-wrapper"><div id="leaf-green-4" class="leaf-green"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/leaf-green.png\' ></div></div>');

  if (dayOrNight == 1) {
    $(".box-temperature").css('background-color', '#5C94FC');
  } else {
      $(".box-temperature").css('background-color', '#090F1B');
    }
}

function cardAdditional(dayOrNight) {
  $(".box-temperature").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/card-clear.png\')');
  $('.displayed-data')
  .after('<div class="leaf-wrapper"><div id="leaf-green-1" class="leaf-green"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/leaf-green.png\' ></div></div>',
         '<div id="cloud-simple-1" class="cloud-simple"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-simple.png\' ></div>',
         '<div id="cloud-simple-2" class="cloud-simple"><img src=\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/cloud-simple.png\' ></div>');

  if (dayOrNight == 1) {
    $(".box-temperature").css('background-color', '#5C94FC');
  } else {
      $(".box-temperature").css('background-color', '#090F1B');
    }
}

function cardAtmosphere(dayOrNight) {
  $(".box-temperature").css('backgroundImage', 'url(\'https://res.cloudinary.com/dt4qeehms/image/upload/v1476716210/weather%20machine/card-clear.png\')');

  if (dayOrNight == 1) {
    $(".box-temperature").css('background-color', '#C6D3D8');
  } else {
      $(".box-temperature").css('background-color', '#828C8F');
    }
}

              
            
!
999px

Console