These are chat archives for FreeCodeCamp/HelpFrontEnd

12th
Apr 2016
J Patrick Lanigan
@planigan
Apr 12 2016 00:00
@dardandemiri i've never seen += with an array, not sure if that works, but you can concat them in.
Stephen James
@sjames1958gm
Apr 12 2016 00:00
@dardandemiri You have run into the dreaded closure issue. You code closes over the variable i which at the time is the user index, but by the time your code runs it is 9
If you console.log(i) you will see it is always 9
Dardan Demiri
@dardandemiri
Apr 12 2016 00:01
yes
true
Candice
@smrtsmrf
Apr 12 2016 00:01
@sjames1958gm no worries, i appreciate it
Stephen James
@sjames1958gm
Apr 12 2016 00:01
@dardandemiri Wrap all of your $.getJSON in a function and call it with the user from the for loop.
Dardan Demiri
@dardandemiri
Apr 12 2016 00:02
okey
J Patrick Lanigan
@planigan
Apr 12 2016 00:02
good catch, that one bites me every time
Bruce Young
@mutantspore
Apr 12 2016 00:04
@dardandemiri to build up an array you use .push
J Patrick Lanigan
@planigan
Apr 12 2016 00:06
where your loop go? you just need to wrap your getJSON call in the loop like ($.getJSON ..... do stuff .... )(i); @dardandemiri
Stephen James
@sjames1958gm
Apr 12 2016 00:07
@planigan Yeah that's the syntax I never remember - Although I think the function might be less obfuscating
J Patrick Lanigan
@planigan
Apr 12 2016 00:07
oops (function(i) {$.getJSON .....})(i);
@sjames1958gm true
Dardan Demiri
@dardandemiri
Apr 12 2016 00:08
I don't understand well
Stephen James
@sjames1958gm
Apr 12 2016 00:08
@smrtsmrf I added a console.log on the value coming into that replace sequence 2 to the 12 -> 2<sup>1</sup><sup>2</sup> - the replace will, I think end up with 2^1^2
Candice
@smrtsmrf
Apr 12 2016 00:09
@sjames1958gm yeah, when i try to do 2^10, i get Math.pow(2, 1)<sup>0</sup>
J Patrick Lanigan
@planigan
Apr 12 2016 00:09
@dardandemiri it's confusing and takes time to get the hang of it, but creating a closure, that's what this does, locks in the value rather than pointing to the variable, i.e. pass the variable by value rather than reference.
Stephen James
@sjames1958gm
Apr 12 2016 00:09
@smrtsmrf You need <sup>10</sup>
Dardan Demiri
@dardandemiri
Apr 12 2016 00:10
hmmm
Candice
@smrtsmrf
Apr 12 2016 00:10
@sjames1958gm Yeah, I understand now the culprit, it’s the $(‘#entry’).append up on line 21
Now I just need to figure out how to resolve it..
Dardan Demiri
@dardandemiri
Apr 12 2016 00:10
yes I admit it's confusing
Stephen James
@sjames1958gm
Apr 12 2016 00:10
@smrtsmrf :+1:
Dardan Demiri
@dardandemiri
Apr 12 2016 00:11
and right now all what I should do is: GET SOME SLEEP !
Stephen James
@sjames1958gm
Apr 12 2016 00:11
@dardandemiri (function(j) {$.getJSON .....})(i); Maybe less confusing if you use a different variable
J Patrick Lanigan
@planigan
Apr 12 2016 00:11
lol, that might help
good call
Dardan Demiri
@dardandemiri
Apr 12 2016 00:12
Because right now here in italy it's 2:11 AM
and I need some good sleep
J Patrick Lanigan
@planigan
Apr 12 2016 00:12
someone with my own poor sleep habits
Dardan Demiri
@dardandemiri
Apr 12 2016 00:12
but: Thank you @sjames1958gm and @planigan
CamperBot
@camperbot
Apr 12 2016 00:12
dardandemiri sends brownie points to @sjames1958gm and @planigan :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Apr 12 2016 00:12
buona notte
CamperBot
@camperbot
Apr 12 2016 00:12
:star: 597 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
:star: 310 | @planigan | http://www.freecodecamp.com/planigan
J Patrick Lanigan
@planigan
Apr 12 2016 00:12
your welcome
Dardan Demiri
@dardandemiri
Apr 12 2016 00:13
Bouna Notte ;)
J Patrick Lanigan
@planigan
Apr 12 2016 00:13
*you're
goodnight
Dardan Demiri
@dardandemiri
Apr 12 2016 00:13
You too ;)
Candice
@smrtsmrf
Apr 12 2016 00:14
@sjames1958gm you wouldn’t have any suggestions on how to go about that, would you?
J Patrick Lanigan
@planigan
Apr 12 2016 00:17
@smrtsmrf wow, that's an ambitious calculator. I'm procastinating working on mine by looking for questions to answer on here, lol. good luck with that, but you're ahead of me.
Candice
@smrtsmrf
Apr 12 2016 00:19
@planigan thanks. I’m making some good progress. It’s definitely a challenge
CamperBot
@camperbot
Apr 12 2016 00:19
smrtsmrf sends brownie points to @planigan :sparkles: :thumbsup: :sparkles:
:star: 311 | @planigan | http://www.freecodecamp.com/planigan
J Patrick Lanigan
@planigan
Apr 12 2016 00:19
@smrtsmrf it's awesome, great work
Candice
@smrtsmrf
Apr 12 2016 00:22
@planigan can’t wait to have the finished product
J Patrick Lanigan
@planigan
Apr 12 2016 00:23
@smrtsmrf well, i think mine is gonna take longer after seeing that, lol
Michael Karpinski
@karpimpski
Apr 12 2016 00:25
for this pen I just copied some JavaScript and adapted it to mine (don't worry, I'm going to re-write it in my own code, I'm just very confused on AJAX). as far as I'm seeing, this should work, but it's not. does anybody know where I went wrong? http://codepen.io/karpimpski/pen/LNQbZm
J Patrick Lanigan
@planigan
Apr 12 2016 00:34
@karpimpski you need to prevent the default behavior of the submit button. set up an onclick as well as the enter button you have, in both return false
@karpimpski alternatively you can call evt.preventdefault in your case since you have evt set as the event that is being passed
Bruce Young
@mutantspore
Apr 12 2016 00:36
@karpimpski at the moment it’s trying to submit a form so it causes a page reload. there are a few ways to stop it but just changing form to div will deal with it. another way is when the event fires is to use .preventDefault()
lol
J Patrick Lanigan
@planigan
Apr 12 2016 00:39
yeah listen to @mutantspore, i messed up the camelcase and didn't include the ()
Jacob Stewart
@JacobStewart1
Apr 12 2016 00:50

hey i'm on the first jquery lesson - Learn how Script Tags and Document Ready Work and i put in the code $(document).ready(funtion()
{

}); and its not taking it does anyone know whats wrong with it?

Bruce Young
@mutantspore
Apr 12 2016 00:51
@JacobStewart1 function
spelling of
Jacob Stewart
@JacobStewart1
Apr 12 2016 00:51
oh duh thanks
@mutantspore
Charles Humphries
@chukaluk
Apr 12 2016 00:57

Hi all. Currently working on the local weather app and ran into a bit of trouble. I'm trying to get the temperature, but no matter what I try the console keeps spitting "cannot read property 'temp' of undefined' Currently using data.main.temp to get the temperature

http://codepen.io/chukaluk/pen/oxEqaX

