Mercurial > hg > forks > multipaint-js
diff docompile.html @ 25:13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
bits for that. Also added in "docompile.html" that can be used to
pre-compile the Multipaint PSJS code to a multipaint.js.
Also included is a patch for Processing.js v1.4.8 that removes use for data:
blob URIs that may be against many sites content security policy (CSP).
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 04 Jul 2018 10:27:30 +0300 |
parents | |
children | 6db5defacbb3 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/docompile.html Wed Jul 04 10:27:30 2018 +0300 @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>Multipaint</title> + <script src="processing.min.js"></script> + <script src="mpui.js"></script> +</head> +<body> +<canvas id="mpCanvas"></canvas> +<div id="mpUI"></div> +<script> +var mpMachine = 0; +var mpCanvas = document.getElementById("mpCanvas"); +new Processing.loadSketchFromSources(mpCanvas, mpSources); + +function mpWaitUntilSketchIsReady() +{ + var inst = Processing.getInstanceById("mpCanvas"); + if (inst) + { + var code = "var multipaintJS =\n"+ inst.externals.sketch.sourceCode; + var uriContent = "data:application/octet-stream,"+ encodeURIComponent(code); + document.getElementById("mpUI").innerHTML = "<a href="+ uriContent +" download=\"multipaint.js\">Here is the download link</a>"; + } + else + setTimeout(mpWaitUntilSketchIsReady, 250); +} + +document.addEventListener('DOMContentLoaded', mpWaitUntilSketchIsReady, false); + +</script> +</body> +</html>