From: Radoslav Gerganov Date: Thu, 25 May 2023 08:27:15 +0000 (+0300) Subject: mnist : add progress indicator on the web page (#194) X-Git-Tag: upstream/0.0.1642~1439 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=73ad593cf84f864f0fcfd3a196253575c70d66a2;p=pkg%2Fggml%2Fsources%2Fggml mnist : add progress indicator on the web page (#194) Prevent user actions before the model and the data set is loaded --- diff --git a/examples/mnist/web/index.html b/examples/mnist/web/index.html index d62beadc..1bd01ae5 100644 --- a/examples/mnist/web/index.html +++ b/examples/mnist/web/index.html @@ -7,14 +7,14 @@ -

MNIST digit recognizer with GGML

-

Draw a single digit on the canvas below:

+

MNIST digit recognizer with GGML

+

Loading model and data set, please wait ...

Your browser does not support the HTML canvas tag.
- +

@@ -114,13 +114,19 @@ if (e.target == canvas) { } }, {passive: false}); -// Use the same handlers for mouse and touch events -canvas.onmousedown = onMouseDown; -canvas.onmouseup = onMouseUp; -canvas.onmousemove = onMouseMove; -canvas.ontouchstart = onMouseDown; -canvas.ontouchend = onMouseUp; -canvas.ontouchmove = onMouseMove; +function onRuntimeInitialized() { + // Use the same handlers for mouse and touch events + canvas.onmousedown = onMouseDown; + canvas.onmouseup = onMouseUp; + canvas.onmousemove = onMouseMove; + canvas.ontouchstart = onMouseDown; + canvas.ontouchend = onMouseUp; + canvas.ontouchmove = onMouseMove; + document.getElementById("msg").innerHTML = "Draw a single digit on the canvas below:" + document.getElementById("random").disabled = false; +} + +Module['onRuntimeInitialized'] = onRuntimeInitialized;