« first day (4275 days earlier)      last day (656 days later) » 

12:07 PM
Hello, can someone help with a simple problem?
 
@Displayname Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
I am doing a foreach loop to capture all td tags from html
document.querySelectorAll(".bolt-list-row").forEach ( row => {

    console.log("row :", row)
})
The above returns multiple html tables inside, but how do I query on the response?
Something like row.getElementById('foo')
 
that will collect the element with id="foo" within <td class="bolt-list-row">
you cna use .querySelector(All) on Node elements. The document here is a Node element ;)
so you cna simply do document.getElementById('foo').querySelectorAll('.bar') to select all these <p> elements here below
<div id="foo">
  <p class="bar"> ... </p>
  <p class="bar"> ... </p>
  <p class="bar"> ... </p>
</div>
Also a point of warning, do know that .forEach on a NodeList (returned collection from calling .querySelectorAll(...) is not supported by Edge below a certain version
 
But I have many `foo` elements, and inside it, there are many `bar` and inside that many `tar`

I can get `tar` easily using because it has a fixed `aria-colindex='x'`
getElementById('foo') will only return one element, so it won't work
 
if you put a space in your selector, you can fine-graine your result list
.foo .bar selects only elements that has class tar in elements with class bar
best to give a part of your document structure
 
12:23 PM
tr > td > div > span > span.text-ellipsis
Those are the elements I need to traverse to find the text (something something)
I need the aria-colindex="2" so the td is not a problem to locate
 
12:40 PM
@Displayname do note that getElementById method is not exposed on elements, so you need to use it on Document. On a related note, are you sure you want to select by id? The screenshot you posted above does not indicate there are ids.
 
@OlegValteriswithUkraine I never wanted to select by Id, I was replying to @KarelG why Id is not needed
 
@Displayname fi you can guarantee that this attribute is always present, you can select by td[aria-colindex="2"]
 
33 mins ago, by Display name
Something like row.getElementById('foo')
^ it was an aside to this
 
figured out it was just giving an example, trying to explain what he want to get?
 
Ah, yeah didn't realize it but meant to overall say query the dom
 
12:45 PM
One never knows, @KarelG :) especially when as per spec, the method exists, but is not exposed on elements
On a more related note, maybe just use a selector that selects tr .text-ellipsis and iterate on that node list of elements? Do you need row for anything else in the callback?
 
document.querySelectorAll('tr.bolt-table-row').forEach((tr, key) => {
    let element = document.createElement('html').innerHTML = tr;
    let title = element.querySelector('td[aria-colindex="2"] div span.text-ellipsis')
    console.log(title )
})
This seems to work currently
But I am getting <span class="text-ellipsis body-m">Something someting</span>
Is there a way to only show the text?
title.innerHTML throws an error
 
use .textContent
 
1:18 PM
thanks
 
2:02 PM
posted on June 30, 2022 by Ben Mason

Hi everyone! We've just released Chrome Dev 105 (105.0.5149.0) for Android. It's now available on Google Play. You can see a partial list of the changes in the Git log. For details on new features, check out the Chromium blog, and for details on web platform updates, check here. If you find a new issue, please let us know by filing a bug. Krishna Govind Google Chrome

 
 
3 hours later…
5:14 PM
posted on June 30, 2022 by Ben Mason

Hi everyone! We've just released Chrome Beta 104 (104.0.5112.29) for iOS; it'll become available on App Store in the next few days. You can see a partial list of the changes in the Git log. If you find a new issue, please let us know by filing a bug. Harry Souders Google Chrome

 
5:29 PM
o/
 
5:43 PM
!async function() {
		let data = fetch('/_api/web/CurrentUser', {
          headers: {
          'Accept': 'application/json;odata=verbose'
          }})
            .then(response => response.json())
            .then((data) => {
              return data;
          })
		  .catch(error => {
			console.error(error);
		  });
		  console.log(d.Title);
		  }();
returns a d : { Title : val }
Why is it telling me d is not defined
 
wdym
 
Trying to get the Title value from the result and use it in another fetch call as a filter
 
@BeerusDev Because... d is indeed not defined
 
i don't see d defined anywhere in your code
 