Bruce Young
@mutantspore
Apr 12 2016 01:03
@chukaluk this is what your url should be
var url = 'http://api.openweathermap.org/data/2.5/weather?lat=' + latitude + '&lon=' + longitude + '&appid=c8607aa7ae3626b974fe743d41355a2e’;
you had forecast as well as weather and were missing an = in the &lon`
Charles Humphries
@chukaluk
Apr 12 2016 01:06
@mutantspore Ah thanks. Copied over the wrong url
CamperBot
@camperbot
Apr 12 2016 01:06
chukaluk sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1390 | @mutantspore | http://www.freecodecamp.com/mutantspore
James Blackwelder
@oldetownjames
Apr 12 2016 02:15
I could use some help. I am working on my portfolio page and created an interactive navigation bar. I was trying to move to my Home page and enter the title of my page. When I use <h1>Iconian Software Solutions</h1> on line 29 of my Html window it puts the text in my nav bar off center to the right. What am I doing wrong, I cannot seem to make this centered in the page below the navbar.http://codepen.io/oldetownjames/pen/NNyPOV
Frank XC
@tenkdayz
Apr 12 2016 02:23
@oldetownjames you need a container div and i dont see a body tag either..
Irfan
@naprirfan
Apr 12 2016 02:24
Hi, I'm currently on D3 force-directed-graph project https://www.freecodecamp.com/challenges/show-relationships-with-a-force-directed-graph. The demo isn't working. I also tried this tutorial https://bl.ocks.org/mbostock/4062045 on codepen. But that won't work either. Is this codepen problem or something? can somebody enlighten me please http://codepen.io/naprirfan/pen/GZQvpM
James Blackwelder
@oldetownjames
Apr 12 2016 02:25
@tenkdayz I do have a body tag, I accidentally deleted the closing tag but I just put it back (oops). I tried a container div before the h1 entry and it still didn't work. Let me try it again.
Aaron Thompkins
@aball6412
Apr 12 2016 02:26
@oldetownjames yeah codepen adds some of the header and body stuff in automatically. You may not need all of that. You can also try to just break it with the <br> tag
jinrawx
@jinrawx
Apr 12 2016 02:27
hello everyone! does anyone know how to prevent the page from suddenly scrolling to the top of a div, after a jquery .html() replacement(& maybe animation)?
James Blackwelder
@oldetownjames
Apr 12 2016 02:28
I just added the div container but it still did not work. I left it in so you can see where it is placing the text. @aball6412 I will try the <br> tag
Bruce Young
@mutantspore
Apr 12 2016 02:29
@naprirfan FCC changed the UIRL of the news data that the project depends upon. It now is https://www.freecodecamp.com/news/hot
I changed my version but FCC hasn’t changed the demo (which I can’t change)
http://codepen.io/MutantSpore/full/KVdbMO/
James Blackwelder
@oldetownjames
Apr 12 2016 02:30
Thank you so much @aball6412 !! The break tag did it!! Thank you as well @tenkdayz for your help!
CamperBot
@camperbot
Apr 12 2016 02:30
oldetownjames sends brownie points to @aball6412 and @tenkdayz :sparkles: :thumbsup: :sparkles:
Bruce Young
@mutantspore
Apr 12 2016 02:30
It no longer looks as good as it used to as FCC are not really using their news site anymore and a new Force graph example is being written (not by me) @naprirfan
CamperBot
@camperbot
Apr 12 2016 02:30
:star: 366 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
:star: 275 | @aball6412 | http://www.freecodecamp.com/aball6412
Irfan
@naprirfan
Apr 12 2016 02:33
@mutantspore ah I see. so that's why the demo doesn't work. Thanks for the info
CamperBot
@camperbot
Apr 12 2016 02:33
naprirfan sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1391 | @mutantspore | http://www.freecodecamp.com/mutantspore
Bruce Young
@mutantspore
Apr 12 2016 02:36
@naprirfan I also just happen to have had that demo json data on my dropbox. I put my DB URL in instead of yours .. here is a fork of yours with my URL
http://codepen.io/MutantSpore/pen/pyaKMr?editors=1010
buiphuking
@buiphuking
Apr 12 2016 02:38
hi guys, is there any way to covert ["1", "2", "3", "4"] to [1, 2, 3,4] ?
Irfan
@naprirfan
Apr 12 2016 02:44
@mutantspore how did you do that? what's the difference between you json and mine? I put the file in dropbox and just copy the link, and put a ?raw=1 on the end of the URL
@buiphuking i think ["1", "2", "3", "4"].map(function(val){return +(val);}) will work
Bruce Young
@mutantspore
Apr 12 2016 02:47
My DB account is probably much older than yours. I actually have a public folder and when I put it in there and get it to give me the share URL.. that’s what I got. Newer accounts need to change the www.dropbox.com to dl.dropboxusercontent.com
.map makes a new array. .forEach will change it in place I think
jinrawx
@jinrawx
Apr 12 2016 02:50
hello everyone! does anyone know how to prevent the page from suddenly scrolling to the top of a div, after a jquery .html() replacement(& maybe animation)?
Bruce Young
@mutantspore
Apr 12 2016 02:50
@naprirfan I changed my fork of your pen again to use your DB json data
http://codepen.io/MutantSpore/pen/pyaKMr?editors=1010
Irfan
@naprirfan
Apr 12 2016 02:51
@mutantspore changing the domain to dl.dropboxusercontent.com did the trick. Thanks!
CamperBot
@camperbot
Apr 12 2016 02:51
naprirfan sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:warning: naprirfan already gave mutantspore points
Bruce Young
@mutantspore
Apr 12 2016 02:51
@naprirfan great :)
Irfan
@naprirfan
Apr 12 2016 02:51
@mutantspore now it's working
buiphuking
@buiphuking
Apr 12 2016 02:52
@naprirfan thanks!
CamperBot
@camperbot
Apr 12 2016 02:52
buiphuking sends brownie points to @naprirfan :sparkles: :thumbsup: :sparkles:
:star: 341 | @naprirfan | http://www.freecodecamp.com/naprirfan
Candice
@smrtsmrf
Apr 12 2016 02:53
a quick regex question if someone has a sec
Frank XC
@tenkdayz
Apr 12 2016 02:57
@smrtsmrf go
Candice
@smrtsmrf
Apr 12 2016 02:59
@tenkdayz I have a string, and I want to replace each instance of ‘e’ with a something else. Easy enough. But if it’s a number then e, I want to replace the e with ‘*e’. Not sure how to do that.
Coy Sanders
@coymeetsworld
Apr 12 2016 03:00
[0-9]e/\*e ?
Candice
@smrtsmrf
Apr 12 2016 03:00
@coymeetsworld can you explain this to me?
Coy Sanders
@coymeetsworld
Apr 12 2016 03:01
first character within range 0-9 (i.e a number)
next character e
thats what you're trying to matc
match
actually, gitter removed my backslash
so after the forward slash is what you would replace it with
Candice
@smrtsmrf
Apr 12 2016 03:02
@coymeetsworld yes. will this catch any e, whether it’s preceded by a number or not? or will this just catch the ones preceded by a number?
Coy Sanders
@coymeetsworld
Apr 12 2016 03:02
only if number is there, but we can change that
[0-9]*e
* means 0+ times you see this
Frank XC
@tenkdayz
Apr 12 2016 03:03
@smrtsmrf for e followed by numbers? then use /e(?=\d)/g
Coy Sanders
@coymeetsworld
Apr 12 2016 03:04
but it sounds like you want to do 2 different things, replace e with something else, and replace a digit + e with * e
right?
Candice
@smrtsmrf
Apr 12 2016 03:04
@coymeetsworld yes, that’s what I want
I got it working now with 2 different replace calls, but is it possible to combine it into one?
Coy Sanders
@coymeetsworld
Apr 12 2016 03:04
oh i see
i want to say yes but not exactly sure what to do
could use lookaheads perhaps
Candice
@smrtsmrf
Apr 12 2016 03:06
@coymeetsworld ok, well my code is messy anyway. One more piece of mess won’t hurt. :)
@coymeetsworld thanks for the help and also @tenkdayz
CamperBot
@camperbot
Apr 12 2016 03:06
smrtsmrf sends brownie points to @coymeetsworld and @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 525 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
:star: 367 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Coy Sanders
@coymeetsworld
Apr 12 2016 03:07
i heard recommendations not to make your regex too complicated if you don't need it to be
if you can break it into smaller ones thats fine
regex can get real messy when you start trying to do too many things
Bojan Radonjic
@nekato
Apr 12 2016 03:08
I'm working on a random quote machine. I always get the same code. How can I change that?
Candice
@smrtsmrf
Apr 12 2016 03:09
@coymeetsworld yeah. I just have 13 replace calls, and I was trying to minimize that. I’m sure there’s got to be a way to clean it up. But right now I’ll just focus on getting the functionality and I’ll clean up code later
Coy Sanders
@coymeetsworld
Apr 12 2016 03:09
oh i see
yeah maybe you can combine a few easily
if you have time maybe watch this video, someone else in FCC posted it and it was pretty good
https://www.youtube.com/watch?v=EkluES9Rvak
Candice
@smrtsmrf
Apr 12 2016 03:13
@coymeetsworld cool I’ll take a look
Paul Borawski
@iAmNawa
Apr 12 2016 03:19
@coymeetsworld thanks
CamperBot
@camperbot
Apr 12 2016 03:19
iamnawa sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 526 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Irfan
@naprirfan
Apr 12 2016 03:21
@nekato the URL sometimes return bad-form JSON. I think it's better if you change to another quote web service
Dan Gallegos
@gallegos20
Apr 12 2016 03:30
I can't figure out how to get lists to be centered
I've been trying for like 2 hours lol
can anyone assist?
Frank XC
@tenkdayz
Apr 12 2016 03:33
@gallegos20 ul li { text-align:center }
Dan Gallegos
@gallegos20
Apr 12 2016 03:36
@tenkdayz I figured it out with google lol. did this: ul {
list-style-position: inside;
} for css
The text WAS centering
but it was the bullet points I couldn't figure out
that fixed it
Bruce Young
@mutantspore
Apr 12 2016 03:37
@nekato I changed the getJON to .ajax . here it is working
http://codepen.io/MutantSpore/pen/PNQBmG?editors=1010
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 03:40
in my .ajax success function.. whenever i loop through the data and try to html the snippets to the page, why do i only get one snippet?
Bruce Young
@mutantspore
Apr 12 2016 03:47
@Dueldrawer8 change .html to .append
they are simply over writting each other
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 03:48
@mutantspore how did you figure that out so i can notice that next time? Append i thought was to add something at the end of an html tag
@mutantspore thanks also
CamperBot
@camperbot
Apr 12 2016 03:48
dueldrawer8 sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1392 | @mutantspore | http://www.freecodecamp.com/mutantspore
Bruce Young
@mutantspore
Apr 12 2016 03:49
@Dueldrawer8 from the jQuery docs
Description: Insert content, specified by the parameter, to the end of each element in the set of matched elements.
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 03:50
:)
@mutantspore can i ask you another question..advice or logic help.. think im trying to do to many things at once
Bruce Young
@mutantspore
Apr 12 2016 04:00
@Dueldrawer8 in what way? I have noticed that you often write too much without testing it properly as you go. Do little steps and make sure it’s working as you go. I use console.log all the time to make sure I’m getting what I need and outputting what I want. I see you had some. A look at the console log in the broswer’s development tools would have told you that you were actually doing the right thing and the only thing that was faiing was putting it to the screen/web page.
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:02
how would i transfer all that info to the browser screen? just put my codepen javascript code into the browsers development tools?
@mutantspore Yes i have started using console.log a lot more now that the projects are becomming more complex with more things to do.
Bruce Young
@mutantspore
Apr 12 2016 04:05
@Dueldrawer8 no what I’m saying is that just using console.log of relevant data is all you need. You could see in the console that your info was being returned correctly. So that left only one line of your js .. the bit doing the .html that must have been wrong.
so yes, break the projects down into bits. even just experiment getting a bit right at a time.
I see people who write a lot, never test it as they go and it’s full of mistakes that make it very hard to even understand let alone fix
Rada
@Radascript
Apr 12 2016 04:08
ugh the common multiple algorithm is messing with my brain
apparently checking every number until you find the one that works isn't a good way to do it, who would have thought.
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:09
@mutantspore i can definitely see that happening. I'm coming up on the hardest if not second hardest part of my code, when the user enters the text in the text box and presses enter, it will display the snippets i am putting into the html based on the value they type.
Bruce Young
@mutantspore
Apr 12 2016 04:12
@Dueldrawer8 ok I can see that you will have trouble. don’t use a form as it will cause the page to reload when you submit it. Either use a Form and add in .preventDefault() in your event handler (look it up) … or simply change the <form> to <div>
@Radascript try the HelpJavaScript Room
help rooms
CamperBot
@camperbot
Apr 12 2016 04:13

:point_right: help rooms [wiki]

FreeCodeCamp Chat Rooms

Help Rooms

Chat Room Description Chat Room
HTML/CSS/Bootstrap FreeCodeCamp/Help
JavaScript/Algorithms FreeCodeCamp/HelpJavaScript
Front End FreeCodeCamp/HelpFrontEnd
Data Visualization FreeCodeCamp/HelpDataViz
Back End FreeCodeCamp/HelpBackEnd

Choose the right room for your questions!

See also: :earth_asia: Language Specific | :satellite: Technology | :crystal_ball: Miscellaneous

back to top

:pencil: read more about help rooms on the FCC Wiki

Rada
@Radascript
Apr 12 2016 04:15
@mutantspore it's ok I was mostly whining
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:15
@mutantspore excellent ill change that now..
@Radascript lol, i know how you feel
mutantspore @mutantspore is giving this a break for now
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:16
@mutantspore thanks for your help.. i hope to have that part of my code finished in the next half hour
CamperBot
@camperbot
Apr 12 2016 04:16
dueldrawer8 sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:warning: dueldrawer8 already gave mutantspore points
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:30
morning :+1:
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:41
morning
sigh.. alright another road block
my enteredSearch variable, when a user types it into the textbox i get the value, I then want that value to display where i put it in the var api so that the ajax function will work
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:43
looking
Sean McDonald
@bewsii
Apr 12 2016 04:43
are we meant to do the portfolio project immediately after doing the tribute page, before starting the javascript section?
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:43
i start it as an empty string since the user hasnt typed anything in it, then have my variable, then use the val() to retreive the value from the textbox and make it equal to the variable enteredSearch..
@bewsii yes
Sean McDonald
@bewsii
Apr 12 2016 04:44
@Dueldrawer8 thanks
CamperBot
@camperbot
Apr 12 2016 04:44
bewsii sends brownie points to @dueldrawer8 :sparkles: :thumbsup: :sparkles:
:star: 383 | @dueldrawer8 | http://www.freecodecamp.com/dueldrawer8
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:44
@bewsii More practice with html and css
@bewsii and also sets you up to put your future projects on your portfolio page
Sean McDonald
@bewsii
Apr 12 2016 04:45
okie
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:45
@Dueldrawer8
$("input[type='textbox']").keypress(function(event) {
    if (event.which === 13) {
      enteredSearch = $(this).val();
      $(this).val('');
      console.log(enteredSearch);
    }
  });
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:46
yes
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:46
look at where you're assigning the value of enteredSearch
you're only assigning a value to that variable if event.which === 13 which means if someone hits enter
but what you want to do is record every keystroke
see what I mean?
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:48
but doesnt $this.val() actually record that value after entered is pressed
@juliankrispel whenever i log enteredSearch, it logs whatever the letters are after i pressed enter
Jackson Bates
@JacksonBates
Apr 12 2016 04:49
Cross-post from HelpJavascript:
Sorry for the long post...
Hoping for some help with an issue using a combination of Array.push(), a for loop and some nested ifs. The codepen link at the end should clarify the issue...
Basically, I have an empty array (twitchArr) that should have some JSON data pushed to it. The for loop and ifs treat different responses in different ways and when I use console.log() for the output for each of the variations on the responses it all works as expected.
I switched the console.log() call to twitchArr.push() to catch the info in a more usable way for my purposes, and this works - but accessing the twitchArr is causing problems, because it seems like javascript tries to access it in the final console.log(twitchArr.length) call at the very end of the code before it has finished the for loop.
So in the codepen example, you can see the console prints a '0', suggesting nothing is in the array, but if you then manually type twitchArr.length at the console prompt (in codepen), you will see that the length is '10' as expected. The only difference I can imagine is that by the time I manually call for the array length again, the for loop has finished and the array has been built.
Any ideas why this might be happening, or how to workaround it? Is this a standard JS problem (i.e. it juggles multiple processes simultaneously, not waiting for loops to complete before addressing other commands), or is it a codepen/browser specific problem?
http://codepen.io/Malgalin/pen/BKYRjg?editors=0012
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:49
one sec @Dueldrawer8
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:50
@juliankrispel sure
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:50
so hold on
@Dueldrawer8 what do you actually need to achieve here?
when you hit search you need to trigger the ajax request right?
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:52
@juliankrispel well when the user enters a search which i saved it under a variable such as 'will smith', i need that text to concatenate to my var api
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:52
right
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:52
that way
Hector Garcia
@augmt
Apr 12 2016 04:53
@JacksonBates ajax (ie. getJSON) is asynchronous so you aren't really sure when the asynchronous code begins executing or ends
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:53
but then you're only issuing an ajax request if a user hits the search button right?
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:53
when the search is executed and it goes to the ajax request, i need the final url to go into the ajax function
so when the ajax function looks up that var api, the api from wikipedia hopefully takes over and finds it
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:54
right
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:54
@juliankrispel that sounds about right
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:55
you're assigning the value of the input field to the enteredSearch variable
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:55
yes
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:55
the problem here is
var api = 'https://en.wikipedia.org//w/api.php?action=query&format=json&prop=links&list=search&srsearch=' + enteredSearch +
'srwhat=text';
Jackson Bates
@JacksonBates
Apr 12 2016 04:55
@augmt I thought the word asynchronous might have something to do with my problem, but couldn't articulate it...so is there a method that allows me to wait until the ajax call has fininshed doing it's thing, like $(document).ready but for ajax, or am I barking up the wrong tree and need to think about a new method all together?
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:56
that you're concatenating the url at the wrong time
instead you could write a function that returns the api url
and then when you execute that function it'll always concatenate with the current value of the enteredSearch variable
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:57
hmm, makes sense.. once i finish writing that function.. what do i put in my ajax request url part
Hector Garcia
@augmt
Apr 12 2016 04:57
@JacksonBates there's .done which runs after a successful ajax request
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:58
$.ajax({url: generateUrl()})
Hector Garcia
@augmt
Apr 12 2016 04:58
@JacksonBates you can find examples here as well
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:58
another way of doing it would be to do the concatenation just before you trigger the ajax request
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 04:59
@juliankrispel how would that look? or rather where would it go?
Guess I'm not even sure if it matters where ajax() goes in my code
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 04:59
rihgt
it matters
right now
Jackson Bates
@JacksonBates
Apr 12 2016 05:00
@augmt hmmm, interesting. I imagine I might have an alternate problem ahead of me, since there are 2 getJSON calls in there and the if statements make the order they trigger in random, I guess. Anyway, I'll have a play around with it and look at the examples to see if I can muddle through. Thanks
CamperBot
@camperbot
Apr 12 2016 05:00
jacksonbates sends brownie points to @augmt :sparkles: :thumbsup: :sparkles:
:star: 367 | @augmt | http://www.freecodecamp.com/augmt
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 05:00
you're initiating an ajax request as soon as your program starts
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 05:00
would it matter if i did document.ready
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 05:01
not really
you want it only to execute if someone presses the search button
so you add an event listener
for the search button
Hector Garcia
@augmt
Apr 12 2016 05:01
@JacksonBates you can also work with $.getJSON's callback as you are right now
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 05:01
and inside the callback function for that event
you do your ajax thing
does that make sense @Dueldrawer8 ?
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 05:02
ahh i see.. i usually like to take the cleaner/readability of code first
I'm assuming it would be the latter?
well maybe i shouldnt worry about how it looks and just try to get it to work first lol
@juliankrispel thanks, makes sense, i will try it and see if it works. I'm not even sure the api search will work
CamperBot
@camperbot
Apr 12 2016 05:03
dueldrawer8 sends brownie points to @juliankrispel :sparkles: :thumbsup: :sparkles:
:star: 2 | @juliankrispel | http://www.freecodecamp.com/juliankrispel
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 05:04
you're welcome :)
I'm trying to help without providing the solution, hope that's useful
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 05:05
@juliankrispel i prefer it that way, makes me learn better and realize my mistake
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 05:05
:+1:
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 05:05
ill probaly get back to you here soon in 10 min or so when my code doesnt work :)
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 05:05
that's cool
Elbert Cortez
@trip16661
Apr 12 2016 05:11
guys i have a question dunno if someone can help me but :worried: im doing some work with api and i needed to create an if statement but because i wanted it to look neat i wanted to try and make the if inside of a functioninside of an external page and then just call the function so the main page looks neat
but when i call it the api argument says undefined in the second page
Samuel Cupidon
@Zerazera
Apr 12 2016 05:12
@trip16661 It would be easier if you showed what you were working on
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 05:13
@juliankrispel its still not capturing whatever the user types in
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 05:13
why do you think that?
sorry i meant i put it inside a function
tried some logs and the api doesnt change
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 05:15
ok
you've put everything inside a function, that's not very useful
forget the function
try to add a click handler for your search button
put the ajax call in that click handler
as well as the api url
Elbert Cortez
@trip16661
Apr 12 2016 05:19
@Zerazera

$("#channel").append("<div id='channel'>"+"<a href='" + channelD.url + "'>" + channelD.display_name +"</a></br>" + imagen() + "</div>");
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 05:19
@juliankrispel ill try it real quick
Elbert Cortez
@trip16661
Apr 12 2016 05:19
function imagen() {
    if(channelD.logo !== null){
            $("channel").append("<img src='" + channelD.logo + "'>");

            }else{
                $("channel").append("<img src='http://random image'>")

            }
}
from this sternal
Jackson Bates
@JacksonBates
Apr 12 2016 05:20
@augmt I'm not having any luck with those pointers - from what I can tell, my code already waits for the call to be successful before adding it to the array. I've worked around it in the short term by using a one second setTimeout() before calling upon the array, which feels like it will obviously break under conditions of a slow connection, but works for now, as in this forked version of the same pen: http://codepen.io/Malgalin/pen/YqejMG?editors=0012
Samuel Cupidon
@Zerazera
Apr 12 2016 05:21
@trip16661 Have you tried logging the variables and seeing if the values are the same in the internal and external functions?
Elbert Cortez
@trip16661
Apr 12 2016 05:21
what do you mean
Samuel Cupidon
@Zerazera
Apr 12 2016 05:22
@trip16661 Like console.log(channelD.logo)
Elbert Cortez
@trip16661
Apr 12 2016 05:22
i know the api works fine
Hector Garcia
@augmt
Apr 12 2016 05:23
@JacksonBates oh i see. you want twitchArr to be populated when accessing it from outside the for loop?
Julian Krispel-Samsel
@juliankrispel
Apr 12 2016 05:23
gotta go :wave:
Elbert Cortez
@trip16661
Apr 12 2016 05:24
Uncaught ReferenceError: channelD is not defined that's what the error says
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 05:25
@juliankrispel another problem
@juliankrispel alright have a goodnight
Jackson Bates
@JacksonBates
Apr 12 2016 05:37
@augmt yes, that's right - Am I missing something obvious, or is setTimeout the way to go?
Hector Garcia
@augmt
Apr 12 2016 05:39
@JacksonBates setTimeout is a possible route you can take, but i can't be sure that twitchArr will always be fully populated after 1 second
in your innermost $.getJSON call you can check to see if twitchArr.length === twitchers.length and go from there
Jackson Bates
@JacksonBates
Apr 12 2016 05:41
@augmt that's my worry, too. I still don't understand why it doesn't naturally wait until the for loop has finished, regardless of the time taken to complete the ajax calls...
Hector Garcia
@augmt
Apr 12 2016 05:41
if you'd prefer outside the for loop, you can set an interval to check for that same condition and clear the interval once the condition is met
Jackson Bates
@JacksonBates
Apr 12 2016 05:41
@augmt ok, I'll try the length matching idea...
Samuel Cupidon
@Zerazera
Apr 12 2016 05:43
@trip16661 Then you want to figure out why the variable is not passing correctly. Probably a scoping issue.
Hector Garcia
@augmt
Apr 12 2016 05:44
@JacksonBates the ajax requests are completed asynchronously; plus, the for loop is only concerned with making the requests and not with waiting until all the requests are completed
Jackson Bates
@JacksonBates
Apr 12 2016 05:45
@augmt ok, I think that makes sense.
@augmt hmm, I have to attend to a toddler - thanks for the help so far. I'll comeback to it later
CamperBot
@camperbot
Apr 12 2016 05:48
jacksonbates sends brownie points to @augmt :sparkles: :thumbsup: :sparkles:
:warning: jacksonbates already gave augmt points
Hector Garcia
@augmt
Apr 12 2016 05:49
@JacksonBates ok! i wish you the best
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 05:52
anyone know how im able to use a searchbox and the submit do the same thing? for example if i type "tom hanks" into textbox and press enter it will do the same function as when i type "tom hanks" into the text box but press the button instead
kirbyedy
@kirbyedy
Apr 12 2016 05:59
@Dueldrawer8 search for keyup in jquery
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 05:59
well i have this so far..
kirbyedy
@kirbyedy
Apr 12 2016 05:59
and the event.keyCode == 13 is equal to pressing enter
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 05:59
correct
Richard
@zerolimitii
Apr 12 2016 06:01
hey how do i make spaces on the side of my page? instead of the contents spread out fully to the sides
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 06:01
on the one hand i have a keypress on the textbox, on the other i have a click listener on the button
i need both
Nazim
@nazimkazim
Apr 12 2016 06:03
how to render weather icon in "Local Weather" project?
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 06:03
@zerolimitii i believe you should look into margin in CSS
probaly also use padding but need to see your page
kirbyedy
@kirbyedy
Apr 12 2016 06:04
@Dueldrawer8 are you getting any results from the api ?
cause I dont
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 06:05
@kirbyedy i am and it works
you have to type say "tom hanks" into the text box
press enter on keyboard
kirbyedy
@kirbyedy
Apr 12 2016 06:05
strange, I dont get anything, and your console says: Uncaught TypeError: Cannot read property 'search' of undefined
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 06:05
then click submit button
very weird
kirbyedy
@kirbyedy
Apr 12 2016 06:06
oh right... got it now
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 06:06
yes
kirbyedy
@kirbyedy
Apr 12 2016 06:07
huh something is messed up
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 06:07
lol
ajaybti
@ajaybti
Apr 12 2016 06:11
give me the overview for how to start with wikipwdia viewer
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 06:12
@ajaybti im working on that one now.. hardest one to me ever
Samuel Cupidon
@Zerazera
Apr 12 2016 06:12
Figure out the API . Parse the JSON. Style the results to your taste.
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 06:12
@Zerazera thast a good way to put it
Nazim
@nazimkazim
Apr 12 2016 06:13
Hey guys who knows how to render weather icon in weather app project?
ajaybti
@ajaybti
Apr 12 2016 06:14
@Dueldrawer8 can you tell me the synopsis to start with ..please
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 06:14
@ajaybti Zerazera probably better at it than i but..
@ajaybti Best place to start is here https://www.mediawiki.org/wiki/API:Main_page
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 06:15
i created a textbox and search button first, then went into the wikipedia api.. took me a day or two to figure out how to use it
Nazim
@nazimkazim
Apr 12 2016 06:15
@Zerazera thanks
CamperBot
@camperbot
Apr 12 2016 06:15
nazimkazim sends brownie points to @zerazera :sparkles: :thumbsup: :sparkles:
:star: 328 | @zerazera | http://www.freecodecamp.com/zerazera
Lee Parham
@parhaml
Apr 12 2016 06:15
Hi All. I'm working on the Quote Machine and was working with the Twitter API. 1.1 needs oAuth, and that doesn't seem to be possible on codepen. Am I reading too much into the instructions about being able to retweet a quote, can I just use the regular retweet button to link to my page?
Randy Goldsmith
@Dueldrawer8
Apr 12 2016 06:17
@ajaybti Use the resource Zerazera suggested and on that same page there should be an API sandbox once you understand how it works to help you search for things. Then go back to your code, try to parse the JSON correctly and project whatever you need onto your page
well.. scratch that last part, that's what i'm doing at least
Nazim
@nazimkazim
Apr 12 2016 06:19
@All please can you take a quick look where i'm wrong?
I cannot reander an weather icon next to temperature
http://codepen.io/nazimkazim/pen/Bjgrzw?editors=1111
Bojan Radonjic
@nekato
Apr 12 2016 06:20
I have one more question about random quote machine. When I tweet a quote with a semicolon in it, the tweet ends at the semicolon. How can I work around that?
ajaybti
@ajaybti
Apr 12 2016 06:20
@Dueldrawer8 thanks a lot
CamperBot
@camperbot
Apr 12 2016 06:20
ajaybti sends brownie points to @dueldrawer8 :sparkles: :thumbsup: :sparkles:
:star: 384 | @dueldrawer8 | http://www.freecodecamp.com/dueldrawer8
Rada
@Radascript
Apr 12 2016 06:20
@parhaml sorry not totally sure exactly what you mean. Twitter has pretty explicit instructions where you can copy paste a thing to your page to retweet
kirbyedy
@kirbyedy
Apr 12 2016 06:25
@nazimkazim weather icon should be an image right ?
Richard
@zerolimitii
Apr 12 2016 06:25
hey can someone please help me? http://codepen.io/pobojangles/pen/grvgQR - my bullets in my list are too far apart how do i fix this
Coryphaeus
@cvdeby
Apr 12 2016 06:27
Does somebody know, how could I get all channels with one request? Like https://api.twitch.tv/kraken/channels/?somethinghere. I tried to get it so - https://api.twitch.tv/kraken/streams/?channel=freecodecamp,storbeck, but I got nothing if channel is offline or doesn't exist.
ajaybti
@ajaybti
Apr 12 2016 06:32
@nazimkazim add this to display image on html with $(target).html<img src='http://openweathermap.org/img/w/" + icon + ".png'>) you figure it out here http://codepen.io/ajaybti/pen/GZObVx
Nazim
@nazimkazim
Apr 12 2016 06:34
@kirbyedy yes
kirbyedy
@kirbyedy
Apr 12 2016 06:35
@nazimkazim check @ajaybti link, there is an answer
Rada
@Radascript
Apr 12 2016 06:37
yeah I was messing with your code and I can make an icon happen separately by creating a div:
<div class="icon"><img id="icon"></img>
</div>
and then adding:
 var icon = respond.weather[0].icon;
      var iconURL = "http://openweathermap.org/img/w/" + icon + ".png"
      console.log(iconURL);
      $("#icon").attr("src", iconURL)
BUT it doesn't show when I try to put it inside your red block for some reason
Nazim
@nazimkazim
Apr 12 2016 06:37
@kirbyedy @ajaybti thanks i will look
CamperBot
@camperbot
Apr 12 2016 06:37
nazimkazim sends brownie points to @kirbyedy and @ajaybti :sparkles: :thumbsup: :sparkles:
:star: 837 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
:star: 275 | @ajaybti | http://www.freecodecamp.com/ajaybti
Coryphaeus
@cvdeby
Apr 12 2016 06:38
@kirbyedy thanks
CamperBot
@camperbot
Apr 12 2016 06:38
cvdeby sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 838 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
Sean McDonald
@bewsii
Apr 12 2016 06:51
Can someone tell me why my "name" class is doing weird stuff when resizing the viewport? I've tried all kinds of things but nothing has worked
Rada
@Radascript
Apr 12 2016 06:54
@bewsii i'm a newbie here but my instinct is you want to put that div inside your "about" div and float it to the right of "About" header
Sean McDonald
@bewsii
Apr 12 2016 06:57
the about is in a completely different container. i want the "name" class to be on top of the iPad screen like it is, but not moving around when resizing the browser
kirbyedy
@kirbyedy
Apr 12 2016 06:58
@bewsii btw, imgur is not very friendly with hotlinking, so you might want to use other host
h4r1m4u
@h4r1m4u
Apr 12 2016 06:58
@bewsii it's because of the absolute positioning on .name. remove it and it'll be fine
and yes to what @kirbyedy is saying, don't use imgur. consider dropbox instead
you'll also probably want to remove the inline style that you have on .iPad
Rada
@Radascript
Apr 12 2016 07:00
@bewsii ah I thought you were hoping to have the name be to the right of About, but you just want it above that block altogether
@kirbyedy what do you usually use instead?
kirbyedy
@kirbyedy
Apr 12 2016 07:08
dropbox
same as @h4r1m4u
Shivam Arora
@shivamarora13
Apr 12 2016 07:09
how can I stop a function while it is running, on a click
can anybody help?
Nazim
@nazimkazim
Apr 12 2016 07:13
@All Why it displays incorrect temperature in my project? http://codepen.io/nazimkazim/pen/Bjgrzw
Shivam Arora
@shivamarora13
Apr 12 2016 07:15
I can't stop the countdown, once it starts running, can't control it, can anyone help?
@nazimkazim its showing temperature in kelvin
you need to convert it into celsius or farheneit
the way you want to show
Nazim
@nazimkazim
Apr 12 2016 07:17
thanks!
lcthornhill
@lsrus
Apr 12 2016 07:18
@shivamarora13 you can save the return value of your setTimeout call in a variable and then use it with the clearTimeout function, if I've understood your question.https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/clearTimeout
Shivam Arora
@shivamarora13
Apr 12 2016 07:24
let me see, if it can work. thanks @lsrus
CamperBot
@camperbot
Apr 12 2016 07:24
shivamarora13 sends brownie points to @lsrus :sparkles: :thumbsup: :sparkles:
:star: 351 | @lsrus | http://www.freecodecamp.com/lsrus
Shivam Arora
@shivamarora13
Apr 12 2016 07:30
@lsrus No it ins't working
the countdown timer isn't stopping
u went thru the code?
Irfan
@naprirfan
Apr 12 2016 07:39
@shivamarora13 you need to explicitly call the stopTimer function in your code. I see that you declare the function but never call it anywhere
maybe set a button or something
Shivam Arora
@shivamarora13
Apr 12 2016 07:40
I have called it, see at the bottom, I have called it through start button
@naprirfan
Irfan
@naprirfan
Apr 12 2016 07:42
@shivamarora13 on start button you call setTimer, but no stopTimer
you need something like :
$(".stop").click(function() {
stopTimer();
});
Shivam Arora
@shivamarora13
Apr 12 2016 07:44
@naprirfan did this, but still, when I start a countdown again, it fluctuates between, two countdowns, can't resolve this
means, the older countdown, doesn't actually stops, it just gets hide.
@naprirfan ?
Sameer Shamsudeen
@sameershamsudheen
Apr 12 2016 07:50
hello please help me with the record collection challenge in JavaScript, Here is my code, tell me what I done wrong.
function updateRecords(id, prop, value) {
  if(id === collection[id]){
    if(value !== "" && prop !== collection[id].tracks){
      collection[id].prop = value;
    }
    if(prop === collection[id].tracks && value !== ""){
      collection[id].tracks.push(value);
    }
    if(value === ""){
      delete collection[id].prop;
    }
  }
  return collection;
}
kirbyedy
@kirbyedy
Apr 12 2016 07:50
@shivamarora13 maybe you should disable the clicks once the countdown starts
except the stop button of course :)
96street
@96street
Apr 12 2016 07:52
why arn't these floated tables inline? http://codepen.io/anon/pen/RaQebB
Shivam Arora
@shivamarora13
Apr 12 2016 07:53
stopping
@kirbyedy ok, but what about reset, when I reset the function should stop, but it is not stoppong
**
Irfan
@naprirfan
Apr 12 2016 07:54
@shivamarora13 yes I can see that. I think It's because you call the updateTimer() recursively. on moment, I'll fork your code and I'll be back with the solution.
Shivam Arora
@shivamarora13
Apr 12 2016 07:54
Ok..
@naprirfan
:)
kirbyedy
@kirbyedy
Apr 12 2016 07:55
@shivamarora13 include the stop function in the reset function
so you stop the function, then reset the timer
how can i make about div rendered in the middle of the page ?
margin:auto doesnt work
any help ?
kirbyedy
@kirbyedy
Apr 12 2016 08:06
@UgurKurt bootstrap is a 12 column grid system
so having 9 is not really good
Uğur
@UgurKurt
Apr 12 2016 08:06
if a have 8 there
kirbyedy
@kirbyedy
Apr 12 2016 08:06
you can make 3 columns of... 2 8 2 for example
yes
Uğur
@UgurKurt
Apr 12 2016 08:06
should i put a 2 columns wide empty div before
?
kirbyedy
@kirbyedy
Apr 12 2016 08:07
yes
one before one after the 8
or one 12 if you want that div to be the whole width of the page
Uğur
@UgurKurt
Apr 12 2016 08:07
no,i want some blank on the either side of the page
but i want about div to be wider than 8 columns
how can i do that ?
and can i nest a row inside another row ?
i mean,can i make a row narrower than full width of the page ?
Irfan
@naprirfan
Apr 12 2016 08:12
@shivamarora13 I modified the function a bit. It's better to use setInterval than setTimeout for this case. There's still bug, but it should be easy since the start and stop function is working now. http://codepen.io/naprirfan/pen/EKQdPX
kirbyedy
@kirbyedy
Apr 12 2016 08:12
@UgurKurt you can do it 1 - 10 -1
lcthornhill
@lsrus
Apr 12 2016 08:25
@shivamarora13 sorry for the late reply, I can see you've got things functioning better now, but so you know, the original issue was that you didn't reassign the variable timeoutID to the value during your looping (updateTimer, I think) function
Elbert Cortez
@trip16661
Apr 12 2016 08:33
LOl i so need help with this? my json object that im getting is undefine most of it which leads to a funny result but it's not what i want xD
http://codepen.io/Trip1666/full/BKYqab/
Uğur
@UgurKurt
Apr 12 2016 08:38
@kirbyedy its too big :smile:
hosni adnane
@hosniadnane
Apr 12 2016 08:42

'''
$(document).ready(function() {
var long;
var lat;
if (navigator.geolocation) {

navigator.geolocation.getCurrentPosition(
function(position) {
lat=position.coords.latitude;
long=position.coords.longitude;
});

   $.getJSON("api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+long+"&APPID=827e82f00d4c348cbfd45b4cf9982473", function(json) {
    var html = "";
    json.forEach(
        function(val) {
        html+=json.name+" "+json.sys.country+" "+json.main.temp+" "+json.weather.main;
    }
    );

     $("body").html(html);
   });
}
else{
alert("Sorry, We can't access to your location");
}
  
});

'''

CamperBot
@camperbot
Apr 12 2016 08:42
:bulb: to format code use backticks! ``` more info
hosni adnane
@hosniadnane
Apr 12 2016 08:43

