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
achudoz
@achudoz
@Aniculaesei
h1tag
@h1tag
@Aniculaesei you can this website to upload you image postimg
and then copy the "Direct link" you get after uploading the image
Aniculaesei
@Aniculaesei
thank you very much!!!! :)
roeP
@roeP
@achudoz solved it! i use <span> to connect the txt to the img :smile:
achudoz
@achudoz
@roeP hooray!
Zhu Wei
@zhuwei12
@achudoz I find the problem. "https://" in the browser stops me getting data
anyone can help me with this? my button just doesnt work...
Ken Haduch
@khaduch
@FL8Liew - y ou should change the way you are detecting your "starting" value - maybe make it a simple flag because you are storing a jQuery object, and you cannot easily compare objects or are not doing it correctly. Then after you "toggle" the value, make sure to toggle the flag so that the next time you come through it will be giving you the correct information.
FL8Liew
@FL8Liew
@khaduch what do u mean by make it a simple flag??
achudoz
@achudoz
@zhuwei12 good job!
Ken Haduch
@khaduch
@FL8Liew - indicate that the value you are currently displaying is either "C" or "F", then when you toggle it, change it to "F" or "C". That way you can test it. You could also make it true and false, just so your conditional tests are doing the right thing. Just make sure that you always flip the sense of the variable.
Ken Haduch
@khaduch

@FL8Liew - and your calculation for the "F" degrees was not correct. You were using the currentC value, which was a jquery object, so it was getting NaN (or maybe that was in my changed version.) My example change to the code would look like this:

   var starting = 'C';

   var currentC = json1.main.temp + "°C";
   var currentF = json1.main.temp * 9 / 5 + 32 + "°F";
   $('.temperature').text(currentC);
   $(".temperature").click(function() {
    if (starting == 'C') {
     $(".temperature").html(currentF);
     starting = 'F';
    } else if (starting == `F`) {
     $(".temperature").html(currentC);
     starting = 'C';
    }

   });

Probably a change of the variable name from "starting" to "currentUnits" or something else that made sense would be helpful.

FL8Liew
@FL8Liew
@khaduch $('.temperature').text(currentC);<< i dont understand what this part is for...
Ken Haduch
@khaduch
@FL8Liew - setting the actual value in your HTML the first time through, otherwise (at least with my changes) it was not set. You were originally doing this: $(".temperature").html(json1.main.temp + "°C"); and saving that? Although I might have lost the original code with my changes. So in my code, the values are being calculated, then the initial HTML for your temperature class button is being set to that "C" value.
FL8Liew
@FL8Liew
@khaduch i think i kinda understand what u mean, thanks!
CamperBot
@camperbot
fl8liew sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2517 | @khaduch |http://www.freecodecamp.com/khaduch
Prateek Gogia
@reeversedev
@khaduch I am getting the wrong country name now.
Ken Haduch
@khaduch

@FL8Liew - you're welcome. And I like this code a little better:

      var unitsC = true; // starting off with Celsius
      var currentC = json1.main.temp + "°C";
      var currentF = json1.main.temp * 9 / 5 + 32 + "°F";
      $(".temperature").html(currentC); // set the initial value in the button
      $(".temperature").click(function() {
        if (unitsC) {
          $(".temperature").html(currentF); // switch to degreesF
        } else {
          $(".temperature").html(currentC); // switch to degreesC
        }
        unitsC = !unitsC; // invert the flag
      });

Made the flag a true / false, and called it "unitsC" so that true means that the C units are being displayed. Then that is just inverted at the end.

@FL8Liew - even more concise:
      var unitsC = true; // starting off with Celsius
      var currentC = json1.main.temp + "°C";
      var currentF = json1.main.temp * 9 / 5 + 32 + "°F";
      $(".temperature").html(currentC);
      $(".temperature").click(function() {
        $('.temperature').html( unitsC ? currentF : currentC);
        unitsC = !unitsC; // invert the flag
      });
@reeversedev - have you posted your URL? Or your most recent code...
Chris
@bestintown23
Why is my images not fullscreen? https://codepen.io/bestintown23/pen/KaOBJR
FL8Liew
@FL8Liew
@khaduch does that mean whenever I compare 2 variables, it is better to use true and false?
Ken Haduch
@khaduch
@FL8Liew - for something like what I showed, I think that it's better - just simpler. If you are generating something more complex, well, it depends on the situation. But for this case, it leads to a cleaner solution since there is one of two possibilities, so a straight true / false test is just perfect for this. And also for this case, you wouldn't want to read a value from the DOM (getting the actual button text itself, which you might have been doing originally? I forget?) There are many ways to make it work, of course.
Gulsvi
@gulsvi
@khaduch I'm curious why it would be bad to read from the DOM. This seems clean as well, but I still have a lot of JS work to do for FCC...
      $('.temperature').text() === currentC ? $(".temperature").text(currentF) : $(".temperature").text(currentC);
So many ways to get one thing done, it gets confusing :/
Prateek Gogia
@reeversedev

