I need to do something like: The above code does not compile; it throws SyntaxError: … ‘import’ and ‘export’ may only appear at the top level. I tried using System.import as shown here, but I don’t know where System comes from. Is it an ES6 proposal that didn’t end up…
Author: admin@master
disconnect client from socket.io id
I can connect specific player to specific room like: And documentation says that ‘you can use leave method to leave room’ like: But I just want any client to leave using io object instead of socket. I need something like: Is there any way to leave client from room using just socket id with io obje…
use js to make html button update select tag onchange function
Running the code as is will simply show you what my core purpose is. Just displaying rearranged data. But I’m trying to add NEXT and PREVIOUS buttons to go to the next option in the select drop menu in order to lessen the miles on the mouse. I don’t have any code/function for the PREVIOUS button y…
querySelectorAll is not a function
I’m trying to find all oferts in the var articleFirst, but the return message in the console says that “querySelectorAll” is not a function. Why I do get that error? This is my HTML: This is my JavaScript: Error: Uncaught TypeError: articleFirst.querySelectorAll is not a function Answer Try …
How to link a javascript object property to another property of the same object?
Is there a way to link the value of one object property to the value of another? The idea is, that I have something like an excepted interface so I need the propertys.name and .value for my obj. In this special case name is easily constructed from value (value is an array and name is array.toString()) I could…
Import not working with JavaScript in PhpStorm/Webstorm
I’m trying to run a piece of JavaScript code written in a tutorial that looks like this: main.js However, PhpStorm is giving the following error: Import declarations are not supported by current JavaScript version How I can get a newer(?) JavaScript version in PhpStorm? Is that really the problem here? …
Pass javascript variable to twig
I just want to pass a javascript variable to a twig path. Now i’m using this, but it doesn’t work. Answer Note You should really look at the FOSJsRoutingBundle.
How to convert file to base64 in JavaScript?
UPD TypeScript version is also available in answers Now I’m getting File object by this line: I need to send this file via json in base 64. What should I do to convert it to base64 string? Answer Modern ES6 way (async/await) UPD: If you want to catch errors
event.clipboardData.setData in copy event
I have looked at many posts but could not find a clear current answer to the following two questions as it seems standards and browser support has been constantly changing. Is it a legal operation according to the standard to change the clipboard with event.clipboardData.setData inside a ‘copy’ ev…
ReactJS: setTimeout() not working?
Having this code in mind: Isn’t the state supposed to change only after 3 seconds? It’s changing immediately. My main goal here is to change the state every 3 seconds (with setInterval()), but since it was not working, I tried setTimeout(), which is not working either. Any lights on this? Thanks! …