сделал настройки универсальными: кассеты и порты можно менять
This commit is contained in:
parent
098029c178
commit
da148f2af9
71
index.html
71
index.html
@ -9,11 +9,17 @@
|
||||
body{font:17px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,sans-serif;background:#f0f2f5;color:#0F1218;min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:24px}
|
||||
.card{background:#fff;border-radius:20px;padding:48px;max-width:520px;width:100%;box-shadow:0 4px 24px rgba(0,0,0,.06)}
|
||||
h1{font-size:28px;font-weight:800;margin-bottom:8px}
|
||||
.sub{color:#5B6573;font-size:15px;margin-bottom:32px}
|
||||
label{display:block;font-weight:600;font-size:15px;margin-bottom:8px}
|
||||
input[type=number]{width:100%;padding:16px 20px;font-size:24px;font-weight:700;border:2px solid #d0d5dd;border-radius:12px;outline:none;transition:.15s;text-align:center}
|
||||
input:focus{border-color:#0F1218}
|
||||
input::placeholder{font-weight:400;color:#9aa3b2;font-size:17px}
|
||||
.sub{color:#5B6573;font-size:15px;margin-bottom:24px}
|
||||
.settings{background:#f6f8fa;border-radius:12px;padding:20px;margin-bottom:24px}
|
||||
.settings-row{display:flex;gap:12px;margin-bottom:12px}
|
||||
.settings-row:last-child{margin-bottom:0}
|
||||
.settings-row label{flex:1;font-size:14px;font-weight:600;color:#5B6573}
|
||||
.settings-row input{width:100%;padding:10px 14px;font-size:16px;font-weight:600;border:2px solid #d0d5dd;border-radius:8px;outline:none;text-align:center;transition:.15s}
|
||||
.settings-row input:focus{border-color:#0F1218}
|
||||
label[for=port]{display:block;font-weight:600;font-size:15px;margin-bottom:8px}
|
||||
input#port{width:100%;padding:16px 20px;font-size:24px;font-weight:700;border:2px solid #d0d5dd;border-radius:12px;outline:none;transition:.15s;text-align:center}
|
||||
input#port:focus{border-color:#0F1218}
|
||||
input#port::placeholder{font-weight:400;color:#9aa3b2;font-size:17px}
|
||||
button{width:100%;padding:16px;background:#0F1218;color:#fff;border:none;border-radius:12px;font-size:18px;font-weight:700;cursor:pointer;margin-top:16px;transition:.15s}
|
||||
button:hover{background:#2a2f3a}
|
||||
button:active{transform:scale(.98)}
|
||||
@ -33,16 +39,23 @@ button:active{transform:scale(.98)}
|
||||
.history-item .h-result{color:#0088cc;font-weight:600}
|
||||
.history-item .h-copy{color:#9aa3b2;font-size:13px;cursor:pointer;padding:4px 8px;border-radius:4px}
|
||||
.history-item .h-copy:hover{background:#d0d5dd;color:#0F1218}
|
||||
@media(max-width:480px){.card{padding:24px}h1{font-size:24px}input[type=number]{font-size:20px}}
|
||||
@media(max-width:480px){.card{padding:24px}.settings-row{flex-direction:column;gap:8px}h1{font-size:24px}input#port{font-size:20px}}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="card">
|
||||
<h1>🔢 Кассеты и порты</h1>
|
||||
<p class="sub">84 кассеты × 16 портов = 1–1344</p>
|
||||
<p class="sub" id="subtitle">84 кассеты × 16 портов = 1–1344</p>
|
||||
|
||||
<div class="settings">
|
||||
<div class="settings-row">
|
||||
<label>Кассет <input type="number" id="cassettes" min="1" max="999" onchange="applySettings()"></label>
|
||||
<label>Портов на кассете <input type="number" id="perPort" min="1" max="999" onchange="applySettings()"></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label for="port">Введи номер порта</label>
|
||||
<input type="number" id="port" min="1" max="1344" placeholder="например, 699" autofocus>
|
||||
<input type="number" id="port" min="1" placeholder="например, 699" autofocus>
|
||||
<div class="error" id="error">Введи число от 1 до 1344</div>
|
||||
<button onclick="calc()">Рассчитать</button>
|
||||
|
||||
@ -58,13 +71,41 @@ button:active{transform:scale(.98)}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const PORTS_PER_CASSETTE = 16;
|
||||
const TOTAL_CASSETTES = 84;
|
||||
const TOTAL_PORTS = TOTAL_CASSETTES * PORTS_PER_CASSETTE;
|
||||
const MAX_HISTORY = 50;
|
||||
|
||||
let PORTS_PER_CASSETTE = 16;
|
||||
let TOTAL_CASSETTES = 84;
|
||||
let TOTAL_PORTS = TOTAL_CASSETTES * PORTS_PER_CASSETTE;
|
||||
let history = JSON.parse(localStorage.getItem('portHistory')||'[]');
|
||||
|
||||
function loadSettings(){
|
||||
const c=localStorage.getItem('pcCassettes');
|
||||
const p=localStorage.getItem('pcPerPort');
|
||||
if(c)document.getElementById('cassettes').value=TOTAL_CASSETTES=parseInt(c);
|
||||
if(p)document.getElementById('perPort').value=PORTS_PER_CASSETTE=parseInt(p);
|
||||
TOTAL_PORTS=TOTAL_CASSETTES*PORTS_PER_CASSETTE;
|
||||
}
|
||||
function saveSettings(){
|
||||
localStorage.setItem('pcCassettes',TOTAL_CASSETTES);
|
||||
localStorage.setItem('pcPerPort',PORTS_PER_CASSETTE);
|
||||
}
|
||||
function updateUI(){
|
||||
document.getElementById('port').max=TOTAL_PORTS;
|
||||
document.getElementById('port').placeholder=`1–${TOTAL_PORTS}`;
|
||||
document.getElementById('subtitle').textContent=`${TOTAL_CASSETTES} кассет${TOTAL_CASSETTES%10===1?'а':''} × ${PORTS_PER_CASSETTE} портов = 1–${TOTAL_PORTS}`;
|
||||
}
|
||||
function applySettings(){
|
||||
const c=parseInt(document.getElementById('cassettes').value);
|
||||
const p=parseInt(document.getElementById('perPort').value);
|
||||
if(!c||c<1)return;
|
||||
if(!p||p<1)return;
|
||||
TOTAL_CASSETTES=c;
|
||||
PORTS_PER_CASSETTE=p;
|
||||
TOTAL_PORTS=TOTAL_CASSETTES*PORTS_PER_CASSETTE;
|
||||
saveSettings();
|
||||
updateUI();
|
||||
document.getElementById('result').classList.remove('show');
|
||||
}
|
||||
|
||||
function calc(){
|
||||
const input=document.getElementById('port');
|
||||
const error=document.getElementById('error');
|
||||
@ -77,6 +118,7 @@ function calc(){
|
||||
result.classList.remove('show');
|
||||
|
||||
if(!val||val<1||val>TOTAL_PORTS){
|
||||
error.textContent=`Введи число от 1 до ${TOTAL_PORTS}`;
|
||||
error.classList.add('show');
|
||||
return;
|
||||
}
|
||||
@ -100,7 +142,6 @@ function addHistory(portNum,cassette,port,firstPort,lastPort){
|
||||
localStorage.setItem('portHistory',JSON.stringify(history));
|
||||
renderHistory();
|
||||
}
|
||||
|
||||
function renderHistory(){
|
||||
const el=document.getElementById('history');
|
||||
const list=document.getElementById('historyList');
|
||||
@ -114,12 +155,10 @@ function renderHistory(){
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function useHistory(i){
|
||||
document.getElementById('port').value=history[i].portNum;
|
||||
calc();
|
||||
}
|
||||
|
||||
function copyResult(i){
|
||||
const h=history[i];
|
||||
const text=`${h.portNum} → ${h.cassette} кассета — ${h.port} порт`;
|
||||
@ -127,6 +166,8 @@ function copyResult(i){
|
||||
}
|
||||
|
||||
document.getElementById('port').addEventListener('keydown',e=>{if(e.key==='Enter')calc()});
|
||||
loadSettings();
|
||||
updateUI();
|
||||
renderHistory();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user