``` $(document).ready(function() {
var long;
var lat;
if (navigator.geolocation) {

navigator.geolocation.getCurrentPosition(
function(position) {
lat=position.coords.latitude;
long=position.coords.longitude;
});

   $.getJSON("api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+long+"&APPID=827e82f00d4c348cbfd45b4cf9982473", function(json) {
    var html = "";
    json.forEach(
        function(val) {
        html+=json.name+" "+json.sys.country+" "+json.main.temp+" "+json.weather.main;
    }
    );

     $("body").html(html);
   });
}
else{
alert("Sorry, We can't access to your location");
}
  
});

```

lcthornhill
@lsrus
Apr 12 2016 08:43
@trip16661 I'm taking a look at it
hosni adnane
@hosniadnane
Apr 12 2016 08:43
hello everybody everything seem fine the code , tha api is working with appid also the long and lat are in the database
where did i mess up ?
Elbert Cortez
@trip16661
Apr 12 2016 08:49
@hosniadnane can u repost the code in a better format?
Abhishek Kumar
@Mr-Kumar-Abhishek
Apr 12 2016 08:58
@trip16661 I have a question if I include slides does this still fulfills user story of the portfolio ? http://s.codepen.io/Mr-Kumar-Abhishek/debug/NxjdrB
Elbert Cortez
@trip16661
Apr 12 2016 08:59
@Mr-Kumar-Abhishek y as long as the user can navigate then y
kirbyedy
@kirbyedy
Apr 12 2016 09:00
@hosniadnane you are missing a http and no need to use for.each
lcthornhill
@lsrus
Apr 12 2016 09:03
@trip16661 so I think the problem is this - you iterate through the variable a to make your initial json calls, so by the time the ajax callback is made, a is greater than the twitchChannels list length, causing you to send twitch a query for channel 'undefined'.
Here is a fork of your pen that uses forEach to iterate through twitchChannels instead (making sure that the channel name is bound as a parameter and therefore stays consistent) http://codepen.io/lsrus/pen/ZWrqwX?editors=0010
Chad Kreutzer
@ChadKreutzer
Apr 12 2016 09:11
Okay. it's probably something simple that I am just too close to it to be seeing, but what am I doing wrong here? http://codepen.io/ChadKreutzer/pen/oxpOGe?editors=1010
Elbert Cortez
@trip16661
Apr 12 2016 09:11
@lsrus really thanks (im going to try to understand what you said xD)
CamperBot
@camperbot
Apr 12 2016 09:11
trip16661 sends brownie points to @lsrus :sparkles: :thumbsup: :sparkles:
:star: 353 | @lsrus | http://www.freecodecamp.com/lsrus
lcthornhill
@lsrus
Apr 12 2016 09:16
@chadKreutzer what is not working as you expect it to atm?
Chad Kreutzer
@ChadKreutzer
Apr 12 2016 09:18
@lsrus when you click start, it should alternate between work and break, decrementing each one appropriately. I'm thinking I'm either missing something in my countdown function, or not properly understanding the implementation of setInterval.
Eldar Tinjić
@EldarT90
Apr 12 2016 09:24
need some1 to patiently explain me certain concepts from wikipedia challenge, thanks
lcthornhill
@lsrus
Apr 12 2016 09:25
@ChadKreutzer sorry if I'm not getting this - but you're trying to time the work and break periods concurrently?
Samuel Cupidon
@Zerazera
Apr 12 2016 09:25
@EldatT90 What's the question
Eldar Tinjić
@EldarT90
Apr 12 2016 09:26
@Zerazera well its series of question or rather i need help , but i would like some1 who is helping me to explain me why is that the proper method/solution , etc
Chad Kreutzer
@ChadKreutzer
Apr 12 2016 09:28

