Merge pull request #7869 from thess/static-web-pages

Some improvements to Web Workflow static web pages
This commit is contained in:
Scott Shawcroft 2023-04-17 09:22:25 -07:00 committed by GitHub
commit 3cd6dff1d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 27 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -3,7 +3,6 @@
<head>
<title></title>
<meta charset="UTF-8">
<script src="/directory.js" defer=true></script>
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="http://circuitpython.org/assets/css/webworkflow-8.css">
</head>
@ -21,4 +20,5 @@
<label>Upload progress:<progress value="0"></progress></label>
<hr>
+📁&nbsp;<input type="text" id="name"><button type="submit" id="mkdir">Create Directory</button>
<script src="/directory.js" defer=true></script>
</body></html>

View File

@ -267,3 +267,13 @@ new_directory_name.oninput = () => {
}
window.onhashchange = refresh_list;
window.addEventListener("pageshow", function (event) {
var historyTraversal = event.persisted ||
(typeof window.performance != "undefined" &&
window.performance.navigation.type === 2);
if (historyTraversal) {
// Handle page restore.
window.location.reload();
}
});

View File

@ -4,7 +4,6 @@
<title>Simple client</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="/serial.js" defer=true></script>
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="http://circuitpython.org/assets/css/webworkflow-8.css">
</head>
@ -16,11 +15,13 @@
<div id="controls" style="flex: none; display: flex;">
<fieldset style="display: inline-block; padding: 0;">
<legend>Ctrl</legend>
<button id="b">B</button>
<button id="c">C</button>
<button id="d">D</button>
</fieldset>
<textarea id="input" rows="1" spellcheck="false" wrap="off" style="resize: none; flex: auto; font-size: 1rem;" autocapitalize="none" autocomplete="off" autocorrect="off"></textarea>
<button onclick="onSubmit(); return false;">Send</button>
</div>
<script src="/serial.js" defer=true></script>
</body>
</html>

View File

@ -72,6 +72,17 @@ input.addEventListener("beforeinput", function(e) {
}
});
window.addEventListener("unload", function() {
if (ws.readyState == WebSocket.OPEN) {
ws.close();
}
});
let ctrl_b = document.querySelector("#b");
ctrl_b.onclick = function() {
ws.send("\x02");
}
let ctrl_c = document.querySelector("#c");
ctrl_c.onclick = function() {
ws.send("\x03");

View File

@ -4,7 +4,6 @@
<title>CircuitPython</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="/welcome.js" defer=true></script>
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="http://circuitpython.org/assets/css/webworkflow-8.css">
</head>
@ -30,5 +29,6 @@
<h2>Here are other CircuitPython devices on your network:</h2>
<ul id="devices">
</ul>
<script src="/welcome.js" defer=true></script>
</body>
</html>

View File

@ -1002,7 +1002,7 @@ STATIC_FILE(edit_js);
STATIC_FILE(style_css);
STATIC_FILE(serial_html);
STATIC_FILE(serial_js);
STATIC_FILE(blinka_16x16_ico);
STATIC_FILE(blinka_32x32_ico);
static void _reply_static(socketpool_socket_obj_t *socket, _request *request, const uint8_t *response, size_t response_len, const char *content_type) {
uint32_t total_length = response_len;
@ -1303,7 +1303,7 @@ static bool _reply(socketpool_socket_obj_t *socket, _request *request) {
} else if (strcmp(request->path, "/favicon.ico") == 0) {
// TODO: Autogenerate this based on the blinka bitmap and change the
// palette based on MAC address.
_REPLY_STATIC(socket, request, blinka_16x16_ico);
_REPLY_STATIC(socket, request, blinka_32x32_ico);
} else {
_reply_missing(socket, request);
}