!async function() {
    let data = fetch('/_api/web/CurrentUser', {
            headers: {
                'Accept': 'application/json;odata=verbose'
            }
        })
        .then(response => response.json())
        .then((data) => {
            return data;
        })
        .catch(error => {
            console.error(error);
        });
    console.log(d.Title);
}();
Here is the formatted code.
There is no declaration of d anywhere.
 
5:46 PM
Does Ctrl+k not format it anymore
 
ctrl+k just indents it
making it a code block, it doesn't properly format it
 
@BeerusDev It doesn't normalise the different indentation
 
also, what does your console.log have to do with the fetch?
the fetch mightaswell not be there, it has no effect on it
 
If you meant to use data.title then you need to await the fetch() call.
You have an async function without an await in it, which should raise alarm bells.
 
Oh my god....
I knew I forgot something
		!async function() {
		let data = await fetch('/_api/web/CurrentUser', {
          headers: {
          'Accept': 'application/json;odata=verbose'
          }})
            .then(response => response.json())
            .then((data) => {
              return data.d;
          })
		  .catch(error => {
			console.error(error);
		  });
		  console.log(data.Title);
		  }();
 
5:48 PM
Also, in general, avoid mixing await and the promise API. It's only because it's might be confusing to you.
 
@BeerusDev 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
1 message moved to Trash can
 
Also, for promise API .then((data) => { return data; }) is completely useless. Just don't add it.
You have a mix of tabs and spaces in your code
 
@BeerusDev 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
 
I am struggling to format this
 
!async function() {
    let data = await fetch('/_api/web/CurrentUser', {
            headers: {
                'Accept': 'application/json;odata=verbose'
            }
        })
        .then(response => response.json())
        .then((data) => {
            return data.d;
        })
        .catch(error => {
            console.error(error);
        });
    console.log(data.Title);
}();
 
1 message moved to Trash can
 
I formatted by 1. Copy the code 2. paste into beautifier.io 3. click Beautify Code 4. Copy the formatted code 5. Paste in the message box here 6. Press Ctrl+K
 
Why is the .then((data) => {return data; }) useless
It returns an undefined results without that
 
It just returns the data that it would otherwise return.
 
5:53 PM
Ah
 
Can someone help me with this error? I thought it was because of using codepen but it is erroring locally as well. codepen error: IndexSizeError: Selection.getRangeAt: 0 is out of range
However the selection is set to 0 so Im not sure what Im missing. Stolen code so dont really know what Im doing. Trying to get this to work: stack
 
@ZackTarr Can't reproduce it. I tried typing in the box but I see no error. What should I do to see it?
 
Well thats super cool. What browser are you using?
Thats all Im doing to get the error.
 
Firefox 101
 
Amen, did you press space or no?
 
5:59 PM
The only logs I get are 1 and then "World"
Yes, I get those logs on a space
 
Wtf, so your selection is 1 then mine is 0
Whyyyy
 
¯\_(ツ)_/¯
 
-_-
I just need a clean way to get the last word a user typed
Back to searching for some solutions
 
lol
 
@ZackTarr like words = $("textbox").text().split(" "); console.log(words[words.length -1])?
I suppose you could improve upon it but that should give you the last one.
 
6:03 PM
Well was hoping for a solution that would find the last word no matter where it was typed.
 
it's so nice having a .last property
(dart)
 
||> ["a", "b", "c"].at(-1)
 
@VLAZ 'c' Logged: [ ] Took: 0ms
 
["a", "b", "c"].last
 
Which that solution I was copying from works correctly in slack. But no idea why Im getting an error and you guys are not lol. Oh well. Ill figure something out.
 
6:05 PM
@KevinB Yeah, no .last but I think .at() is more powerful, since you can also take the second to last or third from last and so on.
Not sure how often exactly they come up but I've needed second to last a few times.
 
yeah i don't think dart has a shortcut for that
or if it does the docs don't show it
.elementAt is similar, but doesn't allow -
 
const userFilter = '';
!async function() {
    let data = await fetch('/_api/web/CurrentUser', {
            headers: {
                'Accept': 'application/json;odata=verbose'
            }
        })
        .then(response => response.json())

        .catch(error => {
            console.error(error);
        });
    //console.log(data.d.Title);
    let userFilter = data.d.Title;
}();
console.log(userFilter);
What I am trying to do is access the data.d.Title value outside of the fetch but cannot
 
that's impossible
 
so the other fetch I am trying to use it in I would have to chain to that fetch?
 
