-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
101 lines (91 loc) · 3.68 KB
/
index.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
<!DOCTYPE html>
<html lang="zh">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<link rel="stylesheet" href="static/bootstrap.css">
<link rel="stylesheet" href="static/main.css">
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
<title>114514 数字论证器</title>
<script>
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?47516ef10e1035e05f66d1923d3b4ae1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</head>
<body class="text-center">
<div id="app" class="form-getflag">
<h1>114514<br />
数字论证器</h1>
<div class="alert alert-success" role="alert" style="display: none;">
你论证的 <span id="num">0</span>:<br />
<b><code id="result"></code></b>
</div>
<div class="alert alert-danger" role="alert" style="display: none;">
<b id="errMsg"></b>
</div>
<p>你想论证的数字:<input type="text" size="12" maxlength="6" id="show"></input></p>
<input type="range" id="number" name="number" class="form-control" value="114514" min="0" max="999999" step="1">
<input type="submit" class="btn btn-lg btn-primary btn-block" id="submit" value="开始论证">
</div>
<footer class="text-center">
Telegram bot: <a href="https://t.me/calc114514bot" target="_blank">@calc114514bot</a>
<br />
本项目开源在 <a href="https://github.com/miaotony/calc114514" target="_blank">GitHub</a> 上
</footer>
<script src="static/jquery.js"></script>
<script src="static/bootstrap.js"></script>
<script type="text/javascript">
var prevVal = 0;
$(document).ready(function () {
$("#show").val($('#number')[0].value);
$('#number').on('input', function () {
$("#show").val($('#number')[0].value.toString());
prevVal = $('#number')[0].value;
});
$('#show').on('input', function () {
$("#number").val($('#show')[0].value.toString());
prevVal = $('#show')[0].value;
});
});
function getAnswer() {
const number = $('#number')[0].value;
const host = window.location.host;
let url = 'https://calc114514.vercel.app/api/calc?isJson=1&num=' + number;
if (host.endsWith("vercel.app")) {
url = '/api/calc?isJson=1&num=' + number;
}
$.ajax({
url: url,
dataType: "json",
async: true,
type: "GET",
success: function (data) {
// console.log(data);
if (data.number === "114514") {
$('#num').text("恶臭的 " + data.number);
} else {
$('#num').text(data.number);
}
$('#result').text(data.answer);
$('.alert.alert-danger').hide();
$('.alert.alert-success').show();
},
error: function (e) {
console.log(e);
$('#errMsg').text("发生错误,请重试!");
$('.alert.alert-success').hide();
$('.alert.alert-danger').show();
}
});
}
$("#submit").click(function (data) {
getAnswer();
});
</script>
</body>
</html>