edid-decode: fix pref timing override check
[edid-decode.git] / emscripten / edid-decode.html
blob143a3a62058fe60378bfd3c414d8a0945505db5b
1 <!DOCTYPE html>
2 <html lang="en-us"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style id="stndz-style"></style>
5 <link rel="icon" type="image/x-icon" href="./edid-decode.ico">
7 <title>EDID Decode</title>
8 <style>
9 body {
10 font-family: arial;
11 margin: 0;
12 padding: none;
15 textarea {
16 margin-top: 10px;
17 border: 0;
18 display: block;
19 background-color: black;
20 color: white;
21 font-family: 'Lucida Console', Monaco, monospace;
22 outline: none;
25 #error {
26 background-color: white;
27 color: red;
30 button {
31 margin: 10px;
34 h3 { margin: 0px; }
35 </style>
36 </head>
37 <body>
38 <div style="display:flex">
39 <div style="margin:10px">
40 <h3 style="float:left">EDID</h3>
41 <input type="file" id="upload" style="float:left; margin-left: 10px;">
42 <div style="clear:both"></div>
43 <textarea id="input" style="width:40vw; height: 300px;" placeholder="Paste EDID hex here"></textarea>
44 <button id="process">Process</button>
45 <div><a href="https://git.linuxtv.org/edid-decode.git/">edid-decode.git</a></div>
46 <br>
47 Credits: copied from Ilia Mirkin's website https://people.freedesktop.org/~imirkin/edid-decode/
48 <textarea readonly="" id="error" style="width: 40vw; height: 100px; resize: none;"></textarea>
49 </div>
50 <div style="margin:10px">
51 <h3>Parsed</h3>
52 <textarea readonly="" id="output" rows="8" style="width:55vw; height: calc(100vh - 80px)"></textarea>
53 </div>
55 <script type="text/javascript">
57 document.getElementById("upload").addEventListener("change", function(e) {
58 if (typeof WebAssembly === 'undefined') return;
59 document.getElementById("output").value = "";
60 document.getElementById("error").value = "";
62 var input = e.target;
63 var file = input.files[0];
64 if (!file) return;
65 var fr = new FileReader();
66 fr.onload = function(e) {
67 process(new Uint8Array(e.target.result));
69 fr.readAsArrayBuffer(file);
70 });
72 document.getElementById("process").addEventListener("click", function(e) {
73 if (typeof WebAssembly === 'undefined') return;
74 document.getElementById("output").value = "";
75 document.getElementById("error").value = "";
76 process(document.getElementById("input").value);
77 });
79 function process(input) {
80 FS.writeFile("input-file", input);
81 Module.ccall('parse_edid', 'number', ['string'], ['input-file']);
83 // Look for the hex in the EDID output
84 var output = document.getElementById("output").value;
85 var m = output.match(/^edid-decode \(hex\):\n([0-9a-f \n]*)\n/ms);
86 if (m) {
87 var hex = m[1].replace(/\s/g, '');
88 console.log(hex);
93 var Module = {
94 noInitialRun: true,
95 preRun: [
97 postRun: [],
98 print: (function() {
99 var element = document.getElementById('output');
100 if (element) element.value = ''; // clear browser cache
101 return function(text) {
102 if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
103 // These replacements are necessary if you render to raw HTML
104 //text = text.replace(/&/g, "&amp;");
105 //text = text.replace(/</g, "&lt;");
106 //text = text.replace(/>/g, "&gt;");
107 //text = text.replace('\n', '<br>', 'g');
108 console.log(text);
109 if (element) {
110 element.value += text + "\n";
111 element.scrollTop = element.scrollHeight; // focus on bottom
114 })(),
115 printErr: (function() {
116 var element = document.getElementById('error');
117 if (element) element.value = ''; // clear browser cache
118 return function(text) {
119 if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
120 console.error(text);
121 if (element) {
122 element.value += text + "\n";
123 element.scrollTop = element.scrollHeight;
126 })(),
127 setStatus: function(text) {
128 if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
129 if (text === Module.setStatus.last.text) return;
130 console.log(text);
132 totalDependencies: 0,
133 monitorRunDependencies: function(left) {
134 this.totalDependencies = Math.max(this.totalDependencies, left);
135 Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
138 Module.setStatus('Downloading...');
139 window.onerror = function(event) {
140 // TODO: do not warn on ok events like simulating an infinite loop or exitStatus
141 Module.setStatus('Exception thrown, see JavaScript console');
142 Module.setStatus = function(text) {
143 if (text) Module.printErr('[post-exception status] ' + text);
146 </script>
147 <script async="" type="text/javascript" src="./edid-decode.js"></script>
150 </div></body></html>