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
JiaLe Guo
@gabygoole
In ikipedia
In Wikipedia Viewer´╝î what kind of thing should I learn?
Adi2Point0
@Adi2Point0
@Rakesh18754
var jsonData = [];

var keysToDrop = ['tagValueName', 'tagValueId'];

jsonArray.forEach(function(json){
  Object.keys(json).forEach(function(key){
    if(keysToDrop.indexOf(key) === -1){
      jsonData.push({
        tagValueName : json.tagValueName,
        type : key,
        count : json[key]
      })
    }
  });
});
tommy
@tommygebru
@khaduch yeah is it possible to get the text? or is that not available through the api?
Thomas Swatland
@swatbone85
Hi all, I'm trying to create a button that toggles through 2 alternating options. This is my code: $("h3 a").on("click", function() { counter += 1; console.log(counter % 2); /* switch(counter % 2) { case 0: $("h3").html(Math.round(data.main.temp * 1.8 + 32) + "<a href='#'>&#176F</a>"); case 1: $("h3").html(Math.round(data.main.temp) + "<a id='temp' href='#'>&#176C</a>"); } */ });
Thing is, the code inside the comments only runs once. Any pointers?
$("h3 a").on("click", function() {
          counter += 1;
          console.log(counter % 2);
          /*
          switch(counter % 2) {
            case 0:
            $("h3").html(Math.round(data.main.temp * 1.8 + 32) + "<a href='#'>&#176F</a>");
            case 1:
            $("h3").html(Math.round(data.main.temp) + "<a id='temp' href='#'>&#176C</a>");
          }
          */
        });
