Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
greg
@wearenotgroot
@dshgna your url
@dshgna you need to append in front of it------>http://
@dshgna or else it will throw an error
Dulshani Gunawardhana
@dshgna
@wearenotgroot yes...figured that out. Thanks very much again :D
CamperBot
@camperbot
dshgna sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: dshgna already gave wearenotgroot points
greg
@wearenotgroot
@dshgna YW
Dulshani Gunawardhana
@dshgna
a quick question, is it generally better to use var when declaring a variable in all cases?
Suryavamsi Teneti
@Surya97
@Surya97
Guys I need some info about how to create a thumbnail which on hover should give options for download, view and delete.
can anyone please tell how to do so?
greg
@wearenotgroot
@dshgna if you dont use var then it will interpreted as a global variable
Suryavamsi Teneti
@Surya97
guys can anyone please help me?
greg
@wearenotgroot
@dshgna the problem lies if a function has a similar named variable. then if not handled properly a variable value might be overridden
Dulshani Gunawardhana
@dshgna
@wearenotgroot yes, so its always best to declare as local variables? I was wondering in scenarios like relatively lesser logic like this.
greg
@wearenotgroot
@dshgna yep
@dshgna also it depends on where those variables are located
@dshgna right now your variables are considered global
@dshgna accessible throughout the entire page
Dulshani Gunawardhana
@dshgna
which may be a problem if future functions modify the value right?
greg
@wearenotgroot
yes
@dshgna try and enclosed them in a function and call the function to execute down the page or with $(document).ready(function(){ "your code here" }); <------this way they are all within the scope of that function

@dshgna would look like this

$(document).ready(function(){

  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var lat = position.coords.latitude;
      var lon = position.coords.longitude;
      var key = "6fccda1c30c7f392d44016c2bb3b6519";
      var url = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&units=metric&APPID=" + key;
      $.getJSON(url, function(data) {
        var temp_celsius = data.main.temp;
        var country = data.sys.country;
        var city = data.country;
        var weather = data.weather.main;
        console.log(temp_celsius);
        console.log(country);
        console.log(data);
        console.log(weather);
      });
    });
  }

});

or

function start(){

  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      var lat = position.coords.latitude;
      var lon = position.coords.longitude;
      var key = "6fccda1c30c7f392d44016c2bb3b6519";
      var url = "http://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&units=metric&APPID=" + key;
      $.getJSON(url, function(data) {
        var temp_celsius = data.main.temp;
        var country = data.sys.country;
        var city = data.country;
        var weather = data.weather.main;
        console.log(temp_celsius);
        console.log(country);
        console.log(data);
        console.log(weather);
      });
    });
  }

}

start();
Dulshani Gunawardhana
@dshgna
@wearenotgroot Thanks so much. I'll do so.
CamperBot
@camperbot
dshgna sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: dshgna already gave wearenotgroot points
greg
@wearenotgroot
@dshgna btw if you look at the api docs ------>http://openweathermap.org/current scroll down on the section for Units Format
@dshgna you can set the unit system to use for the returned result. either imperial or metric. else you will standard measurements
Dulshani Gunawardhana
@dshgna
@wearenotgroot yes I already modified my pen for that using metric.
greg
@wearenotgroot
@dshgna ok :+1:
Dulshani Gunawardhana
@dshgna
@wearenotgroot did you use the OWM icons or another set of icons?
greg
@wearenotgroot
@dshgna nope
@dshgna just use the icon from the site
@dshgna you can get the icon name
@dshgna from the data you received

@dshgna then jsut append the url -------->http://openweathermap.org/img/w/'+iconname+'.png'

use this as source in <img scr=>

Dulshani Gunawardhana
@dshgna
@wearenotgroot yes that's what I meant :)
OWM = open weather map
thanks a lot anyway @wearenotgroot :)
CamperBot
@camperbot
dshgna sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:warning: dshgna already gave wearenotgroot points
greg
@wearenotgroot
@dshgna yes i get the context :smile:
Dulshani Gunawardhana
@dshgna
hopefully I'll be able to finish this soon!
greg
@wearenotgroot
@dshgna btw the icon name is inside the weaher property, just an fyi the weather contains an array
Dulshani Gunawardhana
@dshgna
yes, got it :) that was a bit confusing , figuring out the array
greg
@wearenotgroot
@dshgna yep it was because on some area they have weird weather :smile:
@dshgna so the main weather is at index 0
Dulshani Gunawardhana
@dshgna
oh...like two different types of weather :O?
that's funny
greg
@wearenotgroot
@dshgna other than that additional weather conditions are at index after
@dshgna it's mostly fog and mist mixed in the main weather condtions
Dulshani Gunawardhana
@dshgna
@wearenotgroot ah I see. so at which project are you now at?
greg
@wearenotgroot
@dshgna Iam at tic tac toe and simon game