« first day (3251 days earlier)      last day (1711 days later) » 

ABC
12:19 AM
@KarelG
 
 
3 hours later…
 
2 hours later…
5:09 AM
Anyone can help ? Here is a issue i am facing: stackoverflow.com/questions/57860499/…
 
@appsntech 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.
 
@CapricaSix thanks I just posted my issue.
 
 
1 hour later…
6:31 AM
just curious, what's the usual/easy way of rounding a number, say you had 332 --> round --> 340?
 
n => Math.round(x/(10**n))*(10**n)
for low-precision numbers
I'm assuming you want Math.ceil, to round 33.2 to 34
 
6:49 AM
sorry, that should be (x, n) => ...
 
@towc 332, 339 --> 340, not 33.2 to 34
 
well that's why you'd multiply it afterwards by 10**n
 
@Adan if you spent some time to understand the code I sent, you'd get why I used those numbers
 
im replying to the 2nd last line, where you say i was assuming i want math.ceil
the first - second line is what i was looking for, thanks
 
I know
please try to understand it before you use it
 
7:06 AM
I'm gonna build my own rounding formula. With blackjack! And hookers!
 
7:20 AM
towc long time no see
 
7:52 AM
Hey folks, suppose I want to add an errorCode property to my Error objects. Should I just assign it directly or extend the Error class? Creating a subclass seems like an overkill.
 