in essence
async/await can make it prettier
 
6:18 PM
const mySubmittedLeave = new Request(
is this valid within another fetch to make a new Request?
 
const userFilter = await (async yourfunction () {}())
 
ahh
I see
 
of course, that means the surrounding function needs to be async
 
Or if the environment supports top-level awaits, that can work, too.
 
6:37 PM
const userFilter = async () => {
	let data = await fetch('/_api/web/CurrentUser', {
	  headers: {
	  'Accept': 'application/json;odata=verbose'
	  }})
		.then(response => response.json())
		.then((data) => {
			return data.d.Title;
		})
	  .catch(error => {
		console.error(error);
	  });
}

console.log(userFilter)
 
You don't return anything from userFilter
 
userFilter in this case is redundant
err
const userFilter = await fetch('/_api/web/CurrentUser', {
  headers: {
    'Accept': 'application/json;odata=verbose'
  }})
  .then(response => response.json())
  .then((data) => data.d.Title)
  .catch(error => {
    console.error(error);
  });
}
course, you can also just use multiple awaits rather than multiple .then, and you want a try catch anyway for the await,
 
6:57 PM
    const userFilter = await fetch('/_api/web/CurrentUser', {
      headers: {
        'Accept': 'application/json;odata=verbose'
      }})
      .then(response => response.json())
      .then((data) => data.d.Title)
      .catch(error => {
        console.error(error);
      });
    }

console.log(userFilter);
Why does it give me an udefined, then it console logs the result
 
Was there an error?
And if not, does the response match what you expect?
 
console.log(...) returns undefined
console.log logs the result
so if you ran that from your dev tools, you'd see undefined and what you logged
 
Nope no error. It does match expected value, but its logging an undefined pripr to logging
 
Oh damn, missed that you also get the result. Yeah, console.log() does return undefined.
 
I am just testing in my console
 
7:01 PM
If you try this in the console, you'd get the return value.
 
	const userFilter = await fetch('/_api/web/CurrentUser', {
	  headers: {
	  'Accept': 'application/json;odata=verbose'
	  }})
		.then(response => response.json())
		.then((data) => data.d.Title)
	  .catch(error => {
		//console.error(error);
	  });
Gives undefined in console
console.log(userFilter) after the await gives
undefined
'Expected Value'
 
That would give undefined because it's a declaration. Variable declarations don't have a return value, either. They are statements.
 
that's expected
 
10-4
 
Try const x = 42; and you'd get undefined after it. Then console.log(x) would give you 42 and undefined
 
7:29 PM
await is only valid in async functions and the top level bodies of modules
 
correct
for it to work in the console, you'd need to wrap it in another function that is async
 
For, as it says, it's valid in async functions.
 
8:02 PM
posted on June 30, 2022 by Prudhvikumar Bommana

The Dev channel has been updated to 105.0.5148.2 for Mac, Linux and Windows. A partial list of changes is available in the log. Interested in switching release channels? Find out how. If you find a new issue, please let us know by filing a bug. The community help forum is also a great place to reach out for help or learn about common issues. Prudhvikumar Bommana Google Chrome 

 
8:14 PM
posted on June 30, 2022 by Ben Mason

The Dev channel has been updated to 105.0.5148.2 for Windows, Mac and Linux. A partial list of changes is available in the Git log. Interested in switching release channels? Find out how. If you find a new issue, please let us know by filing a bug. The community help forum is also a great place to reach out for help or learn about common issues. Prudhvi Bommana Google Chrome

 
8:24 PM
No one answers stackoverflow.com/questions/72821382. Is it clear? It's about optimization algorithm. Can someone do it please? Thanks.
 
@RHERWOLF 1. I don't think it's at all related to JS. 2. You posted it less than half an hour ago. There is no obligation or guarantee anybody would see or answer a question in this time.
 
also "In this case, which algorithms are most used, acclaimed for efficiency...? Is in such cases common to prefer improvised algorithms over the widely studied ones?" seems kind of opinion-based
 
8:52 PM
@RyanM Yes, although tests probably indicate good options.
 
 
3 hours later…
11:53 PM
i can consult topist comming from react here?
 
@AlbertoJoséGiuseppeRojas Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
anyone know about implementing Talks.js to a react project maybe I'm doing something wrong and its not working
 

« first day (4275 days earlier)      last day (656 days later) »