Skip to content

Commit

Permalink
Separate endpoint for release and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ninegua committed Sep 21, 2021
1 parent af371ea commit 960d01e
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 12 deletions.
69 changes: 69 additions & 0 deletions release/index.html

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
position: relative;
}
#message {
margin: 10px auto;
margin: 1em auto;
display: block;
}
pre {
Expand All @@ -54,7 +54,6 @@
<div id="text_box" hidden>
<textarea id="message"></textarea>
</div>
<br />
<button id="scan" type="button">Switch to text</button>
<div id="result"></div>
</main>
Expand Down
28 changes: 18 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ async function scan() {
if (res.length > 0) {
let message = await decode_to_json(res[0].data);
if (message.err) {
var [result, pre] = get_result_and_pre();
let [result, pre] = get_result_and_pre();
pre.innerText = "Error decoding message: " + message.err;
} else {
render(res, width, height);
Expand Down Expand Up @@ -255,7 +255,7 @@ function do_send(message) {
if (replied) {
copy_button.style.display = "block";
} else {
quote = (s) => "Status check:\n" + s + "\nPlease wait...";
quote = (s) => "Waiting for response: " + s;
}
let text = typeof reply == "string" ? reply : stringify(reply, null, 2);
pre.innerText = quote(text);
Expand Down Expand Up @@ -322,13 +322,24 @@ function resume_scan() {

async function main() {
const params = new URLSearchParams(window.location.search);
function only_text() {
clear_result();
toggle_input();
const scan_button = document.getElementById("scan");
scan_button.innerText = "(video disabled)";
scan_button.disabled = true;
}
const msg = params.get("msg");
if (msg) {
const message = await decode_to_json(decodeURLComponent(msg));
if (message.errr) {
var [result, pre] = get_result_and_pre();
const message = await decode_to_json(decodeURIComponent(msg));
if (input_type == "video") {
only_text();
}
if (message.err) {
let [result, pre] = get_result_and_pre();
pre.innerText = "Error decoding message: " + message.err;
} else {
document.getElementById("message").value = stringify(message, null, 2);
await prepare_send(message);
}
return;
Expand All @@ -341,12 +352,9 @@ async function main() {
}
} catch (err) {
clear_result();
toggle_input();
const scan_button = document.getElementById("scan");
scan_button.innerText = "(video disabled)";
scan_button.disabled = true;
only_text();
throw err;
}
}

main();
window.addEventListener("load", main);

0 comments on commit 960d01e

Please sign in to comment.