« first day (3320 days earlier)      last day (1611 days later) » 

6:18 AM
Can anyone Help me With this Quuestion stackoverflow.com/questions/58900080/…
 
@MuhammadUsama Ashraf 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.
 
 
6 hours later…
12:40 PM
Hey, was wondering if anyone knew a way to make dynamic flash content WITHOUT flashobject?
I was thinking, what if you had a URL variable that contained the link for an SWF, and you used this to visit a special page that contained several options: a back button to go back to game selection, an embed for the flash content, and a script to attach the flash content to the webpage dynamically.
Would this be possible? would appreciate any further help
I just dont really understand how to use swfobject.
This was my attempt at a dynamic flash, Ive heard its "impossible" but this swfobject thing says they can dynamically create flash embeds..
so I created this script:
function startAGame(id, swf, wi, hi) {
 var el = document.getElementById(id);
 var flashvars = {};
 var params = {};
 var attributes = {};
 swfobject.embedSWF(swf, el, wi, hi, "9.0.0", false, flashvars, params, attributes);
}
swf var represents the swf url, el is your embed element id, wi is width, hi is height, etc etc
 
ew
no
don't use flash
It's blocked in most browsers now anyway
 
flash got flashed
even if you use that little plugin
(had to lookup swfobject)
 
I dont give a flip
 
it is literally in the repo
 
I like flash, if others dont like it, thats their opinion
 
12:52 PM
What's the point in putting work into something that we've told you won't work
 
> SWFObject is no longer in active development. Flash Player is on the decline, and the authors of SWFObject have moved on to other projects. This project is being left on GitHub for historical purposes.
 
I already created my own C# Projecter for it
 
ok. But don't expect aid from us.
 
bruh... so much for that
 
I just tell people to stop with working on it.
 
12:52 PM
It's good advice, take it.
 
I dont need it, its my opinion after all. I just dont believe in killing off a useful platform
 
It's not useful
It's full of pretty serious exploits, it's slow as fuck and hard to use
 
@KarelG swf isn't on the decline. It's already at rock bottom.
 
hey, I was just adding emphasis.
 
Eh, Even if you guys dont like it, thats not a problem.
 
12:54 PM
Dude, it's not a fucking opinion
We're giving you facts
 
Hey, as long as flash still works, Im still going to use it
:)
 
it doesn't
3 mins ago, by Ben Fortune
It's blocked in most browsers now anyway
 
@TaylorS COBOL still works afaik
 
It literally does though, you can still run flash on chrome, firefox, and even IE right now
 
why aren't you working with that?
 
12:55 PM
the downloads are still available, and there are thousands of offline full isntallers saved offline anyways
Honestly, I think flash still works on IE because its an outdated browser
Funnily enough, our school admins added a perm-lock to the flash plugin on chrome
basically its permanently allowed on all sites
 
For good reason
oh, lmao
 
in order to run flash, you need a plugin that can utilize the flash program (aka adobe flash player). It was available in browser that got released pre 2019, but only disabled. Now, that plugin is stripped from most browser. If an user wants to use flash, he has either to revert to an older browser (IE) or install the flash plugin themselves
 
Eh, I dont consider any browser besides edge, opera, chrome, or firefox as "Popular" and would never consider using them myself
Maybe safari, but I never adapt my content for it except for my main website
 
the usage statistics tells you which one is "popular"
 
Flash is blocked in every browser that you just listed by default
 
12:57 PM
ok, but you have to care if you actually want people other than yourself to see your flash program
 
Just wish everyone would move to webkit already lol
wdym dude...
Flash is "disabled" by default, but you can still enable it
might sound outrageous, but I once wanted to write flash, never got the chance to, now its dead, and I still want to enjoy those old games
 
you're missing the point. Today it's disabled. Tomorrow you won't even be able to install it
 
You mean in december
 
it's slowly going the way of COBOL and assembly
 
@TaylorS use HTML canvas for some browser games
 
12:59 PM
Theres already adapted offline installers saved on github for chrome
KarelG, they dont have the classics
They have these shitty io games nowadays
 
i'll be the first to admit that there were some nice flash games back in the day
 
I know. I came from those times. But I don't mind if those aren't accessible anymore
 
*Two lines of code, ball chaces square on line, magical game*

*Reaches higher popularity then minecraft the next day*

- Thats basically our world today
 
but even the flash developers have moved to other things
 
there are many DOS games that were popular back then but is tough to run them these days
 
1:01 PM
yeah, you could write programs that would run in MS-DOS in 1995
 
even with DOSbox
 
