« first day (4059 days earlier)      last day (874 days later) » 

10:40 AM
Hello guys
can somebody explain to me why i cannot call my var (cursorImg) out side ?
when i call it in consolelog, it's 'undefined' !
var cursorImg;
$("#map-france").on("mousemove", function (e) {
if ($(window).width() < 480) {
var x = e.pageX - $("#map-france").offset().left;

return (cursorImg =
x > $("#map-france").width() / 2
? '<div class="hoverinfo" style="position: absolute; right: 0; bottom: -35px;"><strong>'
: '<div class="hoverinfo" style="position: absolute; left: 2rem; bottom: -35px;"><strong>');
 
11:40 AM
cursorImg is only going to be assigned on a mousemove event which cannot happen now and will most definitely happen later. Therefore, when the console.log() runs you get undefined because mousemove hasn't happened yet.
 
i moved console.log in mousemove function, now i can see the result, bu how can i do the same in the return[] ?
here :
        if ($(window).width() < 480) {
            var cursorImg;

            $("#map-france").on("click", function (e) {
              var x = e.pageX - $("#map-france").offset().left;

              cursorImg =
                x > $("#map-france").width() / 2
                  ? '<div class="hoverinfo" style="position: absolute; right: 0; bottom: -35px;"><strong>'
                  : '<div class="hoverinfo" style="position: absolute; left: 2rem; bottom: -35px;"><strong>';
              console.log("test ", cursorImg); // test undefined
    i have this 'return[]' here :
     return [
                      cursorImg,
                      myJson_departement_list[i]["dep_name"],
                      "<br/>",
                      myJson_departement_list[i]["total_parrainages"],
                      " parrainages",
                      "</strong></div>",
                    ].join("");

and the cursorImg in it still empty
 
@mitsu Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
 
12:21 PM
hi, I have following error in typescript. I have one response from API,

result: ApiResponseType | ErrorResponse // ApiResponse { status: string; }

result.status // throw error in typescript
// status is not exist on `ApiResponse | ErrorResponse`
 
 
2 hours later…
user17382064
2:11 PM
I was supposed to do this: Top

const manageUI = (function makeManageUI() {
  const body = document.body;

  const players = [];

  function findPlayers() {

  }

  function getWrapper(cover) {
    const parent = cover.parentElement;
    const wrapper = parent.querySelector(".wrap");
    return wrapper
  }
Bottom

function init() {
    findPlayers();
    const exitButtons = document.querySelectorAll(".exit");
    addClickToExit(exitButtons);
    body.addEventListener("animationend", animationEndHandler);
 
user17382064
 
4:54 PM
Like we can search for [data-src="something"] is it possible to have variable instead of something which we give through a function with values 1,2,3,4... which is decided before search. (It is written inside querySelectorAll)
Something like this: var reed = 1(may be 2,3,...);
querySelectorAll(`[data-src=${reed}]`)
Is it possible to write with literals inside querySelector
 
5:17 PM
Or say some condition and search until value is < 2 and after that querySelector don't search
 
 
5 hours later…
user17382064
9:56 PM
Here I need to use forEach to loop over each of the elements in allCovers, where the looping function is called addToPlayers. The function parameters of loop are cover and index.

  function findPlayers() {
    const allCovers = document.querySelectorAll(".cover");
    const allWrappers = document.querySelectorAll(".wrap");
  }
 
user17382064
How would I do that?
 
user17382064
Is this right?

  function findPlayers() {
    const allCovers = document.querySelectorAll(".cover");
    allCovers.forEach(function addToPlayers(cover, index) {
      const allWrappers = document.querySelectorAll(".wrap");
    });
  }
 
user17382064
I don't think I did it right.
 
user17382064
Vlas, Kevin
 
user17382064
10:25 PM
Is this close?

 function findPlayers() {
    const allCovers = document.querySelectorAll(".cover");
    const allWrappers = document.querySelectorAll(".wrap");
    allWrappers.forEach(function addToPlayers(cover, index) {});
  }
 
user17382064
11:05 PM
That was right. I did it right.
 
user17382064
Inside of the addToPlayers loop, I need to push to the players array an object. That object consists of a property called cover, and a property called wrapper.
 
user17382064
I'm confused on how to do that.
 
user17382064
This was my attempt.

  function findPlayers() {
    const allCovers = document.querySelectorAll(".cover");
    const allWrappers = document.querySelectorAll(".wrap");
    allWrappers.forEach(function addToPlayers(cover, index) {
    cover(index);
    wrapper(index);
    });
  }
 
user17382064
11:46 PM
Those instructions go to this code:

  const players = [];

  function findPlayers() {
    const allCovers = document.querySelectorAll(".cover");
    const allWrappers = document.querySelectorAll(".wrap");
    allWrappers.forEach(function addToPlayers(cover, index) {});
  }
 

« first day (4059 days earlier)      last day (874 days later) »