@khaduch $(document).ready(function() {
$.ajax({
type: 'GET',
data: {
id: '2172797',
appid: 'b1b15e88fa797225412429c1c50c122a1'
},
url: 'https://samples.openweathermap.org/data/2.5/weather/',
xhrFields: {
withCredentials: false
},
headers: {},
success: function(data) {

        $("#show-weather").text("Your location latitude is: " + data.coord.lat + " and longitude is: " + data.coord.lon);
        $("#show-country").text(" Your current location is: " + data.sys.name);

    },
    error: function(data) {

        console.log('error');
        console.log(data);
    },
});

});

@khaduch
$(document).ready(function() {
$.ajax({
type: 'GET',
data: {
id: '2172797',
appid: 'b1b15e88fa797225412429c1c50c122a1'
},
url: 'https://samples.openweathermap.org/data/2.5/weather/',
xhrFields: {
withCredentials: false
},
headers: {},
success: function(data) {

        $("#show-weather").text("Your location latitude is: " + data.coord.lat + " and longitude is: " + data.coord.lon);
        $("#show-country").text(" Your current location is: " + data.sys.name);

    },
    error: function(data) {

        console.log('error');
        console.log(data);
    },
});

});

Torian
@toriancrane

Good Morning! I am working on the Build a Random Quote Machine challenge and I am having some difficulty with my buttons. My code can be found here: http://codepen.io/toriancrane/pen/BWBdwJ

Before, when I used to click the New Quote button, it would cycle through the different test quotes I have just fine. Now it is not working, and neither is the Tweet Out one. I didn't change anything in the JavaScript, only added some font awesome icons to my buttons and put them into a grid. Can someone point me in the right direction?

Gulsvi
@gulsvi
@toriancrane One small change needed in your HTML. The ID can't start with a # in your HTML. id="newQuote" not id="#newQuote"
Torian
@toriancrane
@SkyCoder01 thanks!
CamperBot
@camperbot
toriancrane sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 281 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Ritvars
@RitvarsZ

Hello, I'm fixing a wordpress site, need someone with experience of wordpress development. Take a look at this: http://jurmala.sipnet.lv/galerija/foto
I need to make this gallery pretty. All good, just trying to figure out what sets the heigth of the link?

<a class="photo-gallery equal" href="http://jurmala.sipnet.lv/galerijas/1860" style="height: 375px;">                    
    <img width="4320" height="3240" src="http://jurmala.sipnet.lv/wp-content/uploads/DSC02632.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" srcset="https://i1.wp.com/jurmala.sipnet.lv/wp-content/uploads/DSC02632.jpg">
    <h2>Jūrmalnieki viesojas Tukumā</h2>
</a>

See the style="height:375px" on the link? I wonder what sets it.
And also, why does the img tag have soo many attributes(I didn't paste the whole code, see for yourself)?
Can anyone help me, or can someone point me to a place where i could find an answer? Thanks in advance!

Ken Haduch
@khaduch
@SkyCoder01 :point_up: February 22, 2017 12:23 PM - it is just an expensive thing to access the DOM, so it will work, especially for a small-scale project, but if you read about different ways to do this, they recommend that the DOM is not really to be used as a data storage base. https://www.w3.org/wiki/JavaScript_best_practices has some info, I'm sure that you can find opinions on both sides.
Gulsvi
@gulsvi
Thanks @khaduch That makes sense
CamperBot
@camperbot
skycoder01 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2518 | @khaduch |http://www.freecodecamp.com/khaduch
Gulsvi
@gulsvi
I'm trying to better understand these performance things too... seeing very different results in different browsers. Seems they all have their own way of handling JS
iamlisakong
@iamlisakong
I'm still a noob and just finished the first part of html, css, and bootstrap. I'm nervous about building this personal portfolio webpage. Are there any tips and trickes?
Ken Haduch
@khaduch
@reeversedev - sorry that I've been away. If you want the location which, in your data, is "Cairns", you want data.name. If you want the country, then it would be data.sys.country
@iamlisakong - if you want to take a look at something for other examples, even some techniques, try w3schools.com/bootstrap and look for the "Themes" section - they walk through a few examples of creating a page like a portfolio from the ground up. If you are planning to use Bootstrap, that is - but it might be helpful to just walk through their lesson on how to do it anyway?
Prateek Gogia
@reeversedev
No @khaduch . My location is different.
Ken Haduch
@khaduch
@reeversedev - well, the location that is being returned from the data that you are fetching, which is based on an "id" value that you are requesting, is from a fixed site, as I recall, they have ID values for different cities / locations around the world. Your post has this: id: '2172797' which must translate to "Cairns, AU"? I'd have to go to their site to double check that...
Andrew Steller
@stelleaw
Anyone else have trouble getting a JSON call to work with openweathermap?
function getWeather(){
var api_url = 'https://crossorigin.me/http://api.openweathermap.org/data/2.5/weather?lat='+ lati + '&lon=' + long + '&units=imperial&appid=115fea402e58f61e6277a1c2463adb96';
$.getJSON(api_url, formatWeather);
}
Ken Haduch
@khaduch
you have to put your actual latitude and longitude in there, and change your request, to get your actual location, if that's what you're looking for, @reeversedev ?
iamlisakong
@iamlisakong
@khaduch Thanks, I'll look into w3schools.com/bootstrap.
CamperBot
@camperbot
iamlisakong sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles: