-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBlog.html
146 lines (142 loc) · 8.29 KB
/
Blog.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!--
* @Date: 2019-12-31 19:21:38
* @Author: MemoryShadow
* @LastEditors: MemoryShadow
* @LastEditTime: 2020-07-01 16:39:14
* @Effect: Do not edit
-->
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>墨兮枫的个人博客</title>
<script>
function CaiHongPi(id) {
var XmlHttp = GetXmlHttp();
XmlHttp.onreadystatechange = function () {
// 当响应达成,并且成功的时候,就修改数据
if (XmlHttp.readyState == 4 && XmlHttp.status == 200) {
document.getElementById(id).innerHTML = XmlHttp.responseText;
}
}
XmlHttp.open("GET", "https://memoryshadow.freetzi.com/Template/Public/ToolAPI/?Mode=Ajax&Function=CaiHongPi", true);
XmlHttp.send();
}
function GetErrorMsg(ErrorCode) {
var XmlHttp = GetXmlHttp();
XmlHttp.onreadystatechange = function () {
// 当响应达成,并且成功的时候,就修改数据
if (XmlHttp.readyState == 4 && XmlHttp.status == 200) {
document.getElementById('ErrorCode').value = JSON.parse(XmlHttp.responseText).ErrorCode;
document.getElementById('ErrorText').innerHTML = JSON.parse(XmlHttp.responseText).ErrorText;
document.getElementById('ErrorPrint').innerHTML = JSON.parse(XmlHttp.responseText).ErrorPrint;
document.getElementById('ErrorInfo').innerHTML = XmlHttp.responseText;
}
}
XmlHttp.open("GET", "https://memoryshadow.freetzi.com/Template/Public/ToolAPI/?Mode=Ajax&Function=ErrorMsg&ErrorCode=" + ErrorCode, true);
XmlHttp.send();
}
var Data;
function Translate(Query) {
var XmlHttp = GetXmlHttp();
XmlHttp.onreadystatechange = function () {
// 当响应达成,并且成功的时候,就修改数据
if (XmlHttp.readyState == 4 && XmlHttp.status == 200) {
Data = XmlHttp.responseText;
document.getElementById('TranslateResult').innerHTML = JSON.parse(XmlHttp.responseText).sentences[0].trans;
document.getElementById('TranslateResultSource').innerHTML = XmlHttp.responseText;
}
}
XmlHttp.open("GET", "https://memoryshadow.freetzi.com/Template/Public/ToolAPI/?Mode=Ajax&Function=Translate&Query=" + Query, true);
XmlHttp.send();
}
function Get_CaptchaData(Id) {
var XmlHttp = GetXmlHttp();
XmlHttp.onreadystatechange = function () {
// 当响应达成,并且成功的时候,就修改数据
if (XmlHttp.readyState == 4 && XmlHttp.status == 200) {
Data = XmlHttp.responseText;
document.getElementById(Id).Token = JSON.parse(XmlHttp.responseText).Token;
document.getElementById(Id).src = "data:image/png;base64," + JSON.parse(XmlHttp.responseText).CaptchaImgValue;
}
}
XmlHttp.open("GET", "https://memoryshadow.freetzi.com/Template/Public/ToolAPI/?Mode=Ajax&Function=Captcha&OperateMode=GetData&DataType=Json", true);
XmlHttp.send();
}
function Post_CaptchaData(Id, InputValue) {
var XmlHttp = GetXmlHttp();
XmlHttp.onreadystatechange = function () {
// 当响应达成,并且成功的时候,就修改数据
if (XmlHttp.readyState == 4 && XmlHttp.status == 200) {
Data = XmlHttp.responseText;
document.getElementById('Result').innerHTML = (XmlHttp.responseText == "False") ? "验证失败,验证码无效或发生错误" : "验证成功,验证码有效";
// 并且在响应后刷新验证码
Get_CaptchaData('CaptchaImg');
}
}
XmlHttp.open("POST", "https://memoryshadow.freetzi.com/Template/Public/ToolAPI/?Mode=Ajax&Function=Captcha&OperateMode=SubmitData&SubmitType=ConfirmCaptcha", true);
XmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
XmlHttp.send("Token=" + document.getElementById(Id).Token + "&InputValue=" + InputValue);
document.getElementById(Id).placeholder = InputValue;
document.getElementById(Id).value = "";
}
function GetXmlHttp() {
var XmlHttp;
if (window.XMLHttpRequest) {
// IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
XmlHttp = new XMLHttpRequest();
} else {
// IE6, IE5 浏览器执行代码
XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
return XmlHttp;
}
function Init() {
CaiHongPi('CaiHongPi');
GetErrorMsg(ErrorCode.value);
Translate(TranslateSource.value);
Get_CaptchaData('CaptchaImg');
}
</script>
</head>
<body onload="Init()">
<a href="https://github.com/MemoryShadow/MemoryShadow.github.io">打开项目页面</a>
<a href="https://MemoryShadow.freetzi.com">打开支持官网</a>
<br />
<hr width="100%" size="1" />
<h3>彩虹屁接口调用示例(感谢<a href="https://shadiao.app/">沙雕APP</a>)<button onclick="CaiHongPi('CaiHongPi');">
<img style="height: 17px;"
src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTc3NzgzNDc2ODg4IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjcgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjIxMjciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjAwLjU4NTkzNzUiIGhlaWdodD0iMjAwIj48ZGVmcz48c3R5bGUgdHlwZT0idGV4dC9jc3MiPjwvc3R5bGU+PC9kZWZzPjxwYXRoIGQ9Ik0xMDIwLjQ0NDQ0NCA0NjAuOCA4MzQuODQ0NDQ0IDIzMC40Yy0xOS4yLTI1LjYtNTcuNi0yNS42LTc2LjggMEw1NzIuNDQ0NDQ0IDQ2MC44Yy0xMi44IDE5LjIgMCA0NC44IDE5LjIgNDQuOGw3MC40IDBjMCAxMzQuNCAwIDMwNy4yLTI0My4yIDQ0OC02LjQgNi40IDAgMTIuOCA2LjQgMTIuOCA0NTQuNC03MC40IDQ5Mi44LTM3Ny42IDQ5Mi44LTQ2MC44bDc2LjggMEMxMDIwLjQ0NDQ0NCA1MDUuNiAxMDMzLjI0NDQ0NCA0ODAgMTAyMC40NDQ0NDQgNDYwLjhMMTAyMC40NDQ0NDQgNDYwLjggMTAyMC40NDQ0NDQgNDYwLjh6TTQzOC4wNDQ0NDQgNTE4LjQgMzYxLjI0NDQ0NCA1MTguNGMwLTEzNC40IDAtMzA3LjIgMjQzLjItNDQ4IDYuNC02LjQgMC0xMi44LTYuNC0xMi44QzE0My42NDQ0NDQgMTI4IDEwNS4yNDQ0NDQgNDM1LjIgMTA1LjI0NDQ0NCA1MTguNEwyOC40NDQ0NDQgNTE4LjRDMi44NDQ0NDQgNTE4LjQtOS45NTU1NTYgNTQ0IDkuMjQ0NDQ0IDU2My4yTDE5NC44NDQ0NDQgNzkzLjZjMTkuMiAyNS42IDU3LjYgMjUuNiA3Ni44IDBsMTg1LjYtMjMwLjRDNDcwLjA0NDQ0NCA1NDQgNDU3LjI0NDQ0NCA1MTguNCA0MzguMDQ0NDQ0IDUxOC40TDQzOC4wNDQ0NDQgNTE4LjQgNDM4LjA0NDQ0NCA1MTguNHoiIHAtaWQ9IjIxMjgiPjwvcGF0aD48L3N2Zz4=" />
</button>
</h3>
<span id="CaiHongPi"></span><br />
<hr width="100%" size="1" />
<h3>ErrorMsg项目示例</h3>
错误代码:
<input onblur="this.style.border = 'none';GetErrorMsg(this.value)" onclick="this.style.border = ''"
style="border:none;font-size: 17px;" id="ErrorCode" value="503"></input><br /> 错误描述:
<span id="ErrorText"></span><br /> 调侃/吐槽:
<span id="ErrorPrint"></span><br /> 完整返回:
<span id="ErrorInfo"></span><br />
<hr width="100%" size="1" />
<h3>翻译接口(Google 翻译)</h3>
源内容:
<input onblur="this.style.border = 'none';Translate(this.value)" onclick="this.style.border = ''"
style="border:none;font-size: 17px;" id="TranslateSource" value="TranslateSource"></input><br />
翻译后的内容:
<span id="TranslateResult"></span><br />
返回具体内容:
<span id="TranslateResultSource"></span><br />
<hr width="100%" size="1" />
<h3>验证码功能示例</h3>
<img height="40px" width="120px" id="CaptchaImg" onclick="Get_CaptchaData('CaptchaImg')" />
<br />
<input type="text" value=""
onblur="this.placeholder = this.value;this.value = '';Post_CaptchaData('CaptchaImg', this.placeholder);" />
<br />
<span id="Result"></span>
<hr width="100%" size="1" />
</body>
</html>