|
Knifegrab posted:Yeah that's my understand too, so how do I expose a function that utilizes the class to return a value? I don't actually know how javascript classes work exactly, but if it's similar to Java classes, there is a slight difference whether you want to call a static method or an instance method.
|
# ¿ Mar 8, 2017 16:04 |
|
|
# ¿ May 16, 2024 10:35 |
|
Knifegrab posted:
You're double-escaping your text somewhere.
|
# ¿ Mar 19, 2017 14:29 |
|
CodfishCartographer posted:I actually wound up running into another problem - it doesn't seem to update as often as it should. Even with it updating 1000 times a second, it would only fill up about a quarter of the way per second. I lowered the progress bar max to just be 250 and then it appears to be working, but I know it's not perfect and there's something wrong under the hood but again, I can't quite figure it out. I looked at the java console and it's getting to around 250ish, but moving to quickly for me to pinpoint its exact stopping spot. It feels like only one out of every 4 is actually filling up the progress bar? You can never trust the requested delay being accurate in any language or framework. (Actually, If you're doing embedded work and working on assemly and have counted your cycles, you can) Anyway: Save the current time from before you make your delay request, then request your delay. When your code runs, compare the current time to the time you saved from before you made the call, then animate your thing according to the difference between the two values. Some frameworks make this easier by just telling you the actual delay when your code is run. Here is an example: JavaScript code:
Wheany fucked around with this message at 09:10 on May 6, 2017 |
# ¿ May 6, 2017 09:07 |
|
Maluco Marinero posted:basic facts about JavaScript equality and how to rigorously test it properly. Please elaborate what you mean by this.
|
# ¿ Jun 19, 2017 08:00 |
|
Ghost of Reagan Past posted:I propose we adopt the four Boolean values of LP: true, false, both, and neither. Don't forget FILE_NOT_FOUND
|
# ¿ Jun 20, 2017 17:49 |
|
Honest Thief posted:Maybe this is just me bitching and being annoying but it seems every other article about some new js tool barely covers the basic use cases. Case in point, I'm trying to figure out the syntax it accepts for custom routing, only the given example on the repo doesn't work, and none of the article I can find seem to consider the possibility of wanting to have custom routes. Yeah, that's javascript. Even seemingly well documented frameworks either document a function superficially*, or there have been breaking changes in the api in minor versions and nobody bothered to update the documentation/tutorials. *)something like "the function takes a configuration object and a callback" without telling the structure of the object or the parameters the callback will be called with
|
# ¿ Jul 11, 2017 08:18 |
|
The Merkinman posted:But with HTTP2 you don't need to concatenate so Webpack is useless now. Looking forward to using HTTP2 in 2027
|
# ¿ Jul 12, 2017 11:41 |
|
My greasemonkey boilerplate:JavaScript code:
It's not quite JavaScript code:
Wheany fucked around with this message at 12:40 on Sep 12, 2017 |
# ¿ Sep 12, 2017 12:38 |
|
This is definitely a case of "what? why?"
|
# ¿ Sep 20, 2017 08:17 |
|
Were discussing possible technologies to use with a future project and I suggested React for the UI part. Another person suggested Angular. So my question is: Is Angular good now? edit: also if it isn't, why? (I'm sure they'll ask me the same thing) Wheany fucked around with this message at 12:55 on Oct 30, 2017 |
# ¿ Oct 30, 2017 12:52 |
|
Why do service workers define self? I tried to google it, but google is useless for precise techical questions.
|
# ¿ Sep 18, 2019 13:12 |
|
I have looked at two (or three) new APIs in the last week. Service workers + caches seems like a really good and simple API and Indexed DB looks like complicated garbage. It's really easy to cache a few resources and then just serve them from the cache forever while everything else uses normal http requests. Indexed DB looks like a ton of yak shaving before you get to the part where you can dump data in there. I was looking at Indexed DB because Safari on ios doesn't share localstorage with PWAs and that's where our app's auth keys are stored, but then I read that it doesn't share Indexed DB either. So I guess our iphone users get to log in again with the app.
|
# ¿ Sep 26, 2019 20:31 |
|
I have an actual javascript question: does cache.addAll guarantee that those files will always stay cached? Currently my service worker just caches all the js, css, images and fonts that the app uses using addAll (8 files, a little over 1 megabyte total) and the fetch listener will just return the cached version or fetch the resource if not found in cache. The cache is never updated. Should I be checking if the requested resources match the files listed in addAll and re-cache them if they have been purged?
|
# ¿ Sep 27, 2019 16:40 |
|
I've read that before but I guess what I wanted to hear was that everything in the cache is treated equally and can disappear from under you. I guess that makes the default boilerplate javascript that keeps static resources cached a bit more complex. Or can the browser just reinstall the service worker after a cache purge?
|
# ¿ Sep 28, 2019 09:07 |
|
My react knowledge is old an rusty, so I look up a 2019 react article and see this: JavaScript code:
|
# ¿ Sep 29, 2019 09:27 |
|
model.vehicle.get('device.type') returns a promise. model.vehicle.get('device.type.id') returns the value of the id field directly. Ember! Never having any idea what type or shape the data is that I'm going to get without trial and error for the epic win!
|
# ¿ Dec 4, 2019 11:58 |
|
Is there a way to use some kind of a background worker script (similar to a service worker or a web worker) in TamperMonkey? I have a script that does some heavy processing when I press a button and currently it blocks the UI long enough that Firefox starts complaining about a script slowing the page down. It's not a huge deal since this script is for my own use, but I'd like to get rid of it if possible anyway.
|
# ¿ Dec 9, 2019 12:49 |
|
I have tried making an offline PWA with a service worker that caches all the files needed for the app. I also added a manifest and an icon and I'm able to install the app on my phone's home screen and run it from there. However, if I turn on the phone's airplane mode and try to reload the page it will say "no internet" "chrome will let you know when this page is ready" Am I doing something wrong or does reloading just always bypass the service worker and the cache? edit: okay, I'm definitely doing something wrong since airhorner.com works fine even in airplane mode and reloading the page Wheany fucked around with this message at 16:15 on Jun 1, 2020 |
# ¿ Jun 1, 2020 16:12 |
|
Okay, I followed the "Offline fallback" recipe from https://serviceworke.rs/offline-fallback_service-worker_doc.html That example tries to fetch first, then catch errors and respond with a cached version. Instead I got it working by reading the cache first and then trying to fetch data over the network if not found. Which sounds reasonable in hindsight.
|
# ¿ Jun 1, 2020 16:47 |
|
roomforthetuna posted:Depends if you want to be able to update the data - you've got a permanent cache in what you describe, the server is never asked again once the client has any data. I think what I want to accomplish in the end is to have a fallback cache and a fresh cache and try to fetch the data into the fresh cache. If the fetch succeeds, the fresh cache becomes the new fallback and the old fallback is deleted. This has all been for https://github.com/everestpipkin/image-scrubber where I think the idea is that it stays as offline and simple as possible. Either using service workers for "app like" behavior or easily zippable html js and css that you can unzip and use on your computer without ever sending anything over the network.
|
# ¿ Jun 2, 2020 15:15 |
|
Guildenstern Mother posted:Thanks for the explanations and sorry for wrong thread posting If it's any consolation, javascript was named javascript in the 90s because there was this new cool programming language called java. You were meant to be confused by the name
|
# ¿ Jun 2, 2020 20:18 |
|
Seconding webpack. The tutorial/getting started on the official website is pretty good too. Once you get the project structure mostly there, you can start adding plugins to the mix
Wheany fucked around with this message at 14:01 on Jun 21, 2020 |
# ¿ Jun 21, 2020 13:58 |
|
Doom Mathematic posted:Should your code return the empty string? Then you can use ??. Should it return null instead? Then you should use ||. What's your reasoning here? My opinion is that if you have a default value, always use ?? and only use || if you're dealing with boolean logic.
|
# ¿ Nov 7, 2023 14:56 |
|
Nolgthorn posted:For ages I used || for defaults, going through old code I always change it to ??. Yeah, same.
|
# ¿ Nov 8, 2023 07:59 |
|
Yeah actually I did create a function just today that returns Number(value) || 0, just in case Number(value) evaluates to NaN
Wheany fucked around with this message at 06:37 on Nov 11, 2023 |
# ¿ Nov 10, 2023 21:35 |
|
some kinda jackal posted:but I wanted to manipulate the name properties at assignment time, is the right approach to make the properties private with some sort of name distinction, then make get/set accessors for firstname lastname? Something like To make a property private, prepend its name with a # character: JavaScript code:
|
# ¿ Nov 10, 2023 21:38 |
|
some kinda jackal posted:Is that a style thing or an actual typescript syntax thing because it’s not giving me any errors on private, but for all I know I could be doing something unintended.. quote:» class Person {
|
# ¿ Nov 11, 2023 07:03 |
|
Leng posted:If anyone could point me in the right direction, I would be very grateful for the help! From skimming the code: You seem to be using a non-checkbox element like a checkbox, you could try using checkboxes and trigger your filtering with the "input" event. You also seem to be doing both the active/not active toggling and filtering in the same pass. I would do the toggling in one function, then run a separate function that just gathers the current selection and filters on that.
|
# ¿ Feb 22, 2024 23:18 |
|
|
# ¿ May 16, 2024 10:35 |
|
One case where I will make completely trivial functions is when I'm filtering a collection. So if you have multple things in a list then instead ofJavaScript code:
JavaScript code:
|
# ¿ Feb 24, 2024 17:55 |