example: intro an emscripten wrapper around hello world
authorAlexis Laferrière <alexis.laf@xymus.net>
Sat, 14 Jun 2014 10:00:19 +0000 (06:00 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 16 Jun 2014 16:24:23 +0000 (12:24 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

examples/emscripten/hello_world/Makefile [new file with mode: 0644]
examples/emscripten/hello_world/www/index.html [new file with mode: 0644]

diff --git a/examples/emscripten/hello_world/Makefile b/examples/emscripten/hello_world/Makefile
new file mode 100644 (file)
index 0000000..5fea224
--- /dev/null
@@ -0,0 +1,2 @@
+emscripten:
+       ../../../bin/nitg -o www/hello_world.js ../../hello_world.nit -m emscripten
diff --git a/examples/emscripten/hello_world/www/index.html b/examples/emscripten/hello_world/www/index.html
new file mode 100644 (file)
index 0000000..0820561
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<!-- This file is part of NIT ( http://www.nitlanguage.org )
+
+ Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. 
+-->
+<html>
+<head>
+       <title></title>
+       <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
+       <script>
+               // Redirect print to HTML
+               var Module = {
+                       'print': function(text) {
+                               $("#console").append(text + "\n");
+                               $(document).title = text;
+                       }
+               };
+
+               // Report full loading
+               $(document).ready(function() {
+                       $("#loading").text( "Loaded and executed." );
+               });
+       </script>
+</head>
+<body>
+
+       <h1>Status</h1>
+       <p id="loading">Loading...</p>
+
+       <h1>Program output</h1>
+       <samp id="console"></samp>
+       
+       <script src="hello_world.js"></script>
+
+</body>
+</html>