@lsrus no. well kinda:

function countdown(pom, activity) {
  $("#activity").empty();
  $("#activity").append(activity);

  for (var i = pom; i >= 0; i--) {
    $("#testClock").empty();
    $("#testClock").append(secToTimeString(i));
  }
}

that is my countdown function that I am trying to have my setInterval call thusly:

$("#start").click(function() {
    intervalID = setInterval(function(workTime, breakTime) {
      countdown(workTime, "Work");
      countdown(breakTime, "Break");
    }, 1000);
  });

In theory, I believe that should countdown the work time followed by the break time followed by the work time, and so on !! ohh! I think I just saw at least part of my mistake!

Samuel Cupidon
@Zerazera
Apr 12 2016 09:29
@EldarT90 Broadly, start by figuring out the Wikipedia API. https://www.mediawiki.org/wiki/API:Main_page. Download the JSON you want. Then style it to your taste.
Eldar Tinjić
@EldarT90
Apr 12 2016 09:29
@Zerazera well i dont need broadly, thats the thing, thats why im saying "patinetly explaining concept
i read about apis and wikipedia api and in general
but i need help
lcthornhill
@lsrus
Apr 12 2016 09:31
@chadKreutzer - at the moment, you are making these calls once per second (roughly)

      countdown(workTime, "Work");
      countdown(breakTime, "Break");
The clock, stops and even resets the countdown
Chad Kreutzer
@ChadKreutzer
Apr 12 2016 09:32
@lsrus Yup. that's what I realized as I was typing that last bit to you. okay. I think I need to put the setInterval inside the countdown function and clear it when the for loop reaches 0. and then put the two countdowns inside a while tied to the stop button. that might work.
Shivam Arora
@shivamarora13
Apr 12 2016 09:32
in this countdown timer
but, in console, all the older timers are still running, how to stop it, permanently, on reset click
can anyone help?
lcthornhill
@lsrus
Apr 12 2016 09:34
@ChadKreutzer sorry, missed the last part of your comment :-)
Chad Kreutzer
@ChadKreutzer
Apr 12 2016 09:35
@lsrus no worries. even if you hadn't I didn't at that point explain what I had realized.
lcthornhill
@lsrus
Apr 12 2016 09:35
@shivamarora13 I could take another look - have you get the link?
Eldar Tinjić
@EldarT90
Apr 12 2016 09:36
for exmaple, why is this not working
@EldarT90 the data has not been received yet
how it will append?
Eldar Tinjić
@EldarT90
Apr 12 2016 09:39
@shivamarora13 well there is getjson to get data
@shivamarora13 i dont know mate, thats why im asking for help
Shivam Arora
@shivamarora13
Apr 12 2016 09:39
bro but, console.log(data)
doesn't show any data
yes I know, its ok, i have been on the same point.
Eldar Tinjić
@EldarT90
Apr 12 2016 09:39
@shivamarora13 so what should i do to get data shown
Shivam Arora
@shivamarora13
Apr 12 2016 09:40
first u shud get the right callback, url u have provided is wrong
put it in an address bar
and provide call back manually
it won't return any data
Eldar Tinjić
@EldarT90
Apr 12 2016 09:40
@shivamarora13 yes but if i add lets say asia
it gives me data of asia
so thats why im using the empty var
and i need to append input form form
from form*
Shivam Arora
@shivamarora13
Apr 12 2016 09:41
I added sachin tendulkar
Eldar Tinjić
@EldarT90
Apr 12 2016 09:41
like asia
to the link
thats what im trying but apperentyl its not good
Shivam Arora
@shivamarora13
Apr 12 2016 09:41
yes, exactly, take .val() function of jQuery to dynamically store value, in a variable,
Eldar Tinjić
@EldarT90
Apr 12 2016 09:42
@shivamarora13 and how do i do that
Shivam Arora
@shivamarora13
Apr 12 2016 09:42
with the help of .val() variable..
jQuery
.val() function. **
Eldar Tinjić
@EldarT90
Apr 12 2016 09:43
@shivamarora13 and what should i put inside the function, i really dont know mate
use this as ur API url, and please google .val() than only, u will get to learn, else I can send u my project
Eldar Tinjić
@EldarT90
Apr 12 2016 09:44
but thats the issue
i dont want that
i read alot about this
but in the end i cant solve any harder problem
no matter how much i read
i need examples
Shivam Arora
@shivamarora13
Apr 12 2016 09:44
title = $('input').val();
Eldar Tinjić
@EldarT90
Apr 12 2016 09:44
not plain theory
Shivam Arora
@shivamarora13
Apr 12 2016 09:44
use it like this..
title will store the value of input this way, and provide it in url
@lsrus ?
@lsrus still there or gone?
Eldar Tinjić
@EldarT90
Apr 12 2016 09:47
@shivamarora13 unfortunately i have to go in 5 min, let me get the correct syntax at least, give me few mins
see this for help, u will get an example, and thn code on your own, ok?
@EldarT90 ?
Eldar Tinjić
@EldarT90
Apr 12 2016 09:49
@shivamarora13 nah i wont look at it, thats not the point ; problem is i need too much direct help from "living beings" that usually cant afford that much time
lcthornhill
@lsrus
Apr 12 2016 09:49
@shivamarora13 you need to keep track of the id of the interval, and clear it in the reset function http://codepen.io/lsrus/pen/jqZQBG?editors=0010
Acmer77
@Acmer77
Apr 12 2016 09:50
hey...
Shivam Arora
@shivamarora13
Apr 12 2016 09:50
@lsrus can u help @EldarT90 ? he is in a great problem, can't make him understand
thanks for telling me this, let me try for the solution
Acmer77
@Acmer77
Apr 12 2016 09:50
in Build a Random Quote Machine, do you need to get the quotes from a webpage or is it ok to have "internal" quote set?
Eldar Tinjić
@EldarT90
Apr 12 2016 09:51
@shivamarora13 http://codepen.io/EldarT/pen/qZxJZp is the syntax now better?
lcthornhill
@lsrus
Apr 12 2016 09:51
@Acmer77 I've seen both. Using an api is best if you want to push yourself
Shivam Arora
@shivamarora13
Apr 12 2016 09:52
@EldarT90 yes!
Acmer77
@Acmer77
Apr 12 2016 09:52
I guess I want to coders.push("Acmer77") myself
Chad Kreutzer
@ChadKreutzer
Apr 12 2016 09:52
@Acmer77 the rules don't say not to use an "internal" array, but to be in the spirit of the skill set you are supposed to be learning from the project, it's better to use an API
Shivam Arora
@shivamarora13
Apr 12 2016 09:52
now ur callback, give a data
now u just need to show it..
on ur page
Eldar Tinjić
@EldarT90
Apr 12 2016 09:53
@shivamarora13 ok great, now i have to go off, thanks alot for your help, when i come back i will start working on it, but ofc step by step like so far, thats the only right way, no rush no copypasta ^^ tnx again and good luck
CamperBot
@camperbot
Apr 12 2016 09:53
eldart90 sends brownie points to @shivamarora13 :sparkles: :thumbsup: :sparkles:
:star: 283 | @shivamarora13 | http://www.freecodecamp.com/shivamarora13
Acmer77
@Acmer77
Apr 12 2016 09:53
okay, I'll go for the API. would be so much easier with beautifulsoup...
Shivam Arora
@shivamarora13
Apr 12 2016 09:54
@EldarT90 listen, u still have to call, overall function, when document is ready
lcthornhill
@lsrus
Apr 12 2016 09:54
@Acmer77 that's the spirit :-)
Shivam Arora
@shivamarora13
Apr 12 2016 09:55
this chat room is a good place, everyone is helping the other person, in contrast with the real world! Good!!
Acmer77
@Acmer77
Apr 12 2016 09:58
more than help, I need the occasional slap in the face :/
Shivam Arora
@shivamarora13
Apr 12 2016 10:01
@lsrus thanks, it working, thank you so much!
CamperBot
@camperbot
Apr 12 2016 10:01
shivamarora13 sends brownie points to @lsrus :sparkles: :thumbsup: :sparkles:
:star: 354 | @lsrus | http://www.freecodecamp.com/lsrus
Dardan Demiri
@dardandemiri
Apr 12 2016 10:12
@shivamarora13 That's why FreeCodeCamp is the best place to learn Development
hosni adnane
@hosniadnane
Apr 12 2016 10:21
Acmer77
@Acmer77
Apr 12 2016 10:25
ehh... another question about the random quote task...
kirbyedy
@kirbyedy
Apr 12 2016 10:25
@hosniadnane move this }); from the position place down after the $("body").html(html);
brb
Acmer77
@Acmer77
Apr 12 2016 10:25
most sites seem to offer a ready-made copypaste script to do it. I feel bad for doing that, but it works perfectly
would you consider me a cheater for doing so?
Stephen James
@sjames1958gm
Apr 12 2016 10:27
@hosniadnane You need to move your $.getJSON inside your callback from getPosition (move line 10 to after line 18)
Sorry @kirbyedy did not see your post
Nazim
@nazimkazim
Apr 12 2016 10:28
@All Hey guys how to implement toggle button in "Local Weather" project?
hosni adnane
@hosniadnane
Apr 12 2016 10:28
@sjames1958gm @kirbyedy thank u both it is working now :D
CamperBot
@camperbot
Apr 12 2016 10:28
hosniadnane sends brownie points to @sjames1958gm and @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 842 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
:star: 601 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 12 2016 10:30
@hosniadnane It is because getPosition is asynchronous -
hosni adnane
@hosniadnane
Apr 12 2016 10:31
Yeah the problem wasnt in the json in the first place
i was looking in the wrong area
Dardan Demiri
@dardandemiri
Apr 12 2016 10:32
hey @sjames1958gm
Good morning :P
I tried to change the code but still not working
look at the bottom of the code in javascript section
Does anyone know why is the Array not getting the elements
Stephen James
@sjames1958gm
Apr 12 2016 10:36
@dardandemiri Your console.log is happening before you put the data in the array. Put the console.log after the push and you will see the array getting built up.
Bruce Young
@mutantspore
Apr 12 2016 10:36
@dardandemiri the thing is that it is getting them. The api call is asynchronous so iy get sent off but you have no idea when it will return. the JS just runs ahead and does your console log and it’s empty. if you put the console log in the gets you’ll see it build up
lololol
Stephen James
@sjames1958gm
Apr 12 2016 10:37
@mutantspore Couldn't have said it better myself :)
Dardan Demiri
@dardandemiri
Apr 12 2016 10:37
but how can I use the usersTemp outside the forEach()
with the elements
Stephen James
@sjames1958gm
Apr 12 2016 10:38
@dardandemiri You have to use it inside - just like you did above with the online users.
Bruce Young
@mutantspore
Apr 12 2016 10:38
you can but still inside your getjson BUT...
Stephen James
@sjames1958gm
Apr 12 2016 10:39
@sjames1958gm With AJAX (getJSON is just easier AJAX) you have to operate on the returns within the callback function (future research for you is promises which make async programming seem more synchronous).
Bruce Young
@mutantspore
Apr 12 2016 10:40
what I did was to simply not present them until my returned array length was the same as my initial user array length
then you can use click events to use your array for the subsequent filtering
Dardan Demiri
@dardandemiri
Apr 12 2016 10:41

Actually what I am trying to do is this:
I have an array with all the users name

I want to .getJSON streamers for the Online users...
and store in a usersTemp the Offline users...

Than .getJSON channels for the Offline users ...

https://api.twitch.tv/kraken/streams/' + user +'?callback=?
https://api.twitch.tv/kraken/channel/' + offlineUser +'?callback=?
Nazim
@nazimkazim
Apr 12 2016 10:43
Please suggest me a way to toggle temperature from fahrenheit to celsius
http://codepen.io/nazimkazim/pen/Bjgrzw?editors=0010
Dardan Demiri
@dardandemiri
Apr 12 2016 10:43
so the problem is just in that Storing thing

