« first day (4056 days earlier)      last day (887 days later) » 

6:43 AM
@VLAZ yes, I think same. But I see <br> in the list of replaced elements, as mentioned here, thenewcode.com/461/…
 
 
3 hours later…
user17382064
9:56 AM
I need to split this line into 2 lines.

One line defines a cover variable where querySelector and coverSelector are used to get the cover, and the other line defines a parent variable that uses the cover variable and parentElement.

How do I do that?

const parent = document.querySelector(coverSelector).parentElement;
 
user17382064
vlaz or Kevin
 
Hi All,
IM facing one issue with the facebook redirection on error
below is the error that I get, as my application is in development mode
{"message":"App not set up: This app is still in development mode, and you don't have access to it. Switch to a registered test user or ask an app admin for permissions."}
I get this error on with url on the browser but it does not hit my API endpoint
http://localhost:3005/social/login/facebook/callback?error_code=1349126&error_message=App+not+set+up%3A+This+app+is+still+in+development+mode%2C+and+you+don%27t+have+access+to+it.+Switch+to+a+registered+test+user+or+ask+an+app+admin+for+permissions.#_=_
if I remove the error_code and error_message then it hits my API service endpoint
Im using passport.js for authentication
If i only hit
localhost:3005/social/login/facebook/callback from browser, it does hit my service locally
 
user17382064
10:17 AM
This was my attempt:     const cover = document.querySelector(coverSelector);
    const parent = document.querySelector(cover).parentElement;
 
user17382064
I am supposed to do this: One line defines a cover variable where querySelector and coverSelector are used to get the cover, and the other line defines a parent variable that uses the cover variable and parentElement.
 
10:30 AM
@htmlcssjava321 parent = cover.parentElement ?
 
user17382064
@VLAZ That line is in here: jsfiddle.net/paf0dbvu
 
