修复:带默认值的复选框表现和预期不符

This commit is contained in:
RikaCelery 2023-03-03 16:14:46 +08:00
parent 165b69beaa
commit c3b25ae653

View File

@ -225,7 +225,8 @@
<div class="description">跳过下载</div>
</div>
<div>
<input type="checkbox" name="check-segments-count" id="check-segments-count" checked />
<input type="checkbox" name="check-segments-count" id="check-segments-count" checked
default="true" />
<label for="check-segments-count">check-segments-count</label>
<div class="description">检测实际下载的分片数量和预期数量是否匹配 </div>
</div>
@ -235,7 +236,7 @@
<div class="description">二进制合并</div>
</div>
<div>
<input type="checkbox" name="del-after-done" id="del-after-done" checked />
<input type="checkbox" name="del-after-done" id="del-after-done" checked default="true" />
<label for="del-after-done">del-after-done</label>
<div class="description">完成后删除临时文件 </div>
</div>
@ -265,7 +266,8 @@
<div class="description">只选取字幕轨道</div>
</div>
<div>
<input type="checkbox" name="auto-subtitle-fix" id="auto-subtitle-fix" checked />
<input type="checkbox" name="auto-subtitle-fix" id="auto-subtitle-fix" checked
default="true" />
<label for="auto-subtitle-fix">auto-subtitle-fix</label>
<div class="description">自动修正字幕 </div>
</div>
@ -280,7 +282,8 @@
<div class="description">实时解密MP4分片</div>
</div>
<div>
<input type="checkbox" name="use-system-proxy" id="use-system-proxy" checked />
<input type="checkbox" name="use-system-proxy" id="use-system-proxy" checked
default="true" />
<label for="use-system-proxy">use-system-proxy</label>
<div class="description">使用系统默认代理 </div>
</div>
@ -295,7 +298,8 @@
<div class="description">录制直播时实时合并</div>
</div>
<div>
<input type="checkbox" name="live-keep-segments" id="live-keep-segments" checked />
<input type="checkbox" name="live-keep-segments" id="live-keep-segments" checked
default="true" />
<label for="live-keep-segments">live-keep-segments</label>
<div class="description">录制直播并开启实时合并时依然保留分片 </div>
</div>
@ -332,9 +336,23 @@
}
break;
case 'checkbox':
if (element.checked) {
if (element.checked == Boolean(element.getAttribute('default'))) {
// finalArgs.push('**' + element.id)
// finalArgs.push(String(element.checked))
} else {
finalArgs.push('--' + element.id)
finalArgs.push(String(element.checked))
}
// if (element.checked) {
// finalArgs.push('--' + element.id)
// finalArgs.push('true')
// } else {
// if (element.checked != Boolean(element.getAttribute('default'))) {
// finalArgs.push('--' + element.id)
// finalArgs.push(String(element.checked))
// }
// }
break;
default:
@ -358,16 +376,20 @@
document.getElementById('output').textContent = '.\\N_m3u8DL-RE.exe ' + finalArgs.join(" ")
console.log(finalArgs.join(" "))
}
setInterval(() => generate('generator_body'), 100)
</script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap');
:root {
--backgrond-color-light: rgb(130, 106, 251);
--backgrond-color-dark: rgb(16, 13, 29);
--backgrond-color: var(--backgrond-color-dark);
--accent-color-light: rgb(130, 106, 251);
--accent-color-dark:rgb(130, 106, 251);;
--accent-color-dark: rgb(130, 106, 251);
;
--accent-color: var(--accent-color-dark);
--backgrond-color-hover-light: rgb(81, 57, 202);
@ -403,6 +425,7 @@
--border-color: var(--border-color-dark);
}
* {
margin: 0;
padding: 0;
@ -411,6 +434,7 @@
transition: all 0.2s ease-in-out;
}
body {
min-height: 100vh;
display: flex;
@ -435,6 +459,7 @@ body {
font-weight: 500;
text-align: center;
}
#output {
font-size: 1rem;
color: var(--main-text-color);
@ -445,6 +470,7 @@ body {
padding: 10px 0;
margin-top: 10px;
}
.form :where(input, select) {
background: transparent;
}
@ -588,12 +614,15 @@ body {
.form input {
color: var(--main-text-color);
}
.form input:focus {
background-color: var(--input-color-hover);
}
.form input:invalid:not(input:focus) {
outline: 2px solid red;
}
@media screen and (max-width: 1000px) {
.form .check>div {