File: r-worker.html

package info (click to toggle)
requirejs 2.3.6%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,212 kB
  • sloc: javascript: 80,855; sh: 64; makefile: 10
file content (49 lines) | stat: -rw-r--r-- 1,115 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
<head>
    <style>
        textarea {
            width: 100%;
            height: 20em;
        }
    </style>
    <script>
    var worker = new Worker('r-worker.js');

    worker.onerror = function () {
        console.error("WORKER ERROR", arguments);
    };

    worker.onmessage = function(evt) {
        var data = JSON.parse(evt.data),
            buildText = data.buildText,
            out = data.out;

        document.getElementById('output').value = out;
        document.getElementById('buildMessages').value = buildText;
    };

    document.addEventListener('DOMContentLoaded', function (evt) {
        document.getElementById('build').addEventListener('click', function (evt) {
            worker.postMessage('run');
        }, false);
    }, false);
    </script>
</head>
<body>
    <h1>r.js in the browser</h1>


    <p>A test of running r.js in the browser.</p>

    <p>
        <button id="build">Build it</button>
    </p>

    <h2>Build Messages</h2>
    <textarea id="buildMessages"></textarea>

    <h2>Output</h2>
    <textarea id="output"></textarea>
</body>
</html>