-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcustom.html
More file actions
125 lines (122 loc) · 5.1 KB
/
custom.html
File metadata and controls
125 lines (122 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!doctype html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://fonts.googleapis.cn/css?family=Nunito:,i,b">
<link rel="stylesheet" href="./lit.css">
<title>自定义 ACC 计算器</title>
<script>
"use strict";
let data = { num: 4, note: [0, 0, 0, 0] };
function getFunction() {
return document.getElementById("function").value;
}
function inputData() {
const num = Number(document.getElementById("num").value);
if (num < 1) {
document.getElementById("inputData").innerHTML = "";
document.getElementById("inputACC").innerHTML = "";
document.getElementById("output").innerHTML = "你输了个什么!( `д´)";
return;
}
data.num = num;
const inputData = document.getElementById("inputData");
inputData.innerHTML = "请输入物件数:<br>";
for (let i = 1; i <= num; i++) {
const input = document.createElement("input");
input.className = "card";
input.type = "text";
input.id = `note_${i}`;
input.placeholder = `第 ${i} 首歌的物件数`;
inputData.appendChild(input);
inputData.appendChild(document.createTextNode("\n"));
}
inputData.appendChild(document.createElement("br"));
const button = document.createElement("button");
button.className = "btn primary";
button.type = "button";
button.onclick = inputACC;
button.textContent = "确定并输入 ACC";
inputData.appendChild(button);
document.getElementById("inputACC").innerHTML = "";
document.getElementById("output").innerHTML = "";
}
function inputACC() {
for (let i = 1; i <= data.num; i++) data.note[i] = Number(document.getElementById(`note_${i}`).value);
const inputACC = document.getElementById("inputACC");
inputACC.innerHTML = "请输入 ACC(无需百分号):<br>";
for (let i = 1; i <= data.num; i++) {
const input = document.createElement("input");
input.className = "card";
input.type = "text";
input.id = `input_${i}`;
input.placeholder = getFunction() == "normal" ? `第 ${i} 首歌结束时的 ACC` : `第 ${i} 首歌的单曲 ACC`;
inputACC.appendChild(input);
inputACC.appendChild(document.createTextNode("\n"));
}
inputACC.appendChild(document.createElement("br"));
const button = document.createElement("button");
button.className = "btn primary";
button.type = "button";
button.onclick = calc;
button.textContent = "确定并复制结果到剪贴板";
inputACC.appendChild(button);
inputACC.appendChild(document.createTextNode("\u2002"));
const tip = document.createElement("code");
tip.id = 'tip';
inputACC.appendChild(tip);
document.getElementById("output").innerHTML = "";
}
function calc() {
let noteNum = data.note, inputAcc = [0], preNoteNum = [0]; // 物量的前缀和
for (let i = 1; i <= data.num; i++) {
preNoteNum[i] = preNoteNum[i - 1] + noteNum[i];
inputAcc[i] = Number(document.getElementById(`input_${i}`).value).toFixed(2);
}
let output = "";
if (getFunction() == "normal") { // 由段位 ACC 变化计算单曲 ACC
output = `${inputAcc[1]}`;
for (let i = 2; i <= data.num; i++) output += `-${inputAcc[i]}`;
output += '\n单曲';
for (let i = 1; i <= data.num; i++) {
let acc = (inputAcc[i] * preNoteNum[i] - inputAcc[i - 1] * preNoteNum[i - 1]) / noteNum[i];
output += ` ${acc.toFixed(2)}`;
}
} else { // 由单曲 ACC 推算段位 ACC 变化
output = "单曲";
for (let i = 1; i <= data.num; i++) output += ` ${inputAcc[i]}`;
output += `\n推算 ${inputAcc[1]}`;
let sum = inputAcc[1] * noteNum[1];
for (let i = 2; i <= data.num; i++) {
sum += inputAcc[i] * noteNum[i];
output += `-${(sum / preNoteNum[i]).toFixed(2)}`;
}
}
document.getElementById("output").innerHTML = output;
document.getElementById("tip").innerHTML = "计算结果已复制 (ゝ∀・)";
navigator.clipboard.writeText(output);
}
</script>
</head>
<body class="c">
<i><b>自定义 ACC 计算器</b> <small>2026.03.25 更新</small></i>
<hr>
请选择计算方式:
<select class="card" id="function">
<option value="normal" selected>由段位 ACC 变化计算单曲 ACC</option>
<option value="deduce">由单曲 ACC 推算段位 ACC 变化</option>
</select>
<br>
段位有多少首歌:
<input class="card" type="number" id="num" min="1" value="4" placeholder="默认值为 4">
<button class="btn primary" type="button" onclick="inputData()">确定</button>
<br>
<div id="inputData"></div>
<div id="inputACC"></div>
<textarea id="output" readonly class="card w-100" rows="3" style="resize: none" placeholder="我是结果框 (`ε´ )"></textarea>
<hr>
本站累计访问量:<br>
<img src="https://count.getloli.com/@:uzxn-github-io-acc" alt=":uzxn-github-io-acc">
</body>
</html>