summaryrefslogtreecommitdiffhomepage
path: root/web/shell.html
blob: 199756b69edaff621120b7a501b1fd3372cb75ba (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Study Player</title>
<style>
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body {
    background: #0d0d1a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #eaeaea;
  }
  #controls {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: center;
  }
  #controls button, #controls label {
    background: #1a1a2e;
    color: #eaeaea;
    border: 2px solid #e94560;
    border-radius: 6px;
    padding: 8px 18px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s;
  }
  #controls button:hover, #controls label:hover {
    background: #e94560;
  }
  #controls input[type="file"] {
    display: none;
  }
  #canvas-container {
    position: relative;
    display: inline-block;
    border: 2px solid #333;
    border-radius: 4px;
    overflow: hidden;
  }
  canvas.emscripten {
    display: block;
  }
  #status {
    margin-top: 10px;
    font-size: 13px;
    color: #8c8ca0;
  }
</style>
</head>
<body>
  <div id="controls">
    <label for="file-input">📂 Load MP3</label>
    <input type="file" id="file-input" accept=".mp3">
    <button id="fullscreen-btn">⛶ Fullscreen</button>
  </div>
  <div id="canvas-container">
    <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex="-1"></canvas>
  </div>
  <div id="status"></div>

  <script>
    var Module = {
      canvas: document.getElementById('canvas'),
      onRuntimeInitialized: function() {
        console.log('Emscripten runtime initialized');
        document.getElementById('status').textContent = 'Ready \u2014 load an MP3 file';
      }
    };

    document.getElementById('fullscreen-btn').addEventListener('click', function() {
      var container = document.getElementById('canvas-container');
      if (container.requestFullscreen) container.requestFullscreen();
      else if (container.webkitRequestFullscreen) container.webkitRequestFullscreen();
      else if (container.msRequestFullscreen) container.msRequestFullscreen();
    });

    document.getElementById('file-input').addEventListener('change', function(e) {
      var file = e.target.files[0];
      if (!file) return;
      console.log('File selected:', file.name, 'size:', file.size);
      document.getElementById('status').textContent = 'Loading ' + file.name + '...';
      var reader = new FileReader();
      reader.onload = function(ev) {
        var data = new Uint8Array(ev.target.result);
        var filename = '/tmp/' + file.name;
        console.log('Writing to virtual FS:', filename, 'bytes:', data.length);
        try { FS.unlink(filename); } catch(ex) {}
        try { FS.mkdir('/tmp'); } catch(ex) {}
        FS.writeFile(filename, data);
        console.log('Calling load_file_web...');
        Module.ccall('load_file_web', null, ['string'], [filename]);
        console.log('load_file_web returned');
        document.getElementById('status').textContent = file.name;
      };
      reader.readAsArrayBuffer(file);
    });
  </script>

  {{{ SCRIPT }}}

</body>
</html>