« first day (3177 days earlier)      last day (1787 days later) » 

1:47 AM
morn
 
2:22 AM
@JBis im 13
Can anyone help me put multiple Variables into one localstorage call? I dont want to use like 8 of those enormous localstorage savers
 
what is an enormous localstorage saver?
 
@david Like one of these but for EVERY VARIABLE (I have like 8, so its around 2k characters)
var saveGameLoop7 = window.setInterval(function() {
  localStorage.setItem('miner3Save', JSON.stringify(miners3))
}, 3000);
var savegame7 = JSON.parse(localStorage.getItem("miner3Save"));
if (savegame7 !== null) {
  miners3 = savegame7;
}
That saves the variable miners3 every 3 seconds and loads it on page load
codepen.io/SkylerSpark/pen/vqgbao Scroll down to the bottom where I stored the localstorages and things, youll see why i call it enormous
 
2:41 AM
@TaylorSpark Oh... I'd just make a gamestate object that holds all those variables
and serialise that
 
No idea what that is
Still learning buddy :3
 
instead of miners3 you do gamestate.miners3
just a big object with all your game's state in it
 
can you give me a codesnippet of a localstorage SAVING and LOADING two variables: "variable1" and "variable2"
Its easier to learn with examples lol
 
instead of all those variables at the top, do this:
const state = {
  coal: 0,
  iron: 0,
  gold: 0,
  money: 0,
  miners: 0,
  miners2: 0,
  miners3: 0,
  sAmt: 10,
};
 
Oh!
A Constant!
Ive used those before
Ok now i understand
 
2:44 AM
no... you can use var
or let
 
Wow
facepalm
 
infact if you want to be able to nuke the entire state you will need to use let
 
Ive used let before actually. codepen.io/SkylerSpark/pen/ELwmoa\
 
or var
 
my most popular project
also my longest one in the making
It tooks me months to research all the little portions of how to customize the canvas elements
and even more months to learn dat.gui
cuz Im slow
also @david to make things easier, Id probably use:
const a = {
  coal: 0,
  iron: 0,
  gold: 0,
  money: 0,
  miners: 0,
  miners2: 0,
  miners3: 0,
  sAmt: 10,
};
that way I can just do a.VARIABLE rather than having to write the whole word
it will make it easier to replace things in the project
a.coal and a.gold and such... Hmm i like it
Im almost done editing my project
@david It no longer saves. I just refreshed my page so if it doesnt work Ill have to retype all those sections for savegames
var saveGameLoop = window.setInterval(function() {
  localStorage.setItem('miningSave', JSON.stringify(a))
}, 3000);
var savegame = JSON.parse(localStorage.getItem("miningSave"));
if (savegame !== null) {
 a.coal = savegame;
 a.iron = savegame;
 a.gold = savegame;
 a.money = savegame;
 a.miners = savegame;
 a.miners2 = savegame;
 a.miners3 = savegame;
}
I converted everything to constant data
did I do something wrong
 
2:58 AM
don't use const
use var
and do a = savegame
 
ohhh
so... just rewrite const as a var and remove all those to just a = savegame; correct?
 
yes
 
oh cool
even smaller data size
 
and if you ever add more variables, like a.wood, you don't need to update the savegame logic
 
Long story, test Angular sucks...anyone know how to change the environment variables after the app has been compiled?
I don't have access to the code that it was compiled from.
 
3:02 AM
UHHH...
@david
window.setInterval(function(){
	a.mine(a.miners);
}, 1000);
window.setInterval(function(){
	a.mine2(a.miners2);
}, 2000);
window.setInterval(function(){
	a.mine3(a.miners3);
}, 3000);
my autocounters no longer work
normally it would count up based on how many miners you hire (MIners mine for you)
but after the whole var a thing, it no longer functions at all
 
you havne't put mine/mine2/mine3 on a
 
omfg
 
just do mine(a.miners), mine2(a.miners2), etc
 
lol Those arent variables
those are functions
im stupid
 
you could put them on a
 
3:05 AM
mustve been flying through replacing shet and accidentally did that
 
you should probably abstract the idea of a miner so you don't need to do that stuff 3 times
 
