Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
James Payne
@jamespayne
maybe a nested loop would help you solve that problem?
DavidMinAZ
@DavidMinAZ
@jamespayne Looks great... and you used the same API that I have been trying to use without success
James Payne
@jamespayne
@DavidMinAZ Thanks. Yeah I really struggled to find a solution that worked. It took a fair amount of research to figure it out. Learnt a lot during that process.
CamperBot
@camperbot
jamespayne sends brownie points to @davidminaz :sparkles: :thumbsup: :sparkles:
:cookie: 265 | @davidminaz |http://www.freecodecamp.com/davidminaz
James Payne
@jamespayne
@DavidMinAZ Do you have a link to your pen?
DavidMinAZ
@DavidMinAZ
@jamespayne Yes, though it's far from complete... I'm stuck on trying to figure out how to use the .getJSON() with that API
My pen: http://codepen.io/dmattiuz/pen/zogGeB?editors=0011
@jamespayne I see you used the jsonp option in your call... which I avoided because I didn't know what sort of slippery slope there would be with trying to do something "unvanilla"
Lean Junio
@leanjunio
@leanjunio
Hey everybody,
Are front-end developers also responsible for making the websites dynamic?
In that sense, introducing a CMS to the site or something along those lines, are those under the web developer's job?
trieucrew
@trieucrew
Trying to switch between military time and regular time with click and ran into this wall where it keeps switching back and forth when I press the time. Any suggestions?
James Payne
@jamespayne
@DavidMinAZ Yeah you're probably right. I think the main problem is having to deal with the limitations of codepen and apis together.
DavidMinAZ
@DavidMinAZ
@jamespayne Does it have something to do with the code being hosted in CodePen as to why I'd need the multi-server-skirting goodness of jsonp?
Saif Ali Khan
@saifat29
Need help here with the Wikipedia Viewer Project - After searching on the Wikipedia Viewer for the second time, the previous search results doesn't go away. I tried replaceWith(); ,replace(); , show(); , hide(); , but I can't get it right.
DavidMinAZ
@DavidMinAZ
@jamespayne I just swapped your jsonp url for mine and now mine is returning the query to the console with my test code... WOW
Saif Ali Khan
@saifat29
Here is my JS code -
$(document).ready(function() {
  $resultsList = $('#resultsList');

  $('#submit').click(function() {
    var query = $("#query").val();

    var url = "https://cors.now.sh/https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=" + query + "&namespace=0&limit=10";
    $.getJSON(url, function(data) {
      //console.log(data);

      for (var i = 0; i < data[1].length; i++) {
        $resultsList.append('<li><div class="card"><div class="card-content"><span class="card-title">'+ data[1][i] +'</span><p>'+ data[2][i] +'</p></div><div class="card-action"><a href="'+ data[3][i] +'" target="_blank">read full article</a></div></div></li>');
      }

    });
  });
});
currently I am using append(); to show the data on the page
James Payne
@jamespayne
@DavidMinAZ I don't really know the intricacies of it to be honest. That was the only way I found to get around the problem. I'm learning a lot myself and need to do more reading on it because it seems that its a serious security issue. I'll be doing some reading into it. Here is where I started. http://stackoverflow.com/questions/24349907/what-is-difference-between-json-and-jsonp
DavidMinAZ
@DavidMinAZ
@jamespayne Thanks! Really appreciate that insight and the resource link! Now that I have data coming in I can go back to being frustrated remembering how to get it to show up at my target :laughing:
CamperBot
@camperbot
davidminaz sends brownie points to @jamespayne :sparkles: :thumbsup: :sparkles:
:cookie: 257 | @jamespayne |http://www.freecodecamp.com/jamespayne
trieucrew
@trieucrew
can someone help me with the asynchronous problem that I'm having
still confused on how they work
Darth Skywalker
@adityaparab
@trieucrew shoot
James Payne
@jamespayne
@DavidMinAZ No worries. Glad I could help. This chat really is a good resource for people to discuss problems and share experiences. Love it.
trieucrew
@trieucrew
Trying to update time using a boolean variable and setInterval.
Darth Skywalker
@adityaparab
@trieucrew show your code
Darth Skywalker
@adityaparab
@trieucrew yes. what is the problem?
trieucrew
@trieucrew
when i click military is supposed to change to the opposite value.
however it keeps running with what was already declared for military which is true
it as in updatetime
Darth Skywalker
@adityaparab
@trieucrew what do you mean when i click military ?
trieucrew
@trieucrew
like the time on the page
the time that is displayed
DavidMinAZ
@DavidMinAZ
@jamespayne You have no idea how relieved I am to have someone that stumbled along with the solution to my exact issue. I posted in three rooms and didn't get the usual instant response so I went back to looking at it for hours... what a relief!
Darth Skywalker
@adityaparab
@trieucrew : You will have to do something like this
$(document).ready(function(){
  var int = setInterval(updateTime.bind(this, military),1000,military);
  $("#time").click(function(){
    if(int) {
      clearInterval(int);
      int = setInterval(updateTime.bind(this, military),1000,military);
    }
    military = !military;
  });
});
your military variable was not getting passed as a parameter (format) in your updateTime function.
trieucrew
@trieucrew
can you explain what bind does
I remember seeing this somewhere
Darth Skywalker
@adityaparab
additionally, since your military is a global variable, you can also do
function updateTime(){
  var d = new Date(),
      hours = d.getHours(),
      displayHours = military == true ? hours : hours % 12,
      minutes = d.getMinutes() > 9 ? d.getMinutes() : ("0" + d.getMinutes()),
      time = displayHours + ":" + minutes;
  if(hours < 12){
    time += " a.m.";
  }else{
    time += " p.m.";
  }
  $("#time").html(time);
}
$(document).ready(function(){
  $("#time").click(military, function(){
    military = !military;
  });
  setInterval(updateTime,1000);
});
trieucrew
@trieucrew
oh okay
just wondering is it good technique to keep military as a global or does it not matter
Darth Skywalker
@adityaparab
@trieucrew keeping things global is generally a bad practice
bind does what bind means.
It will bind scope and parameters to be passed to a function.
but bind will not call the function
when you call the function, whatever is bound to the function using .bind will be reflected in your function.
trieucrew
@trieucrew
okay i think that helps alot