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
Ghost
@ghost~55a04b725e0d51bd787af54c
I need some help fixing some jQuery
When I change the speed of the rotation, it doesn't occur immediately, but after 30seconds (1 full normal rotation).
How can I change this?
Here is the pen: https://codepen.io/Refath/pen/zdeWxa?editors=1010
Any help is appreciated!
Tom
@moT01
what's the problem
changing the css, .parent - animation not work?
rafaelmonroy
@rafaelmonroy
@gothamknight
$(document).ready(function (){

  function getWeather(position) {

      var lat = position.coords.latitude;
      var long = position.coords.longitude;

      $.ajax({
        type:'GET',
        url:'https://maps.googleapis.com/maps/api/geocode/json?latlng='+lat+','+long+'&key=AIzaSyCwOc9_sxzQyW-U96Eg_2kiLsfwRxhkBf0',
        success: function(location){
          var city = location.results[0].address_components[2].long_name
          $('#city').text(city)
        }
      });
        var celcius = Math.floor(weatherInfo.main.temp)
        var farenheit = Math.floor((1.8 * celcius) + 32)

      $.ajax({
        type:'GET',
        url:'https://fcc-weather-api.glitch.me/api/current?lat='+lat+'&lon='+long,
        success: function(weatherInfo){
          //var celcius = Math.floor(weatherInfo.main.temp)
          //var farenheit = Math.floor((1.8 * celcius) + 32) 
          var icon = '<img src='+ weatherInfo.weather[0].icon+'>'
          $('#weather').text(celcius+' C')
          $('#icon').html(icon) 
        },   
        error: function (){
          alert('weather API not responding')
        }

      });

  }

  function getLocation() {

      if(navigator.geolocation){
        navigator.geolocation.getCurrentPosition(getWeather);
      } else {
        alert('your browser does not support Geolocation')
        }
  }

  getLocation();

});
iso
@iso1048
@rafaelmonroy try declaring the variables outside the ajax call, then assigning the values to the variables inside success function of the ajax call.
rafaelmonroy
@rafaelmonroy
@gothamknight ohh ok, so just leave them as blank outside the call and declare the value inside the call?
iso
@iso1048

@rafaelmonroy outside the ajax call (declaration of variables):

var c;
var f;

inside the success function of the ajax call (assignment of the declared variables):