Well they are functions, theres no real need. One day Ill compile miners 1-3 into 1 function with replaceable variables mine(name, value)
That way I can specify variables from the html
1 issue tho
people WILL be able to edit it
basically you can cheat with like 3 clicks
:P
So, either the js file is messy and big, but its slightly harder to cheat in the game, OR, I make it flush, functional, and clean. But people will be able to easily cheat
One more thing david if you have the time... It seems when I reload the page, though the gamesave data is THERE, the rendered values dont update until I change them (The miners will show 0 yet I bought 3 on reload, so when i buy 1 more, it goes form 0 to 4)
how do I manually update them every 2 seconds?
or atleast manually update after document load
Wow actually sometimes it DOESNT save the data it seems
(only sometimes?!)??
@david ?
 
3:20 AM
Or anyone have a way to get the original code back from compiled without a source map? Someone just hosed everything including our history and prod.
 
lol
your asking us for a magic decompiler?
sorry dude things like that dont exist
you can find "decryptors" that slightly make the code readable
but it never goes back to its original form
 
Yeah bro, I know.
I'm just saying, I have a bunch of compiled files, does anyone know a good way to change a value in those compiled files?
I did find the string I was looking for with a grep, then ran a sed and confirmed the sed worked. Appears that it wasn't actually what was being read.
 
well
 
I have a feeling we're screwed.
 
if you want to modify a compiled file
you could always hack it
like how a hacker would
 
3:27 AM
That's what I was trying to do with the sed, right?
 
change values with embedded JS hooks and things like that
 
What's strange is...where else could it read that value from?
Did it like encode it and decode it every time it needs the value or some shit like that?
 
so
are you asking how the computer reads js?
 
-_- Never mind. I'm not a moron.
 
still got no idea what your asking or even talking about :P
 
3:35 AM
I have a set of compiled JS files. That set of JS files was compiled from TS (also not my idea) and used a JSON file as configuration. Meaning when that TS got compiled, it replaced references in the code to the environment with the values in the JSON file.
One of those variables is wrong. I need to change it, and for reasons out of my control I have neither the source nor the source map.
 
@Allenph there are prettifiers out there, but what do you mean by 'hosed'?
were you not using version control?
 
When using request module in node, do I need to clear the cache/memory when downloading a big file?
 
3:51 AM
@david Trust me, I have since remedied that situation.
I mean "hosed" as in I have no copy of a good state, compiled or otherwise. But I do have a copy of a compiled state with the wrong environment variable in it. That seems like it MIGHT be fixable, wheras a code change would be virtually impossible.
 
4:33 AM
Sed worked. Cloud front was caching. Thanks guys.
 
 
2 hours later…
6:27 AM
Hi @Zirak @rlemon , Is it possible for you to share source of what you have deployed here : sleepy-bastion-8674.herokuapp.com ? Or at least you could tell how are you doing that random words generation, that would be great help. I want to extend that feature by adding meaning at the completion of a word guess(success/fail).
 
7:00 AM
Hi. I want to lazy load a div tag containing an Html table. Basically I have a scrollable div where this huge html table is getting loaded by AJAX. The table content is not just text it has dropdowns, some cells are clickable where you click and a window pops up. Hence, I don't think i can use SlickGrid. Is there a way I can achieve lazy load on this div tag?
 
 
3 hours later…
9:32 AM
Found another oddity on my React adventures that I don't know how to work with/around. I am using react-router-dom and I am rebuilding a section of the UI where I cannot use the NavLink anymore and instead opted for a button. To still be able to make the routing work, i wanted to use withRouter.
This is my old function: https://paste.ofcode.org/TL9VEJxPcMrZaJWZWG7Hrg
*old function that renders the correct thingy but without the router.
But when I wrap that with withRouter first TS complains that the result is not a React.ReactElement anymore but a React.ComponentClass and if I just do as it pleases, it still breaks on the website because.... No idea.
There must be something wrong with how I am using that withRouter function but I cannot get my head around it :c
 
I don't have a lot insight in react :|
 