there were some great games then
 
Take a look at this site, these developers have made some of the greatest flash games of all time: flipline.com
 
and yeah, you could install DOSBox and run it..
 
I would play those games deprecated, dead, and old even years from now
 
1:01 PM
there's nothing wrong with this
but don't develop in flash
 
^ Dont worry, gave that up years ago
actionscript, now Ill admit thats old as fuck
 
What would be the best solution to store immutable data, publicly visible, (possibly free)?
 
I hear some of the popular flash game developers are ATTEMPTING to convert everything to html5
 
The data exists of single hashes.
 
but some of the classics are so old, the source is long gone
hard to create something that there isnt even a source for
 
1:03 PM
@user10198470 do you expect a non-primitive being immutable in browser's JavaScript?
the answer is: don't.
 
@user10198470 sounds like a database with readonly access
that's fairly simple to achieve
 
Just curious, is it possible to send data to the page ahead in a redirect
like... page1 redirects to page2, and executes a function in page2 from page1
 
just make one user which lets you read and write, and another which just lets you read, and make that user publicly available
 
i know you can open blank documents and send data to the document right before its created, but not sure about full on websites
 
hey there
 
1:06 PM
@Neil Exactly but I need to "proof" to the public that this "write user" doesn't change any existing records
 
@TaylorS hmm, you can pull data from the URL directly if that's what you mean
 
I have an android question but I am not allowed to go to the android chat :'(
 
@Suisse I would have sent you to there anyways :P
 
no.. I mean like... in javascript, use document to redirect to another page, and write an element to the page right before it opens
 
@user10198470 you'd need a write user though.. otherwise how are you going to create the records to begin with?
 
1:07 PM
check java room and tell why you cannot go to Android room
could be a java-esque question
 
you could give a client the username and password, with a means to change that password so that you could guarantee you could not change it not even if you wanted to
 
Like, you can do this with about:blank to create custom documents
but can you use it with webpages
 var w = window.open("about:blank", "Progress Bar Maker");
 w.document.write("<title>Progress Bar</title>");
(copied form a random project)
 
you can't write an element on a page which hasn't opened yet, no
I mean, ok, you could create a window, but I wouldn't really consider that its own page
 
rip
ok, I was just curious
 
@Neil That's true, unfortunately it's not just one client. I was thinking maybe it would be a good idea to sign the data and then post the hash online (preferably in a decentralized way)
 
1:09 PM
Could create some cool dynamic pages if that sort of thing was possible
Only other thing I could think of is URL Variables, no idea how to use em though
 
Or maybe even post it to sites like: archive.org
 
@user10198470 you would do well to look into block chains and how they do it
 
you'd need a system where it's public, but to decrypt would require an access key that you yourself don't have full possession of
 
That page is blocked
:P
 
1:12 PM
@Neil Something like that. But instead of decrypting maybe just computing the hash together with the signed data to make sure the original hashed data is not altered..
 
I think to ensure this you'd need to build some sort of infrastructure
I don't think a mere database would be sufficient
but yeah, you could design something like that
 
@Neil I guess you're right
Thanks!
 
np :)
 
but can I anyways ask an android question here?
 
@BenFortune whats in that page? it was blocked by my school
 
1:14 PM
hehe
 
Dont ya just love when people throw links at ya which ya dont know what theyre about, and then the thrower of links disapears lol
 
@BenFortune that's cool :)
 
?????????
 
@BenFortune Nice use of location.hash
 
Oh, I found its github source
I see, thats a cool URL variable game
 
1:20 PM
it's just a chicken variant of space invader
 
Its clever though...
 
I've seen chatrooms built using console.log
I thought that was pretty clever
 
That wouldnt be complicated
 
no, probably not
I just never would have considered doing that
 
But I bet itd be less convenient then just using innerHTML and CreateElement or some simple thing like that
Im going to steal that animated url from that game though
Never thought of that
Bet itd look cool for a website XD
 
1:25 PM
you would have loved to be a web developer in the 90s :)
 
How have I not known about this -_- location.hash
Wouldve been so fun to make animated URL games now that i know this actually exists
codepen.io/SkylerSpark/pen/LYYMryV I ripped out that date moon animation. If you used a location based Moon-cycle detecting script, you could make the moon change depending on your day's Moon Cycle
Wouldnt that be something..
Nevermind, I guess that was easier to find then I thought: gist.github.com/endel/dfe6bb2fbe679781948c
 
I'd think using a canvas would be better for that
 
Yeah, itd be more Realistic or Interesting
 