Thomas Swatland
@swatbone85
Anyone?
Abhishek Kumar
@Mr-Kumar-Abhishek
@swatbone85 I don't get what are you trying to do but..... why aren't there break; after switch cases ??
@swatbone85 uh.. nevermind seems those are commented out ... hard to fiqure via IRC
@swatbone85 oh, so you were asking about commented out code lol
@swatbone85 so my question remains ~
Thomas Swatland
@swatbone85
@Mr-Kumar-Abhishek Yes, because the console.log works fine, but when I remove the comments the code only runs once...
Abhishek Kumar
@Mr-Kumar-Abhishek
@swatbone85 so my question remains why not using break; after switch cases ??
Thomas Swatland
@swatbone85
@Mr-Kumar-Abhishek Because I forgot them, and added them after. Thanks for that! The code still only runs once though...
CamperBot
@camperbot
swatbone85 sends brownie points to @mr-kumar-abhishek :sparkles: :thumbsup: :sparkles:
:cookie: 413 | @mr-kumar-abhishek |http://www.freecodecamp.com/mr-kumar-abhishek
Abhishek Kumar
@Mr-Kumar-Abhishek
@swatbone85 hmm... okay so after breaks what is the error here...
@swatbone85 is this over codepen ??
Thomas Swatland
@swatbone85
@Mr-Kumar-Abhishek I'm working on the local weather challenge. I'm trying to alternate between C and F, so the button needs to toggle between the two. No this is pasted from Atom
Abhishek Kumar
@Mr-Kumar-Abhishek
@swatbone85 i see.. let me fiddle it around https://jsfiddle.net/ then..
tommy
@tommygebru
is it possible to make a getjson call within another getjson call?
Thomas Swatland
@swatbone85
@tommygebru I put a .ajax inside the success function of another .ajax and it worked fine!
@tommygebru So I reckon the same should work for getJSON :)
tommy
@tommygebru
ok :smile:
Adi2Point0
@Adi2Point0
@tommygebru : Yes you can.
tommy
@tommygebru
im really confused right now though
regStreamers.map(function(val) {
$.getJSON(twitchAPI + streams + val + callback, function(data1) {
            if (data1.status === 404) {
                $(".wrap").append("<div class='streamers offline delete'><span class='i-fix'><i class='ion-close'></i><img src='https://68.media.tumblr.com/2bab580406f69a3ff294bd0782d83c5a/tumblr_ohkte1EwLM1sj6gx1o1_540.png'></span><div class='info'><span>" + val + " </span><span>does not exist</span></div></div>");
                $(".offline i").click(function() {
                    $(this.closest(".delete")).remove();
  });
            } else if (data1.status === null) {
                $.getJSON(twitchAPI + channels + val + callback, function(data2) {
                    $(".wrap").append("<a href=" + data2.url + "><div class='streamers offline'><img src='https://68.media.tumblr.com/2bab580406f69a3ff294bd0782d83c5a/tumblr_ohkte1EwLM1sj6gx1o1_540.png'><div class='info'><span>" + val + " </span><span>is currently offline</span></div></div></a>");
                });
            } else {
                $(".wrap").append("<a href=" + data1.stream.channel.url + "><div class='streamers online'><img src=" + valData.stream.channel.logo + "><div class='info'><span>" + val + " </span><span class='game'>streaming " + valData.stream.game + "</span><span>" + valData.stream.viewers + " viewers</span></div></div></a>");
            } //ELSE
        }); //data1
});//map
Abhishek Kumar
@Mr-Kumar-Abhishek
@swatbone85 probably your html structure messes around after the first run your script
Thomas Swatland
@swatbone85
@Mr-Kumar-Abhishek Yeah that may be it. I'll dig a little deeper, thank you!
CamperBot
@camperbot
swatbone85 sends brownie points to @mr-kumar-abhishek :sparkles: :thumbsup: :sparkles:
:warning: swatbone85 already gave mr-kumar-abhishek points
Abhishek Kumar
@Mr-Kumar-Abhishek
@swatbone85 after js changes your html it should still maintain <h3><a>your text</a></h3> no texts between h3 and a
@swatbone85 I making js fiddle to show you ...
tommy
@tommygebru
@Adi2Point0 @swatbone85 basically i was able to get all working but when i mixed the jsons together only 2/3 conditions would execute code not all 3 though...
data1 is pulling from this json https://wind-bow.hyperdev.space/twitch-api/streams/ESL_SC2
data2 is pulling from this json https://wind-bow.hyperdev.space/twitch-api/channels/ESL_SC2
I want to be able to create anchor links and wrap divs...
however because some streamers are offline... I have to change the api call to get the url from a different json
tommy
@tommygebru
oops ok i fixed some of it
but still the same problem
regStreamers.map(function(val) {
        $.getJSON(twitchAPI + streams + val + callback, function(data1) {
            if (data1.status === 404) {
                $(".wrap").append("<div class='streamers offline delete'><span class='i-fix'><i class='ion-close'></i><img src='https://68.media.tumblr.com/2bab580406f69a3ff294bd0782d83c5a/tumblr_ohkte1EwLM1sj6gx1o1_540.png'></span><div class='info'><span>" + val + " </span><span>does not exist</span></div></div>");
                $(".offline i").click(function() {
                    $(this.closest(".delete")).remove();
                });
            } else if (data1.status === null) {
                $.getJSON(twitchAPI + channels + val + callback, function(data2) {
                    $(".wrap").append("<a href=" + data2.url + "><div class='streamers offline'><img src='https://68.media.tumblr.com/2bab580406f69a3ff294bd0782d83c5a/tumblr_ohkte1EwLM1sj6gx1o1_540.png'><div class='info'><span>" + val + " </span><span>is currently offline</span></div></div></a>");
                });//data2
            } else {
                $(".wrap").append("<a href=" + data1.stream.channel.url + "><div class='streamers online'><img src=" + data1.stream.channel.logo + "><div class='info'><span>" + val + " </span><span class='game'>streaming " + data1.stream.game + "</span><span>" + data1.stream.viewers + " viewers</span></div></div></a>");
            } //ELSE
        }); //data1
    }); //map
Adi2Point0
@Adi2Point0
@tommygebru I wish I could help. But the APIs seem to have been blocked at my work proxy
so can't get the data
tommy
@tommygebru
@Adi2Point0 ok no worries...
i am not sure it has to do with the api links maybe has to do with the logic of the if statement?
Abhishek Kumar
@Mr-Kumar-Abhishek
@swatbone85 is this is how you have done conceptually ? https://jsfiddle.net/st7qaeu2/8/
@swatbone85 https://jsfiddle.net/st7qaeu2/11/ ... new...
Thomas Swatland
@swatbone85
@Mr-Kumar-Abhishek Yes. Maybe something changes in the html. I tried using a button to convert instead of the text, and then it works fine. Although I'd rather not use a button, but click the text like I'm doing here.
Sorin Ruse
@sorinr
@tommygebru as far as i know, the twitch api from august or so, requires you get an registered user key. its free but you have to register
kirbyedy
@kirbyedy
I think fcc did something about that twitch api, I saw couple of times people using some hyperdev link
to bypass that client-id process
tommy
@tommygebru
i posted the links earlier @kirbyedy @sorinr
Sorin Ruse
@sorinr
@kirbyedy yep. u r right. read about it somewere
tommy
@tommygebru
Screen Shot 2016-12-05 at 12.21.43 AM.png
this screenshot shows that the first if condition passes and the last else condition passes.....
but then that leaves the second condition else if, which does not pass