I have also done something like that before in the same project:
<Route path={"/createWorkshop"}>
	{withRouter(({history}) => <CreateWorkshopView
		onComplete={(id: number) => history.push("/workshop/" + id)}/>)}
</Route>
But I have no idea what I am doing differently :D
 
10:09 AM
"I love using TypeScript in my project, but I give everything a type of any and it works!!" — David Barker Apr 14 at 17:00
 
10:21 AM
Anyone using Galen.js ?
Or any other sort of frontend responsivness testing framework
 
We started using cypress recently
 
Can you compare both?
 
Not really, I've never used galen
 
I am looking into some sort of tooling / framework that could test my frontend as it looks
like responsivness
and stuff like that
 
Cypress does that.
 
10:26 AM
So I hound that Galen.js can do that, now I am looking in Cypress as well
Like in short what is it?
Like is it framework, is it a website that does it for me
 
It's a front-end testing framework, doesn't use selenium IIRC
 
How do I run it
 
Read the docs.
 
Well I am on it now, I hoped you could give me that info faster
 
@BenFortune *chants RTFM*
 
10:29 AM
From what I can see it is paid and hosted on their website
 
they have a free membership
check that pricing first
 
They have paid options, but it's OS
 
I am looking for something that won't create more services
something that I can self host
ideally it would be js library / framework
 
literally describing cypress
selenium is a pain
 
I mean I am using gitlab now
So this is only thing I want to ever access
 
10:35 AM
what does that have to do with anything
You can put any testing framework in your CI
 
I think I'd rather read docs than try to explain what you are missing
 
10:47 AM
is it okay to use props in setting default state value in hooks
const [val, updateVal] = useState(props.something) ?
 
@NatGeo Sure
 
Thank you @MadaraUchiha
 
Anyone happen to know whether an execution context persists in memory after it completes (if there’s a reference to a lexical environment created in it)?

Or is the execution context garbage collected, but lexical environments created within it persist if there's a reference to them?
 
@AskProgrammers 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.
 
11:15 AM
@AskProgrammers pretty sure it wouldn't, otherwise there'd be a huge memory leak
though maybe there are bugs that will still cause leaks
 
@Neil Do you suspect everything in the Ex. Context is garbage collected other than the LexicalEvironment instances?
 
@AskProgrammers by LexicalEnvironment instances, what do you mean exactly?
 
12:02 PM
@Neil can you aid me with something?
 
@Neil I mean that LexicalEnvironment is a type.

And all lexical environment objects (i.e. every block scope) are an instance of this type.

(I could be wrong in how I'm stating this)
 
@KarelG if I can, sure
 
I have a problem with upgrade hierarchies.
 
this could probably explain it better than I ever could
@KarelG no diamond hierarchies I hope
 
assume that you have X. You can upgrade that to Y. For that, there is a table From|To(simplified) with X | Y
but you have have multiple things, A, B, C upgrading to X. So that leads to 3 records in that table
and A can be an upgrade as well, but from another type (so aa | A )
that is in another table
 
12:05 PM
we talking about updating a database here?
 
now let's say, I am at X
I want to find all upgrades from and to's that X in the whole hierarchy
so as result, I should get aa, A, B, C, Y, ...
it seems like a recursive operation, but the addition of that second tables makes it harder.
 
well it's really just the accumulation of all updates isn't it?
 
and I am not at the top of the tree
just "middle"
yes
 
you don't have to get to the top, you only have to worry about upgrading to another type I'd think
 
@Neil This hackernoon article doesn't get into the garbage collection/memory aspect of Execution Contexts.
 
12:08 PM
I do have to find all upgrades to top and to bottom from that spot
and not to mention that eg Y can have other child upgrades besides X
eg W
I need to get that as well X.x
 
can you give me a more practical example?
 
so from X -> upper upgrade = Y. But Y is upgraded from W as well. So in result, Y and W is included
 
you're talking about aa, A B, X, Y here and I'm still not sure what you're referring to
 
can you see images from a specific site?
all those letters are items
 
try it, some images get through and some don't, even from imgur
 
12:12 PM
give me a minute or two to conceptualize the problem. We had a long discussion about that this morning
 
if order is important, then you should know which order is safe and which isn't
presumably oldest to most recent
 
what is "upgrading"?
 
thank you
that totally helped
-_-
 
12:28 PM
anytime ( ゚ヮ゚)
 
currently order is not important. IDGAF it actually. Unless the manager wants it... pftt
but that approach is so meh. Not sure if there is an algorithm that I could use
a means to search nicely
I thought to join up the upgrade tables. Even then ...
 
@KarelG if it could be infinitely deep, you can't do this with a simple select
 
yup
 
but the good news is if you know how deep it runs, it's only a matter of doing enough joins
 
I thought to do a recursive method
 
12:38 PM
a procedure could do this too
 
I do not know the depths because it varies
 
well you know that for any joined type, you know if it has a child type
 
eh, a handful of my employees knows SPROC's
 
so you can at least know if you can go deeper
 
we won't do that because of that
and the db does not support CTE (yet)
 
12:40 PM
it just has to be done programmatically
 
yeah.
I thought to loop up first
then all subtrees from the top
that is just a basic well-known problem that got solved many times
 
12:56 PM
well one way is to use a stack
add X to the stack, and then one by one you pop the item from the stack and add its children
you continue like that until you've reached all the leaves
 
that is one of solutions to that tree problem :)
gotcha write a functionality to find the top of the hierarchy if I start from type2
if I come from type1, I can re-use that functionality to go higher
 
