Spaces:
Running
Running
Download static/index.html from bevisssssss/driver: direct link, hf CLI and curl.
- Browser
- Download file 53.8 kB
-
https://huggingface.co/spaces/bevisssssss/driver/resolve/main/static/index.html
- Command line
-
hf download hf://spaces/bevisssssss/driver/static/index.html
-
curl -L -o index.html https://huggingface.co/spaces/bevisssssss/driver/resolve/main/static/index.html
53.8 kB
<!DOCTYPE html>
<html lang="en" data-theme="cool">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>MES Info Query</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext y='.9em' font-size='90'%3E%F0%9F%93%A6%3C/text%3E%3C/svg%3E">
<style>
/* โโโโโโโโโโโโ Design System โโโโโโโโโโโโ */
:root {
--bg-page:#f0f4f8; --bg-card:#fff; --bg-subtle:#f8fafc;
--text-primary:#0f172a; --text-secondary:#475569; --text-muted:#94a3b8;
--border-light:#e2e8f0; --border-subtle:#f1f5f9;
--shadow-card:0 1px 3px rgba(0,0,0,.04),0 1px 2px rgba(0,0,0,.06);
--shadow-hover:0 10px 30px -5px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);
--header-start:#0b1426; --header-mid:#14203a; --header-end:#0b1426;
--header-text:#f1f5f9; --header-sub:#64748b;
--glow-1:rgba(59,130,246,.08); --glow-2:rgba(139,92,246,.08);
--accent:#3b82f6; --accent-strong:#2563eb;
--chip-bg:#eff6ff; --chip-text:#1d4ed8;
--muted-bg:#f1f5f9;
--ok:#16a34a; --err:#dc2626;
--bg-pattern:rgba(59,130,246,.015);
}
[data-theme="warm"] {
--bg-page:#fef7ee; --bg-card:#fff; --bg-subtle:#fffbeb;
--text-primary:#1c1917; --text-secondary:#57534e; --text-muted:#a8a29e;
--border-light:#e7e5e4; --border-subtle:#f5f5f4;
--shadow-card:0 1px 3px rgba(120,80,40,.04),0 1px 2px rgba(120,80,40,.06);
--shadow-hover:0 10px 30px -5px rgba(120,80,40,.1),0 4px 6px -2px rgba(120,80,40,.05);
--header-start:#1c130d; --header-mid:#2d1f14; --header-end:#1c130d;
--header-text:#fefce8; --header-sub:#a8a29e;
--glow-1:rgba(245,158,11,.07); --glow-2:rgba(239,68,68,.06);
--accent:#d97706; --accent-strong:#b45309;
--chip-bg:#fef3c7; --chip-text:#92400e;
--muted-bg:#fef3c7;
--ok:#15803d; --err:#dc2626;
--bg-pattern:rgba(245,158,11,.015);
}
*{margin:0;padding:0;box-sizing:border-box}
body{
font-family:"PingFang SC","Microsoft YaHei","Noto Sans SC","Helvetica Neue",Arial,sans-serif;
background:var(--bg-page);color:var(--text-primary);min-height:100vh;
transition:background .4s ease,color .3s ease;
}
body::before{
content:'';position:fixed;inset:0;z-index:-1;
background-image:linear-gradient(var(--bg-pattern) 1px,transparent 1px),
linear-gradient(90deg,var(--bg-pattern) 1px,transparent 1px);
background-size:60px 60px;
}
.hidden{display:none!important}
a{color:inherit}
/* โโ Theme toggle โโ */
.theme-toggle{
position:fixed;top:18px;right:18px;z-index:100;width:42px;height:42px;border-radius:50%;
border:2px solid var(--border-light);background:var(--bg-card);cursor:pointer;font-size:19px;
display:flex;align-items:center;justify-content:center;transition:all .3s cubic-bezier(.4,0,.2,1);
box-shadow:0 2px 12px rgba(0,0,0,.08);
}
.theme-toggle:hover{transform:scale(1.1);box-shadow:0 4px 20px rgba(0,0,0,.12)}
/* โโ Header โโ */
.header{
background:linear-gradient(135deg,var(--header-start) 0%,var(--header-mid) 50%,var(--header-end) 100%);
color:var(--header-text);padding:30px 0 26px;position:relative;overflow:hidden;
transition:background .4s ease;
}
.header::before{
content:'';position:absolute;top:-50%;left:-50%;width:200%;height:200%;
background:radial-gradient(ellipse at 30% 50%,var(--glow-1) 0%,transparent 60%),
radial-gradient(ellipse at 70% 50%,var(--glow-2) 0%,transparent 60%);
}
.header-inner{
position:relative;max-width:1100px;margin:0 auto;padding:0 24px;
display:flex;align-items:center;justify-content:space-between;gap:20px;flex-wrap:wrap;
}
.brand h1{font-size:26px;font-weight:700;letter-spacing:.5px}
.brand .sub{color:var(--header-sub);font-size:13px;margin-top:6px}
.top-nav{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.top-nav a,.lang-btn{
font-size:13px;color:var(--header-text);text-decoration:none;padding:8px 14px;border-radius:8px;
background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.14);
transition:background .2s;cursor:pointer;font-family:inherit;
}
.top-nav a:hover,.lang-btn:hover{background:rgba(255,255,255,.18)}
.lang-btn{font-weight:600;min-width:64px}
/* โโ Layout โโ */
.wrap{max-width:1100px;margin:0 auto;padding:28px 24px 60px}
.card{
background:var(--bg-card);border:1px solid var(--border-light);border-radius:14px;
box-shadow:var(--shadow-card);padding:22px;
}
/* โโ Gate โโ */
.gate{max-width:440px;margin:40px auto;text-align:center}
.gate h2{font-size:20px;margin-bottom:10px}
.gate p{color:var(--text-secondary);font-size:13px;line-height:1.6;margin-bottom:18px}
.gate .row{display:flex;gap:10px}
input[type=text],input[type=password]{
flex:1;padding:12px 14px;border:1px solid var(--border-light);border-radius:10px;
font-size:15px;font-family:inherit;background:var(--bg-subtle);color:var(--text-primary);outline:none;
transition:border-color .2s,box-shadow .2s;
}
input[type=text]:focus,input[type=password]:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--glow-1)}
.btn{
padding:12px 22px;border:none;border-radius:10px;background:var(--accent);color:#fff;
font-size:15px;font-weight:600;font-family:inherit;cursor:pointer;transition:background .2s,transform .1s;
white-space:nowrap;
}
.btn:hover{background:var(--accent-strong)}
.btn:active{transform:scale(.98)}
.btn:disabled{opacity:.55;cursor:not-allowed}
.btn-ghost{
padding:8px 14px;border:1px solid var(--border-light);border-radius:9px;background:var(--bg-card);
color:var(--text-secondary);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;transition:all .2s;
}
.btn-ghost:hover{border-color:var(--accent);color:var(--accent)}
/* โโ Query โโ */
.query-card{margin-top:6px}
.query-row{display:flex;gap:12px}
.err{color:var(--err);font-size:13px;margin-top:12px}
.progress-wrap{margin-top:18px}
.progress-bar{height:8px;background:var(--muted-bg);border-radius:6px;overflow:hidden}
.progress-bar > div{height:100%;width:0;background:linear-gradient(90deg,var(--accent),var(--accent-strong));transition:width .35s ease}
.progress-msg{font-size:13px;color:var(--text-secondary);margin-top:8px}
/* โโ Result toolbar โโ */
.result-toolbar{
display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:20px 0 14px;
}
.search-input{flex:1;min-width:180px}
.toggle-label{display:flex;align-items:center;gap:7px;font-size:13px;color:var(--text-secondary);cursor:pointer;user-select:none}
.toggle-label input{width:16px;height:16px;cursor:pointer}
.badge-cached{
font-size:12px;padding:4px 10px;border-radius:20px;background:var(--muted-bg);color:var(--text-secondary);font-weight:600;
}
.badge-sn{font-size:12px;padding:4px 10px;border-radius:20px;background:var(--chip-bg);color:var(--chip-text);font-weight:600}
/* โโ Sections โโ */
.sect{margin-bottom:16px;padding:0;overflow:hidden}
.sect-title{
font-size:14px;font-weight:700;padding:14px 20px;border-bottom:1px solid var(--border-subtle);
color:var(--text-primary);letter-spacing:.3px;
}
.sect.summary{background:linear-gradient(135deg,var(--chip-bg),transparent 70%)}
.frows{display:grid;grid-template-columns:repeat(auto-fill,minmax(320px,1fr));gap:0}
.frow{
display:flex;align-items:baseline;gap:10px;padding:11px 20px;border-bottom:1px solid var(--border-subtle);
min-width:0;
}
.flabel{flex:0 0 132px;font-size:12.5px;color:var(--text-muted);font-weight:600;word-break:break-word}
.fval{
flex:1;min-width:0;font-size:13.5px;color:var(--text-primary);word-break:break-word;cursor:copy;
padding:2px 6px;border-radius:6px;transition:background .15s;
}
.fval:hover{background:var(--bg-subtle)}
.fval.muted{color:var(--text-muted);cursor:default}
.fval.muted:hover{background:none}
/* Wide modules: full-width rows so long OS strings stay on few lines */
.sect.wide .frows{grid-template-columns:1fr}
.sect.wide .flabel{flex:0 0 150px}
.sect.wide .fval{font-size:13px;line-height:1.6}
/* Collapsed secondary fields */
.sect.more>summary{cursor:pointer;list-style:none;user-select:none}
.sect.more>summary::-webkit-details-marker{display:none}
.sect.more>summary::before{content:'โธ ';color:var(--text-muted)}
.sect.more[open]>summary::before{content:'โพ '}
.more-body{border-top:1px solid var(--border-subtle)}
.more-body .sect{border:none;border-radius:0;box-shadow:none;margin:0;border-bottom:1px solid var(--border-subtle)}
.more-body .sect-title{font-size:13px;padding:12px 20px;color:var(--text-secondary)}
/* โโ Raw JSON โโ */
.raw-box{margin-top:8px;border:1px solid var(--border-light);border-radius:12px;overflow:hidden;background:var(--bg-card)}
.raw-box summary{padding:14px 20px;font-size:13px;font-weight:600;cursor:pointer;color:var(--text-secondary);list-style:none}
.raw-box summary::-webkit-details-marker{display:none}
.raw-box summary::before{content:'{ } ';color:var(--accent)}
.raw-box pre{
margin:0;padding:16px 20px;background:var(--bg-subtle);font-family:"SFMono-Regular",Consolas,"Liberation Mono",monospace;
font-size:12px;line-height:1.6;max-height:480px;overflow:auto;white-space:pre;color:var(--text-secondary);
border-top:1px solid var(--border-subtle);
}
/* โโ Toast โโ */
.toast{
position:fixed;bottom:28px;left:50%;transform:translateX(-50%) translateY(20px);opacity:0;
background:#0f172a;color:#fff;padding:11px 22px;border-radius:10px;font-size:13.5px;pointer-events:none;
transition:all .25s ease;z-index:200;box-shadow:0 8px 24px rgba(0,0,0,.2);
}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
.toast.err{background:var(--err)}
/* โโ MEGA manual search โโ */
.mega-card{margin-top:8px;padding:20px}
.mega-card h3{font-size:14.5px;font-weight:700;margin-bottom:4px}
.mega-hint{font-size:12.5px;color:var(--text-muted);margin-bottom:12px;line-height:1.5}
.mega-chips{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:12px}
.chip{border:1px solid var(--border-light);background:var(--bg-subtle);color:var(--text-secondary);font:inherit;font-size:11.5px;padding:5px 10px;border-radius:999px;cursor:pointer;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:border-color .15s,color .15s}
.chip:hover{border-color:var(--accent);color:var(--accent)}
.chip-k{font-weight:700;color:var(--accent);margin-right:5px}
.mega-row{display:flex;gap:10px;align-items:center}
.mega-row input{flex:1;min-width:0;padding:11px 14px;border:1px solid var(--border-light);border-radius:10px;font:inherit;font-size:13.5px;background:var(--bg-card);color:var(--text-primary)}
.mega-results{margin-top:14px;display:flex;flex-direction:column;gap:8px}
.mega-item{display:flex;align-items:center;gap:12px;padding:11px 14px;border:1px solid var(--border-light);border-radius:10px;background:var(--bg-subtle)}
.mega-name{flex:1;min-width:0;font-size:12.5px;word-break:break-all;font-family:"SFMono-Regular",Consolas,"Liberation Mono",monospace}
.mega-size{font-size:11.5px;color:var(--text-muted);margin-top:2px}
.mega-act{display:flex;gap:6px;flex-shrink:0}
.mega-none{font-size:12.5px;color:var(--text-muted);padding:4px 0}
.map-list{display:flex;flex-direction:column;gap:8px}
.map-item{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--border-light);border-radius:10px;background:var(--bg-subtle)}
.map-item .mega-name{flex:1}
.map-none{font-size:12.5px;color:var(--text-muted);padding:2px 0}
.map-actions{margin-top:14px}
.modal{position:fixed;inset:0;background:rgba(15,23,42,.55);display:flex;align-items:center;justify-content:center;z-index:200;padding:20px}
.modal.hidden{display:none}
.modal-box{background:var(--bg-card);border:1px solid var(--border-light);border-radius:14px;padding:22px;width:100%;max-width:520px;max-height:90vh;overflow:auto}
.modal-box h3{margin:0 0 6px;font-size:16px}
.modal-box label{display:block;font-size:12px;color:var(--text-secondary);margin:14px 0 6px}
.modal-box select,.modal-box textarea,.modal-box input{width:100%;box-sizing:border-box;padding:10px 12px;border:1px solid var(--border-light);border-radius:9px;font:inherit;font-size:13px;background:var(--bg-card);color:var(--text-primary)}
.modal-box textarea{min-height:100px;resize:vertical}
.modal-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:20px}
@media(max-width:640px){
.mega-row{flex-direction:column;align-items:stretch}
.map-item{flex-direction:column;align-items:flex-start}
.mega-item{flex-direction:column;align-items:flex-start}
}
@media(max-width:640px){
.theme-toggle{top:12px;right:12px;width:38px;height:38px;font-size:16px}
.brand h1{font-size:21px}
.wrap{padding:18px 14px 50px}
.frows{grid-template-columns:1fr}
.frow{padding:10px 16px}
.flabel{flex-basis:104px;font-size:12px}
.query-row{flex-direction:column}
}
</style>
</head>
<body>
<button class="theme-toggle" id="themeToggle" title="Theme">โ๏ธ</button>
<div class="header">
<div class="header-inner">
<div class="brand">
<h1 id="appTitle">MES Info Query</h1>
<div class="sub" id="appSub"></div>
</div>
<nav class="top-nav">
<a href="admin.html" id="navAdmin"></a>
<button class="lang-btn" id="langToggle" onclick="toggleLang()">ไธญๆ</button>
</nav>
</div>
</div>
<div class="wrap">
<!-- Access gate -->
<section id="gate" class="card gate hidden">
<h2 id="gateTitle"></h2>
<p id="gateDesc"></p>
<div class="row">
<input type="password" id="codeInput" autocomplete="off">
<button class="btn" id="accessBtn" onclick="verifyCode()"></button>
</div>
<div class="err hidden" id="gateError"></div>
</section>
<!-- Query -->
<section id="queryCard" class="card query-card hidden">
<div class="query-row">
<input type="text" id="snInput" autocomplete="off" spellcheck="false">
<button class="btn" id="queryBtn" onclick="doQuery()"></button>
</div>
<div class="progress-wrap hidden" id="progressWrap">
<div class="progress-bar"><div id="progressFill"></div></div>
<div class="progress-msg" id="progressMsg"></div>
</div>
<div class="err hidden" id="queryError"></div>
</section>
<!-- Results -->
<section id="results" class="hidden">
<div class="result-toolbar">
<input type="text" class="search-input" id="fieldSearch" oninput="applyFilter()">
<label class="toggle-label"><input type="checkbox" id="emptyToggle" onchange="applyFilter()"><span id="showEmptyLabel"></span></label>
<button class="btn-ghost" id="copyJsonBtn" onclick="copyJson()"></button>
<button class="btn-ghost" id="downloadJsonBtn" onclick="downloadJson()"></button>
<button class="btn-ghost" id="relockBtn" onclick="relock()"></button>
<span class="badge-sn hidden" id="snBadge"></span>
<span class="badge-cached hidden" id="cachedBadge"></span>
</div>
<div id="sections"></div>
<!-- MEGA manual search -->
<section class="card mega-card" id="megaCard">
<h3 id="megTitle"></h3>
<div class="mega-hint" id="megHint"></div>
<div class="mega-chips" id="megChips"></div>
<div class="mega-row">
<input type="text" id="megInput" autocomplete="off" spellcheck="false">
<button class="btn" id="megBtn" onclick="doMegaSearch()"></button>
</div>
<div class="mega-results" id="megResults"></div>
</section>
<!-- OS name mapping -->
<section class="card mega-card" id="mapCard">
<h3 id="mapTitle"></h3>
<div class="mega-hint" id="mapHint"></div>
<div class="map-list" id="mapList"></div>
<div class="map-actions"><button class="btn-ghost" id="reportBtn" onclick="openReport()"></button></div>
</section>
<details class="raw-box" id="rawBox">
<summary id="rawSummary"></summary>
<pre id="rawPre"></pre>
</details>
</section>
</div>
<div class="modal hidden" id="reportModal">
<div class="modal-box">
<h3 id="repTitle"></h3>
<label id="repTypeLabel" for="repType"></label>
<select id="repType" onchange="onReportTypeChange()"></select>
<label id="repFieldLabel" for="repField"></label>
<select id="repField" onchange="onReportFieldChange()"></select>
<label id="repOsLabel" for="repOs"></label>
<input type="text" id="repOs" autocomplete="off">
<label id="repDescLabel" for="repDesc"></label>
<textarea id="repDesc"></textarea>
<div class="modal-actions">
<button class="btn-ghost" id="repCancel" onclick="closeReport()"></button>
<button class="btn" id="repSubmit" onclick="submitReport()"></button>
</div>
</div>
</div>
<div class="toast" id="toast"></div>
<script>
/* โโโโโโโโโโโโ i18n โโโโโโโโโโโโ */
const I18N = {
en: {
title:"MES Info Query",
sub:"Query device production & system info by SN",
navAdmin:"Admin",
gateTitle:"Access Code Required",
gateDesc:"Enter the access code to use MES query. You only need to do this once per browser.",
codePh:"Access code", verifyBtn:"Verify",
accessError:"Invalid access code", serverError:"Server error, please retry", networkError:"Network error, please retry",
snPh:"Enter SN, e.g. M1TA688A0NXA25M0356", queryBtn:"Query",
queueing:"Submitting...", querying:"Querying...",
showEmpty:"Show empty fields", searchPh:"Search fields...",
copyJson:"Copy JSON", downloadJson:"Download JSON", relock:"Change code",
cached:"cached",
summary:"Device Summary", additional:"Additional Fields",
noData:"No data returned", copied:"Copied", copyFail:"Copy failed",
rawJson:"Raw JSON", emptyNote:"No matching fields",
megTitle:"Manual MEGA Search",
megHint:"MES OS names often carry dirty prefixes. Click a detected name below, or paste the correct file name, then search MEGA for the download link.",
megSearchPh:"Paste or edit an OS file name, e.g. SCD_20250610_...",
megSearchBtn:"Search MEGA", megSearching:"Searching MEGA...",
megNoResult:"No matching file in MEGA", megRefreshing:"Refreshing MEGA index (about 30s)...", megIndexRefreshed:"MEGA index refreshed", megResultCount:"{n} result(s)",
megDownload:"Open", megCopy:"Copy", megLinkFail:"Link generation failed",
megNoCand:"No OS name detected โ paste one manually",
mapTitle:"OS Name Mapping",
mapHint:"Some MES OS names are non-standard. Admins map them to real MEGA file names; mapped files are listed here.",
mapNone:"No mapping registered for this OS name yet",
mapMapped:"Mapped",
reportBtn:"Report an Issue",
repTitle:"Report an Issue",
repTypeLabel:"Issue type", repFieldLabel:"Which field", repOsLabel:"Field content / file name", repDescLabel:"Details",
repDescPh:"Describe the problem, e.g. this OS name has no mapping, or the file is missing on MEGA",
repCancel:"Cancel", repSubmit:"Submit",
repOk:"Report submitted, thank you!", repFail:"Submit failed, please retry"
},
zh: {
title:"MES ไฟกๆฏๆฅ่ฏข",
sub:"้่ฟ SN ๆฅ่ฏข่ฎพๅค็ไบงไธ็ณป็ปไฟกๆฏ",
navAdmin:"็ฎก็ๅๅฐ",
gateTitle:"้่ฆ่ฎฟ้ฎ็ ",
gateDesc:"่พๅ
ฅ่ฎฟ้ฎ็ ๅณๅฏไฝฟ็จ MES ๆฅ่ฏขใๆฏไธชๆต่งๅจๅช้่พๅ
ฅไธๆฌกใ",
codePh:"่ฎฟ้ฎ็ ", verifyBtn:"้ช่ฏ",
accessError:"่ฎฟ้ฎ็ ้่ฏฏ", serverError:"ๆๅกๅจ้่ฏฏ๏ผ่ฏท้่ฏ", networkError:"็ฝ็ป้่ฏฏ๏ผ่ฏท้่ฏ",
snPh:"่ฏท่พๅ
ฅ SN๏ผไพๅฆ M1TA688A0NXA25M0356", queryBtn:"ๆฅ่ฏข",
queueing:"ๆไบคไธญ...", querying:"ๆฅ่ฏขไธญ...",
showEmpty:"ๆพ็คบ็ฉบๅญๆฎต", searchPh:"ๆ็ดขๅญๆฎต...",
copyJson:"ๅคๅถ JSON", downloadJson:"ไธ่ฝฝ JSON", relock:"ๆดๆข่ฎฟ้ฎ็ ",
cached:"ๆฅ่ช็ผๅญ",
summary:"่ฎพๅคๆฆ่ฆ", additional:"ๅ
ถไปๅญๆฎต",
noData:"ๆช่ฟๅๆฐๆฎ", copied:"ๅทฒๅคๅถ", copyFail:"ๅคๅถๅคฑ่ดฅ",
rawJson:"ๅๅง JSON", emptyNote:"ๆ ๅน้
ๅญๆฎต",
megTitle:"ๆๅจ MEGA ๆฃ็ดข",
megHint:"MES ่ฟๅ็ OS ๅ็งฐๅธธๅธฆ่ๆฐๆฎใ็นๅปไธๆน่ฏๅซๅบ็ๅ็งฐ๏ผๆ็ฒ่ดดๆญฃ็กฎ็ๆไปถๅ๏ผๅไป MEGA ๆฃ็ดขไธ่ฝฝ้พๆฅใ",
megSearchPh:"็ฒ่ดดๆไฟฎๆน OS ๆไปถๅ๏ผไพๅฆ SCD_20250610_...",
megSearchBtn:"ๆฃ็ดข MEGA", megSearching:"ๆญฃๅจๆฃ็ดข MEGA...",
megNoResult:"MEGA ไธญๆฒกๆๅน้
ๆไปถ", megRefreshing:"ๆญฃๅจๅทๆฐ MEGA ็ดขๅผ๏ผ็บฆ 30 ็ง๏ผโฆ", megIndexRefreshed:"ๅทฒๅทๆฐ MEGA ็ดขๅผ", megResultCount:"ๅ
ฑ {n} ๆก็ปๆ",
megDownload:"ๆๅผ", megCopy:"ๅคๅถ", megLinkFail:"้พๆฅ็ๆๅคฑ่ดฅ",
megNoCand:"ๆช่ฏๅซๅฐ OS ๅ็งฐ๏ผ่ฏทๆๅจ็ฒ่ดด",
mapTitle:"OS ๅ็งฐๆ ๅฐ",
mapHint:"้จๅ MES OS ๅ็งฐไธ่ง่๏ผ็ฎก็ๅไผๅฐๅ
ถๆ ๅฐไธบ็ๅฎ็ MEGA ๆไปถๅ๏ผๆ ๅฐ็ปๆๅจๆญคๆพ็คบใ",
mapNone:"่ฏฅ OS ๅ็งฐๅฐๆช็ป่ฎฐๆ ๅฐ",
mapMapped:"ๅทฒๆ ๅฐ",
reportBtn:"้ฎ้ขไธๆฅ",
repTitle:"้ฎ้ขไธๆฅ",
repTypeLabel:"้ฎ้ข็ฑปๅ", repFieldLabel:"้ฎ้ขๅญๆฎต", repOsLabel:"ๅญๆฎตๅ
ๅฎน / ๆไปถๅ", repDescLabel:"่ฏฆ็ป่ฏดๆ",
repDescPh:"่ฏทๆ่ฟฐ้ฎ้ข๏ผไพๅฆ่ฏฅ OS ๅ็งฐๆฒกๆๆ ๅฐ๏ผๆๆไปถๆชไธไผ ๅฐ MEGA",
repCancel:"ๅๆถ", repSubmit:"ๆไบค",
repOk:"ไธๆฅๅทฒๆไบค๏ผๆ่ฐขๅ้ฆ๏ผ", repFail:"ๆไบคๅคฑ่ดฅ๏ผ่ฏท้่ฏ"
}
};
/* โโโโโโโโโโโโ Main field groups [key, en, zh] โโโโโโโโโโโโ */
/* 3 primary modules. `wide:true` gives long OS strings the full card width. */
const GROUPS = [
{en:"Work Order", zh:"ๅทฅๅไฟกๆฏ", fields:[
["ASD_SN","Serial Number","ๅบๅๅท"],["MACHINECODE","Machine Code","ๆบๅจ็ผ็ "],["ASD_MACHINETYPE","Machine Type","ๆบๅ"],
["DPI","Resolution","ๅ่พจ็"],["MID_IMEI","IMEI (MID)","IMEI(MID)"],["ASD_IMEI","IMEI (ASD)","IMEI(ASD)"],
["OSTYPE","OS Type","็ณป็ป็ฑปๅ"]
]},
{en:"Neutral System", zh:"ไธญๆง็ณป็ป", wide:true, fields:[
["MID_OSVERSION","OS Version","็ณป็ป็ๆฌ"],["MID_BIOSVERSION","BIOS","BIOS"],["MID_EC","EC","EC"]
]},
{en:"Custom System", zh:"ๅฎขๅถ็ณป็ป", wide:true, fields:[
["ASD_OS","OS Version","็ณป็ป็ๆฌ"],["ASD_BIOS","BIOS","BIOS"],["ASD_EC","EC","EC"]
]}
];
/* โโโโโโโโโโโโ Secondary groups (collapsed under "ๅ
ถไปๅญๆฎต") โโโโโโโโโโโโ */
const MORE_GROUPS = [
{en:"Device", zh:"่ฎพๅค", fields:[
["MODEL","Model","ๅๅท"],["MID_SN","SN (MID)","SN(MID)"],["GENERATION","Generation","ไปฃ็ณป"],
["ASD_KIND","Kind","็ฑปๅซ"],["ASD_STATUS","Status","็ถๆ"]
]},
{en:"System (extra)", zh:"็ณป็ปไฟกๆฏ(ๆฉๅฑ)", fields:[
["MID_DRIVERVERSION","Driver Version","้ฉฑๅจ็ๆฌ"],["MID_OSPRODUCTID","OS Product ID","็ณป็ปไบงๅID"],
["MID_OSPRODUCTKEY","OS Product Key","็ณป็ปไบงๅๅฏ้ฅ"],["MID_PROCESSID","Process ID","ๅ ๅทฅๅๅท"]
]},
{en:"Hardware", zh:"็กฌไปถ้
็ฝฎ", fields:[
["ASD_CONFIG","Config","็กฌไปถ้
็ฝฎ"],["RAM","RAM","ๅ
ๅญ"],["ROM","ROM","ๅญๅจ"],["CPU","CPU","CPU"],
["LCD","LCD","ๆถฒๆถๅฑ"],["TP","Touch Panel","่งฆๆธๅฑ"],["CAMERA","Camera","ๆๅๅคด"],["BAT","Battery","็ตๆฑ "],
["MAINBOARDVER","Mainboard Ver","ไธปๆฟ็ๆฌ"],["SUBBOARDVER","Subboard Ver","ๅฏๆฟ็ๆฌ"],["MCU","MCU","MCU"],
["BRIDGEIC","Bridge IC","ๆกฅๆฅIC"],["MID_HARDDISKMODEL","Disk Model","็กฌ็ๅๅท"],["MID_HARDDISKSN","Disk SN","็กฌ็ๅบๅๅท"]
]},
{en:"Sensors & Peripherals", zh:"ไผ ๆๅจไธๅค่ฎพ", fields:[
["WIFI","WiFi","WiFiๆจกๅ"],["NFC","NFC","NFC"],["GPS","GPS","GPS"],["MAGNETOMETER","Magnetometer","็ฃๅ่ฎก"],
["GYROSCOPE","Gyroscope","้่บไปช"],["LIGHTSENSOR","Light Sensor","ๅ
ๆ"],["ACCELEROMETER","Accelerometer","ๅ ้ๅบฆ่ฎก"],
["FINGERPRINT","Fingerprint","ๆ็บน"],["IDENTITYMODULE","Identity Module","่บซไปฝๆจกๅ"]
]},
{en:"Connection IDs", zh:"้ไฟกๆ ่ฏ", fields:[
["MID_WIFIMAC","WiFi MAC","WiFi MAC"],["MID_BTMAC","Bluetooth MAC","่็MAC"]
]},
{en:"Order", zh:"่ฎขๅไฟกๆฏ", fields:[
["MID_ORDERCODE","Order Code","่ฎขๅ็ผๅท"],["ORDERNUMBER","Order Number","่ฎขๅๅท"],["ORDERQUANTITY","Order Qty","่ฎขๅๆฐ้"],
["ASD_QTY","Qty","ๆฐ้"],["ASD_CUSTNAME","Customer Name","ๅฎขๆทๅ็งฐ"],["CUSTOMER","Customer","ๅฎขๆท"]
]},
{en:"Production", zh:"็ไบงๆต็จ", fields:[
["ASD_RECIVETIME","Received","ๆถๅๆถ้ด"],["ASD_FINISHTIME","Finished","ๅฎๅทฅๆถ้ด"],["ASD_INDATE","Inbound","ๅ
ฅๅบๆถ้ด"],
["MID_CREATETIME","Created","ๅๅปบๆถ้ด"],["ASD_DEALMAN","Handler","ๅค็ไบบ"],["ASD_SALEER","Sales","ไธๅกๅ"],
["ASD_SENDMAN","Sender","ๅ่ดงไบบ"],["ASD_CONTENT","Content","ไฝไธๅ
ๅฎน"],["ASD_ACTREMAKETIME","Actual Rework Time","ๅฎ้
่ฟๅทฅๆถ้ด"]
]},
{en:"Delivery", zh:"ๅบๅ
ฅๅบ", fields:[
["OUT_DELIVERY","Out Delivery","ๅบ่ดงๅๅท"],["IN_DELIVERY","In Delivery","ๅ
ฅๅบๅๅท"],["IN_SALES","In Sales","้ๅฎๅ
ฅๅบ"],
["OUT_SALES","Out Sales","้ๅฎๅบๅบ"],["IN_CUSTOMER","In Customer","ๅ
ฅๅบๅฎขๆท"],["OUT_CUSTOMER","Out Customer","ๅบ่ดงๅฎขๆท"],
["MID_ID","MID ID","MID ID"],["OUT_SN","Out SN","ๅบ่ดงSN"],["IN_SN","In SN","ๅ
ฅๅบSN"],
["OUT_IMEI","Out IMEI","ๅบ่ดงIMEI"],["IN_IMEI","In IMEI","ๅ
ฅๅบIMEI"]
]},
{en:"Repair (RMD)", zh:"็ปดไฟฎ่ฎฐๅฝ", fields:[
["RMD_SN","Repair SN","็ปดไฟฎSN"],["RMD_MACHINETYPE","Repair Machine Type","็ปดไฟฎๆบๅ"],["RMD_STATUS","Status","็ถๆ"],
["RMD_TYPE","Type","็ฑปๅ"],["RMD_BADTYPE","Defect Type","ไธ่ฏ็ฑปๅ"],["RMD_BADNAME","Defect Name","ไธ่ฏๅ็งฐ"],
["RMD_BADREASON","Defect Reason","ไธ่ฏๅๅ "],["RMD_BADCONFRM","Defect Confirm","ไธ่ฏ็กฎ่ฎค"],["RMD_ANAREASON","Analysis Reason","ๅๆๅๅ "],
["RMD_REPAIR","Repair","็ปดไฟฎ"],["RMD_REPAIRKIND","Repair Kind","็ปดไฟฎ็ฑปๅซ"],["RMD_DETNO","Detail No","ๆ็ปๅๅท"],
["RMD_RECIVETIME","Received","ๆถๆบๆถ้ด"],["RMD_FINISHTIME","Finished","ๅฎๆๆถ้ด"],["RMD_SALEER","Sales","ไธๅกๅ"],
["RMD_DEALMAN","Handler","ๅค็ไบบ"],["RMD_ASSISTANT","Assistant","ๅๅฉไบบ"],["RMD_QTY","Qty","ๆฐ้"],
["RMD_CUSTNAME","Customer","ๅฎขๆท"],["RMD_DAYS","Days","ๅคฉๆฐ"],["RMD_MDM","MDM","MDM"],["RMD_REMARK","Remark","ๅคๆณจ"]
]},
{en:"Other", zh:"ๅ
ถไปๅคๆณจ", fields:[
["REMARK","Remark","ๅคๆณจ"],["ASD_REMARK","Remark (ASD)","ๅคๆณจ(ASD)"],["BARCODE","Barcode","ๆก็ "],
["ASD_DETNO","Detail No (ASD)","ๆ็ปๅๅท(ASD)"],["MID_DETNO","Detail No (MID)","ๆ็ปๅๅท(MID)"],["MID_MIID","MIID","MIID"]
]}
];
/* โโโโโโโโโโโโ State โโโโโโโโโโโโ */
let LANG = localStorage.getItem('mes_lang') || 'en';
let TOKEN = localStorage.getItem('mes_token') || '';
let PROFILE = null;
try { PROFILE = JSON.parse(localStorage.getItem('mes_profile') || 'null'); } catch(e){ PROFILE = null; }
let pendingAction = null;
let currentResult = null;
let VALUES = [];
let pollTimer = null;
const $ = (id) => document.getElementById(id);
/* โโโโโโโโโโโโ Demo sample โโโโโโโโโโโโ */
const SAMPLE = {"ASD_STATUS":"CLOSE","ASD_BIOS":null,"MID_OSVERSION":"M10X_OneRuggedEEA_MT6789_PCB_V3.0_A14_LCD_hx8279_TP_GT9271_SE4710_HDMI_yongbang_20250619_093557_M01A","RMD_MACHINETYPE":null,"RMD_ANAREASON":null,"MID_ID":"","CUSTOMER":null,"RMD_REPAIR":null,"RMD_BADCONFRM":null,"MID_ORDERCODE":"XX-WK202500594-1","MID_BTMAC":"00E004740858","OUT_DELIVERY":null,"RMD_BADNAME":null,"ASD_CONFIG":"8GB+128GB+WIFI+GPS+NFC+LTE FHD ้็ฐ่ฒ (EU) Android 14(Onerugged)","ASD_QTY":"30","CAMERA":"HC-T17XB-V2.0","RMD_CUSTNAME":null,"RMD_BADREASON":null,"RMD_REMARK":null,"RMD_STATUS":null,"ASD_RECIVETIME":"2026-03-05 00:00:00.0","GENERATION":"ๅฅ็","DPI":"1920*1200","WIFI":null,"ASD_DETNO":null,"MAINBOARDVER":"M10T/MV0258CDE81D_V3.0-3","MAGNETOMETER":null,"ASD_CUSTNAME":"็ฌ็ซ็ซๆตทๅคไป้ๅค่ดง","ASD_CONTENT":"ๆน2D ๅทๅฎๅๅฎๅ14้ๆฌง็GMS/ๅ็","MID_HARDDISKMODEL":null,"ORDERNUMBER":"XX-WK202500594-1","ASD_ACTREMAKETIME":"3","RMD_DETNO":null,"MID_SN":"M1TA688A0NXA25M0356","ASD_KIND":"G+S","REMARK":null,"ASD_DEALMAN":"ๆฏๆๅ
จ/้ซๅจๅจ/ๆๅฐ้ธฟ","BRIDGEIC":null,"ORDERQUANTITY":"500","GYROSCOPE":null,"RMD_RECIVETIME":null,"MODEL":"M10T","RMD_FINISHTIME":null,"ASD_OS":"\\\\192.168.0.74ไบฟ้ไฟกๆฏReleaseMTKM10Tๅ็ๅคฉๅฅ่พพไธปๆฟAndroid14_NOEEAHDMIM10X_OneRuggedNOEEA_MT6789_PCB_V3.0_A14_LCD_hx8279_TP_GT9271_SE4710_HDMI_yongbang_20250624_153430_M01A(user)","LIGHTSENSOR":null,"ACCELEROMETER":null,"IN_DELIVERY":null,"IN_SALES":null,"TP":"10.1ๅฏธTP_M10J","IN_CUSTOMER":null,"MCU":null,"MID_HARDDISKSN":null,"RMD_SALEER":null,"RMD_BADTYPE":null,"MID_DRIVERVERSION":null,"BARCODE":null,"CPU":null,"NFC":"ๅฅ็","GPS":"ๅฅ็","FINGERPRINT":null,"OSTYPE":"Android14","ASD_FINISHTIME":"2026-03-08 00:00:00.0","OUT_IMEI":null,"RMD_TYPE":null,"IN_SN":null,"MID_EC":null,"OUT_SALES":null,"MID_MIID":null,"MID_WIFIMAC":"00E0047404BE","ASD_SENDMAN":"ไน","OUT_SN":null,"RMD_DAYS":null,"LCD":"3AMM101PP05-X0","ASD_IMEI":"861143061995615|861143061990616","IDENTITYMODULE":null,"ASD_SALEER":"ๆจๅฐๆด","ROM":"128GB","RMD_REPAIRKIND":null,"MID_IMEI":"861143061990616","MID_PROCESSID":null,"RMD_SN":null,"IN_IMEI":null,"SUBBOARDVER":null,"OUT_CUSTOMER":null,"RMD_DEALMAN":null,"MACHINECODE":"03.DMH.M10T881001A","ASD_MACHINETYPE":"M10T","RMD_QTY":null,"RMD_MDM":null,"RMD_ASSISTANT":null,"MID_BIOSVERSION":null,"MID_OSPRODUCTID":null,"ASD_INDATE":"2026-04-20 10:30:53.0","MID_OSPRODUCTKEY":null,"MID_DETNO":null,"ASD_SN":"M1TA688A0NXA25M0356","MID_CREATETIME":"2026-05-08 11:28:42.0","BAT":"489569_1S2P_3.8V_10000mAh","ASD_REMARK":null,"RAM":"8GB"};
/* โโโโโโโโโโโโ Helpers โโโโโโโโโโโโ */
function t(k){ return (I18N[LANG] && I18N[LANG][k]) || I18N.en[k] || k; }
function esc(v){ return String(v).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); }
function hasVal(v){ return !(v===null || v===undefined || v==='' || v==='null' || v==='None'); }
function fmt(v){
if(typeof v === 'string'){
const m = v.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2}:\d{2})(?:\.\d+)?$/);
if(m) return m[2] === '00:00:00' ? m[1] : m[1] + ' ' + m[2];
}
return v;
}
function labelOf(en, zh){ return LANG === 'zh' ? zh : en; }
/* โโโโโโโโโโโโ i18n apply โโโโโโโโโโโโ */
function applyI18n(){
document.documentElement.lang = LANG === 'zh' ? 'zh-CN' : 'en';
document.title = t('title');
$('appTitle').textContent = t('title');
$('appSub').textContent = t('sub');
$('navAdmin').textContent = t('navAdmin');
$('langToggle').textContent = LANG === 'zh' ? 'English' : 'ไธญๆ';
$('gateTitle').textContent = t('gateTitle');
$('gateDesc').textContent = t('gateDesc');
$('codeInput').placeholder = t('codePh');
$('accessBtn').textContent = t('verifyBtn');
$('snInput').placeholder = t('snPh');
$('queryBtn').textContent = t('queryBtn');
$('fieldSearch').placeholder = t('searchPh');
$('showEmptyLabel').textContent = t('showEmpty');
$('copyJsonBtn').textContent = t('copyJson');
$('downloadJsonBtn').textContent = t('downloadJson');
$('relockBtn').textContent = t('relock');
$('cachedBadge').textContent = t('cached');
$('rawSummary').textContent = t('rawJson');
$('megTitle').textContent = t('megTitle');
$('megHint').textContent = t('megHint');
$('megBtn').textContent = t('megSearchBtn');
$('megInput').placeholder = t('megSearchPh');
$('mapTitle').textContent = t('mapTitle');
$('mapHint').textContent = t('mapHint');
$('reportBtn').textContent = t('reportBtn');
$('repTitle').textContent = t('repTitle');
$('repTypeLabel').textContent = t('repTypeLabel');
$('repFieldLabel').textContent = t('repFieldLabel');
$('repOsLabel').textContent = t('repOsLabel');
$('repDescLabel').textContent = t('repDescLabel');
$('repDesc').placeholder = t('repDescPh');
$('repCancel').textContent = t('repCancel');
$('repSubmit').textContent = t('repSubmit');
$('repType').innerHTML = REPORT_TYPES.map(([v,en,zh]) =>
'<option value="' + v + '">' + esc(labelOf(en, zh)) + '</option>').join('');
}
function toggleLang(){
LANG = LANG === 'en' ? 'zh' : 'en';
localStorage.setItem('mes_lang', LANG);
applyI18n();
if(currentResult) renderResult(currentResult);
}
/* โโโโโโโโโโโโ Theme โโโโโโโโโโโโ */
function initTheme(){
const saved = localStorage.getItem('drivers_theme');
if(saved === 'warm'){ document.documentElement.setAttribute('data-theme','warm'); $('themeToggle').textContent = 'โ๏ธ'; }
}
function toggleTheme(){
const warm = document.documentElement.getAttribute('data-theme') === 'warm';
document.documentElement.setAttribute('data-theme', warm ? 'cool' : 'warm');
localStorage.setItem('drivers_theme', warm ? 'cool' : 'warm');
$('themeToggle').textContent = warm ? 'โ๏ธ' : 'โ๏ธ';
}
/* โโโโโโโโโโโโ Toast โโโโโโโโโโโโ */
let toastTimer = null;
function toast(msg, isErr){
const el = $('toast');
el.textContent = msg;
el.classList.toggle('err', !!isErr);
el.classList.add('show');
clearTimeout(toastTimer);
toastTimer = setTimeout(() => el.classList.remove('show'), 1600);
}
/* โโโโโโโโโโโโ Access gate โโโโโโโโโโโโ */
function showGate(){
$('gate').classList.remove('hidden');
$('queryCard').classList.add('hidden');
$('results').classList.add('hidden');
}
function hideGate(){
$('gate').classList.add('hidden');
$('queryCard').classList.remove('hidden');
}
function relock(){
TOKEN = '';
PROFILE = null;
localStorage.removeItem('mes_token');
localStorage.removeItem('mes_profile');
clearInterval(pollTimer);
hideProgress();
$('results').classList.add('hidden');
$('gateError').classList.add('hidden');
showGate();
}
async function verifyCode(){
const code = $('codeInput').value.trim();
const errEl = $('gateError');
errEl.classList.add('hidden');
if(!code){ errEl.textContent = t('accessError'); errEl.classList.remove('hidden'); return; }
$('accessBtn').disabled = true;
try{
const r = await fetch('/api/drivers/mes-access', {
method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({code})
});
if(r.ok){
const d = await r.json();
TOKEN = d.token; localStorage.setItem('mes_token', TOKEN);
PROFILE = d.profile || null;
localStorage.setItem('mes_profile', JSON.stringify(PROFILE));
$('codeInput').value = '';
hideGate();
const act = pendingAction;
pendingAction = null;
if(act) act();
} else if(r.status === 403){
errEl.textContent = t('accessError'); errEl.classList.remove('hidden');
} else {
errEl.textContent = t('serverError'); errEl.classList.remove('hidden');
}
}catch(e){
errEl.textContent = t('networkError'); errEl.classList.remove('hidden');
}finally{
$('accessBtn').disabled = false;
}
}
/* โโโโโโโโโโโโ Query โโโโโโโโโโโโ */
async function apiFetch(path, opts){
opts = opts || {};
opts.headers = Object.assign({'Content-Type':'application/json','Authorization':'Bearer ' + TOKEN}, opts.headers || {});
const ctrl = new AbortController();
const timeoutMs = opts.timeoutMs || 30000;
delete opts.timeoutMs;
const to = setTimeout(() => ctrl.abort(), timeoutMs);
try{
return await fetch(path, Object.assign({signal:ctrl.signal}, opts));
} finally { clearTimeout(to); }
}
function showProgress(pct, msg){
$('progressWrap').classList.remove('hidden');
$('progressFill').style.width = (pct||0) + '%';
$('progressMsg').textContent = msg || '';
}
function hideProgress(){ $('progressWrap').classList.add('hidden'); }
function showQueryError(msg){
hideProgress();
const el = $('queryError');
el.textContent = msg;
el.classList.remove('hidden');
}
async function doQuery(){
const sn = $('snInput').value.trim();
if(!sn) return;
$('queryError').classList.add('hidden');
$('results').classList.add('hidden');
$('queryBtn').disabled = true;
showProgress(0, t('queueing'));
try{
const r = await apiFetch('/api/drivers/mes-query', {method:'POST', body:JSON.stringify({sn})});
if(r.status === 401){ $('queryBtn').disabled = false; pendingAction = doQuery; relock(); return; }
if(!r.ok){ showQueryError(t('serverError')); return; }
const d = await r.json();
poll(d.task_id);
}catch(e){
showQueryError(t('networkError'));
}finally{
$('queryBtn').disabled = false;
}
}
function poll(taskId){
let tries = 0;
clearInterval(pollTimer);
pollTimer = setInterval(async () => {
tries++;
if(tries > 90){ clearInterval(pollTimer); showQueryError(t('serverError')); return; }
try{
const r = await apiFetch('/api/drivers/mes-query/status/' + taskId);
if(r.status === 401){ clearInterval(pollTimer); pendingAction = doQuery; relock(); return; }
if(!r.ok){ return; }
const d = await r.json();
showProgress(d.progress, d.message);
if(d.status === 'done'){
clearInterval(pollTimer); hideProgress();
renderResult(d.result || {sn:'', data:{}, cached:false});
} else if(d.status === 'error'){
clearInterval(pollTimer); showQueryError(d.error || t('serverError'));
}
}catch(e){ /* transient, keep polling */ }
}, 700);
}
/* โโโโโโโโโโโโ Render โโโโโโโโโโโโ */
function rowHTML(label, key, val){
const idx = VALUES.length;
VALUES.push(hasVal(val) ? String(val) : '');
const ok = hasVal(val);
const disp = ok ? esc(String(fmt(val))) : 'โ';
const search = esc((label + ' ' + key + ' ' + (ok ? String(val) : '')).toLowerCase());
return '<div class="frow" data-idx="' + idx + '" data-search="' + search + '" data-empty="' + (ok ? 0 : 1) + '">' +
'<span class="flabel">' + esc(label) + '</span>' +
'<span class="fval' + (ok ? '' : ' muted') + '" data-idx="' + idx + '">' + disp + '</span></div>';
}
function sectionHTML(title, rows, extraClass){
return '<section class="card sect ' + (extraClass || '') + '"><h3 class="sect-title">' + esc(title) + '</h3>' +
'<div class="frows">' + rows + '</div></section>';
}
function renderResult(res){
currentResult = res;
const data = (res && res.data) || {};
VALUES = [];
const known = new Set();
GROUPS.forEach(g => g.fields.forEach(f => known.add(f[0])));
MORE_GROUPS.forEach(g => g.fields.forEach(f => known.add(f[0])));
// ๅ้่ฎฟ้ฎ็ ๏ผๆๅก็ซฏๅทฒๅ้คไธๅฏ่งๅญๆฎต๏ผ่ฟ้ๅๆญฅ่ทณ่ฟ็ฉบๅ็ป๏ผ้ฟๅ
ๆด้ฒๅญๆฎตๅ
const restricted = !!(PROFILE && !PROFILE.is_admin);
const keep = f => !restricted || Object.prototype.hasOwnProperty.call(data, f[0]);
let html = '';
GROUPS.forEach((g, i) => {
const fields = g.fields.filter(keep);
if(!fields.length) return;
const rows = fields.map(([k,en,zh]) => rowHTML(labelOf(en,zh), k, data[k])).join('');
const cls = (i === 0 ? 'summary ' : '') + (g.wide ? 'wide' : '');
html += sectionHTML(labelOf(g.en, g.zh), rows, cls);
});
let more = '';
MORE_GROUPS.forEach(g => {
const fields = g.fields.filter(keep);
if(!fields.length) return;
const sec = sectionHTML(labelOf(g.en, g.zh), fields.map(([k,en,zh]) => rowHTML(labelOf(en,zh), k, data[k])).join(''));
if(restricted) html += sec; else more += sec;
});
const extras = Object.keys(data).filter(k => !known.has(k));
if(extras.length){
const sec = sectionHTML(labelOf("Additional", "ๅ
ถไปๅญๆฎต"), extras.map(k => rowHTML(k, k, data[k])).join(''));
if(restricted) html += sec; else more += sec;
}
if(more){
html += '<details class="card sect more"><summary class="sect-title">' +
esc(labelOf("Other Fields", "ๅ
ถไปๅญๆฎต")) + '</summary><div class="more-body">' + more + '</div></details>';
}
$('sections').innerHTML = html;
$('megInput').value = '';
$('megResults').innerHTML = '';
renderMegaCandidates(data);
renderMapping();
$('rawPre').textContent = JSON.stringify(data, null, 2);
$('snBadge').textContent = res.sn || '';
$('snBadge').classList.toggle('hidden', !res.sn);
$('cachedBadge').classList.toggle('hidden', !res.cached);
$('results').classList.remove('hidden');
$('results').querySelectorAll('.fval').forEach(el => el.addEventListener('click', onValueClick));
applyFilter();
}
function onValueClick(e){
const idx = e.currentTarget.getAttribute('data-idx');
const val = VALUES[Number(idx)];
if(!val) return;
copyText(val);
}
function applyFilter(){
const q = $('fieldSearch').value.trim().toLowerCase();
const showEmpty = $('emptyToggle').checked;
document.querySelectorAll('#sections .sect').forEach(sec => {
let visible = 0;
sec.querySelectorAll('.frow').forEach(r => {
const okQ = !q || (r.getAttribute('data-search') || '').indexOf(q) !== -1;
const okE = showEmpty || r.getAttribute('data-empty') === '0';
const show = okQ && okE;
r.style.display = show ? '' : 'none';
if(show) visible++;
});
sec.style.display = visible ? '' : 'none';
});
}
/* โโโโโโโโโโโโ Copy / Download โโโโโโโโโโโโ */
function copyText(text){
const done = () => toast(t('copied'));
const fail = () => toast(t('copyFail'), true);
if(navigator.clipboard && navigator.clipboard.writeText){
navigator.clipboard.writeText(text).then(done).catch(() => { fallbackCopy(text, done, fail); });
} else { fallbackCopy(text, done, fail); }
}
function fallbackCopy(text, done, fail){
try{
const ta = document.createElement('textarea');
ta.value = text; ta.style.position = 'fixed'; ta.style.opacity = '0';
document.body.appendChild(ta); ta.select();
document.execCommand('copy'); document.body.removeChild(ta);
done();
}catch(e){ fail(); }
}
function copyJson(){
const data = currentResult ? currentResult.data : null;
if(!data){ return; }
copyText(JSON.stringify(data, null, 2));
}
function downloadJson(){
const data = currentResult ? currentResult.data : null;
if(!data){ return; }
const sn = (currentResult && currentResult.sn) || 'mes';
const blob = new Blob([JSON.stringify(data, null, 2)], {type:'application/json'});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url; a.download = sn + '.json';
document.body.appendChild(a); a.click(); document.body.removeChild(a);
URL.revokeObjectURL(url);
}
/* โโโโโโโโโโโโ MEGA manual search โโโโโโโโโโโโ */
function extractOsCandidates(data){
const out = [];
const seen = new Set();
const add = (tag, val) => {
val = (val || '').trim();
if(!val || seen.has(val)) return;
seen.add(val);
out.push({tag: tag, value: val});
};
const scan = (str) => {
if(typeof str !== 'string') return;
const scd = str.match(/SCD_\d{8}_[\w.\-]+/g) || [];
const rcd = str.match(/RCD_\d{8}_[\w.\-]+/g) || [];
scd.forEach(v => add('SCD', v));
rcd.forEach(v => add('RCD', v));
};
scan(data.ASD_OS);
scan(data.MID_OSVERSION);
if(!out.length){
[['ASD_OS','ASD'], ['MID_OSVERSION','MID']].forEach(([key, tag]) => {
const v = data[key];
if(typeof v === 'string' && v.trim()){
add(tag, v.replace(/^.*[\\/]/, ''));
}
});
}
return out;
}
function renderMegaCandidates(data){
const box = $('megChips');
box.innerHTML = '';
const cands = extractOsCandidates(data || {});
if(!cands.length){
const none = document.createElement('span');
none.className = 'mega-none';
none.textContent = t('megNoCand');
box.appendChild(none);
return;
}
cands.forEach(c => {
const btn = document.createElement('button');
btn.type = 'button';
btn.className = 'chip';
btn.title = c.value;
const k = document.createElement('span');
k.className = 'chip-k';
k.textContent = c.tag;
btn.appendChild(k);
btn.appendChild(document.createTextNode(c.value));
btn.addEventListener('click', () => { $('megInput').value = c.value; doMegaSearch(); });
box.appendChild(btn);
});
}
function fmtSize(n){
n = Number(n) || 0;
if(n <= 0) return '';
const units = ['B','KB','MB','GB','TB'];
let i = 0, x = n;
while(x >= 1024 && i < units.length - 1){ x /= 1024; i++; }
return (i === 0 ? String(x) : x.toFixed(1)) + ' ' + units[i];
}
function renderMegaResults(items){
const box = $('megResults');
box.innerHTML = '';
if(!items.length){
const none = document.createElement('div');
none.className = 'mega-none';
none.textContent = t('megNoResult');
box.appendChild(none);
return;
}
const head = document.createElement('div');
head.className = 'mega-none';
head.textContent = t('megResultCount').replace('{n}', items.length);
box.appendChild(head);
items.forEach(it => {
const row = document.createElement('div');
row.className = 'mega-item';
const nameEl = document.createElement('div');
nameEl.className = 'mega-name';
nameEl.textContent = it.name || '';
const size = fmtSize(it.size);
if(size){
const s = document.createElement('div');
s.className = 'mega-size';
s.textContent = size;
nameEl.appendChild(s);
}
row.appendChild(nameEl);
const act = document.createElement('div');
act.className = 'mega-act';
if(it.link){
const a = document.createElement('a');
a.className = 'btn-ghost';
a.href = it.link;
a.target = '_blank';
a.rel = 'noopener';
a.textContent = t('megDownload');
const c = document.createElement('button');
c.type = 'button';
c.className = 'btn-ghost';
c.textContent = t('megCopy');
c.addEventListener('click', () => copyText(it.link));
act.appendChild(a);
act.appendChild(c);
} else {
const s = document.createElement('span');
s.className = 'mega-size';
s.textContent = t('megLinkFail');
act.appendChild(s);
}
row.appendChild(act);
box.appendChild(row);
});
}
async function doMegaSearch(){
const q = $('megInput').value.trim();
const box = $('megResults');
if(!q) return;
box.innerHTML = '';
const loading = document.createElement('div');
loading.className = 'mega-none';
loading.textContent = t('megSearching');
box.appendChild(loading);
$('megBtn').disabled = true;
const slowTimer = setTimeout(() => { loading.textContent = t('megRefreshing'); }, 4000);
try{
const r = await apiFetch('/api/drivers/mes-mega-search', {
method:'POST', body:JSON.stringify({query:q, limit:10}), timeoutMs:180000
});
if(r.status === 401){ $('megBtn').disabled = false; pendingAction = doMegaSearch; relock(); return; }
if(!r.ok){
box.innerHTML = '';
const err = document.createElement('div');
err.className = 'mega-none';
err.textContent = t('serverError');
box.appendChild(err);
return;
}
const d = await r.json();
renderMegaResults(d.items || []);
if(d.refreshed){
const note = document.createElement('div');
note.className = 'mega-none';
note.textContent = t('megIndexRefreshed');
box.appendChild(note);
}
}catch(e){
box.innerHTML = '';
const err = document.createElement('div');
err.className = 'mega-none';
err.textContent = t('networkError');
box.appendChild(err);
}finally{
clearTimeout(slowTimer);
$('megBtn').disabled = false;
}
}
/* โโโโโโโโโโโโ OS name mapping โโโโโโโโโโโโ */
const MAP_CACHE = {};
async function fetchOsMap(osVersion){
if(!osVersion) return null;
if(Object.prototype.hasOwnProperty.call(MAP_CACHE, osVersion)) return MAP_CACHE[osVersion];
try{
const r = await fetch('/api/drivers/os-file-maps/lookup?os_version=' + encodeURIComponent(osVersion));
if(!r.ok){ MAP_CACHE[osVersion] = null; return null; }
const d = await r.json();
MAP_CACHE[osVersion] = d.map || null;
return MAP_CACHE[osVersion];
}catch(e){ return null; }
}
function currentOsNames(){
const d = (currentResult && currentResult.data) || {};
return [d.MID_OSVERSION, d.ASD_OS].filter(v => typeof v === 'string' && v.trim());
}
async function renderMapping(){
const list = $('mapList');
if(!list) return;
const names = currentOsNames();
list.innerHTML = '<div class="map-none">' + esc(t('mapNone')) + '</div>';
if(!names.length) return;
const maps = await Promise.all(names.map(fetchOsMap));
if(!currentResult) return;
const files = [];
maps.forEach(m => {
if(m && Array.isArray(m.files)){
m.files.forEach(f => { if(f && files.indexOf(f) === -1) files.push(f); });
}
});
if(!files.length) return;
list.innerHTML = files.map(f =>
'<div class="map-item"><span class="chip-k">' + esc(t('mapMapped')) + '</span>' +
'<span class="mega-name">' + esc(f) + '</span>' +
'<span class="mega-act">' +
'<button class="btn-ghost" data-file="' + esc(f) + '" onclick="searchMapped(this)">' + esc(t('megSearchBtn')) + '</button>' +
'<button class="btn-ghost" data-file="' + esc(f) + '" onclick="copyMapped(this)">' + esc(t('megCopy')) + '</button>' +
'</span></div>'
).join('');
}
function searchMapped(el){
$('megInput').value = el.getAttribute('data-file') || '';
doMegaSearch();
}
function copyMapped(el){
copyText(el.getAttribute('data-file') || '');
}
/* โโโโโโโโโโโโ Problem report โโโโโโโโโโโโ */
const REPORT_TYPES = [
["missing_mapping","Missing mapping","็ผบๅฐๆ ๅฐ"],
["file_not_on_mega","File not on MEGA","ๆไปถๆชไธไผ MEGA"],
["no_match","No MEGA match","MEGA ๆชๅน้
ๅฐ"],
["parse_error","Parse error","่งฃๆ้่ฏฏ"],
["wrong_link","Wrong link","้พๆฅ้่ฏฏ"],
["wrong_file","Wrong file","ๆไปถ้่ฏฏ"],
["suggestion","Suggestion","ๆน่ฟๅปบ่ฎฎ"],
["other","Other","ๅ
ถไป"]
];
const REPORT_FIELDS = [
["MID_OSVERSION","Neutral OS version","ไธญๆง็ณป็ป็ๆฌ"],
["ASD_OS","Custom OS version","ๅฎขๅถ็ณป็ป็ๆฌ"],
["MID_BIOSVERSION","Neutral BIOS","ไธญๆง BIOS"],
["ASD_BIOS","Custom BIOS","ๅฎขๅถ BIOS"],
["MID_EC","Neutral EC","ไธญๆง EC"],
["ASD_EC","Custom EC","ๅฎขๅถ EC"],
["OSTYPE","OS type","็ณป็ป็ฑปๅ"],
["MODEL","Model","ๆบๅ"],
["MACHINECODE","Machine code","ๆบๅจ็ผ็ "],
["ASD_SN","Serial number","ๅบๅๅท"]
];
function reportData(){
return (currentResult && currentResult.data) || {};
}
function onReportFieldChange(){
const d = reportData();
const k = $('repField').value;
$('repOs').value = k && hasVal(d[k]) ? String(d[k]) : '';
}
function pickDefaultReportField(){
const d = reportData();
const type = $('repType').value;
const prefer = type === 'missing_mapping'
? ['MID_OSVERSION','ASD_OS']
: ['MID_BIOSVERSION','ASD_BIOS','MID_EC','ASD_EC','MID_OSVERSION','ASD_OS'];
const opts = Array.from($('repField').options).map(o => o.value);
const pick = prefer.find(k => opts.includes(k) && hasVal(d[k]))
|| prefer.find(k => opts.includes(k))
|| opts[0] || '';
if(pick) $('repField').value = pick;
onReportFieldChange();
}
function onReportTypeChange(){
pickDefaultReportField();
}
function openReport(){
const d = reportData();
const avail = REPORT_FIELDS.filter(([k]) => hasVal(d[k]));
const list = avail.length ? avail : REPORT_FIELDS;
$('repField').innerHTML = list.map(([k,en,zh]) =>
'<option value="' + k + '">' + esc(labelOf(en, zh)) + ' (' + esc(k) + ')</option>').join('');
$('repType').value = 'missing_mapping';
$('repDesc').value = '';
$('reportModal').classList.remove('hidden');
pickDefaultReportField();
}
function closeReport(){
$('reportModal').classList.add('hidden');
}
async function submitReport(){
const d = (currentResult && currentResult.data) || {};
const btn = $('repSubmit');
btn.disabled = true;
try{
const r = await fetch('/api/drivers/reports', {
method:'POST',
headers:{'Content-Type':'application/json'},
body: JSON.stringify({
sn: (currentResult && currentResult.sn) || '',
problem_type: $('repType').value,
os_type: d.OSTYPE || '',
field_name: $('repField').value,
os_version: $('repOs').value.trim(),
matched_filenames: '',
description: $('repDesc').value.trim()
})
});
const j = await r.json().catch(() => ({}));
if(!r.ok || j.error){ toast(j.error || t('repFail'), true); return; }
closeReport();
toast(t('repOk'));
}catch(e){
toast(t('repFail'), true);
}finally{
btn.disabled = false;
}
}
/* โโโโโโโโโโโโ Boot โโโโโโโโโโโโ */
async function verifyToken(){
const probe = TOKEN;
if(!probe) return;
try{
const r = await apiFetch('/api/drivers/mes-me');
if(r.status === 401){
if(TOKEN === probe) relock();
return;
}
if(r.ok){
const d = await r.json();
PROFILE = d.profile || null;
localStorage.setItem('mes_profile', JSON.stringify(PROFILE));
if(currentResult) renderResult(currentResult);
}
}catch(e){ /* keep the cached token when the network is down */ }
}
function boot(){
initTheme();
applyI18n();
$('themeToggle').addEventListener('click', toggleTheme);
$('snInput').addEventListener('keydown', e => { if(e.key === 'Enter') doQuery(); });
$('codeInput').addEventListener('keydown', e => { if(e.key === 'Enter') verifyCode(); });
$('megInput').addEventListener('keydown', e => { if(e.key === 'Enter') doMegaSearch(); });
$('reportModal').addEventListener('click', e => { if(e.target.id === 'reportModal') closeReport(); });
if(/[?&]demo=1/.test(location.search)){
hideGate();
$('snInput').value = 'M1TA688A0NXA25M0356';
renderResult({sn:'M1TA688A0NXA25M0356', data:SAMPLE, cached:false, code:'0', message:'success'});
return;
}
if(TOKEN){ hideGate(); verifyToken(); } else { showGate(); }
}
boot();
</script>
</body>
</html>
<html lang="en" data-theme="cool">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>MES Info Query</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext y='.9em' font-size='90'%3E%F0%9F%93%A6%3C/text%3E%3C/svg%3E">
<style>
/* โโโโโโโโโโโโ Design System โโโโโโโโโโโโ */
:root {
--bg-page:#f0f4f8; --bg-card:#fff; --bg-subtle:#f8fafc;
--text-primary:#0f172a; --text-secondary:#475569; --text-muted:#94a3b8;
--border-light:#e2e8f0; --border-subtle:#f1f5f9;
--shadow-card:0 1px 3px rgba(0,0,0,.04),0 1px 2px rgba(0,0,0,.06);
--shadow-hover:0 10px 30px -5px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05);
--header-start:#0b1426; --header-mid:#14203a; --header-end:#0b1426;
--header-text:#f1f5f9; --header-sub:#64748b;
--glow-1:rgba(59,130,246,.08); --glow-2:rgba(139,92,246,.08);
--accent:#3b82f6; --accent-strong:#2563eb;
--chip-bg:#eff6ff; --chip-text:#1d4ed8;
--muted-bg:#f1f5f9;
--ok:#16a34a; --err:#dc2626;
--bg-pattern:rgba(59,130,246,.015);
}
[data-theme="warm"] {
--bg-page:#fef7ee; --bg-card:#fff; --bg-subtle:#fffbeb;
--text-primary:#1c1917; --text-secondary:#57534e; --text-muted:#a8a29e;
--border-light:#e7e5e4; --border-subtle:#f5f5f4;
--shadow-card:0 1px 3px rgba(120,80,40,.04),0 1px 2px rgba(120,80,40,.06);
--shadow-hover:0 10px 30px -5px rgba(120,80,40,.1),0 4px 6px -2px rgba(120,80,40,.05);
--header-start:#1c130d; --header-mid:#2d1f14; --header-end:#1c130d;
--header-text:#fefce8; --header-sub:#a8a29e;
--glow-1:rgba(245,158,11,.07); --glow-2:rgba(239,68,68,.06);
--accent:#d97706; --accent-strong:#b45309;
--chip-bg:#fef3c7; --chip-text:#92400e;
--muted-bg:#fef3c7;
--ok:#15803d; --err:#dc2626;
--bg-pattern:rgba(245,158,11,.015);
}
*{margin:0;padding:0;box-sizing:border-box}
body{
font-family:"PingFang SC","Microsoft YaHei","Noto Sans SC","Helvetica Neue",Arial,sans-serif;
background:var(--bg-page);color:var(--text-primary);min-height:100vh;
transition:background .4s ease,color .3s ease;
}
body::before{
content:'';position:fixed;inset:0;z-index:-1;
background-image:linear-gradient(var(--bg-pattern) 1px,transparent 1px),
linear-gradient(90deg,var(--bg-pattern) 1px,transparent 1px);
background-size:60px 60px;
}
.hidden{display:none!important}
a{color:inherit}
/* โโ Theme toggle โโ */
.theme-toggle{
position:fixed;top:18px;right:18px;z-index:100;width:42px;height:42px;border-radius:50%;
border:2px solid var(--border-light);background:var(--bg-card);cursor:pointer;font-size:19px;
display:flex;align-items:center;justify-content:center;transition:all .3s cubic-bezier(.4,0,.2,1);
box-shadow:0 2px 12px rgba(0,0,0,.08);
}
.theme-toggle:hover{transform:scale(1.1);box-shadow:0 4px 20px rgba(0,0,0,.12)}
/* โโ Header โโ */
.header{
background:linear-gradient(135deg,var(--header-start) 0%,var(--header-mid) 50%,var(--header-end) 100%);
color:var(--header-text);padding:30px 0 26px;position:relative;overflow:hidden;
transition:background .4s ease;
}
.header::before{
content:'';position:absolute;top:-50%;left:-50%;width:200%;height:200%;
background:radial-gradient(ellipse at 30% 50%,var(--glow-1) 0%,transparent 60%),
radial-gradient(ellipse at 70% 50%,var(--glow-2) 0%,transparent 60%);
}
.header-inner{
position:relative;max-width:1100px;margin:0 auto;padding:0 24px;
display:flex;align-items:center;justify-content:space-between;gap:20px;flex-wrap:wrap;
}
.brand h1{font-size:26px;font-weight:700;letter-spacing:.5px}
.brand .sub{color:var(--header-sub);font-size:13px;margin-top:6px}
.top-nav{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.top-nav a,.lang-btn{
font-size:13px;color:var(--header-text);text-decoration:none;padding:8px 14px;border-radius:8px;
background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.14);
transition:background .2s;cursor:pointer;font-family:inherit;
}
.top-nav a:hover,.lang-btn:hover{background:rgba(255,255,255,.18)}
.lang-btn{font-weight:600;min-width:64px}
/* โโ Layout โโ */
.wrap{max-width:1100px;margin:0 auto;padding:28px 24px 60px}
.card{
background:var(--bg-card);border:1px solid var(--border-light);border-radius:14px;
box-shadow:var(--shadow-card);padding:22px;
}
/* โโ Gate โโ */
.gate{max-width:440px;margin:40px auto;text-align:center}
.gate h2{font-size:20px;margin-bottom:10px}
.gate p{color:var(--text-secondary);font-size:13px;line-height:1.6;margin-bottom:18px}