user17382064
const players = (function coverUIPlayerFacade() {

  function addPlayer(coverSelector, playerOptions) {
    const parent = document.querySelector(coverSelector).parentElement;
    const wrapper = parent.querySelector(".wrap");
    const callback = managePlayer.adder(wrapper, playerOptions);
    manageCover.addCoverHandler(coverSelector, callback);
  }
 
user17382064
The code should still work after the change is made.
 
It should const cover = document.querySelector(coverSelector); will get the cover so you can use it later, const parent = cover.parentElement; would get its parent. It's effectively the same as your current const parent` line. Just split into two.
 
user17382064
That did not work in the code as there is no video after the curtain opens now. jsfiddle.net/7n0beocu
 
user17382064
10:41 AM
const cover = document.querySelector(coverSelector);
const parent = cover.parentElement;
 
user17382064
What is wrong?
 
user17382064
Original line: const parent = document.querySelector(coverSelector).parentElement;
 
It should work. The two are exactly equivalent - extracting a sub-expression (in this case the document.querySelector(coverSelector)) to a separate variable has no effect. Other than allowing you to use the new variable later.
 
user17382064
I got it now: jsfiddle.net/p40sefr8
 
user17382064
  function addPlayer(coverSelector, playerOptions) {
    const cover = document.querySelector(coverSelector);
    const parent = cover.parentElement;
    const wrapper = parent.querySelector(".wrap");
    const callback = managePlayer.adder(wrapper, playerOptions);
    manageCover.addCoverHandler(coverSelector, callback);
  }
 
user17382064
10:51 AM
I accidently removed a line in my previous attempt.
 
1:37 PM
o/
 
Hi buddddies
In this video they're using readFile from node fs as a global function... is this code wrong?
I tought one has to require fs:
const fs = require('fs')
 
1:54 PM
@HenriqueMilli Look how far down has this been scrolled. Who knows what code is above.
 
2:20 PM
How to use generic type? What am I wrong here? The following does not compile.
  type Func = <T>(arg: T) => T;
  let foo: Func = <number> (arg: number) => arg * 10;
 
@VLAZ I guess. Misleading at least
@GodMustBeCrazy or you must lack the ability to understand it's logic
 
@HenriqueMilli I want to create a generic type with type reserved word.
And I want to use the type to instantiate an object called foo. I have no idea how to declare and initialize foo.
 
Say I have a variable currentUser, and that is equal to Player 6. How can I loop through the following to get Team 2 returned?
var teamData = [
  {
    "Team" : "Team 1",
    "Players" : [
    "Player 1",
    "Player 2",
    "Player 3",
    "Player 4"
    ]
  },
  {
  "Team" : "Team 2",
  "Players" : [
  "Player 5",
  "Player 6",
  "Player 7",
  "Player 8"
  ]
  }
];
 
I don't want to use interface here for the sake of learning purpose only.
I got the answer:
  type Func<T> = (arg: T) => T;
  let foo: Func<number> = (arg: number) => arg * 10;
  console.log(foo(2));
 
2:46 PM
@HenriqueMilli Probably done to avoid focusing on details that are basically irrelevant. When you want to present, you want to focus as much as possible on what you're presenting. Any extra details can be distracting.
 
ok but you should declare that this is not real working code, just pseudo-code.
Otherwise people will copy paste, run, and feel stupid cause it doesn't work
 
3:20 PM
function getTeam(player) {
	// Code to loop through teamData
  return 'Team 2';
}

var currentUser = "Player 6";
var currentTeam = getTeam(currentUser)
so instead of hard coding the return 'Team 2'; would something along the following lines work teamData.Players.forEach(player)
 
3:35 PM
hey when you upload files, how do you name them?
one solution was to md5 hash a combination of original name, datetime and random string/number. Yet, there is still a chance a file with that name exists in the folder.
 
hash + date
if there's a file already append a number
like (2)..(3) and so on
 
does the fs module have something for that or do I have to check number in filename and increment by 1?
 
@BeerusDev .forEach() doesn't return anything. You probably want `.map()
@MisterGeeky depends - if you don't care about names, then some prefix + timestamp is enough, e. g. export_data_12345
If you want them more representative, then you can embed the date in ISO8601 format
export_data_2021-11-22-16-14-22-12345 for example. It should still be unique
You can embed customer ID/username/user ID or similar to distinguish the files more, e.g. export_data_Fred_12345 will tell you that "Fred" exported it and 1234 is whatever time format you want to embed there.
And "export_data" is whatever the file is actually about, of course. Just picked something sounding relevant at random.
 
3:50 PM
I will try map(), I am close with this
	for(i=0; i < teamData.length; i++){
		if(teamData[i].Players.includes(currentUser)){
    console.log(player);
    }
  }
 
@VLAZ map for searching/lookup work?
 
@BeerusDev team.filter(x => x.Players.includes(currentUser)) is what you want here.
@makadev Yeah, sorry I was distracted - I thought it was extracting information
Like, extract via projection
 
@VLAZ I vote for nested for loops, not that fancy filter/include/find/forEach stuff :>
 
I dunno, what is the actual goal here?
 
I guess it's finding the "Team" for a "Player"
 
3:55 PM
if it's finding one thing, a for loop might be preferrable
 
the actual goal is to do the following
 
i dont understand how the for loop relates to the function it is in
the only parameter passed to the function isn't used in the loop
and the return value doesn't seem to be related to the loop, at least in your samples
 
if the currentUser value is say "Player 6" then I will get the currentTeam value to be Team 2 which is where Player 6 is located
the Team 2 return is hardcoded, that is the end goal I want to achieve dynamically
 
i could just leap ahead and guess player is some value related to the player you're looking for, but then i don't get why it wasn't used in place of currentUser
 
const team = teamData
  .find(team => team.Players.includes("Player 6"))
 
4:00 PM
//In other words, you've given us this:

function getTeam(player) {
  // Code to loop through teamData
  for(i=0; i < teamData.length; i++){
    if(teamData[i].Players.includes(currentUser)){
      console.log(player);
    }
  }
  return 'Team 2';
}
// where player isn't used and currentUser is magic and we don't know where to pull 'Team 2' from
 
function getTeam(player, teamData=teamData) {
  for(let i=0; i < teamData.length; i++) {
    for(let j=0; j < teamData[i].Players.length; j++) {
      if(teamData[i].Players[j] === player) {
        return teamData[i].Team;
      }
    }
  }
  throw new Error("PANIC");
}
:>
 
const search = player =>
  teamData.find(team => team.Players.includes(player))?.Team;
 
//???

function getTeam(player) {
  // Code to loop through teamData
  for(i=0; i < teamData.length; i++){
    if(teamData[i].Players.includes(player)){
      return teamData[i].name;
    }
  }
}
 
function getTeam() {

const team = teamData
  .find(team => team.Players.includes(currentUser));
  console.log(team.Team)
	return team.Team;
}

var currentUser = "Player 6";
var currentTeam = getTeam(currentUser)
Now I can dynamically filter the table based on the team that user is in to only show something pertaining to that team
Many thanks
 
 
1 hour later…
user17382064
5:13 PM
Kevin.
 
user17382064
These 3 work in the code, which should be used?

let currentPlayButton = {};

let currentPlayButton = “”;

let currentPlayButton;
 
user17382064
  function animationEndHandler(evt) {
    const animationName = evt.animationName;

    if (animationName === "initial-fade") {
      body.classList.remove("initial-fade");
      showCover(currentPlayButton);
    }
  }

  function coverClickHandler(evt) {
    currentPlayButton = evt.currentTarget;
    body.classList.add("initial-fade");
  }
 
user17382064
or vlaz
 
user17382064
 
user17382064
of these which should be used?

let currentPlayButton = {};

let currentPlayButton = “”;

let currentPlayButton;
 
5:23 PM
why do you need it at all
 
user17382064
5:47 PM
The code won't work without it.
 
it can
if you remove the dependence on it.
but to answer your actual question, it's irrelevant
if you can't default it with something that can perform the actions you intend to perform on it, then what you default it to doesn't matter, because no matter what you default it to it will fail if you try to use it before you set it to something else.
 
user17382064
I was told: "those absolutely do not do the same thing under the hood. While the code might run, and appears to run in both JSFiddle versions, it actually doesn’t."
 
out of context that statement doesn't say anything useful
if it's in context of which of the 3 let currentPlayButton is correct, it's a useless distinction.
 
 
3 hours later…
8:30 PM
@htmlcssjava321 If you have to choose one of these, go with option 3 then add if (!currentPlayer) showCover(currentPlayer); to make sure you're not calling that with a weird value. However, I feel like there is probably a better way to handle than a shared variable. I just don't want to try to read and understand 300 lines of code to find it.
 
user17382064
9:19 PM
:53510789 jsfiddle.net/kLdfr0pv

With this line removed: //let currentPlayButton;

The code still works.

What does that mean?

Clicking on the play buttons, they stil fade-out.

function animationEndHandler(evt) {
    const animationName = evt.animationName;

    if (animationName === "initial-fade") {
      body.classList.remove("initial-fade");
      showCover(currentPlayButton);
    }
  }

  function coverClickHandler(evt) {
    currentPlayButton = evt.currentTarget;
    body.classList.add("initial-fade");
 
that creates a global variable
it works similarly to it not being commented out, but it results in window.currentPlayButton existing.
 
 
2 hours later…
11:42 PM
I have a CLI tool that uses Ink, so it has a dependency on `"react": ">=16"`. If it is installed in an application that uses `"react": "17.0.1"`, you get the "Invalid Hook Call" error. The cause of this is that the dependencies are resolved like this:

"react@npm:17.0.1":
version: 17.0.1
resolution: "react@npm:17.0.1"

"react@npm:>=16":
version: 17.0.2
resolution: "react@npm:17.0.2"

How do I mark a dependency as only necessary if it a matching dependency doesn't already exist?
 

« first day (4056 days earlier)      last day (887 days later) »