These are chat archives for MontCode/GeneralChat

11th
Sep 2016
Lily Romano
@Lilyheart
Sep 11 2016 15:30
@SimplyPhy are you coming Wednesday? I have to record a speech for my online public speaking class in front of 3 people (due Wednesday). I'm so rarely around that many people at once where I'd have the opportunity to record a speech. I don't think my roommate + 2 cats would count :laughing: .
Eric Phy
@SimplyPhy
Sep 11 2016 16:37
yeah i’ll be there :steam_locomotive:
Lily Romano
@Lilyheart
Sep 11 2016 17:08
Thanks! It’s upstairs in the limited space so you might wanna go on Meetup and RSVP to ensure you have a seat (not that I think there will be a run on people, but still…) I am tryin’ to get people today on Tuesday to do it, but Wednesday (the due date) will be a backup in case anyone can’t make it.
Hopefully I can find a few more people for Tuesday and it’ll be a non-issue. heh
Jonathan Herman
@lantech19446
Sep 11 2016 18:26
my schedule changed and i'm only 10-4 now on Wednesdays so if my wife ever has to work til 10 that night or pull and overnight I may actually come
Eric Phy
@SimplyPhy
Sep 11 2016 18:39
i don’t think i can make it tuesday, just fyi :le sigh: doing doylestown software dev meetup. They haven’t done one in awhile
so i’m baffled atm, anybody know why this works where it does and doesn’t where it does?
// Add guest functionality
var new_guest,
    guest_div,
    first_guest = true,
    guest_array = [],
    guest_id = 0;

function createGuestDiv(guestName) {

  guest_div = "<div id='guest"+guest_id+"' class='new-guests'>" +
                "<span class='guest-span'>"+guestName+"</span>" +
                "<button type='button' class='guest-remove'> x</button>" +
              "</div>";
  return guest_div;
}

$guests_button.click(function() {
  if ($event_guests.val().length > 0) {
    if (first_guest) {
      $guests_container.show();
      first_guest = false;
    }
    new_guest = $event_guests.val();
    // guest_array.push({id: guest_id, name: new_guest});                 <-- doesn't work here
    $guests_container.append(createGuestDiv(new_guest));
    // guest_array.push({id: guest_id, name: new_guest});                 <-- doesn't work here
    removeGuestListener($('#guest'+guest_id+' .guest-remove'));
    guest_array.push({id: guest_id, name: new_guest});//                  <-- works here!??                   
    guest_id++;
    $event_guests.val('');
    $event_guests.focus();
    $guests_button.css('background', 'linear-gradient(170deg, rgb(255, 255, 255) 30%, hsl(147, 47%, 96%) 60%)');
  }
  console.log(guest_array);
});

// I need to search the array for the value of the parent, find it's index, and slice/remove it
function removeGuestListener(guest) {
  guest.click(function(){
    $(this).parent().remove();
  });
  for (var i = 0; i < guest_array.length; i++) {
    if (i === guest_array[i].id) {
      guest_array.splice(i, 1);
    }
  }
}
Lily Romano
@Lilyheart
Sep 11 2016 18:40
Wednesday?
Eric Phy
@SimplyPhy
Sep 11 2016 18:40
if you scroll right you’ll see the notes in the middle
Lily Romano
@Lilyheart
Sep 11 2016 18:40
Ooh chat. Right.
On the phone rn. Can't tell from here. @davidjcastner ?
Eric Phy
@SimplyPhy
Sep 11 2016 18:43
no rush, i have it working, i just have no idea why it works in only one of three places. doesn’t appear to make any sense.
Eric Phy
@SimplyPhy
Sep 11 2016 18:53
figured it out
i accidentally put the for loop in the removeGuestListener outside of the click handler, which made it run automatically regardless of click xD
<— idiot
Lily Romano
@Lilyheart
Sep 11 2016 19:05
Not idiot. You figure it out. So many people quit before then.
Eric Phy
@SimplyPhy
Sep 11 2016 19:40
#determinedIdiot :P
Eric Phy
@SimplyPhy
Sep 11 2016 20:04
Here’s the corrected and completed function (yay)
function removeGuestListener(guest) {
  guest.click(function(){
    var thisElem = $(this).parent();
    var thisIndex = $('.new-guests').index(thisElem);
    $(this).parent().remove();

    for (var i = 0; i < guest_array.length; i++) {
      if (i === thisIndex) {
        guest_array.splice(i, 1);
      }
    }
  });
} // corrected*