HTML5 pauses always when unfocused...

Monkey Forums/Monkey Beginners/HTML5 pauses always when unfocused...

ElRageO(Posted 2015) [#1]
Is there a way to keep an html 5 program running when the page is not focused ?I have made a program that uses the api of a crypto stock place and it displays the stocks I want and will update on a timer.

However, when the page is unfocused the program timer pauses I can see on my debug text. Is there a way to keep it refreshing or running on the all the time regardless of it the page is focused or not ?

When I go back to the page I want it to be recently updated with current stock info.


muruba(Posted 2015) [#2]
Comment out the line in main.js:

canvas.onblur=function( e ){
for( var i=0;i<256;++i ) game.KeyEvent( BBGameEvent.KeyUp,i );
if( CFG_MOJO_AUTO_SUSPEND_ENABLED=="1" ){
// game.SuspendGame();
}
}


ElRageO(Posted 2015) [#3]
You the man thanks! worked great!


DruggedBunny(Posted 2015) [#4]
It's best to use this either directly in the code, at the top of your main file:

#MOJO_AUTO_SUSPEND_ENABLED=False


... or in the CONFIG.MONKEY file within your platform-specific build folder, otherwise you'll have to change it every time you rebuild.


ElRageO(Posted 2015) [#5]
Sweet even better thanks I was wondering if I had the ability to change it in the code as its a pain for testing editing the main.js


ElRageO(Posted 2015) [#6]
Quesiton on httpRequest on html 5. If I querry crypto coin chats through html 5 in monkey Everything works fine I get a return string however If I querry poloniex url I get a nan on the response text.

Both addresses yield a string when pasted into a browser... Is this due to poloniex's protocal on the api ?

 get_req=New HttpRequest( "GET","http://api.cryptocoincharts.info/tradingPair/[bts_btc]",Self )' 'works fine
get_req=New HttpRequest( "GET"," https://poloniex.com/public?command=return24hVolume",Self ) ' gives a nan on response


Both retrun when pasted into browser ??


Nobuyuki(Posted 2015) [#7]
hmm, when the mojo auto suspend is disabled in HTML5, not having a set update rate causes the app to fail! I wonder if this is a bug