how useful would it be having a moon cycle indicator in the URL?
 
but imagine like.. a weather site... that the title bar had an adapting moon emoji for your current moon phase
:3
I think itd be interesting
Not really useful, just a tacky feature
 
1:37 PM
given the number of sites out there, it may already exist to be perfectly honest
 
Probably
Im just hilariously happy to find 2 new things to play with... document.title and location.hash
Ive done title animations before, but had to make them anoyyingly slow due to needing to select the title manually with document.querySelector
 
> select the title manually with document.querySelector
it is just document.title fyi
 
I know..
I just said that
lol
> Im just hilariously happy to find 2 new things to play with... document.title and location.hash
 
https://github.com/c3js/c3

A dependency of C3 was update this weekend breaking it
Is there a way I can target a specific version of D3?
Ive tried adding d3 with a specific version as its own dependency but the sourcemap still points out that c3 is using the latest version
 
1:56 PM
I already tried to install d3 itself
on a previous version
but it seems that as C3 has a dependency on D3, it still somehow is using d3 latest
 
2:41 PM
How do I clear a setInterval declared inside a function?
anyone know how I can do it efficiently
 
you need to store it somewhere
either use a class that manages it (my preference) or just put it in the global scope
 
@TaylorS you can use a mixin to save and hide the handle to the interval and to cancel it
 
Is there a way to have a setInterval OUTSIDE of the function that DOESNT run automatically then?
I was creating a simple Animation API for Divs in my project, and I need the setInterval to activate upon animating
then turn it off if you cancel the animation
neil no idea how to use mixins
 
you wouldn't call setInterval inside the callback of the setInterval unless you wanted to exponentially create intervals
 
function x() {
  setInterval(x,10);
}
How to murder your JS engine 101
 
2:51 PM
lol
window.x would be SCREWED
 
@TaylorS You create a function which defines local variables holding the interval handle and then returns a function which when called will stop
 
HAMMERTIME!
 
Neil i want to call the intervals Dynamically
so you can Pause, Reset, Play, and Unpause the animation
 
the returned function can access the interval handle, but it isn't a global variable
 
and I need to be able to access SetInterval via an Object without it being outside the function
 
2:53 PM
then I suppose you'd return an object with several functions
 
Js doesnt have static vars
ffffffssssssssssss
 
thank god for small favors
 
> either use a class that manages it
 
3:35 PM
@TaylorS are you talking about const?
||> const x = 2; x = 5
 
@JBis "TypeError: Assignment to constant variable." Logged: ``
 
4:16 PM
If I used a constant to define the Interval, could I stop it from outside the function
 
How is it being a const vs let or var relevant to that question
 
I dont know...
 
4:56 PM
@TaylorS That question could be answered with reading the mdn article on scope developer.mozilla.org/en-US/docs/Glossary/Scope
As Kevin said, const vs let is irrelevant. var vs let could be relevant but for the most part its not.
 
I gave up on canceling the interval
but Ive come across a new problem
(ignore that im using prototype), This code should be giving me an Interval at 60 miliseconds (60fps) and running the code, but it isnt visualizing my arrays at all
Element.prototype.divAnim = function(a, s) {
 setInterval(function(){
  this.innerHTML = a[Math.floor((Date.now() / 100) % a.length)];
 }, s);
}
Heres my test code:
var array1 = ["🌑", "🌘", "🌗", "🌖", "🌕", "🌔", "🌓", "🌒"];
document.getElementById("test").divAnim(array1, 60);
basically im playing with that moon animation I saw earlier
 
don't overwrite prototypes for no reason
 
I dislike using variables as methods, you cant select anything
unlike prototype, which can attach to elements
 
|| mdn clearInterval
 
5:02 PM
JBis, you cant use that on a NON GLOBAL SCOPE
 
Learn something new every day:
> It's worth noting that the pool of IDs used by setInterval() and setTimeout() are shared, which means you can technically use clearInterval() and clearTimeout() interchangeably. However, for clarity, you should avoid doing so.
@TaylorS yes you can
 
Its inside a function
the variable cant be accessed
that ruins the point of scopes??
 
||> let x; function run(){ x = setInterval(()=> console.log("not logged"), 5000)} clearInterval(x)
 
@JBis "ReferenceError: clearInterval is not defined" Logged: ``
 
in real js that would have worked
 
5:05 PM
.-.
Ive always been told that if the scope is private and local, it cant be accessed... EVER...
 
@TaylorS Simply define the variable in the outer most scope you need to use it and then assign it in the deepest scope when you need to
 