ABC
how to check if the data is duplicated in foreach?
this.global.getData(`/services/getData.php`)
      .pipe(take(1))
      .subscribe((res: any) => {
        this.rowData = res;
        this.rowData.forEach((room) => {
 
8:04 AM
@ABC if this.rowData is an array, you can use .some
 
ABC
8:20 AM
@KarelG do you have example for .some
 
9:16 AM
@AaditMShah If you have hundreds of errors, then it wouldn't be overkill, no
but otherwise, yeah, just use Error class in my opinion
 
who uses native node assert methods?
 
9:27 AM
me
I use chai for most stuff though
omg @AaditMShah how have you been . man :]?
@AaditMShah subclassing is probably better for debuggability since that would mean a better error experience
 class MyError extends Error { constructor(message) { super (message); this.errorCode = 'MY_CODE' } }
 
hi there
dynamically setting `00:00` to input mask, makes input blank, how do I fix it?

fiddle ==> https://jsfiddle.net/jrL85301/
 
You really don't want to use a jQuery plugin for this @AbhishekPandey that hurts accessibility and UX and mobile UX especially
Luckily, the web already has you covered :] developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time
 
how do I set 24 hours format?
 
it is in 24h by default
and yours jsfiddle contains ancient code. Don't use html attributes for actions (eg onclick)
 
@KarelG it was quick reproduce of what I'm facing in my project
 
9:38 AM
@AbhishekPandey The cool part is that it will automatically adapt to the way the operating system time works so people will always get the format they expect from the control.
 
@KarelG naah, it is not 24h for me, also it's not compatible with IE and safari, I can ignore IE but not safari
 
That's because your operating system is configured to use 12h time
 
@BenjaminGruenbaum I get it, but it will break my time calculation
 
Hello,

I've been trying to generate HTML by JS.

I'm stuck at parsing parameters in onclick.

It only works with integers.

Here is the functions at there I'm stuck

/**
* Generate the list
*
* @param content
* @returns {string}
*/
elementsList(content, query_filter, id){
var form = this.form.toString();
var elements = '';
var count = id;
content.forEach(function(element){

var tempObj = {element:element, form:form};

elements += '<a id="select'+count+'" value="'+element[0]+'" onclick="submitForm(tempObj)">'+element[0]+'</a>\n';
 
@DaAmidza 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.
 
9:40 AM
@AbhishekPandey whatever works for you
 
@BenjaminGruenbaum I'm writing code for an attendance system. which will calc in - out time, OT lunch etc.
 
did you have tried that built-in function?
 
@KarelG yup, still blank
 
ok, it seems that the function does not do the job correctly
bah, crappy plugin.
figured it out by checking the source
just do
const inp = $('#adas');
inp.val('00:00');
inp.trigger('mouseenter');
in your click handler
 
9:56 AM
I defined a class in TypeScript and exported it (export default class UserDetails). Now in another file I want to both export an instance of that class and that class, so I did export const UserDetails = new _UserDetails(); export const UserDetailsType = __UserDetails(); with _UserDetails being the import from the above class.
Now when importing that type, TS tells me that it's a value but being used as a type. What am I missing?
Ah scrap all that; export type.
Sorry ^^
 
> Don't forget, union all is a way to add records to a record set without sorting or merging (as opposed to union)
I liked that A -> !A
 
I also thought union disregards order
 
10:11 AM
the end result is not ordered if you want to say that
( but at some SQL db's, it is just the results from first select, followed by results of second select)
 
that's what I had understood
of course if you order the first select, the results from that query will be ordered
 
10:29 AM
@BenjaminGruenbaum Hey Benjamin, I'm doing well. How is life treating you?
 
OHAI @AaditMShah
Wow a MS!
 
10:58 AM
Hey @ShrekOverflow, how are you doing?
 
Good good, moved to London 😃
 
Cool. Pursuing higher studies or working?
 
@ShrekOverflow enjoy a Guiness for me, would ya?
 
@KarelG bit dirty, but worked, thanks
 
@Neil what's that?
@AaditMShah Work
no edu for a while 😛 for me
 
11:12 AM
@AbhishekPandey the other approach is github.com/RobinHerbots/Inputmask/blob/5.x/lib/… which does not work properly if the hooks did not got set correctly
hence that "crappy plugin"
 
Dis I guess
 
mhm guinness
but NEIL!!!
 
@ShrekOverflow Got it. What company do you work for?
 
Auth0 😃
 
That Guinness is an Irish beer, you beer barbarian.
 
11:15 AM
I am staying away from alcohol for a while
 
11:26 AM
			if(thirteenYrsDenom != "" && thirteenYrsDenom != NaN && thirteenYrsNumer != "" && thirteenYrsNumer != NaN && ninteen26YrsDeno != "" && ninteen26YrsDeno != NaN && ninteen26YrsNume != "" && ninteen26YrsNume != NaN) {
			thirteenYrsNumer = parseInt($("#13yrs-numer-valu").val());
			thirteenYrsDenom = parseInt($("#13yrs-denom-valu").val());
 
This ain't no IDE mah dude ;)
 
			ninteen26YrsNume = parseInt($("#1926yrs-numer-valu").val());
			ninteen26YrsDeno = parseInt($("#1926yrs-denom-valu").val());
lol @geisterfurz007 - unless you feel it's a challenge
this condition is failing... it's a right way to check NaN
or i have to use isNan()
or typeof
i checked typeof won't help
 
isNaN is the proper way of checking for NaN
> Unlike all other possible values in JavaScript, it is not possible to rely on the equality operators (== and ===) to determine whether a value is NaN or not, because both NaN == NaN and NaN === NaN evaluate to false. Hence, the necessity of an isNaN function.
 
@KarelG And pizza is italian, but you don't see that stopping you from eating one outside Italy (ಠ_ಠ)
 
			if(thirteenYrsDenom != "" && isNaN(thirteenYrsDenom) != false && thirteenYrsNumer != "" && isNaN(thirteenYrsNumer) != false && ninteen26YrsDeno != "" && isNaN(ninteen26YrsDeno) != false && ninteen26YrsNume != "" && isNaN(ninteen26YrsNume) != false) {
done while waiting for your reply... ;)
that hurt of IDE drove me... ;)
 
11:32 AM
isNaN(thirteenYrsNumer) != false
that comparison check is obsolete fyi
 
thank you @KarelG and gisterfurz007
 
._.
You're welcome ^^
 
btw @geisterfurz007 best to use Number.isNaN instead
it is more robust than what you suggested
 
How so?
 
bust a ro
 
11:34 AM
nvm
 
!!> isNaN('1A');
 
@KarelG true
 
@geisterfurz007 ^
 
Yeah, I just found the entry in the MDN
 
!!> Number.isNaN('1A');
 
11:34 AM
@Neil false
 
interesting
 
you guys must be aluminus from MDN
 
ah, it is just experience and actually doing research yourself
 
chuckles
 
12:00 PM
Hello everyone
 
@Carlos \o
 
I have a problem with ajax 3 weeks ago and I have not been able to solve it. Can someone help me?
 
Just ask and if someone wants to and is able to help, they will get to you :)
 
I have a creation form and another one for editing. In both forms I have three drop-down lists. The idea is to select an item from the first drop-down list and, through ajax, the second one is update and when an item is selected in the second drop-down list, the third one is loaded. codeshare.io/5QYp1q
I'm interested in 3 things:

1- I would like the values ​​not to be lost if you try to register / modify and have been wrong in some data.

2- In the case of the modify form, I would like the DB values ​​to be obtained.

3- If it is a registration (there are no values ​​in the database) and the form is opened for the first time, the ideal would be to select the first item from each drop-down list.

In principle I have all that developed, but I have rare errors. Sometimes, the lists are not loaded and the values ​​are not preserved.
I have seen the code a lot of times and I am not able to see errors.
It is clear that I do not serve for frontend code
I think some of you are probably able to see some error in that code
 
12:50 PM
Hey, didn't get a chance to gist this yet but..I have a div container set as display:block which contains a scrollable list and a child div with position:absolute; bottom:0....the problem Indeed is when the list scrolls via the y-a is overflow it moves the absolute item I had placed at the bottom
Is there any way to keep the absolute div at the bottom even if the relative list overflows? Or should I just move the absolute item outside of this div container?
If that even makes a small bit of sense lol
 
@KarelG :D
 
@BrianJ is that similar as how this chat box behaves?
don't nail a div with position if you don't want to. Using that means "this position and not somewhere else"
 
1:11 PM
@KarelG yeah very similar to the way this chat box is layed out
What other suggestions would you make here in terms of the CSS?
I can make each element withing the display:block; container relative...but this means the bottom element doesn't move to the bottom of the container until the list is expanded
So let's say the block div is rendered it contains an U expaded list, directly after it is this button div that I want to push to the bottom...how would I position it so its at the bottom of the container instead, top or margin maybe? In that case I'd need to know the containers height somehow
 
you should have a look at flexbox
 
1:27 PM
Yeah now that you've said it I reckon display:flex; column would work better and align-item for the button to flex-end
 
Guessing it looks a bit like this
 
Hey! My question has been getting ignored for a bit so I was wondering if anyone could check it out - stackoverflow.com/questions/57857647/…
 
Sounds like you want a module system 😃
 
I tried modules but it didn't go too well because the url for file2.js can be dynamic... it might be /assets/file2.js or ../assets/file2.js
And I want to use vanilla js, so I can't use anything like require.js
 
1:56 PM
really sounds like you want modules.
modules are native 'vanilla'.
just cutting edge. so you'll wanna use a bundler for now
 
I love that vanilla means native
makes me think of ice cream, and vanilla is such a kickass flavor afterall
 
2:12 PM
@Neil Yeah. It's a shame the name got associated with "ordinary".
 
kind of ironic when you think about it
one of the better aspects of node is its simplicity afterall
 
Hey everyone,
1) go to http://react-rte.org
2) type something in editor there
3) now select some text inside the editor and click on the toolbar button which says "Normal"
You see, the selection is visually gone. Can you tell me how does selection work as I am trying to maintain the selection while user plays with toolbar
 
you cannot
fake it
while the select has focus, apply a 'fake' highlighting to the previous selection range, and remove it when the select blurs
 
2:32 PM
@rlemon I was talking about the import tag, which can't have a variable of any kind for the url.
 
well your two locations don't make sense for that issue to be a problem with import.
but if that is the case (assuming you just forgot a .) you can use System.import
which does allow for dynamic imports
 
you mean promise version of import, import()? I thought that was just a proposal
 
supported almost everywhere import is. however that support is still kinda wonky. I still use a bundler.
but once again.. I can almost promise you you don't need dynamic imports
in 99/100 cases people say they need dynamic imports, they don't.
 
I think I do...
The file can be from from the base index, or from another page
(I'm testing the new version out on page options only for now
 
I think the architecture is wrong if you need to swap the location of a single resource like that
but reguardless, you have options if you wanna do it that way
 
2:42 PM
If I do use import() will that fix my issue?
Because I'm pretty sure I tried to use it
 
it'll allow you to use modules and not change how much works (probably)
 
0
Q: Load JS library from another JS library, and let the page use it

VirxECFor my purposes, I want to be able to load a JavaScript library (file1.js) from the HTML page (file.html) and within file1.js, load file2.js. I then want file2.js's functions to be able to run in file.html without loading it directly from file.html. Also, file1.js successfully loads from file.ht...

that ^
 
upon a second look at your script file
script.src = (sessionStorage.getItem("index") == "On")?"assets/CPquery.js":"../assets/CPquery.js";
//script.onload = script.onreadystatechange = start;
script.text = "loadOptions();"; <-- I'm pretty sure, like 99% positive, this won't ever work. and if it does you're a magician.
script tags with src values ignore their contents.
 
oh! that.
I was just trying something
I already tried script.onload and stuff
in the comment above
That was just an experiment
 
Hi everyone! Good Morning
Does any of you knows Gatsby.js?
I'm trying to install react-styleguidist but I can't found how to get the webpack react-styleguidist.js.org/docs/…
 
2:51 PM
Greetings fellow javascript developers.
Life is fleeting. Death is approaching. I'll be 40 tomorrow and 64 the next day.
Despite this, for my brief moment in the sun, I have a question related to react
Has anyone used the graphql query component to search for records in a database, and use rxjs debounce/throttle to rate limit the search queries?
 
not yet, sadly
 
I reverted the changes to Options.js to now use onload and onreadystatechange
 
3:07 PM
Does anyone know of a good node.js package that caches network requests and uses the cache if the server is unresponsive?
 
You can't cache the node files with service workers?
 
@AdrianK. 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.
1 message moved to Trash can
@AdrianK. Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
1 message moved to Trash can
@AdrianK. Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
 
wth, I did ctrl+k
I'm trying to get data through http via HttpClient in Angular, like this:

this.myService.getUserFromLogin("mylogin")
.subscribe((resp) => {
this.userModel = resp.data;
});

The problem is that API returns data inside a "data" object, so in order to assign userModel I need to access resp's data property, how can I do that?
that this.userModel = resp.data; obviously throws me an error since the code doesn't have any idea that resp has a "data" property...
 
> this.userModel = resp.data; obviously throws me an error
well, that isn't obvious
if it's supposed to have that property, that'd be how you'd access it
 
exactly, and since the code treats resp as a plain object there's no such property there, I think
 
3:20 PM
So you'd have to give it a type right? (resp: any), or anything you've created
 
@AdrianK. "since the code treats resp as a plain object"
makes no sense
 
so my userModel is of UserModel type, which is flat (no nested objects), contains regular user stuff
@rlemon this is what I get when I build it: error TS2339: Property 'data' does not exist on type 'Object'.
so I'm assuming that resp is defined as an Object type, thus don't have this property visible and that's why it can't build
 
and that's in your interface?
Cameron has a (I think) short solution. give it any
 
export interface UserModel {
    id: number;
    login: string;
    display_name: string;
}
That's my interface
Data being returned from the API looks like this:
 
I see no data there.
 
3:23 PM
My solution isn't the best, but unless you want to create another interface for the response object, just giving it a type of any will work
 
^
 
{
    "data": [
        {
            "id": "12345",
            "login": "mylogin",
            "display_name": "mydisplayname",
        }
    ]
}
oh, so just strongly type it as any inside the subscribe method...
 
.subscribe((resp: any) => {
just do this
 
yup
Thanks, gentlemen!
 
 
1 hour later…
4:40 PM
you can just do .subscribe((resp: {data: UserModel[]}) => { ... }) though @AdrianK.
 
ooooh, this is an interesting thing to try out
 
alternatively define an interface for the response object
interface APIResponse {
  data: UserModel[];
}
 
so, with the first approach it should be this:
.subscribe((res : {data: UserModel}) => {
          this.userModel = res.data;
        });
or this:
.subscribe((res : {data: UserModel}) => {
          this.userModel = res;
        });
I'd think the first one is correct
 
not really o_O. you need to have an array of UserModel, not a single one
 
API is returning a single user details, why would I need an array of those if the API is returning only one?
 
4:55 PM
because you described it as an array of objects containing one result
[{foo:1}]
still an array
 
oooh, I see
even though it's returning a single user details it's defined as an array in response
 
user11867329
a bee is in my office, what do
 
leave it alone
maybe give it some water
bees are friends.
 
with sugar
 
user11867329
i no but fear and buzzing
 
4:57 PM
bees will only sting you if you're fucking with them.
wasps and hornets are the evil ones
know the difference. bees are friends.
 
user11867329
And I should trust its judgment call of "He's attacking me" ?
 
they never attack first
they defend by attacking, I think
 
user11867329
No, but if they land where I'll be momentarily
 
user11867329
Yes they do, cause they die upon attack
 
user11867329
I'll try to swoop it with a glass and do the ole paper+glass thing
 
5:00 PM
not all bees drop their stingers
 
user11867329
But generally I think they are very swift at deducting they'll die.

Like, somewhat trigger happy, even if it mean death.
 
yea, that's not the case tho
 
user11867329
This one does (Classic bee over here)
 
spend a few minutes looking into it.
 
user11867329
what isn't?
 
5:01 PM
bees are for the most part very docile and friendly.
 
user11867329
Yes.
 
user11867329
Didn't refute that.
 
and not all bees die after a sting. only some
 
user11867329
I did not refute that either.
 
also, did I mention bees are friends.
you didn't refute it but you're still looking for excuses to kill the bee, it sounds like
 
user11867329
5:02 PM
but yeah, I feel like they're collibris
 
user11867329
and swiftly decide to attack if they judge they'll die. issue is, what if gets stuck in my clothes... what if it lands on my glass of water right before I grab it.
 
that's a lot of what if's
 
user11867329
e.g. what if I unknowingly hurt the bee a little
 
just be aware it's there and continue on your day
 
user11867329
isn't that what fear is?
 
5:04 PM
this seems like a pretty... silly discussion
 
user11867329
did I mention fear also?
 
that's what irrational fear is
 
user11867329
You're right, he dragged it out of me, I'll end it.
 
@KevinB the less people hurting bees the better everyone is for it
 
user11867329
i never even let suppose I was going to hurt it
 
user11867329
5:05 PM
>Irrational fear
 
kill all the bugs, that's going to be my motto if I ever run for president
 
user11867329
2020 Ikari
 
user11867329
rhymes also
 
7:37 PM
New users
 
@EmmanuelDavid 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.
 
8:04 PM
I keep wondering if `array.map(conversion).filter(filterfun)` or `array.reduce((acc, val) = {const t = conversion(val); if (filterfun(t)) { acc.push(val); } return acc;})` is clearer/more optimized.
First one seems to indicate more iterations over the data (twice). Second however seems harder to "optimize" as it mutates the accumulator, while the first could be more easily optimized, the map function could notice the inner function is independent of the rest of the data and thus could be handled in parallel (just like how linear calculations are optimized when using luca/the graphical card).
But the worst is: even after often searching about this for hours I cannot find any information regarding this.
 
meh
reduce can be used to do a lot of things
it can replace map, filter, every, some, for loops, while loops, etc, but... rarely should it ever do any of those things
 
reduce can pretty much do everything
in an uglier way
when it's the only choice, it's obvious
@paul23 you won't get any further in here either. we've had this discussion.
I argued reduce with a filter inside of the loop isn't bad. I was told off saying .filter.map is always superior
perf shouldn't matter
 
Hmm actually the performance of our app is kind of "on the breaking point" where we notice that hte lower end mobile phones have trouble giving a smooth user experience. (Basically samsung s4 and older have a lot of trouble keeping up).
 
I just see it as pointless to even think about if you're not trying to solve some performance issue. just use whichever makes the most sense from a readability/usability stand point until performance becomes a problem.
if performance is a problem, be sure and prove that it's this loop that is one of the causes.
 
@paul23 I mean in this operation. if it's bogging you down to run .filter.map over .reduce, you can probably get more benefit from reworking other stuff than a single reduction before the loop
 
8:16 PM
A bit hard to debug, even though I now have the hardware, using software emulation doesn't show the jerkiness in dragging stuff around. - But using the hardware makes dragging near impossible due to the "lag", and if I look into the views it's basically when you drag "filters" over data it shows a preview of how the data would change in a light alpha overlay.
It's weird though, since dragging went from "perfectly smooth" to "not working at all, phone is just not registering the drag event/dragend is immediately triggered after first redraw".
 
8:35 PM
are you debouncing the event?
 
9:01 PM
no, but I'm not using events that should trigger again? ondragstart ondragsend ondrop should all happen exactly once given very distinct user actions? (Clicking + moving & releasing button/finger)
the updating of the UI due to dragging I obviously do not wish to slow down, if the browser can make it more smooth by firing events faster than I'm happy to oblige.
 
9:41 PM
@AaditMShah currently at Testim.io, doing a lot of open source, conferences etc - having fun. Thinking about the next thing in lifie - happy overall.
@AaditMShah how did your thesis go :]?
 

« first day (3251 days earlier)      last day (1711 days later) »