Files
  • index.html
  • queue.c
  • queue.js
  • queue.wasm
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Program Queue Menggunakan WASM</title>
</head>
<body>
  <div id="output" rows="8"></div>
  <button id="enqueue">enqueue</button> 
  <button id="dequeue">dequeue</button> 
  <script>
    var enqueue = document.getElementById('enqueue');
    var dequeue = document.getElementById('dequeue');

    enqueue.addEventListener('click', function(){
      var data = prompt("Tambahkan Data Queue :", "");
      _enqueue(data);
  
    });

    dequeue.addEventListener('click', function(){
     _dequeue();
    });

    (function () {
    var old = console.log;
    var logger = document.getElementById('output');
    console.log = function () {
      for (var i = 0; i < arguments.length; i++) {
        if (typeof arguments[i] == 'object') {
            logger.innerHTML = (JSON && JSON.stringify ? JSON.stringify(arguments[i], undefined, 2) : arguments[i]) + '<br />';
        } else {
            logger.innerHTML = arguments[i] + '<br />';
        }
      }
    }
    })();
  </script> 
  <script async type="text/javascript" src="queue.js"></script>
</body>
</html>
result
console