wait... so is the variable you assign the interval.. like on a second level scope
that isnt restricted by functions...?
 
It can't, but outer can't access inner, but inner can access outer so define in outer
 
look up closures
 
If... I... define it in the outter... it will be ran when the page loads
thats completely NOT what Im looking for
 
5:08 PM
let x; doesn't cause anything to run
 
5:52 PM
 
Guys, can someone please check this:
0
Q: Input loses focus even though I do everything to keep focus

storagemode11I have a very interesting situation. This is my component: export const checkbox = ({ data }) => { const [data, setData] = useState({ data: [] }); const [checkBox, setCheckBox] = useState([]); const [textArea, setTextArea] = useState(''); const inputRef = useRef(null); useE...

I am losing my mind here :(
 
6:46 PM
Apparently you also lost the question
 
@ndugger oof
 
7:08 PM
@storagemode11 you should be able to do something like this:
yourInput.onblur = function() {
    console.log("lost focus");
    setTimeout(()=>{
        yourInput.focus();
        console.log("gained focus");
    },100);
}
 
@JayB Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. 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
 
good going james
 
wtf is this new bot?
 
idk I'm new here
 
Hi new here, I'm dad
 
7:12 PM
:P
Any idea how to post small code snippets (non-one-liners)?
 
ctrl+k
don't mix code blocks and text though.
 
ah okay
yourInput.onblur = function() {
    console.log("lost focus");
    setTimeout(()=>{
        yourInput.focus();
        console.log("gained focus");
    },100);
}
 
👍
though i'm pretty sure that wouldn't have helped the asker of that question
 
oh?
 
they're using react, it's likely the element is being recreated, thus causing it to lose focus
 
7:14 PM
It just seems like a really bizarre solution for anything
 
it would also lose the blur event if that were the case
 
using a timeout there is just bizarre anyways. would you not rather just prevent the default behaviour of blur and then force a refocus?
Obvously doesn't work for OP, but still just a bad solution
what
 
The timeout was to override anything that might be taking the focus away (but if it's just the fact thatt react is recreating the input then I guess they'd just need to reset yourInput in an update callback)
 
might want to... self-censor that message before you lose the ability to chat for a little while
 
@JayB using a timeout in this fashion is just a bandaid for lack of understanding of the DOM
 
7:18 PM
1 message moved to friendly bin
 
@JayB, I don;t think that will help..
 
The timeout is a catch-all for edge cases within their mystery stack that may or may not be overwriting trying to steal the focus
Other things listening to for that blur might have critical page functionality
Then the problem is found months later when QA notices something obscure doesn't work
@storagemode11 you're right it wont
window.permafocus_selector = "#myEternalFocus";
window.enforce_permafocus = true;
setInterval(()=>{
    if(!window.enforce_permafocus)return;
    const pf = document.querySelector(window.permafocus_selector);
    if(pf)pf.focus();
}, 100);
 
@JayB Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
 
what's the latest industry standard for database management in nodejs? Say I have a postgres database and I want to provide a neat api for managing hierarchical user permissions and actions
I'm leaning towards knex/bookshelf because I've used them before, but a few google searches seem to suggest bookshelf isn't used much anymore
 
I've never used bookshelf, but knex was great. You don't see a ton of "enterprise" node outside of silicon valley, so I couldn't tell you what's industry standard, though
 
7:28 PM
and you make your abstractions on top of knex? Filling out the queries manually (even within knex) sounds like quite a pain
on the other hand, bookshelf can be a pain because it's too locked-in
I've used raw knex before actually, it was ok. Just a lot of repetition, that could well be because I was using anti-patterns
 
It's nice to follow a service/repository pattern in this case, where you would abstract your knex queries inside regular function calls, like createUser, or whatever
 
do you have any samples that you think implemented the pattern well?
the main way I imagine to do it is with a lot of utility functions that look very similar, and could well have been abstracted out by someone else
but maybe the trick is to just power through it for a few hours, and hope you cover all your usecases
 
I can't think of any node projects where I did anything cleanly, but if you google service pattern, it should give you an idea on how to separate your service/db calls from your controllers/business logic
Service layer is a design pattern, applied within the service-orientation design paradigm, which aims to organize the services, within a service inventory, into a set of logical layers. Services that are categorized into a particular layer share functionality. This helps to reduce the conceptual overhead related to managing the service inventory, as the services belonging to the same layer address a smaller set of activities. == Rationale == Grouping services into functional layers reduces the impact of change. Most changes affect only the layer in which they're made, with few side-effects that...
 
@towc mysql, mongodb, postgres, sqlite depnding on what you need to do
 
7:43 PM
@JBis I already said it would probably be a postgres db :) Question is what is a good way to interface with it
 
ah. my bad
 
8:06 PM
or does anyone know a community better fit for discussing this?
 
I've heard good things about w3schools
 
how serious are you?
 
0/10
 
that's like half of the correct digits of ten. I give that score 5/10
 
that comment was so dumb it was funny lmao
 
8:10 PM
Is there a better way to write this? More concise?
order = {
        bar: [
          {
            id: 1,
            date: this.props.fooItems[0].date,
            amount: this.props.fooItems[0].amount,
          },
          {
            id: 2,
            date: this.props.fooItems[1].date,
            amount: this.props.fooItems[1].amount,
          },
          {
            id: 3,
            date: this.props.fooItems[2].date,
            amount: this.props.fooItems[2].amount,
          },
          {
            id: 4,
            date: this.props.fooItems[3].date,
 
yes, Array#map
 
you can use Array(n).fill().map((_, i) => ...) (or extrapolate something similar to a utility function and use that)
 
this.props.fooItems.map
 
or listen to dugger
 
I would be mapping the indices?
 
8:15 PM
you would be mapping the items in the array
bar: this.props.fooItems.map((fooItem, i) => ({ id: i + 1, ... })
up to you what that implementation looks like
I won't write that part for you
 
I need my built-in range function now
 
just now, I am tempted to implement something akin to a bit mask to more easily compare activated elements of the UI, and I wonder if that's like the surest sign I should stop programming for today. Anoyone ever uses bit masks to compare a selection of toggled elements?
 
I hate that proposal
 
8:20 PM
JS is becoming more and more fucked and convoluted
 
@FélixGagnon-Grenier nope, go for a walk
 
ever since the braindead syntax for private fields and globalThis
Just pump the breaks
 
@towc :P thx
 
Not everyone's crappy ideas need to make it into the spec
 
@ndugger so you wouldn't want more built-in stuff, in an organized fashion?
 
8:21 PM
No, I want people to abandon JS
 
you feel comfortable always needing to pull from npm or re-implementing the same stuff over and over?
 
it's a garbage fire
 
@ndugger make a proposal of it and see if it passes
 
wat
 
> Hello tc39, today I'd like to suggest you all go ******* ***** and we start moving away from js. Thank you
 
8:23 PM
@ndugger what do you suggest as the alternative
 
sounds like I also need to go for a walk
 
@JBis I envision a future where WASM apps don't need any JS glue code
so Rust, C++, C#, Java maybe
Literally anything else
because JS is a mess
 
web assembly is way to complicated for it to live alone
i don't think js is that bad
Front end js is annoying but node is good
 
you don't write WASM directly, for 99% of use cases, so that's a moot and weird point
 
i haven't used wasm so i don't really know but from what i know its basically assembly for the web
 
8:28 PM
It's a compile-to target. You don't write it, you compile to it
 
compile from what? js
 
So you'd write your Rust code like a regular rust app, then compile to WASM
no, jesus
ok, you're not allowed to have an opinion on it, because you clearly don't even know what it is
 
Yeah thats fair
wasm seems like it could be good to compile to but i dont think we should abandon js
 
I see no value in dynamically typed languages these days, and on top of all the brain dead ideas coming into the ES spec, I just don't see it as a viable option for development moving forward.
 
whats wrong with dynamically typed?
 
8:36 PM
it makes things like jquery possiblw
 
8:50 PM
All of these people discovered that they can have a voice and have a turn at steering the ship, so now we've got way too many cooks in the kitchen, shoving every idea they can come up with into the language spec, and it's php 2.0
 
 
1 hour later…
9:59 PM
uhm. wtf
0
Q: how to prevent a function parameter in javascript destructuring assignment from being overrided by DOM element with same ID

cesarpachonI am trying the ES6 destructuring assignment feature to pass an options object containing multiple parameters to a function, but one of the parameters is being overridden by a DOM element with the same id! //javascript function call: createPicture({name: "aaa", width: 100, height: 100, ...

 
TypeScript has this thing where you can declare an interface and then have your function return an object that automatically maps to that interface’s fields. Anyone know what’s that thing called? I’m trying to do the same in Kotlin, but it’s forcing me to create a class that implements that interface, initialize it and return it
 
10:39 PM
really dumb question. new Date(Date.now()) how do i get back to the milliseconds from Date.now()?
 
getTime()
 
thanks
 

« first day (3320 days earlier)      last day (1611 days later) »