Browse Source

Added low budget OpenUrl for emscripten - it just replaces the app page with the given url so effectively ends app! Not sure if it's even possible to open a new window from js. I get pop up warnings from the browser when I try with window.open().

Mark Sibly 7 years ago
parent
commit
6fcdfbb7ba
3 changed files with 13 additions and 1 deletions
  1. 1 1
      modules/std/module.json
  2. 8 0
      modules/std/requesters/requesters.monkey2
  3. 4 0
      modules/std/std.monkey2

+ 1 - 1
modules/std/module.json

@@ -4,5 +4,5 @@
 	"author":"Mark Sibly",
 	"version":"1.0.0",
 	"support":"http://monkeycoder.co.nz",
-	"depends":["libc","jni","sdl2","miniz","stb-image","stb-image-write","stb-vorbis","zlib"]
+	"depends":["libc","emscripten","jni","sdl2","miniz","stb-image","stb-image-write","stb-vorbis","zlib"]
 }

+ 8 - 0
modules/std/requesters/requesters.monkey2

@@ -121,4 +121,12 @@ Function OpenUrl( url:String )="bbRequesters::OpenUrl"
 	
 Public
 
+#Elseif __TARGET__="emscripten"
+
+Function OpenUrl( url:String )
+	
+	emscripten.emscripten_run_script( "window.location.href='"+url+"'" )
+	
+End
+
 #Endif

+ 4 - 0
modules/std/std.monkey2

@@ -15,6 +15,10 @@ Namespace std
 #Endif
 #Endif
 
+#If __WEB_TARGET__
+#Import "<emscripten>"
+#endif
+
 #Import "collections/container"
 #Import "collections/stack"
 #Import "collections/list"