1:09 PM
@Neil btw, just fyi, there is a difference between a stored procedure and a function (IMO)
 
you'd be able to do it without using recursion
which is ideal if you don't know how deep the rabbit hole goes
 
I don't know the depth of it. So is recursion not a better approach? Unless I am not having a bright mind atm
 
1:23 PM
nice
 
How does that shit work again?
Looking through eggs.js
 
1:34 PM
window.Eggs.Cthulu({ search: () => 1 }) lol
 
is there a place to find free one page html templates?
 
@csandreas1 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:57 PM
hi
all
my application is going live today and tomorrow...
we would like to analyze the bootstrap version
which is between version 4 and version 4.3.1
will there be any negative impact if we upgrade to 4.3.1
 
@CommonMan you'll have to read the changelog to see if there are breaking changes
 
thank you sterling archer
I can read the release notes and ship list but how do i ever know if there will be an impact or not
 
2:14 PM
@CommonMan Because it will tell you in the changelog.
 
Yes I am reading line by line Ben Fortune
 
2:35 PM
I am planning to upgrade from bootstrap 4.0. to 4.3 and i have used
cursor: not-allowed
in one place... i couldn't understand github.com/twbs/bootstrap/pull/28188
this from release notes
they have mentioned that they have removed... what did they removed.
will cursor: not-allowed will work or not
 
They removed it according to the referenced commit: github.com/twbs/bootstrap/commit/…
 
will my individual css property definittion in css file will work or not
 
you know the best way to determine if you have breaking changes? test it
 
    <input
            #colorPicker  <-- this
            id="color-picker-input"
            class="input-color"
            type="color"
            colorpick-eyedropper-active="false"
            (change)="changeColor(colorPicker.value)" <--this
          />

What do you call this approach to getting the value from #colorPicker? Is this like 'anchoring'?
 
2:39 PM
what library is that?
 
no i haven't used anything like this...
thank you rlemon and ben fortune
 
angular
90
Q: What does Angular 2 hashtags in template mean?

ackuserI am working with angular 2 and I have found something like <input #searchBox (keyup)="search(searchBox.value)" and it works. However, I don't understand the meaning of #searchBox. I haven't found anything clear neither in the doc. Could anyone explain to me how it works? Thanks

 
@BenFortune thank you
dom elements as variables.. I like it.
 
is 13yrs-age-cat is a good css naming convention or not
In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier "B&W?" may be written as "B\&W\?" or "B\26 W\3F".
will the above context from w3.org will impact my selector in DOM
 
3:05 PM
I would not start it with a number.
I like the kebob case
how about age-thirteen-cat
 
3:18 PM
so JoJo are you saying it will impact?
I had already implemented it and it is going to be in production
sooner
 