c = Math.floor(weatherInfo.main.temp);
f = Math.floor((1.8 * c) + 32);
rafaelmonroy
@rafaelmonroy
@gothamknight oh snap, didn't even know that was possible, let me try it out
rafaelmonroy
@rafaelmonroy
@gothamknight I tried console.log(celcius) returns as undefined
$(document).ready(function (){

  function getWeather(position) {

    var lat = position.coords.latitude;
    var long = position.coords.longitude;

    $.ajax({
      type:'GET',
      url:'https://maps.googleapis.com/maps/api/geocode/json?latlng='+lat+','+long+'&key=AIzaSyCwOc9_sxzQyW-U96Eg_2kiLsfwRxhkBf0',
      success: function(location){
        var city = location.results[0].address_components[2].long_name
        $('#city').text(city)
      }
    });

    var celcius;
    var farenheit;

    $.ajax({
      type:'GET',
      url:'https://fcc-weather-api.glitch.me/api/current?lat='+lat+'&lon='+long,
      success: function(weatherInfo){
        celcius = Math.floor(weatherInfo.main.temp)
        farenheit = Math.floor((1.8 * celcius) + 32) 
        var icon = '<img src='+ weatherInfo.weather[0].icon+'>'
        $('#weather').text(celcius+' C')
        $('#icon').html(icon) 
      },   
      error: function (){
        alert('weather API not responding')
      }
    });

    console.log(celcius)

  };

  function getLocation() {

      if(navigator.geolocation){
        navigator.geolocation.getCurrentPosition(getWeather);
      } else {
        alert('your browser does not support Geolocation')
        }
  }

  getLocation();

});
iso
@iso1048
@rafaelmonroy are you working on codepen?
rafaelmonroy
@rafaelmonroy
@gothamknight yeah
aRtoo
@artoodeeto
yow fam. i have this regex ^1?[- .]?\(?\d{3}\)?[- .]\d{3}[- .]\d{4}
its returning me some of the true except this
5555555555 should return true.
(555)555-5555 should return true
1(555)555-5555 should return true
and its returning me this false values.
555)-555-5555 should return false.
(555-555-5555 should return false.
trying to add \s? between the square brackets but nothing happens. any idea fam?
iso
@iso1048

@rafaelmonroy oh ok. What I did in my weather app was store the temperatures inside an element using the jquery .data() function (https://api.jquery.com/data/) - do this inside the success function of the ajax call.

$('#weather').data({
          f: farenheit,
          c: celcius
        });

try using the above after the variables are assigned. Then outside the success function, console.log this: $('#weather').data() to see the object.
hopefully that works. sorry for taking a long time to reply.

legendinraze
@legendinraze
how do I seperate my links and put them next to eachother? https://codepen.io/manny45/pen/GvPypQ?editors=1100
rafaelmonroy
@rafaelmonroy
@gothamknight no worries, thanks for me helping out. Im going to give that a shot
CamperBot
@camperbot
rafaelmonroy sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 413 | @gothamknight |http://www.freecodecamp.com/gothamknight
iso
@iso1048
@legendinraze try
.nav-pills{
  font-family:lobster;
  font-size:2.0em;
  list-style-type: none;
}
.nav-pills li {
  display: inline-block;
}
@rafaelmonroy awesome. then in your button function you can switch between accessing the temperatures inside that stored object.
legendinraze
@legendinraze
thx @gothamknight
didnt work
iso
@iso1048
@legendinraze are you sure?
Mercy Manrique
@mers89
Do we need to add a key to use the twitch api. I didn't use it and I got this message on console not sure if its related: "Channel identifier '\'+following[i]+\'' is in an invalid format"
iso
@iso1048
@mers89 you should not need to add key if you are using the api provided by fCC (to my understanding)
Mercy Manrique
@mers89
@gothamknight https://codepen.io/mers89/pen/RZeeLW?editors=0002 im referencing line 30
rafaelmonroy
@rafaelmonroy
@gothamknight I added the data inside the success function but when I console.log($('#weather').data()) it returns Object {}
Mercy Manrique
@mers89
@gothamknight if you check the console it says it is invalid format as to the api
@gothamknight eventually I wanted to be able to pass this code but not until I get the api to work $.getJSON(url2).done(function(data3){
var logo;
var status;
var name;
if (data3.error){
logo= "https://media.istockphoto.com/vectors/error-404-vector-id538038858";
name = data3.message;
status= data3.error;
$("#followerInfo").prepend("div class = 'row'>" | "<div class='col-md-4'>" | "img src='" | logo | "'>"
+
"</div>" + "<div class='col-md-4'>" + data2.message + "</div>" + "<div class='col-md-4'>" + status + "</div> </div>");
iso
@iso1048
@mers89 'https://wind-bow.glitch.me/twitch-api/channels/'+following[i]+'?callback=?' it is a matter of using constant quote marks: 'test' + variable + 'test' NOT 'test" + variable + "test' the former is concatenating the variable into the string
the latter is a continuous string
@rafaelmonroy try clicking on the arrow next to the object in the console (on the left of the {})
Mercy Manrique
@mers89
thank you @gothamknight you're awesome!
CamperBot
@camperbot
mers89 sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 414 | @gothamknight |http://www.freecodecamp.com/gothamknight
iso
@iso1048
@mers89 no worries. haha.
rafaelmonroy
@rafaelmonroy
@gothamknight they don't have that on the codepen console lol when I inspect through google chrome its still blank.. :/
@gothamknight
$(document).ready(function (){

  function getWeather(position) {

    var lat = position.coords.latitude;
    var long = position.coords.longitude;

    $.ajax({
      type:'GET',
      url:'https://maps.googleapis.com/maps/api/geocode/json?latlng='+lat+','+long+'&key=AIzaSyCwOc9_sxzQyW-U96Eg_2kiLsfwRxhkBf0',
      success: function(location){
        var city = location.results[0].address_components[2].long_name
        $('#city').text(city)
      }
    });

    $.ajax({
      type:'GET',
      url:'https://fcc-weather-api.glitch.me/api/current?lat='+lat+'&lon='+long,
      success: function(weatherInfo){
        var celcius = Math.floor(weatherInfo.main.temp)
        var fahrenheit = Math.floor((1.8 * celcius) + 32)
        var icon = '<img src='+ weatherInfo.weather[0].icon+'>'
        $('#weather').text(fahrenheit+' F')
        $('#icon').html(icon) 
        $('#weather').data({
          f: fahrenheit,
          c: celcius
        });
      },   
      error: function (){
        alert('weather API not responding')
      }
    });

    console.log($('#weather').data())

  };

  function getLocation() {

      if(navigator.geolocation){
        navigator.geolocation.getCurrentPosition(getWeather);
      } else {
        alert('your browser does not support Geolocation')
        }
  }

  getLocation();

});
iso
@iso1048
@rafaelmonroy could you link the pen again bro
rafaelmonroy
@rafaelmonroy
iso
@iso1048
@rafaelmonroy you sure bro. this is what i got:
test.gif
Long Nguyen
@longnt80
@rafaelmonroy ^ same here
rafaelmonroy
@rafaelmonroy
@longnt80 @gothamknight really? wtf, is that under the console window?
Long Nguyen
@longnt80
@rafaelmonroy devtool
if you're using Windows, hit Ctrl+Shift+I
iso
@iso1048
or F12
rafaelmonroy
@rafaelmonroy
@longnt80 @gothamknight ah man, gotta run, I'll check it out at computer at home. thanks! brb