@sjames1958gm @mutantspore what do you mean by Inside ?

Because I think it's inside the getJSON function it's just the ELSE of the IF statment

Bruce Young
@mutantspore
Apr 12 2016 10:45
@dardandemiri you can stick them all in the same array, just have a item to say if they are on/off line
Stephen James
@sjames1958gm
Apr 12 2016 10:46
@dardandemiri You can store them in an array, for later use. If you are building HTML then build while you get them back add handlers while you get them back.
Dardan Demiri
@dardandemiri
Apr 12 2016 10:47
hmmm it's interesting why I am not getting what you are suggesting
:worried:
Shivam Arora
@shivamarora13
Apr 12 2016 10:47
can anyone help, can't find an appropriate solution to my problem
Dardan Demiri
@dardandemiri
Apr 12 2016 10:47
can you make an example
Shivam Arora
@shivamarora13
Apr 12 2016 10:48
need to stop the countdown, it keeps running..
and need to start session of break length, just after the countdown gets over
Stephen James
@sjames1958gm
Apr 12 2016 10:48
@dardandemiri Let's say you sent a bunch of friend out to the store to get ingredients for dinner, until they all come back you can't make dinner.
Shivam Arora
@shivamarora13
Apr 12 2016 10:48
can anyone help?
Dardan Demiri
@dardandemiri
Apr 12 2016 10:49
yes that's true
Stephen James
@sjames1958gm
Apr 12 2016 10:49
@dardandemiri Your code is sending them out and then going into the kitchen to look for ingredients.
Dardan Demiri
@dardandemiri
Apr 12 2016 10:49
hahahha
Rada
@Radascript
Apr 12 2016 10:50
@sjames1958gm that's how I like my dinner parties anyway
Shivam Arora
@shivamarora13
Apr 12 2016 10:50
@nazimkazim keep a toggle, button, keep two global variables, change them, on the click of button, and attach that text on the button, with the help of jQuery
Dardan Demiri
@dardandemiri
Apr 12 2016 10:50
:P okey Ill add this comment in my code:
// go home Code, you are drunk
Stephen James
@sjames1958gm
Apr 12 2016 10:51
@dardandemiri lol
Shivam Arora
@shivamarora13
Apr 12 2016 10:51
can anyone help me with a problem pls?
Bruce Young
@mutantspore
Apr 12 2016 10:51
@nazimkazim you need a “flag” to keep track of which is being shown. .. and you change it’s value when you click . like isCelcius = true
Chad Kreutzer
@ChadKreutzer
Apr 12 2016 10:51
Dardan Demiri
@dardandemiri
Apr 12 2016 10:51
@sjames1958gm how to fix that problem
Bruce Young
@mutantspore
Apr 12 2016 10:55
@shivamarora13 once the session time counts down to zero you will need to reset the countdown function you have to work with the values of the break length. You’ll beed a variable that you flip to keep track of if it’s a session or a break time
Shivam Arora
@shivamarora13
Apr 12 2016 10:59
Ok lemme try!
Dardan Demiri
@dardandemiri
Apr 12 2016 10:59
@mutantspore @sjames1958gm can you tell me how to fix that problem or not
Bruce Young
@mutantspore
Apr 12 2016 11:05
@dardandemiri as the data comes in you can display stuff as you go and also put it away in the array (of objects). make a note in the array of if the user is online or not. That array wil not be available to simply console log out side of the getjson. However you should be ok for a click event to filter and present the array data. I actually didn’t display anything as I went. I didn’t display anything until the length of my users array was equal to the length of my returned data array
Dardan Demiri
@dardandemiri
Apr 12 2016 11:11
Ill look at your project
and see what you mean
Bruce Young
@mutantspore
Apr 12 2016 11:12
@dardandemiri well mine has extra stuff too
and I sort the lists
Dardan Demiri
@dardandemiri
Apr 12 2016 11:13
Yeah thanks @mutantspore ;)
CamperBot
@camperbot
Apr 12 2016 11:13
dardandemiri sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1393 | @mutantspore | http://www.freecodecamp.com/mutantspore
Dardan Demiri
@dardandemiri
Apr 12 2016 11:18
@mutantspore your project looks amazing
with those extra futures
arjunpunnam
@arjunpunnam
Apr 12 2016 11:54
Hi every one
how is the text box designed
is is a rectangle in CSS?
Just wanted to do without looking into the Code
Dardan Demiri
@dardandemiri
Apr 12 2016 11:56
It's just a Div with a <p> element that contains the quote
@arjunpunnam
Guillermo
@stygmah
Apr 12 2016 11:57
Hello, quick question, can someone tell me how to wait untill a jsonp call has finished to execute another function? thanks in advance
arjunpunnam
@arjunpunnam
Apr 12 2016 11:59
Hi @dardandemiri I understand its for the text but i would like to know how is that box designed
or Im I missing something
Chad Kreutzer
@ChadKreutzer
Apr 12 2016 11:59
@arjunpunnam just use a div with CSS.
kirbyedy
@kirbyedy
Apr 12 2016 12:00
@arjunpunnam its a div with border radius
arjunpunnam
@arjunpunnam
Apr 12 2016 12:01
Got that.Thanks @dardandemiri @ChadKreutzer @kirbyedy
CamperBot
@camperbot
Apr 12 2016 12:01
arjunpunnam sends brownie points to @dardandemiri and @chadkreutzer and @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 557 | @chadkreutzer | http://www.freecodecamp.com/chadkreutzer
:star: 843 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
:star: 288 | @dardandemiri | http://www.freecodecamp.com/dardandemiri
Chad Kreutzer
@ChadKreutzer
Apr 12 2016 12:02
@arjunpunnam keep in mind: if you are trying to exactly copy the sample page, you don't have to. :) copy the functionality so that you meet the user stories, but have fun with the styling.
kirbyedy
@kirbyedy
Apr 12 2016 12:03
yea, mine is totally different :D
sky is the limit :D
Helicondeco
@Helicondeco
Apr 12 2016 12:12
```
$(document).ready(function(){
  var lon;
  var lat;
  $.getJSON("http://ip-api.com/json", function(coord){
    lon = coord.lon;
    lat = coord.lat;
    $.getJSON("api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon+"", function(data){
      console.log(data);
    });
  });

});
i cant get my data in console.log, but when u call console log(lat) i prints out. Whats the problem?
Acmer77
@Acmer77
Apr 12 2016 12:14
http://codepen.io/Acmer77/pen/QNQZxE why won't this refresh the quote?
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 12:15
@Helicondeco There's a redundant speech mark at the end of the first arg, the url must be wrong. Have you tested the url in your browser? You can get the local coords from the geo API btw
Helicondeco
@Helicondeco
Apr 12 2016 12:16
@AndrewGHC i know but i want to fix this problem coz its making me rly mad...cant give up D
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 12:16
You need http:// else it won't work ;)
arjunpunnam
@arjunpunnam
Apr 12 2016 12:17
@ChadKreutzer Yes I have that in Mind.But the text display is one of the user story.Dont you think :)
?
kirbyedy
@kirbyedy
Apr 12 2016 12:18
@Acmer77 your console says: Uncaught SyntaxError: Unexpected token (
Acmer77
@Acmer77
Apr 12 2016 12:18
eh? have to check that then
Helicondeco
@Helicondeco
Apr 12 2016 12:19
@AndrewGHC oh.. i forgot this time but i typed it every other time and still didnt work. changed it again...nothing. I am so mad.
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 12:19
@Helicondeco Can you post the pen?
kirbyedy
@kirbyedy
Apr 12 2016 12:20
@Acmer77 maybe it would be better if you fire the click in the js and not in the html part
Helicondeco
@Helicondeco
Apr 12 2016 12:20
@AndrewGHC sure... but just started woring on it. i only have jquery
Acmer77
@Acmer77
Apr 12 2016 12:21
@kirbyedy got no idea how to do that src-thing in javascript
kirbyedy
@kirbyedy
Apr 12 2016 12:23
@Helicondeco sorry for disturbing, but how are you going to retrieve the weather data without the api key ?
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 12:23
@Helicondeco If I recall
Don't you need an API key to use open weather maps?
Think you may well do
Helicondeco
@Helicondeco
Apr 12 2016 12:24
@AndrewGHC @kirbyedy didnt know that. Gonna google about it. Thanks guys.
CamperBot
@camperbot
Apr 12 2016 12:25
helicondeco sends brownie points to @andrewghc and @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 328 | @andrewghc | http://www.freecodecamp.com/andrewghc
:star: 844 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
kirbyedy
@kirbyedy
Apr 12 2016 12:25
@Helicondeco you will have to register on the site
Chad Kreutzer
@ChadKreutzer
Apr 12 2016 12:25

@arjunpunnam not really all you need to fulfill to get credit is:
User Story: I can click a button to show me a new random quote.

User Story: I can press a button to tweet out a quote.

how you display that new quote is completely up to you.

Helicondeco
@Helicondeco
Apr 12 2016 12:26
@kirbyedy and add at the end of the code. Got it! ty! D
Henry Quinn
@Quinncuatro
Apr 12 2016 12:29
You do need the open maps API key. However, mine changed on me without notification, so it took a few minutes to figure out why my app broke.
Not sure what that's about
Signing up for a basic account and getting the key is free, though!
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 12:30
@Quinncuatro Mine's also broken
Henry Quinn
@Quinncuatro
Apr 12 2016 12:31
Go into your account dashboard and copy paste the new key.
I feel like it shouldn't reset but maybe that's a stipulation of the free account?
Helicondeco
@Helicondeco
Apr 12 2016 12:33
Its woring now with Api's key. 10x guys
Parminder Singh
@Trion129
Apr 12 2016 12:34
How can I pause and stop a setTimeout(fn , 1000); loop?
Helicondeco
@Helicondeco
Apr 12 2016 12:34
I would give you more brownie points if i could tho. D
kirbyedy
@kirbyedy
Apr 12 2016 12:34
@Helicondeco neka hvala :thumbsup:
arjunpunnam
@arjunpunnam
Apr 12 2016 12:37
@ChadKreutzer Got that.Will try according to the user stories.
Joshua Travis
@jktravis
Apr 12 2016 12:50
Hi. I have a question about webpack and bootstrap.

For whatever reason, If I I require the bootstrap css from node_modules, webpack fails to process everything. If I download it fromt he web site, and drop it in another folder, it does fine.

Has anyone seen this kind of behavior?

Islam Ibakaev
@dagman
Apr 12 2016 12:54
about @jktravis
CamperBot
@camperbot
Apr 12 2016 12:54
:star: 339 | @jktravis | http://www.freecodecamp.com/jktravis
Henry Quinn
@Quinncuatro
Apr 12 2016 13:02
Can anyone help me figure out some CSS mumbo jumbo? When you change the app width to anything vaguely smartphone sized, the row height jumps.
http://codepen.io/quinncuatro/full/GZQvzX/
abdallah-amoudi
@abdallah-amoudi
Apr 12 2016 13:09
When I use
$(".message").html(json.quoteAuthor);
to get the quote i get a reply and i display the quote because it is one reply, but when I try to loop throw JSON reply it does not work. Can anybody help me in this?
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 13:14
@abdallah-amoudi You need to parse it
JSON.parse( - JSON string file)
abdallah-amoudi
@abdallah-amoudi
Apr 12 2016 13:16
@AndrewGHC I was just trying to follow the example at https://www.freecodecamp.com/challenges/convert-json-data-to-html and I could not use json.forEach()
Henry Quinn
@Quinncuatro
Apr 12 2016 13:19
Got it. Line-heights were messing up.
Acmer77
@Acmer77
Apr 12 2016 14:02
I need some serious help. I'm losing my nerve because a lot of things and the code not working is such a mystery I can't even begin to figure it out..
http://codepen.io/Acmer77/pen/QNQZxE why won't this refresh?
it reloads the page, but the quote doesn't update
is it because of the API or what?
Henry Quinn
@Quinncuatro
Apr 12 2016 14:06
Why isn't your new quote button coming up?
You have a lot of work to do on that code.
Acmer77
@Acmer77
Apr 12 2016 14:08
what? it's there
Henry Quinn
@Quinncuatro
Apr 12 2016 14:08
I'm not seeing it.
But I spoke too soon. I didn't realize you could just drop that api line in the body like that. Pretty neat.
Acmer77
@Acmer77
Apr 12 2016 14:09
could be that the colors are off and you just don't see it because of that
Islam Ibakaev
@dagman
Apr 12 2016 14:09
@Acmer77 it's just a mess you should rewrite it from scratch with api request using
Acmer77
@Acmer77
Apr 12 2016 14:09
well I haven't found anything even remotely useful as quotes API so far
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 14:10
@Acmer77 Just throw some quotes in an array
Worry about APIs later
Henry Quinn
@Quinncuatro
Apr 12 2016 14:10
Well you can use that same api and get json data
Acmer77
@Acmer77
Apr 12 2016 14:10
I don't want to take the easy way :(
could try that
Henry Quinn
@Quinncuatro
Apr 12 2016 14:10
I know I made my own array for the quote one, then moved to API's for wiki/twitch/weather
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 14:10
You'll be working on apis after this challenge
Henry Quinn
@Quinncuatro
Apr 12 2016 14:10
Just because the other ones are way better documented.
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 14:10
extensively
Henry Quinn
@Quinncuatro
Apr 12 2016 14:11
I'm not a fan of the easy way either, but this one's forgivable :)
Acmer77
@Acmer77
Apr 12 2016 14:11
oh, okay. I guess I'll do it the cheaty way :)
no problems with APIs on Python, ever. and now this...
javascript is sometimes just a big bucket of horse...stuff...
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 14:12
@Acmer77 it's all the callbacks, somewhat different approach
it's the 10th circle of hell
Acmer77
@Acmer77
Apr 12 2016 14:13
still 100x more logical than anything I had at work today
hmm, a lot of APIs say don't use javascript
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 14:18
doesn't make any difference
try $.get(url).success(callbackFunction);
Acmer77
@Acmer77
Apr 12 2016 14:19
how?
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 14:20
just a bit of jquery
Acmer77
@Acmer77
Apr 12 2016 14:20
just paste that to js-window?
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 14:20
url will be a string of the url containing what you're trying to get, json hopefully
same as in the first ten lines here http://codepen.io/AndrewGHC/pen/QNOKbe
Acmer77
@Acmer77
Apr 12 2016 14:23
k, I'll try to figure that out and put it in my code
thanks @AndrewGHC
CamperBot
@camperbot
Apr 12 2016 14:23
acmer77 sends brownie points to @andrewghc :sparkles: :thumbsup: :sparkles:
:star: 329 | @andrewghc | http://www.freecodecamp.com/andrewghc
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 14:24
@Acmer77 np and as a tip to avoid future frustration, make sure your API url begins with http://
or you're gonna have a bad time
Acmer77
@Acmer77
Apr 12 2016 14:24
yeah, I've learned that over the years
Henry Quinn
@Quinncuatro
Apr 12 2016 14:36
@AndrewGHC What happens if you don't use the http://?
ehekatlOf
@ehekatlOf
Apr 12 2016 14:37
I've got a curiosity question
what exactly is going on when specifying a callback method in an api call?
the only FCC project that needed it was the wikipedia API
and it seems like the only thing needed was &callback=? which didn't explain much
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 14:39
@Quinncuatro It won't work
@ehekatlOf API requests are asynchronous, as they have to request information from the server. Since JS normally executes all the code in order, API calls wouldn't be possible unless your script was able to wait to receive a response
ehekatlOf
@ehekatlOf
Apr 12 2016 14:41
ohhh
so a blank callback is there to control flow?
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 14:42
Callback functions are called once the request is received, be that an error or with the data. That means your code is free to do other things, imagine if it had to wait for each API call
Wouldn't really make sense to have a blank callback
Stephen James
@sjames1958gm
Apr 12 2016 14:44
@Quinncuatro Without the http:// it assumes that the url is local and prepends http://codepen..
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 14:44
It's really easy though, if you have an api at http://ayy.com that has a JSON file with a single property 'cake', you print this to the console with nothing more than (jquery) $.get("http://ayy.com").success(function(data){console.log(data.cake)})
Eldar Tinjić
@EldarT90
Apr 12 2016 14:44
anyone can help with wikipedia challenge, thanks
ehekatlOf
@ehekatlOf
Apr 12 2016 14:45
right
Acmer77
@Acmer77
Apr 12 2016 14:49
still ost as someone who's hopelessly lost :(
I wish I could just push the json stuff in the html raw just to check the results
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 14:51
just copy paste the json from their api
Stephen James
@sjames1958gm
Apr 12 2016 14:51
@Acmer77 use JSON.stringify(json) and put in html
@EldarT90 One thing is your id is on the wrong element - you are looking at the button value not the input field value.
Acmer77
@Acmer77
Apr 12 2016 14:52
problem is I have no idea where and how to put that JSON.stringify and how to put it in html
ehekatlOf
@ehekatlOf
Apr 12 2016 14:53
I guess what I'm asking is
what exactly is &callback=? doing
Ghost
@ghost~564bf69916b6c7089cbb1fef
Apr 12 2016 14:53
@ehekatlOf it's jsonp
ehekatlOf
@ehekatlOf
Apr 12 2016 14:53
when doing a cross domain url
Eldar Tinjić
@EldarT90
Apr 12 2016 14:54
@sjames1958gm yes, but how to change it , i mean what to call on, i cant call on empty search bar or ?
Stephen James
@sjames1958gm
Apr 12 2016 14:54
@EldarT90 Your button is submitting the form and resetting the page. Return false from your handler function
$("#results").append('<p>' + JSON.stringify(data) + '</p>');
@EldarT90 Put the searching id on your <input type="text" and read the value from there
Eldar Tinjić
@EldarT90
Apr 12 2016 14:56
@sjames1958gm when i do that i still dont get any output
Stephen James
@sjames1958gm
Apr 12 2016 14:56
@Acmer77 $("#results").append('<p>' + JSON.stringify(data) + '</p>'); something like this - assume results is the id of an element in your html and data is the passed in value for your getJSON call
ehekatlOf
@ehekatlOf
Apr 12 2016 14:56
so pretty much &callback=? is a required parameter for JSONP and that's that?
Christina
@cgraham74
Apr 12 2016 14:57
I'm so glad that I am not the only one that got stuck on that Random Quote thing. I ended up getting mine working but it's an ugly mess lol
Dylan
@dhcodes
Apr 12 2016 14:57
congrats @cgraham74 that's the way I feel about my tic tac toe
Acmer77
@Acmer77
Apr 12 2016 14:58
I'm slightly starting to understand, but still a long way to go
Christina
@cgraham74
Apr 12 2016 14:58
I had to use global scope variables just to get the twitter button to work. (and I know it's supposed to be bad form to use global) but it's the only way it would work
Dylan
@dhcodes
Apr 12 2016 14:59
@cgraham74 the twitter button was odd. I had to recreate my own because otherwise it wouldn't update with the new quote. I'm sure you're fine
Eldar Tinjić
@EldarT90
Apr 12 2016 14:59
@sjames1958gm it should be like this ? http://codepen.io/EldarT/pen/qZxJZp
Stephen James
@sjames1958gm
Apr 12 2016 14:59
@EldarT90 Make your onclick - onclick="overall(); return false;" or "return overall();" and return false from overall
Christina
@cgraham74
Apr 12 2016 15:00
Yeah @dhcodes mine would only put the very first quote in the form no matter how many quotes were cycled through. Once I made the variables global, it worked.
Eldar Tinjić
@EldarT90
Apr 12 2016 15:00
@sjames1958gm can you explain what it does, but also with bit more detail; im sorry, but i said to myself i want to understand every letter and line of code i put into this project ^^ so if you dont mind
Acmer77
@Acmer77
Apr 12 2016 15:00
so... it's still about 30 lines of code to get anything out of that JSON stringift?
why not just print(json) ...
dang this is hard for me
Eldar Tinjić
@EldarT90
Apr 12 2016 15:01
@Acmer77 it was hard for me too, and it still is as you can see
@Acmer77 but you will learn from every project at least something, and look it this way: if it wasnt hard, than programming would be easy and not important
Acmer77
@Acmer77
Apr 12 2016 15:02
it's hard in a way that javascript seems so messed up
Eldar Tinjić
@EldarT90
Apr 12 2016 15:03
@Acmer77 would not be relevant like it is in todays world, and you would be doing something else
Christina
@cgraham74
Apr 12 2016 15:04
@Acmer77 You should try and use other resources other than FCC too. It's helped me along the way to use w3schools along with FCC. Sometimes just getting a different explanation on the same thing helps to better understand it.
Stephen James
@sjames1958gm
Apr 12 2016 15:04
@EldarT90 Because you are using submit the browser wants to submit a form. If you return false from the handler what is in onclick="" then it bypasses that
onclick="overall(); return false;" < this returns false and prevents the page from reloading after trying to submit the form
Acmer77
@Acmer77
Apr 12 2016 15:04
so now I found a great looking line that might be what I'm looking for. problem is that there's a hundred functions tied to that line and nothing works if everything is not perfect. and there's no error of any kind if there's something wrong :(
Stephen James
@sjames1958gm
Apr 12 2016 15:05
@Acmer77 json is just a data structure
Eldar Tinjić
@EldarT90
Apr 12 2016 15:05
@sjames1958gm but it still refreshes http://codepen.io/EldarT/full/qZxJZp/
Juwdohr
@Juwdohr
Apr 12 2016 15:06
Trying to do a search function for my Twitch app. Any help is greatly appreciated. This is what I have currently:
function searchUsers() {
  $(".user").css("display", "none");
  $("#status").css("display", "none");
  var input = $(this);

  $("." + input + "").css("display", "block");

}
Acmer77
@Acmer77
Apr 12 2016 15:06
yeah, but how can I just push it to html without formatting it in any way
Stephen James
@sjames1958gm
Apr 12 2016 15:06
@Acmer77 Do you want to push it to html without formatting?
Acmer77
@Acmer77
Apr 12 2016 15:07
yes, just to get something out of it. formatting is easy
Stephen James
@sjames1958gm
Apr 12 2016 15:07
$("#results").append('<p>' + JSON.stringify(json) + '</p>');
This does enough formatting so you can see what the data looks like.
ehekatlOf
@ehekatlOf
Apr 12 2016 15:08
oh I see
Acmer77
@Acmer77
Apr 12 2016 15:08
but it doesn't output anything to the webpage
ehekatlOf
@ehekatlOf
Apr 12 2016 15:08
&callback=? is just asking jquery to create a random function name for the callback
Acmer77
@Acmer77
Apr 12 2016 15:10
@sjames1958gm so how do I do the getJSON call...
Stephen James
@sjames1958gm
Apr 12 2016 15:11
If eldar doesn't mind look at his codepen posted up above @EldarT90
Eldar Tinjić
@EldarT90
Apr 12 2016 15:12
ofc not take a look if that can help you ^^
@sjames1958gm so have i done it correctly , i mean with false statements ? ^^ and if i did , what is the next step, why the site is still refreshed
Stephen James
@sjames1958gm
Apr 12 2016 15:13
All you were supposed to put in there is
onclick="overall(); return false;"
you put in my comments as well.
This is not correct onclick= Make your onclick - onclick="overall();
hosni adnane
@hosniadnane
Apr 12 2016 15:14
hello , i am trying to fire a click event on a button but it doesnt
is it because the button is created by javascript ?
Eldar Tinjić
@EldarT90
Apr 12 2016 15:15
@sjames1958gm i cant believe how i havent seen it ... sorry mate
Acmer77
@Acmer77
Apr 12 2016 15:16
$.getJSON('http://quotesondesign.com/api/3.0/api-3.0.json', function() {
   $("#quoteStuff").append('<p>' + JSON.stringify(json) + '</p>');
});
apparently this is totally wrong... :(
Eldar Tinjić
@EldarT90
Apr 12 2016 15:16
@sjames1958gm ok now im getting object as an output, so the next step is to make that object an actual object like an article ?
WilliamDecker
@WilliamDecker
Apr 12 2016 15:20
Wondering if someone can take a look at my Tribute and give some feedback, after looking at the code for the example one I think I missed the point of the exercise (using Bootstrap) but I didn't know how to utilize a lot of the classes, or even what they were. http://codepen.io/Decker/pen/BKYVmB?editors=1100
I basically coded mine in pure HTML/CSS
Eldar Tinjić
@EldarT90
Apr 12 2016 15:23
@WilliamDecker you were using bootstrap classes there, i see img-responsive
that is bootstrap
Islam Ibakaev
@dagman
Apr 12 2016 15:24
@WilliamDecker very good! :ok_hand: :
WilliamDecker
@WilliamDecker
Apr 12 2016 15:24
yeah that's true, that's one I actually took from the previous exercises I did
I didn't quite grasp how to use the grid system, it makes sense when I look at the code for the example (setting grid widths, using offsets, etc) but like...the jumbotron class I had never heard of
and it seems to be doing a lot of the styling
Brittany
@brittanyleigh
Apr 12 2016 15:25
Hi all, I have a couple questions on my Twitch TV app.... 1. I cannot figure out how to center my logo images at a smaller size. I'm using matching height & line-height to center everything else, and it seems to be messing up my images. 2. How do I get the online streamers to show up at the top of the table, like the sample?? http://codepen.io/brittanyleigh/pen/xVXdzv
Stephen James
@sjames1958gm
Apr 12 2016 15:32
@EldarT90 Yes - examine the object and go from there
Eldar Tinjić
@EldarT90
Apr 12 2016 15:33
@sjames1958gm examine, f12 ?
Acmer77
@Acmer77
Apr 12 2016 15:35
I'm almost crying here :(
http://www.w3schools.com/jquery/ajax_getjson.asp this doesn't work even the slightest with getting json stuff
googling getJSON doesn't help a bit, just massive walls of code
Stephen James
@sjames1958gm
Apr 12 2016 15:36
@EldarT90 since you are dumping the json to the HTML you can just look in there and see.
@Acmer77 This might be a slightly smaller wall? http://api.jquery.com/jquery.getjson/
Eldar Tinjić
@EldarT90
Apr 12 2016 15:37
@sjames1958gm sorry for asking silly questions, but how i dont get what you mean by examining , all i get as an output is object object
Acmer77
@Acmer77
Apr 12 2016 15:39
I'll try that
Erik Villoria
@kire73
Apr 12 2016 15:42
almost done with the wiki search page but im running back into the:
No 'Access-Control-Allow-Origin' header
problem. I had found someone suggest appending the url with a proxy address, which was working until this morning. still not quite sure how to write a proper header for this. any pointers?
Stephen James
@sjames1958gm
Apr 12 2016 15:42
@EldarT90 Oops
use append('<p>' + JSON.stringify(json) + '</p>');
Ademola Adegbuyi
@ooade
Apr 12 2016 15:43
@kire73 how do you grab the data?
Stephen James
@sjames1958gm
Apr 12 2016 15:43
@EldarT90 JSON.stringify will give you better output for reading;
Eldar Tinjić
@EldarT90
Apr 12 2016 15:43
@sjames1958gm ok let me try
@sjames1958gm btw tnx for ongoing help
CamperBot
@camperbot
Apr 12 2016 15:43
eldart90 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Erik Villoria
@kire73
Apr 12 2016 15:43
 $.getJSON("https://crossorigin.me/https://en.wikipedia.org/w/api.php?action=opensearch&search=" + input + "&rvlimit=100&format=json",
@marhyorh
CamperBot
@camperbot
Apr 12 2016 15:43
:star: 604 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 12 2016 15:44
@EldarT90 Not a problem
Acmer77
@Acmer77
Apr 12 2016 15:44
http://codepen.io/Acmer77/pen/QNQZxE/ so this doesn't work even a tiny bit
how far off am I ?
Eldar Tinjić
@EldarT90
Apr 12 2016 15:45
@sjames1958gm http://codepen.io/EldarT/pen/qZxJZp like this ?
updated, had 1 tiny error
but still i dont see an output
Stephen James
@sjames1958gm
Apr 12 2016 15:46
@EldarT90 Make sure JSON.stringify is using same variable as you are -
@EldarT90 Pass it data ( not json)
Erik Villoria
@kire73
Apr 12 2016 15:46
@Acmer77 you've got to create a click event that triggers the getJSON
Ademola Adegbuyi
@ooade
Apr 12 2016 15:47
@kire73 Use just the https://en.wikipedia.org/w/api.php?action=opensearch&search=" + input + "&rvlimit=100&format=json but dont use $.getJSON. You need to parse the json i.e using jsonP and it can be achieved using $.ajax.
$.ajax( " https://en.wikipedia.org/w/api.php?action=opensearch&search=" + input + "&rvlimit=100&format=json", {
    dataType: "jsonp"
  })
    .done(function( data ) {
        //do whatever you want with the data
    });
Acmer77
@Acmer77
Apr 12 2016 15:47
like put that monster in a function and use onClick to call it?
Eldar Tinjić
@EldarT90
Apr 12 2016 15:47
@sjames1958gm aa now it makes sense,
@sjames1958gm ok i get the output now, ofc its "stringified" similar to a weather problem part
Stephen James
@sjames1958gm
Apr 12 2016 15:48
@EldarT90 yes -
Erik Villoria
@kire73
Apr 12 2016 15:48
@Acmer77 yes, should change background color and get the random quote. pass values into your console to make sure your using the data right
Eldar Tinjić
@EldarT90
Apr 12 2016 15:49
@sjames1958gm next part would be to make sense of data, ie to isolate only few things from arrays that we need; however for wikipedia article i doubt its the same as for weather; because there it was easier to target what you needed, this string looks like total mess
Erik Villoria
@kire73
Apr 12 2016 15:49
@marhyorh thank you. anywhere I could read more about ajax syntax?
CamperBot
@camperbot
Apr 12 2016 15:49
kire73 sends brownie points to @marhyorh :sparkles: :thumbsup: :sparkles:
:star: 652 | @marhyorh | http://www.freecodecamp.com/marhyorh
Acmer77
@Acmer77
Apr 12 2016 15:52
@kire73 I think thoat would be helpful. how can I pass stuff to console? it's always been empty for me
well what a surprise. it doesn't work http://codepen.io/Acmer77/pen/QNQZxE/
ranyehushua
@ranyehushua
Apr 12 2016 16:01
Hi all, looks like a few of us are working on the Random Quote Machine project right now. I just had a couple questions:
Erik Villoria
@kire73
Apr 12 2016 16:02
@Acmer77 console.log('your value to check')
ranyehushua
@ranyehushua
Apr 12 2016 16:02
1) Are you all finding a quote generating API to pull the quotes from? Or just using an array of nested arrays of pre-determined quotes to randomly select?
and 2) can someone give me a hint as to how to get a Tweet button to pull the quote and place it in a tweet?
Acmer77
@Acmer77
Apr 12 2016 16:04
@kire73 console.log doesn't do anything
oh, have to put it in html
Erik Villoria
@kire73
Apr 12 2016 16:06
@ranyehushua it depends on the api you use. get the data and pass it to console to check if the site you get it from doesn't tell you in its documentation. usually, you'll have to generate a random id to select from an array of quotes and authors.
you'll need another api from twitter, go to their site to get it and read the documentation on form. remember to use target="_blank" for anchor elements in codepen
@Acmer77 @ranyehushua if you still have trouble, use f12 to check the developer console to see the data you're passing and check for errors
ranyehushua
@ranyehushua
Apr 12 2016 16:07
@kire73 Is this what I would be looking at? https://dev.twitter.com/web/tweet-button
Also, I was more curious whether anyone found an API for quotes... I haven't had much luck finding a good one.
Erik Villoria
@kire73
Apr 12 2016 16:10
@ranyehushua that's what you're looking for, you just have to modify it to say the random quote and author. they suggest using this one:
http://forismatic.com/en/api/
ranyehushua
@ranyehushua
Apr 12 2016 16:11
@kire73 Thanks very much!
Acmer77
@Acmer77
Apr 12 2016 16:11
@kire73 thanks , that F12 is really helpful!
CamperBot
@camperbot
Apr 12 2016 16:11
acmer77 sends brownie points to @kire73 :sparkles: :thumbsup: :sparkles:
:star: 280 | @kire73 | http://www.freecodecamp.com/kire73
Erik Villoria
@kire73
Apr 12 2016 16:12
@ranyehushua i used this one because it has easier to understand documentation:
http://quotesondesign.com/the-api/
you're welcome!
Acmer77
@Acmer77
Apr 12 2016 16:14
seems that the problem is cross-domain stuff
"XMLHttpRequest cannot load http://quotesondesign.com/api/3.0/api-3.0.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access."
newcoderpdx
@newcoderpdx
Apr 12 2016 16:16
Hi! Is the Portfolio project only to use Bootstrap and no custom CSS?
Erik Villoria
@kire73
Apr 12 2016 16:18
@Acmer77 I'm still learning about this one. scroll up its the last thing I asked about, should apply to your problem to. $.ajax() method worked for me
Eldar Tinjić
@EldarT90
Apr 12 2016 16:19
still need help with wikipedia challenge, thanks
Stephen James
@sjames1958gm
Apr 12 2016 16:27
@EldarT90 The following processes the first element of data.query.search array.
    $("#results").append('<h1>' + data.query.search[0].title + '<h1><p>' + data.query.search[0].snippet + '</p>') ;
h4r1m4u
@h4r1m4u
Apr 12 2016 16:27
@newcoderpdx the portfolio project has no limitations. you're free to use any libraries/frameworks you wish
Eldar Tinjić
@EldarT90
Apr 12 2016 16:28
@sjames1958gm could you explain me how did you get that from the big array , i mean how did you extrapolate useful information
Erik Villoria
@kire73
Apr 12 2016 16:28
also working on the wiki challenge. i used &rvlimit=100, but I'm still being capped at 10 results. am I going about this right?
Stephen James
@sjames1958gm
Apr 12 2016 16:29
@EldarT90
{"batchcomplete":"",
"continue":{"sroffset":10,"continue":"-||"},
"query":{
        "searchinfo":{"totalhits":28382},
        "search":[{"ns":0,"title":"Frog","snippet":"article is about the group of amphibians. For other uses, see Frog (disambiguation). Frogs are a diverse and largely carnivorous group of short-bodied","size":156709,"wordcount":18197,"timestamp":"2016-04-04T10:07:33Z"},
@EldarT90 The above is the stuff stored in data -> the information you want is "title": "Frog" and "snippet"
Working back to the root of the object you have and array '[' and "search:" and "query:"
That gives in reverse order data.query.search[0].title for the title and data.query.search[0].snippet for the snippet
You would loop over this search array and append each of the title/snippet into your html
Eldar Tinjić
@EldarT90
Apr 12 2016 16:33
@sjames1958gm oke, that part i understand, but how did you target it so fast, i mean it looks so messy as stringified ooutput
@sjames1958gm i couldnt target it properly, so do you have some method that helps you
@sjames1958gm or just practice?
Acmer77
@Acmer77
Apr 12 2016 16:34
still no access with the Ajax style
Stephen James
@sjames1958gm
Apr 12 2016 16:35
@EldarT90 Practice probably Working from the inside out is a technique -
@sjames1958gm Experience to see what is or is not important
Eldar Tinjić
@EldarT90
Apr 12 2016 16:37
@sjames1958gm aa inside out, thats good trick
Erik Villoria
@kire73
Apr 12 2016 16:42
@sjames1958gm any advice on forcing continue? i used &rvlimit=100 but I'm still being limited to 10 results
KortsF
@KortsF
Apr 12 2016 16:46

I'm probably making some very basic mistake, but could anybody tell me why my code here: http://codepen.io/KortsF/pen/RaQOeQ

returns "undefined" from the else if instead of the string for each element of the users array?

newcoderpdx
@newcoderpdx
Apr 12 2016 16:47
@h4r1m4u thank you
CamperBot
@camperbot
Apr 12 2016 16:47
newcoderpdx sends brownie points to @h4r1m4u :sparkles: :thumbsup: :sparkles:
:star: 1757 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u
h4r1m4u
@h4r1m4u
Apr 12 2016 16:47
np
Stephen James
@sjames1958gm
Apr 12 2016 16:48
@KortsF Because of closure. The variable i is captured by the definition of the callback for $.getJSON - by the time of execution i is now users.length
Bruce Young
@mutantspore
Apr 12 2016 16:48
@KortsF the process is asynchronous and your for loop will race ahead. try something that initiates a function call for each user .. for example .forEach. This is your pen set up like that
http://codepen.io/MutantSpore/pen/pyamyj?editors=0010
KortsF
@KortsF
Apr 12 2016 16:49
@sjames1958gm Right, I remember reading about that
Stephen James
@sjames1958gm
Apr 12 2016 16:49
@KortsF You can wrap $.getJSON in a function and call it with the values you need (including i)
KortsF
@KortsF
Apr 12 2016 16:50
@sjames1958gm @mutantspore Thanks guys!
CamperBot
@camperbot
Apr 12 2016 16:50
kortsf sends brownie points to @sjames1958gm and @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1394 | @mutantspore | http://www.freecodecamp.com/mutantspore
:star: 605 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Leigh
@LBCDWB
Apr 12 2016 17:07
How do I change the font size below the photo. I have tried changing the font to all different px sizes in the CSS
Jami Gibbs
@jamigibbs
Apr 12 2016 17:08
@LBCDWB Do you have a link?
Jami Gibbs
@jamigibbs
Apr 12 2016 17:12
@LBCDWB You'll need to remove the style wrapper around it (this only belongs in an HTML file) and do something like this:
.caption {
  width: 400px;
  font-family: Arial;
  line-height: 1.5;
  text-align: center;
  font-size: 20px;
}
Leigh
@LBCDWB
Apr 12 2016 17:12
OK. Thanks. Having a hard time trying to figure out when to use CSS and when to use “style” in HTML
h4r1m4u
@h4r1m4u
Apr 12 2016 17:13
@LBCDWB a) remove the inline font-size: 80%; style from the div that wraps the image and the caption. b) remove the <style type="text/css"> and </style> tags from the CSS pane (you don't need them on codepen). c) set the font-size on .caption as @jamigibbs shows above
Jami Gibbs
@jamigibbs
Apr 12 2016 17:13
The style tag allows you to embed CSS into an HTML file
h4r1m4u
@h4r1m4u
Apr 12 2016 17:13
the style attribute is still CSS. it's just called inline style. as a rule of thumb, you almost never want to use inline styles
Jami Gibbs
@jamigibbs
Apr 12 2016 17:13
The CSS file should just directly include CSS.
Helicondeco
@Helicondeco
Apr 12 2016 17:18
I'am working on weather app. And have problem with switch statmen for icons. I cant find the solution.
Jami Gibbs
@jamigibbs
Apr 12 2016 17:19
@Helicondeco A weather icon can be loaded directly through the API http://bugs.openweathermap.org/projects/api/wiki/Weather_Condition_Codes
Leigh
@LBCDWB
Apr 12 2016 17:19
@jamigibbs @h4r1m4u thanks for the help! But, now the caption is not centered under the photo. https://codepen.io/LBCDWB/pen/pyaYbd
CamperBot
@camperbot
Apr 12 2016 17:19
:star: 321 | @jamigibbs | http://www.freecodecamp.com/jamigibbs
:star: 1758 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u
lbcdwb sends brownie points to @jamigibbs and @h4r1m4u :sparkles: :thumbsup: :sparkles:
h4r1m4u
@h4r1m4u
Apr 12 2016 17:20
@LBCDWB try .caption {text-align: center;}
Stephen James
@sjames1958gm
Apr 12 2016 17:20
This message was deleted
Jami Gibbs
@jamigibbs
Apr 12 2016 17:20
@LBCDWB margin: 0 auto; should center it.
Dylan
@dhcodes
Apr 12 2016 17:20
@LBCDWB use margin: 0 auto;
dang it @jamigibbs too fast
lol
Jami Gibbs
@jamigibbs
Apr 12 2016 17:20
lol. I was anticipating that question! :)
Dylan
@dhcodes
Apr 12 2016 17:21
had it pretyped I bet too
Candice
@smrtsmrf
Apr 12 2016 17:21
regex question… how can I replace an E, but not a .E
Stephen James
@sjames1958gm
Apr 12 2016 17:21
@Helicondeco Are you calling the icons function? also the icon is in the data returned from api
data.weather[0].icons
Jami Gibbs
@jamigibbs
Apr 12 2016 17:21
Nah. 🚀fingers
Leigh
@LBCDWB
Apr 12 2016 17:21
@jamigibbs @dhcodes thanks again!
CamperBot
@camperbot
Apr 12 2016 17:21
:warning: lbcdwb already gave jamigibbs points
lbcdwb sends brownie points to @jamigibbs and @dhcodes :sparkles: :thumbsup: :sparkles:
:star: 608 | @dhcodes | http://www.freecodecamp.com/dhcodes
Dylan
@dhcodes
Apr 12 2016 17:22
@smrtsmrf guessing... ^.E
Leigh
@LBCDWB
Apr 12 2016 17:22
@h4r1m4u thank you also. Should this have gone into the CSS definition of the “caption” class or the HTML - .caption {text-align: center;}
CamperBot
@camperbot
Apr 12 2016 17:22
lbcdwb sends brownie points to @h4r1m4u :sparkles: :thumbsup: :sparkles:
:warning: lbcdwb already gave h4r1m4u points
Dylan
@dhcodes
Apr 12 2016 17:22
ugh
^\.E
h4r1m4u
@h4r1m4u
Apr 12 2016 17:23
@Helicondeco the icon is part of the weather object you get from the API. check the weather array inside the response. it contains icon
Helicondeco
@Helicondeco
Apr 12 2016 17:23
@sjames1958gm yes. but i wanted to try this way. Why isnt the switch function working. I want to figure that out. I am confused, and cant find the problem.
Candice
@smrtsmrf
Apr 12 2016 17:23
@dhcodes Thanks!!
CamperBot
@camperbot
Apr 12 2016 17:23
smrtsmrf sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star: 609 | @dhcodes | http://www.freecodecamp.com/dhcodes
Stephen James
@sjames1958gm
Apr 12 2016 17:23
@Helicondeco You aren't calling icons(weather) anywhere I could find
h4r1m4u
@h4r1m4u
Apr 12 2016 17:23
which is icon filename. you can just use the filename to then construct the URL to the image
Helicondeco
@Helicondeco
Apr 12 2016 17:25
@sjames1958gm no i am adding the src to img with switch statment
@sjames1958gm i have list of diffrent imgs in switch statemant depending on weather
Stephen James
@sjames1958gm
Apr 12 2016 17:26
@Helicondeco Which is insides a function (not sure why you have the function icons) also your img has the id="#img"
Helicondeco
@Helicondeco
Apr 12 2016 17:27
@sjames1958gm so I should remove function and only leave switch statemt?
h4r1m4u
@h4r1m4u
Apr 12 2016 17:27
@LBCDWB inside the .caption class (in the CSS pane). as i mentioned above, you almost never want to use inline styles. you should probably read up on the difference
Stephen James
@sjames1958gm
Apr 12 2016 17:27
@Helicondeco I can't see a reason for the function -
Dylan
@dhcodes
Apr 12 2016 17:28
@smrtsmrf since you had a Regex question yesterday too, might I recommend a helpful site: http://www.regexone.com
It's pretty handy for learning all the regex codes
cheers
Stephen James
@sjames1958gm
Apr 12 2016 17:28
@Helicondeco And fix the img tag <img id="#img" src="" alt="" /> should be id="img"
Helicondeco
@Helicondeco
Apr 12 2016 17:29
@sjames1958gm oh i didnt see that one. ill try to fix it now. and tell you if its working.
Bascarau Claudiu
@clauub
Apr 12 2016 17:30
This message was deleted
Helicondeco
@Helicondeco
Apr 12 2016 17:30
@sjames1958gm its working D. thanks a lot buddy,
CamperBot
@camperbot
Apr 12 2016 17:30
helicondeco sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star: 606 | @sjames1958gm | http://www.freecodecamp.com/sjames1958gm
Michael Karpinski
@karpimpski
Apr 12 2016 17:31
http://codepen.io/karpimpski/pen/LNQbZm I'm very confused on Ajax, even after watching video tutorials, researching, and reading about it in my book. so I copied this code and adapted it to my HTML (don't worry, I will re-write my own code, I just am struggling to figure out how the Ajax calls work). however, this still isn't working. can anybody tell me what I did wrong
I posted this last night but accidentally deleted my mentions, so sorry if you've already seen it
Bascarau Claudiu
@clauub
Apr 12 2016 17:32
This message was deleted
What shoude I do my website is acting very strange.. Help me please !!
Untitled.png
sd.png
Michael Karpinski
@karpimpski
Apr 12 2016 17:33
@clauub it looks like you have your container set to a fixed absolute height
Stephen James
@sjames1958gm
Apr 12 2016 17:34
@Helicondeco :+1:
Bruce Young
@mutantspore
Apr 12 2016 17:36
@karpimpski there is nothing at all wrong with your .ajax. it’s the form you are using. It causes a reload of the page. change the <form> to <div> and also put evt.preventDefault(); just before the event handler if statement.
here is that done
http://codepen.io/MutantSpore/pen/KzQLGN?editors=1010
Bascarau Claudiu
@clauub
Apr 12 2016 17:36
@karpimpski I have my boxes set width:85%
@karpimpski is that a problem ?
Candice
@smrtsmrf
Apr 12 2016 17:37
@dhcodes awesome. I’ll take a look at that. I’m decent with the basics, but I definitely could use some extra help
Michael Karpinski
@karpimpski
Apr 12 2016 17:37
@mutantspore wow, thank you!
CamperBot
@camperbot
Apr 12 2016 17:37
karpimpski sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1395 | @mutantspore | http://www.freecodecamp.com/mutantspore
Michael Karpinski
@karpimpski
Apr 12 2016 17:37
@clauub that shouldn't be, no
@clauub it would be easier if you were using CodePen and we could see your code
Acmer77
@Acmer77
Apr 12 2016 17:38
uhh... we're suppsed to do cross-domain requests and it's not allowed for security reasons...
Michael Karpinski
@karpimpski
Apr 12 2016 17:38
@mutantspore could you explain to me what preventDefault does in this context and why the form made it so that my code didn't work?
Bascarau Claudiu
@clauub
Apr 12 2016 17:38
@karpimpski ok, i'll be back, thanks for the ideea
CamperBot
@camperbot
Apr 12 2016 17:38
clauub sends brownie points to @karpimpski :sparkles: :thumbsup: :sparkles:
:star: 287 | @karpimpski | http://www.freecodecamp.com/karpimpski
Bruce Young
@mutantspore
Apr 12 2016 17:40
@karpimpski a form with a submit button tries to go off to a server ..sending it’s data there but as you have no url for that it just causes a page reload.
.preventDefault does exactly that stop it doing it’s default action
http://api.jquery.com/event.preventdefault/
"Description: If this method is called, the default action of the event will not be triggered."
@karpimpski you could probably change the button type away from being “submit” also
Michael Karpinski
@karpimpski
Apr 12 2016 17:42
@mutantspore oh, got it. thanks! and i haven't added functionality, but I guess I could just give it an id and add a JQuery statement saying if I click that ID, it sends me to the same function where I hit enter, right?
CamperBot
@camperbot
Apr 12 2016 17:42
karpimpski sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:warning: karpimpski already gave mutantspore points
Michael Karpinski
@karpimpski
Apr 12 2016 17:42
@mutantspore for the submit button
Bruce Young
@mutantspore
Apr 12 2016 17:42
@karpimpski yes you’ll need that too
Bascarau Claudiu
@clauub
Apr 12 2016 17:45
thanks @karpimpski
CamperBot
@camperbot
Apr 12 2016 17:45
clauub sends brownie points to @karpimpski :sparkles: :thumbsup: :sparkles:
:warning: clauub already gave karpimpski points
Michael Karpinski
@karpimpski
Apr 12 2016 17:46
@clauub thanks for what?
CamperBot
@camperbot
Apr 12 2016 17:46
karpimpski sends brownie points to @clauub :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for clauub
Bascarau Claudiu
@clauub
Apr 12 2016 17:47
@karpimpski for your help ! however i'll come with the website on the codepen
Michael Karpinski
@karpimpski
Apr 12 2016 17:48
@clauub I'll do my best to help, but having the code will let people way more experiences than me figure out what's wrong
Michael Karpinski
@karpimpski
Apr 12 2016 17:57
I'm trying to match an element with Bootstrap's default text color, but I can't find the value for Bootstrap's default color. can anybody help?
Michael Karpinski
@karpimpski
Apr 12 2016 17:58
@kire73 this just looks like a normal color table, I can't find a Bootstrap value
Erik Villoria
@kire73
Apr 12 2016 18:02
@karpimpski Bootstrap value? are you looking for a hex, rgb, name...?
feedback?
Michael Karpinski
@karpimpski
Apr 12 2016 18:03
@kire73 any of those, name if there is one. hex if not
for some reason the last array always turns up a blank string for its content
Acmer77
@Acmer77
Apr 12 2016 18:05
$('#quoteText').html('<p>' + text + '</p>') why doesn't that push 'text' to #quoteText ?
Erik Villoria
@kire73
Apr 12 2016 18:06
@karpimpski are you looking for the bootstrap primary color or what? I'd just use my eyes to match the color from a color picker online or that table to get the value
Coy Sanders
@coymeetsworld
Apr 12 2016 18:06
do you have a semicolon after the statement @Acmer77 ?
Erik Villoria
@kire73
Apr 12 2016 18:06
@Acmer77 using .html() changes the html, doesn't just add to it
Michael Karpinski
@karpimpski
Apr 12 2016 18:06
@kire73 yeah, I'm just trying to get an exact color for Bootstrap's text. I can use my eyes, I'd just prefer to have an exact color. thanks anyway
CamperBot
@camperbot
Apr 12 2016 18:06
karpimpski sends brownie points to @kire73 :sparkles: :thumbsup: :sparkles:
:star: 281 | @kire73 | http://www.freecodecamp.com/kire73
Acmer77
@Acmer77
Apr 12 2016 18:07
@coymeetsworld of course not, because Python doesn't use semicolons :D
thanks @camperbot
CamperBot
@camperbot
Apr 12 2016 18:07
acmer77 sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1531 | @camperbot | http://www.freecodecamp.com/camperbot
Bruce Young
@mutantspore
Apr 12 2016 18:07
@karpimpski did you try using teh browsers dev tools ?
h4r1m4u
@h4r1m4u
Apr 12 2016 18:07
@karpimpski it should be #333
Acmer77
@Acmer77
Apr 12 2016 18:07
thanks @coymeetsworld
Coy Sanders
@coymeetsworld
Apr 12 2016 18:07
no it does not lol
CamperBot
@camperbot
Apr 12 2016 18:07
acmer77 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 528 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Michael Karpinski
@karpimpski
Apr 12 2016 18:08
@h4r1m4u that looks great, thanks!
CamperBot
@camperbot
Apr 12 2016 18:08
karpimpski sends brownie points to @h4r1m4u :sparkles: :thumbsup: :sparkles:
:star: 1760 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u
h4r1m4u
@h4r1m4u
Apr 12 2016 18:08
my pleasure
Bruce Young
@mutantspore
Apr 12 2016 18:08
@karpimpski #555
Robert Friedman
@robfr77
Apr 12 2016 18:08
can anyone help me with why this button click function to change temperature from Fahr to Cels is not working? here is the relevant code. it's for the local weather project
var fahrenheit = Math.round(val.main.temp) + "&deg; F";
  var celsius = (val.main.temp - 32) / (9 / 5) + "&deg; C";
  var tempMode = fahrenheit;
$(".temperature").html(tempMode);
$(".toggletemp").click(function() {
    if (tempMode == fahrenheit ) {
      tempMode = celsius;
    }
    if (tempMode == celsius) {
      tempMode = fahrenheit;
    }
  });
Michael Karpinski
@karpimpski
Apr 12 2016 18:09
@mutantspore Bootstrap's webpage looks like it has #373a3c when i use dev tools. where did you get yours? (not trying to sound sarcastic, you're probably right)
Wojciech Kałużny
@mrkaluzny
Apr 12 2016 18:10
Guys I have a huge problem… I just broke FreeCodeCamp..
Bruce Young
@mutantspore
Apr 12 2016 18:10
@karpimpski I gues it depens on which text .. I just looked at some <p> text
Erik Villoria
@kire73
Apr 12 2016 18:10
@Acmer77 try using a variable in your loop like:
var html = ""

html += "<p> + text + </p>"

$("#quoteText").html(html)
Coy Sanders
@coymeetsworld
Apr 12 2016 18:10
@robfr77 you need to change the html also in your click function
Erik Villoria
@kire73
Apr 12 2016 18:11
@mrkaluzny noprotect yourself an infinite loop?
Coy Sanders
@coymeetsworld
Apr 12 2016 18:11
youre just changing the variable tempMode
Wojciech Kałużny
@mrkaluzny
Apr 12 2016 18:11
@kire73 Yep.
Is there anything I can do with that?
Bruce Young
@mutantspore
Apr 12 2016 18:11
@karpimpski I see some bigger text is #333
Erik Villoria
@kire73
Apr 12 2016 18:12
@mrkaluzny log in with a different computer or chrome incognito, go to the challenge, reset it, save, whatever, you should be good
Robert Friedman
@robfr77
Apr 12 2016 18:12
@coymeetsworld why doesn't it work by changing the variable tempMode that is located as such : $(".temperature").html(tempMode);
Erik Villoria
@kire73
Apr 12 2016 18:12
clearing cache works too
Coy Sanders
@coymeetsworld
Apr 12 2016 18:13
because that function doesn't repeatedly refresh the value and monitor when that variable changes
if tempMode changes and you want to display it in your HTML you need to call it again
Robert Friedman
@robfr77
Apr 12 2016 18:13
ah okay
thanks
Coy Sanders
@coymeetsworld
Apr 12 2016 18:13
np
Robert Friedman
@robfr77
Apr 12 2016 18:14
thanks @coymeetsworld
CamperBot
@camperbot
Apr 12 2016 18:14
robfr77 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 529 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Wojciech Kałużny
@mrkaluzny
Apr 12 2016 18:14
@h4r1m4u @kire73 Thanks!
CamperBot
@camperbot
Apr 12 2016 18:14
mrkaluzny sends brownie points to @h4r1m4u and @kire73 :sparkles: :thumbsup: :sparkles:
:star: 1761 | @h4r1m4u | http://www.freecodecamp.com/h4r1m4u
:star: 282 | @kire73 | http://www.freecodecamp.com/kire73
Wojciech Kałużny
@mrkaluzny
Apr 12 2016 18:14
I disabled auto-run :)
Islam Ibakaev
@dagman
Apr 12 2016 18:15
what should i know before beginning pomidoro timer challenge?
Erik Villoria
@kire73
Apr 12 2016 18:15
feedback?
for some reason the last array always turns up a blank string for its content
http://codepen.io/evilloria/pen/YqeGqQ
Arturo
@quake004
Apr 12 2016 18:16
hey I'm going to stream for the first time I want to know how can I put some music
Bruce Young
@mutantspore
Apr 12 2016 18:16
@dagman setInterval() and clearInterval()
Jeff
@adzam5
Apr 12 2016 18:16
If I use onkeyup="myFunction()" within an input is it possible to identify the input that called the function within the function?
Acmer77
@Acmer77
Apr 12 2016 18:19
not going to spend days on stuff like this
coud add fade, more quotes, limit the colors to darker ones etc
Robert Friedman
@robfr77
Apr 12 2016 18:20
@coymeetsworld how would you write if $(".temperature").html() === fahrenheit?
Erik Villoria
@kire73
Apr 12 2016 18:21
@Acmer77 don't forget the twitter button. that can be another headache. ok -me comes up quite a bit also
Acmer77
@Acmer77
Apr 12 2016 18:21
yeah, the -me is 6-10 on random :/
ah, twitterbuttor
Bruce Young
@mutantspore
Apr 12 2016 18:22
@Acmer77 if you at least add in your getQuote(); right at the end it will start off with a quote rather than have to press the button to get teh first one
Coy Sanders
@coymeetsworld
Apr 12 2016 18:22
if you're trying to get the value use val()
Erik Villoria
@kire73
Apr 12 2016 18:22
@Acmer77 yeah i'm looking at your js. I started out doing the same thing, but theyre going to want you to call an api. its kinda the point of the project
Acmer77
@Acmer77
Apr 12 2016 18:22
@mutantspore oh, thanks
CamperBot
@camperbot
Apr 12 2016 18:22
acmer77 sends brownie points to @mutantspore :sparkles: :thumbsup: :sparkles:
:star: 1396 | @mutantspore | http://www.freecodecamp.com/mutantspore
Robert Friedman
@robfr77
Apr 12 2016 18:23
vanilla javascript seems easier in this regard
Acmer77
@Acmer77
Apr 12 2016 18:23
@kire73 kept banging my head to security issues and this shouldn't be about breaching security
thanks @kire73
CamperBot
@camperbot
Apr 12 2016 18:24
acmer77 sends brownie points to @kire73 :sparkles: :thumbsup: :sparkles:
:star: 284 | @kire73 | http://www.freecodecamp.com/kire73
Coy Sanders
@coymeetsworld
Apr 12 2016 18:28
sorry actually you use html @robfr77 not val like i said
but i wouldn't be checking if its Fahrenheit or Celcius that way, I would just create a toggle variable to keep track of it
Erik Villoria
@kire73
Apr 12 2016 18:28
@Acmer77 yeah certain api's will do that. its codepen really. the api I used didnt give me this problem. it was http://quotesondesign.com/the-api/
Acmer77
@Acmer77
Apr 12 2016 18:29
well I just used that and no access
it's not the API, it should be a security issue afaik
Bruce Young
@mutantspore
Apr 12 2016 18:30
Robert Friedman
@robfr77
Apr 12 2016 18:31
@coymeetsworld so just put what i had inside the function right
Coy Sanders
@coymeetsworld
Apr 12 2016 18:31
yeah you can use tempMode if you want
Bruce Young
@mutantspore
Apr 12 2016 18:32
@Acmer77 @kire73 it’s version 4 of the API now http://quotesondesign.com/api-v4-0/ and there is a codepen example on that page .. right down the bottom of teh page
Robert Friedman
@robfr77
Apr 12 2016 18:32
@coymeetsworld lol in the meanwhile i had set up a for loop to alternate between even and odd for a toggle
Coy Sanders
@coymeetsworld
Apr 12 2016 18:32
lol yeah don't nee that
@Acmer77 @mutantspore and version 4 looks way easier, they even include the ajax
Bruce Young
@mutantspore
Apr 12 2016 18:36
@kire73 yes the codepen example is functional
Acmer77
@Acmer77
Apr 12 2016 18:36
dang, so it's back to square 2 again :(
really want that proper API thing
Erik Villoria
@kire73
Apr 12 2016 18:38
@Acmer77 don't give up. I wanted to put my head through my computer and I'm still learning it slowly, but all the upcoming projects use it and it gets more complicated, so just take your time to read through documentation, keep asking for help, it'll start to come together
Acmer77
@Acmer77
Apr 12 2016 18:39
I'm not even close to giving up. I just hate doing things many times over
ranyehushua
@ranyehushua
Apr 12 2016 18:39
@kire73 I am using the API from http://quotesondesign.com/the-api/ and it is working, although it only seems to change the quote every 10 or so minutes. Were you able to get it to work with this API where it would refresh the quote with every click?
Erik Villoria
@kire73
Apr 12 2016 18:45
@ranyehushua yeah, it definitely didn't take 10 minutes, post your pen?
@ranyehushua try:
http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=20&callback=
if you don't set the posts per page it may be looking for a post that doesnt exist
sethun60
@sethun60
Apr 12 2016 18:50
@dhcodes so they mean to say for the beginners it is enough to know certain things strongly and increase the knowledge vastly as you progress and become more experienced?
ranyehushua
@ranyehushua
Apr 12 2016 18:50
@kire73 I may be way off here... Here is my pen
Bare with me one sec
<p data-height="268" data-theme-id="0" data-slug-hash="YqeKYg" data-default-tab="result" data-user="yehoosh" class="codepen">See the Pen <a href="http://codepen.io/yehoosh/pen/YqeKYg/">Intermediate Front End Dev Projects - Random Quote Machine</a> by Ran Yehushua (<a href="http://codepen.io/yehoosh">@yehoosh</a>) on <a href="http://codepen.io">CodePen</a>.</p>
<script async src="//assets.codepen.io/assets/embed/ei.js"></script>
Bruce Young
@mutantspore
Apr 12 2016 18:51
@ranyehushua lol I’m not taking my clothes off!
ElvisTheStriker
@ElvisTheStriker
Apr 12 2016 18:51
@ranyehushua try this.... $("#getQuote").on("click", function() {
// Only change code below this line.
var urlStr = "";
var i = 0;
i = Math.floor(Math.random() * 20) + 1;
urlStr = "http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=" + i + "&callback="
$.getJSON(urlStr, function(a) {
$(".quote").html(a[0].content + "<p>— " + a[0].title + "</p>")
});
ranyehushua
@ranyehushua
Apr 12 2016 18:52
hahaha
sorry one second again
ElvisTheStriker
@ElvisTheStriker
Apr 12 2016 18:52
I found that by changing the number in the url it would change th quote
Islam Ibakaev
@dagman
Apr 12 2016 18:52
@mutantspore done :smile: is it all?
ElvisTheStriker
@ElvisTheStriker
Apr 12 2016 18:52
quicker
@ranyehushua I found that by changing the number in the url it would change th quote quicker
</