-
Notifications
You must be signed in to change notification settings - Fork 3
/
avBV.html
117 lines (117 loc) · 3.27 KB
/
avBV.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<title>Bilibili conversion between av and BV.</title>
<style>
body {
font-family: sans-serif;
position: absolute;
border: 0;
height: 100%;
margin: 0;
padding: 1vh 25vw 5vh 25vw;
width: 100%;
}
input[type="text"] {
background-color: #F0F0F0;
border:2px solid #F0F0F0;
font-family: monospace;
}
input[type="text"]:hover {
background-color: #E0E0E0;
}
input[type="text"]:active {
background-color: #D0D0D0;
}
input[type="button"] {
font-family: monospace;
background-color: #F0F0F0;
border:2px solid;
border-color: #F0F0F0;
border-radius:5px;
}
input[type="button"]:hover {
background-color: #E0E0E0;
}
input[type="button"]:active {
background-color: #D0D0D0;
}
</style>
<script>
var xorn=177451812;
var add=8728348608;
var s=[11,10,3,8,4,6];
const TABLE=['f','Z','o','d','R','9','X','Q','D','S','U','m','2','1','y','C','k','r','6','z','B','q','i','v','e','Y','a','h','8','b','t','4','x','s','W','p','H','n','J','E','7','j','L','5','V','G','3','g','u','M','T','K','N','P','A','w','c','F'];
var tr=new Array(123);
function enc(x) {
x=(x^xorn)+add;
var r=['B','V','1',' ',' ','4',' ','1',' ','7',' ',' '];
for (var i = 0; i < r.length; i++) {
r[s[i]]=TABLE[Math.floor(x/Math.pow(58, i))%58]
}
var ret="";
for (var i = 0; i < r.length; i++) {
ret+=r[i];
}
return ret;
}
function dec(x) {
for (var i = 0; i < 58; i++) {
tr[TABLE[i]] = i;
}
var r=0;
for(var i = 0; i < 6; i++) {
r+=(Math.pow(58, i)*tr[x[s[i]]]);
}
return (r-add)^xorn;
}
function id(x) {
if (typeof x=="string") return document.getElementById(x);
return x;
}
function exec(type) {
if (type=="avtobv") {
var x=id("av").value;
if(x=="") {
id("result").innerHTML='NO VALUE!';
return;
}
var av=parseInt(x);
id("bv").value=enc(av);
id("result").innerHTML=enc(av);
} else {
var bv=id("bv").value;
if(bv=="") {
id("result").innerHTML="NO VALUE!";
return;
}
id("av").value=dec(bv);
id("result").innerHTML="av"+dec(bv);
}
}
function clr() {
id("av").value="";
id("bv").value="";
id("result").innerHTML="";
return;
}
</script>
</head>
<body>
<h1 style="text-align: center">Bilibili conversion between av and BV.</h1>
<label style="text-align: left">av number (DO NOT input the letters "av"!):</label>
<input type="text" class="form-control" id="av">
<br>
<input type="button" class="btn" id="submitav" value="Convert" onclick="exec('avtobv')">
<br><br><br>
<label style="text-align: left">BV string:</label>
<input type="text" class="form-control" id="bv">
<br>
<input type="button" class="btn" id="submitbv" value="Convert" onclick="exec('bvtoav')">
<hr>
<div style="text-align: center"><input type="button" class="btn-lg" value="Clear" onclick="clr()"></div>
<h1 id="result" style="text-align: center"></h1>
</body>
</html>