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
Gulsvi
@gulsvi
The reason why it's expanding out like that is because it's in a col-4 which is meant to be 33% the width of the row. You have some additional CSS making it 200px wide by default.
col is meant to get wide/narrow depending on the size of the screen
neovks
@neovks
I see well I'll look into that then, thanks @gulsvi
CamperBot
@camperbot
neovks sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
:star2: 2640 | @gulsvi |http://www.freecodecamp.org/gulsvi
Eric Hasegawa
@EricHasegawa
Can anyone help me with the Simon Game project? Having trouble using the .focus() jQuery method
Ken Haduch
@khaduch
@EricHasegawa - do you have a link to your project, we can take a look...
Eric Hasegawa
@EricHasegawa
The issue is on line 71 of the js
Ken Haduch
@khaduch
@EricHasegawa - I don't know what's wrong with .focus() - but there might be something about the way you are using it. Still looking. IN the meanwhile, changing from.focus() to .click() makes the handler fire.
Eric Hasegawa
@EricHasegawa
@khaduch Yeah I'm working on it, I think I'm getting there
Ken Haduch
@khaduch
@EricHasegawa - yeah, it seems to be working now - at least I uncommented the code and tried the .focus() again and it changes the color... did you have multiple handlers set up, perhaps?
@EricHasegawa - at least it is working once, then something seems to go awry...
Eric Hasegawa
@EricHasegawa
@khaduch Thanks! using a different method
CamperBot
@camperbot
erichasegawa sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3774 | @khaduch |http://www.freecodecamp.org/khaduch
Gulsvi
@gulsvi
@EricHasegawa You may want to blur() the element after it has focus(), and jQuery has a delay() method you can use instead of setTimeout if preferred:
$("#red").focus(function() {
  $("#red")
    .css("box-shadow", "0 0 10px 15px yellow")
    .delay(5000)
    .queue(function() {
      $("#red").css("box-shadow", "none").blur();
    });
});
Ken Haduch
@khaduch

@EricHasegawa - that sounds like a good idea that @gulsvi has. I find that if I use the .focus method, which I set up to alternate colors between red and black, that unless I get the red button "unfocused" (which would be blur) that it will not trigger the focus handler again.

Another good idea with jquery is to cache the various selectors that you are using, jquery goes through a lot of contortions to find things - so you could create variables like this:

var $red = $("#red");
var $blue = $("#blue");

// and use them like this:
$red.css("background-color", "black");

That would mean that instead of jquery going through gobs of code to find the element each time, you would only do that once and then just use the cached information to access it with the various jquery methods.

Gulsvi
@gulsvi
^That's a great suggestion. If you don't expect to call $("#red") anywhere else, you could speed up that method above with:
$("#red").focus(function() {
  var $this = $(this);
  $this
    .css("box-shadow", "0 0 10px 15px yellow")
    .delay(5000)
    .queue(function() {
      $this.css("box-shadow", "none").blur();
    });
});
Ken Haduch
@khaduch
@gulsvi - great tips - I haven't used jquery queue at all - I'll have to remember that, probably will come in handy sometimes - thanks!
CamperBot
@camperbot
khaduch sends brownie points to @gulsvi :sparkles: :thumbsup: :sparkles:
:star2: 2641 | @gulsvi |http://www.freecodecamp.org/gulsvi
Gulsvi
@gulsvi
@khaduch Thank you too! A jQuery Promise also works :)
$("#red").focus(function() {
  var $this = $(this);
  $this
    .css("box-shadow", "0 0 10px 15px yellow")
    .delay(5000)
    .promise()
    .done(function() {
      $this.css("box-shadow", "none").blur();
    });
});
CamperBot
@camperbot
gulsvi sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3775 | @khaduch |http://www.freecodecamp.org/khaduch
Daniel
@DanJP2016
working out the javascript for the tic tac toe challenge. I'm thinking the best approach would be to have a core function keep track of the game state and update the board instead of letting the player clicks fire everything off, but I am at a loss and open to suggestions.
Multivac
@univacc
in mdn's cascade and inheritance page, it says "The only way to win against an ID selector is to use !important", but we can win against ID selectors with inline styles o.O
Is there something I'm missing
Bin Gao
@gaobin1019
"Inline styles added to an element (e.g., style="font-weight:bold") always overwrite any styles in external stylesheets, and thus can be thought of as having the highest specificity."
Multivac
@univacc
Thanks @gaobin1019
CamperBot
@camperbot
enigmacipher sends brownie points to @gaobin1019 :sparkles: :thumbsup: :sparkles:
api offline
abraham anak agung
@padunk
@enigmacipher !important will ignore any inline styles
Eric Weiss
@eweiss17
!important is great
Ken Haduch
@khaduch
@enigmacipher - they make a point when referring to inline style attributes: (such declarations don't have selectors, so their specificity is always simply 1000.) So, technically, there is no "selector" involved in an inline style, so they are talking about a "win against an ID selector" - and they are talking about other selectors (which, an inline style doesn't have) so there isn't any way to "beat" an ID selector with any other selector unless you use !important. I think that is the logic behind their statement.
Heathercoraje
@Heathercoraje
Hello friends, consider this code
arr1.sort(function(a, b) {
        return a[1] > b[1] ? 1 : a[1] < b[1] ? -1 : 0;
    });
}
I don't understand why returning 1,-1 or 0 would sort an array?
Bin Gao
@gaobin1019
the function let you specify who is bigger, a or b. It serves as a parameter to the sort function.
Heathercoraje
@Heathercoraje
but when return with 1, what happens?
Bin Gao
@gaobin1019
-1 means a < b, 0 means a === b, 1 means a > b
Heathercoraje
@Heathercoraje
then it just sorts based on that
brilliant.
Thanks! @gaobin1019
CamperBot
@camperbot
heathercoraje sends brownie points to @gaobin1019 :sparkles: :thumbsup: :sparkles:
api offline
check this example @Heathercoraje
Heathercoraje
@Heathercoraje
@gaobin1019 precisely. I also found docs. it was silly one haha
Bin Gao
@gaobin1019
:)