Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Releasing the keyboard in a HTML 5 compiled application after loading new content into the DIV

Author
Message
rudyardcatling
6
Years of Service
User Offline
Joined: 3rd Nov 2017
Location:
Posted: 21st Oct 2021 02:43
I know the standard easy way is to refresh into a new page, that way all the trash gets auto-collected but as it so happens the site is constructed heavily around loading into divs and tabs. In a few instances there are AppGameKit (and also phaser) snippets which load into a div that holds the whole application/canvas.
But when from the menu an option is selected apparently the scripts keep running in the background. Loading a whole new set of data into the div does not remove any execution going on. As a result the keyboard stays locked.

So : practically in <div id = thisone> the whole AppGameKit is running, then the user clicks login on the menu and a fieldset is loaded into <div id=thisone> but its impossible to input anything, when i open the console i see agkplayer.js is still getting keydown events. I thought this would be all be "auto-collected" as javascript goes but apparently thats not the case when loading subsets with jquery. (same thing goes for Phaser , music keeps playing in the background etc although that one doesnt seem to get an exclusive lock)

My question (finally) : how do i stop this ? Is there a function i can call that effectively stops all execution of the AppGameKit scripts before loading the new content or (and thats more HTML but i cant find what i need not even on stack overlords so far) something more generic and general i can use to reset or unhinge all event listeners (which probably not b/c you usually can't touch scripts from other places due to the nature of the beast (for the safety of the children and what not)

All that without re-loading the page . Doing that would be easy in one command but not pretty or the way i want it.

It's not life-threatening but its been bugging me , at least the agkplayers should have a function that makes it stop running somewhere but going through the whole thing seems a bit much for me.

Maybe a 15 year service expert or a dev can help me out ?

A total html/js-guru who knows the seven magic words to stop all scripts or remove a specific one would also be great.

Any response would be awesome anyway, thanks in advance,

J
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 21st Oct 2021 23:18 Edited at: 21st Oct 2021 23:22
You need to remove or disable the event handlers initiated by the agk script, the div is bound to a html5 canvas so once initiated that div will consume all events even (as you noticed) if the content changes the events are still bound

look for: div.removeEventListener

This page any use to you?

There seems to be several solutions there, one must work?
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
rudyardcatling
6
Years of Service
User Offline
Joined: 3rd Nov 2017
Location:
Posted: 23rd Oct 2021 05:18 Edited at: 23rd Oct 2021 07:13
Thanks for the reply , i have been over a few of those before, the clone gives no errors

but

if i add an id "test" to the div containing the canvas



i get no errors but the keyboards stays locked

also if i add



same thing

using



clears the canvas but i can hear the application continuing to run and the keyboard stays locked


if i use



straight at the end of the page the keyboard stays loose , however , it gives a Module = null error in the statusdiv above the canvas

if i use it in a function

<script>
function closure(){
/*
//with or without

//id = test and / or

var oldNode = document.getElementById("canvas");
var newNode = oldNode.cloneNode(true);
oldNode.parentNode.insertBefore(newNode, oldNode);
oldNode.parentNode.removeChild(oldNode);

*/
window.Module = null;
}
</script>

and link that to a button , then when i click it gives Module = null , but the listeners stay active, what i see in the concole is that agkplayer.js is still responding so its the script thats still running, the events seem to be linked to the document and there's no specifi id i can find (im not really a professional, lol)

so actually once its loaded and running it keeps running until the whole document is replaced ( as far as i can figure) and i have no clue how to interrupt that because i dont know the function (method?) if any at all exists and how to call it.

So i can break it (haha) but thats not really what it should be and once its fully loaded it wont even if the visible execution will stop.

All things considered, since these are just for snippets , and AppGameKit is only one, if i really need the actual identifiers then its folly to try this without a generic or general killall() command , i noticed phaser keeps running too (the sound just goes on) when a div is loaded so thats gonna be the script looping , if i move on to three.js and more its gonna be too much to add to the end of the page if each one needs a specific break or hack (if you can call it that) and there's also the question of leaky memory spots b/c i noticed firefox (or any of the others) arent always as great as they promise to be ... sometimes more like windows 95 : "reboot every four hours"

If anyone has a reference doc to the functions and calls used in agkplayer.js that would be still awesome and thank YOU for the page, that was certainly educational but unless im really mistaken there is no general method to do this (assume its "in the name of safety") without complete reloading (which collects all trash at once)

and

well i can keep talking but i think that summarizes it , a general sort of killall() command or a way to remove running scripts might help all across the board , and always any suggestions or tips at all are most welcome

thanks a lot for the reply !!!

<hr>

the loaders are random daily (https://tyrnannoght.eu) but the main AppGameKit would be here : https://tyrnannoght.eu/dlgame/ its using the mesh constructor from the minecraft thing (but i see the guy got banned) so still looking for a way to remove meshes (but it DOES have collision, although compound primitive, not mesh-perfect) and atm trying to mesh thorbjorn tiled (delimited csv) for easy levelmapping but the readtimes seem really slow ... but thats for another topic (and its a hobby, not a project)
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 23rd Oct 2021 10:40
Well the only thing I can think of for a hard reset while keeping the page intact is replace the div with an iFrame then you *should* be able to reload the content, div's are not really meant for this kind of thing.

Other than that I cant really help, I know very little Javascript.
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
rudyardcatling
6
Years of Service
User Offline
Joined: 3rd Nov 2017
Location:
Posted: 24th Oct 2021 06:11 Edited at: 24th Oct 2021 06:20
the whole browsergame isnt really made for it probably but it shows the gaps if you can remove bits and leave background process untouchable. Gods know on how many sites using dynamic content loading processes get stuck b/c half the people developing use a framework where they dont know whats under the hood. Im not much of a pro myself but ive just been kind of dabbling on and off since the c64 - its sure beats telly

Thus far :


That's just the whole bowl of spaghetti ... including replacing, removing, deleting all timeouts from the document, breaking the execution (...somewhere...) by setting Module to null and all of it combined in several stages.

Your suggestions (for which im much obliged) and also here https://stackoverflow.com/questions/550574/how-to-terminate-the-script-in-javascript (among others) the closest it gets is remving agkplayer.asm.js but agkplayer.js stays inthere because every time i click the button it keeps logging the element to console even after element.remove();

Execution seems to stop somewhere because the sounds stops playing but they keyboard isnt released, however (i first didnt get it, tbh) if i click inside the iframe after it replaces the div , [i]then[b] it will indeed respond to keyboard ( CTRL-S i tried) but the rest of the page wont and also after replacing it doesnt seem to log #yo id to the console or $('#yo').load( ....something....);

So, as the overlord on stackoverlords mentions there window.location.reload() works but that was the whole thing - and since the script stays inthere somewhere it will spill over into something sooner or later if the page stays open too long.

I fear .reload() and location.href() will be the only way they'll allow it

with a specific function call it could probably be done but thats application dependent so without a general killall i'm gonna throw in the towel here before it becomes not-pleasant

It was certainly a few very educational hours , thanks a lot taking time to respond to all of this, i really appreciate it.

i guess the answer is "computer says no"

thanks a lot for your time !!!!!

(probably doesnt need saying but i added the id tags agkplayer and agkplayerasm where the agk code in the html page adds them , but it can be found by script src too apparently - its basically why i started agk, i got miffed on the limits imposed by chrome and firefox and here i am again - sorry to trouble you with all this and once more my heartfelt thanks for taking time to answer, i sure got a lot wiser on the subject )
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 24th Oct 2021 16:18
Quote: " its sure beats telly"


Cant argue with that

Quote: "computer says no"


lol, Yup, pretty dam smart dumb machines!

Quote: "once more my heartfelt thanks for taking time to answer"


No problem, I like these questions, they get me Googling and also learning a thing or 2, or in this case, nada! lol

Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Oct 2021 15:14
I do javascript for a living, perhaps I can help. My guess is the key listener isn't attached to the DIV but to the document (the whole page).

Are you able to show me your code or the page hosted somewhere?
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2024-04-25 00:11:02
Your offset time is: 2024-04-25 00:11:02