加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.html 16.16 KB
一键复制 编辑 原始数据 按行查看 历史
以安 提交于 2023-09-09 08:42 . update README.md.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>浏览器串口调试工具</title>
<link href="https://cdn.bootcdn.net/ajax/libs/bootstrap/5.1.0/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.bootcdn.net/ajax/libs/bootstrap-icons/1.5.0/font/bootstrap-icons.min.css" rel="stylesheet">
<script src="https://cdn.bootcdn.net/ajax/libs/bootstrap/5.1.0/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="css/style.css">
<link rel="icon" href="imgs/logo.svg" type="image/svg+xml">
<script>
hideTop = function () {
var header = document.querySelector('.bd-header');
header.remove();
document.documentElement.style.setProperty('--top-height', '0px');
}
</script>
<script>
!function (p) { "use strict"; !function (t) { var s = window, e = document, i = p, c = "".concat("https:" === e.location.protocol ? "https://" : "http://", "sdk.51.la/js-sdk-pro.min.js"), n = e.createElement("script"), r = e.getElementsByTagName("script")[0]; n.type = "text/javascript", n.setAttribute("charset", "UTF-8"), n.async = !0, n.src = c, n.id = "LA_COLLECT", i.d = n; var o = function () { s.LA.ids.push(i) }; s.LA ? s.LA.ids && o() : (s.LA = p, s.LA.ids = [], o()), r.parentNode.insertBefore(n, r) }() }({ id: "JuSxXIvOMGPBMkpo", ck: "JuSxXIvOMGPBMkpo" });
</script>
</head>
<body>
<header class="bd-header bg-dark py-3 d-flex align-items-stretch border-bottom border-dark">
<div class="container-fluid d-flex align-items-center">
<h1 class="d-flex align-items-center fs-4 text-white mb-0">
<img src="imgs/logo.svg" width="38" height="30" class="me-3" alt="Web Serial">
浏览器串口调试工具
</h1>
</div>
</header>
<div id="main" class="d-flex">
<!--左侧串口配置-->
<div id="serial-options" class="col-auto m-0 bg-light sidebar">
<div class="collapse show p-2 float-start">
<div class="input-group mb-3">
<span class="input-group-text">波特率</span>
<input type="number" id="serial-baud" class="form-control" placeholder="选择波特率" value="9600"
list="baud-list">
<datalist id="baud-list">
<option>9600</option>
<option>115200</option>
</datalist>
</div>
<div class="input-group mb-3">
<span class="input-group-text">数据位</span>
<select class="form-select" id="serial-data-bits">
<option>8</option>
<option>7</option>
</select>
</div>
<div class="input-group mb-3">
<span class="input-group-text">停止位</span>
<select class="form-select" id="serial-stop-bits">
<option>1</option>
<option>2</option>
</select>
</div>
<div class="input-group mb-3">
<span class="input-group-text">校验位</span>
<select class="form-select" id="serial-parity">
<Option value="none">None</Option>
<Option value="even">Even</Option>
<Option value="odd">Odd</Option>
</select>
</div>
<div class="input-group mb-3">
<span class="input-group-text">缓冲区</span>
<input type="number" id="serial-buffer-size" class="form-control" placeholder="缓冲区大小"
list="buffer-size-list" max="1677216" value="1024">
<datalist id="buffer-size-list">
<option>255</option>
<option>512</option>
<option>1024</option>
<option>2048</option>
<option>4096</option>
<option>8192</option>
</datalist>
</div>
<div class="input-group mb-3">
<span class="input-group-text">流控制</span>
<select class="form-select" id="serial-flow-control">
<Option value="none">None</Option>
<Option value="hardware">HardWare</Option>
</select>
</div>
<div class="d-flex mt-2">
<button class="btn btn-secondary me-3" id="serial-select-port">选择串口</button>
<button class="btn btn-primary flex-grow-1" id="serial-open-or-close">打开串口</button>
</div>
<div id="serial-status" class="mt-2">
<div class="alert alert-info" role="alert">
未选择串口
</div>
</div>
</div>
<button class="toggle-button float-end" title="隐藏/打开边栏">
<i class="bi bi-chevron-compact-left"></i>
</button>
</div>
<div class="clear"></div>
<!--中间串口日志-->
<div id="log-main" class="flex-fill px-md-2">
<div
class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-1 pb-1 mb-1 flex-shrink-0">
<h1 class="h3">串口日志</h1>
<div class="btn-toolbar">
<div class="input-group input-group-sm me-2">
<span class="input-group-text">分包超时</span>
<input type="number" id="serial-timer-out" class="form-control" placeholder="0不分包" value="50"
style="width: 100px;" />
</div>
<div class="input-group input-group-sm me-2">
<span class="input-group-text">日志类型</span>
<select class="form-select" id="serial-log-type" style="width: 120px;">
<Option value="hex&ascii">全部</Option>
<Option value="hex">Hex</Option>
<Option value="ascii">ASCII</Option>
</select>
</div>
<div class="btn-group">
<button class="btn btn-sm btn-outline-secondary" id="serial-auto-scroll">自动滚动</button>
<button class="btn btn-sm btn-outline-secondary" id="serial-clear">清空</button>
<button class="btn btn-sm btn-outline-secondary" id="serial-copy">复制</button>
<button class="btn btn-sm btn-outline-secondary" id="serial-save">导出</button>
</div>
</div>
</div>
<div id="serial-logs" class="flex-grow-1 border border-2 rounded mb-2"></div>
<div class="flex-shrink-0 mb-2">
<textarea class="form-control" rows="3" id="serial-send-content" style="resize: none;"
placeholder="在此输入要发送的内容,可以是字符串(如:你好,世界!),也可以是HEX(如:49544c4447)"></textarea>
<div
class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-1 pb-1 mb-1 flex-shrink-0">
<div class="btn-toolbar">
<div class="form-check align-self-center me-2">
<input class="form-check-input" type="checkbox" id="serial-add-crlf">
<label class="form-check-label" for="serial-add-crlf">
末尾加回车换行
</label>
</div>
<div class="form-check align-self-center me-2">
<input class="form-check-input" type="checkbox" id="serial-hex-send">
<label class="form-check-label" for="serial-hex-send">
HEX发送
</label>
</div>
<div class="form-check align-self-center me-2">
<input class="form-check-input" type="checkbox" id="serial-loop-send">
<label class="form-check-label" for="serial-loop-send">
循环发送
</label>
</div>
<div class="input-group input-group-sm">
<span class="input-group-text">发送间隔(MS)</span>
<input type="number" id="serial-loop-send-time" class="form-control" placeholder="" min="1"
value="1000" style="width: 100px;" />
</div>
</div>
<button id="serial-send" class="btn btn-primary h-10 px-5"><i class="bi bi-send"></i>
发送</button>
</div>
</div>
</div>
<div class="clear"></div>
<!--右侧串口工具-->
<div id="serial-tools" class="col-auto m-0 bg-light sidebar">
<button class="toggle-button float-start" title="隐藏/打开边栏">
<i class="bi bi-chevron-compact-right"></i>
</button>
<div class="collapse show p-1 float-start overflow-hidden" style="width:428px">
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<button class="nav-link active" id="nav-quick-send-tab" data-bs-toggle="tab"
data-bs-target="#nav-quick-send" type="button" role="tab" aria-controls="nav-quick-send"
aria-selected="true">快捷发送</button>
<button class="nav-link" id="nav-options-tab" data-bs-toggle="tab" data-bs-target="#nav-options"
type="button" role="tab" aria-controls="nav-options" aria-selected="false">系统选项</button>
</div>
</nav>
<div class="tab-content pt-2 flex-fill" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-quick-send" role="tabpanel"
aria-labelledby="nav-quick-send-tab">
<div class="btn-toolbar">
<div class="flex-grow-1 input-group input-group-sm me-2">
<span class="input-group-text">选择分组</span>
<select class="form-select" id="serial-quick-send">
</select>
</div>
<div class="btn-group">
<button class="btn btn-sm btn-outline-secondary"
id="serial-quick-send-add-group">新增</button>
<button class="btn btn-sm btn-outline-secondary"
id="serial-quick-send-rename-group">改名</button>
<button class="btn btn-sm btn-outline-secondary"
id="serial-quick-send-remove-group">删除</button>
</div>
</div>
<div class="d-flex mt-2">
<button id="serial-quick-send-add" class="btn btn-sm btn-outline-secondary me-5"><i
class="bi bi-plus-square"></i> 增加一条</button>
<button class="btn btn-sm btn-outline-secondary me-2 flex-grow-1"
id="serial-quick-send-import-btn"><i class="bi bi-folder-plus"></i>
导入</button>
<input type="file" id="serial-quick-send-import" style="display: none;"
accept="application/json" />
<button class="btn btn-sm btn-outline-secondary flex-grow-1"
id="serial-quick-send-export"><i class="bi bi-folder-symlink"></i>
导出</button>
</div>
<div class="mt-2">
<div class="d-flex">
<span class="me-2 ms-3">移除</span>
<span class="flex-grow-1 me-1">发送内容,点击修改,双击改名</span>
<span class="flex-shrink-0 me-3">显示名称</span>
<span class="flex-shrink-0 me-2">HEX</span>
</div>
</div>
<div id="serial-quick-send-content"
class="flex-grow-1 border border-2 p-2 rounded overflow-auto">
</div>
</div>
<div class="tab-pane fade" id="nav-options" role="tabpanel" aria-labelledby="nav-options-tab">
<h5>系统配置</h5>
<button class="btn btn-sm btn-outline-secondary me-2" id="serial-reset"><i
class="bi bi-arrow-repeat"></i> 重置参数</button>
<button class="btn btn-sm btn-outline-secondary me-2" id="serial-export"><i
class="bi bi-folder-symlink"></i> 导出配置</button>
<button class="btn btn-sm btn-outline-secondary me-2" id="serial-import"><i
class="bi bi-folder-plus"></i> 导入配置</button>
<input type="file" id="serial-import-file" style="display: none;" accept="application/json" />
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="model-tip" aria-hidden="true" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="modal-title"></h1>
<button class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body" id="modal-message">
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-bs-dismiss="modal">好的</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="model-change-name" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5">名称</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form>
<div class="mb-3">
<label for="model-new-name" class="col-form-label">请输入新的名字:</label>
<input type="text" class="form-control" id="model-new-name">
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
<button type="button" class="btn btn-primary" id="model-save-name">保存</button>
</div>
</div>
</div>
</div>
<script src="js/common.js"></script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化