Yes I think the CSS spec you linked states you cannot start with digit. will impact
 
ok now read this and tell me again if it will impact
Fixed: Silenced bad selectors in our JS plugins for the href HTML attribute to avoid JavaScript errors. Please try to use valid selectors or the data-target HTML attribute/target option where available.
when I use yrs after 13... it's becoming a text
 
I would not use them.
 
@CommonMan Test it
 
3:35 PM
in every browser
 
ok Ben fortune.. and Kevin B
 
Why use something that may or may not fail, in some random browser that decided to follow the spec, when you could just... not
 
4:14 PM
that's what I'm saying...
not sticking though...
 
hello all o/
 
4:30 PM
 
 
1 hour later…
5:40 PM
That's good
 
6:40 PM
Can anyone tell what's happeing plpease ?
 
What's your question?
 
7:02 PM
did you expect let b = 84 to create a global var? because that's not gonna happen in the console.
 
7:15 PM
Can someone help? This loader won't stay in the center of the page even with position: fixed
 
1 message moved to Trash can
@GameMaster1928 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
@GameMaster1928 Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
 
uhh I hit ctrl+K and it indented
 
don't mix code and text
If any one line isn't indented, the whole thing isn't indented
 
hey guys quick question. if i am specifying a function like in this line
document.querySelectorAll(".drum")[i].addEventListener("click", onclick);
that would generally apply the function
to be used when the item is clicked
is there a way to pass the inner html of [i] to the function
document.querySelectorAll(".drum")[i].addEventListener("click", onclick());
because i know that is a nono
 
this in the function will most likely be the element
 
7:29 PM
nevermind i think ill just make a global variable like current html and set it right before i call my function
this is the element yeah
 
so this.innerHTML
 
right
but i was wondering if there is a way to pass paramaters to the onclick function
 
yes
make it return a function
or .bind
 
can you write out what you mean
?
still learning js
 
function onclick(a) {
  return function(event) {
    // ..
  }
}

.addEventListener('click', onclick('value for a'));
 
7:32 PM
that seems like too many nested functions as opposed to just setting a global variable when i call the add event listener which i do in a loop
 
your approach sounds bad. and seeing the code above I'm inclined to believe it is.
a function returning a function is a perfectly fine approach for many things
 
im sorry one more time. im a little slow
that i have a set of drums gonna make them play a sound
nevermind i think im just stupid
sec
let me try something
yeah ok yeah i think my idea is probably pretty bad
in most of my compsci classes they say avoid global variables when possible
 
8:00 PM
that's generally a good idea
 
why is that a good idea
?
@KevinB ^
 
because, well, they're global
you have no control over what interacts with it
 
If I have an array of objects that update frequently, and I need to push those changes to the html representing those objects, would it be bad design to store references to the html element in the object in the array. So I could do something like array[0].htmlElement.innerText = "Test"
If not how do you suggest I do it?
 
8:16 PM
Hi
 
@JBis sounds fine to me but i started learning js yesterday.
 
Does this question make sense?
https://stackoverflow.com/questions/56812794/when-building-a-keyword-finder-is-it-easier-to-search-for-the-keyword-within-an
 
@JBis are you using a framework or vanilla
 
vanilla
 
ok so I would really recommend against holding onto DOM element references like that
IME they get stale easily
do you have an easy way of re-referencing them?
others might disagree with me but I wouldn't hold onto an array of elements like that
 
8:32 PM
neither would I, but I would happily store a nodeList for later use
:P
 
@forresthopkinsa I haven't designed anything yet. I am looking for good design for something like this.
@rlemon Isn't that the same thing as I was suggesting?
 
basically.
or an HTMLCollection if you want it to be live
 
I take that back
 
Whats the differences? NodeLists can apparently be live too.
 
> can
 
8:38 PM
2ndly, is there any good ways to split up html in an electron app without a templating engine?
 
a + b + c
 
And then append that to <html>?
 
without templating, you're left with string concatenation.
 
Ok. thanks
 
 
1 hour later…
9:46 PM
They should really add the parent selector to css
 
10:01 PM
y
most elements have a parent
 

« first day (3177 days earlier)      last day (1787 days later) »