-
Notifications
You must be signed in to change notification settings - Fork 5
/
index-location.html
128 lines (123 loc) · 5.07 KB
/
index-location.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
<!doctype html>
<html>
<head>
<meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>
<link rel="stylesheet" href="../main.css">
<link rel="shortcut icon" href="/favicon.ico">
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="0">
<title>🚀短链服务🚀</title>
</head>
<body class='typora-export os-windows'><div class='typora-export-content'>
<div id='write' class=''><h1 id='🚀短链服务🚀'><span>🚀短链服务🚀</span></h1><h4 id='欢迎使用学习资源库'><span>欢迎使用图欧学习资源库</span></h4><ul><li><span>当您看到此页面时,短链服务应该已经正常工作了。</span></li></ul><h6 id='若没有正常下载'><span>若没有正常跳转</span></h6><ul><li><span>请刷新。</span></li><li><span>或者</span><a href='https://tuostudy.vercel.app/'><span>返回图欧学习资源库主页</span></a><span>找到你想下载的资源。</span></li></ul></div></div>
<!-- js 跳转 -->
<!-- <script>
//ajax 对象
function ajaxObject() {
var xmlHttp;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
}
catch (e) {
// Internet Explorer
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
window.location.replace("https://tuostudy.vercel.app")
}
}
}
return xmlHttp;
}
// ajax post请求:
function ajaxPost ( url ) {
var ajax = ajaxObject();
ajax.open( "get" , url , true );
ajax.setRequestHeader( "Content-Type" , "application/json;charset=utf-8" );
ajax.onreadystatechange = function () {
if( ajax.readyState == 4 ) {
if( ajax.status == 200 ) {
var response = JSON.parse(ajax.responseText)
console.log(response)
url = window.location.href.split('?')[1]
long = response[url]
if(long === undefined) { // 只能用 === 运算来测试某个值是否是未定义的
long = 'https://tuostudy.vercel.app'}
console.log(long)
window.location.replace(long)
}
}
}
ajax.send( null );
}
var titleUrl='https://tuo-site.oss-cn-beijing.aliyuncs.com/data.json'
ajaxPost(titleUrl)
</script> -->
<script>
/* 封装ajax函数
* @param {string}opt.type http连接的方式,包括POST和GET两种方式
* @param {string}opt.url 发送请求的url
* @param {boolean}opt.async 是否为异步请求,true为异步的,false为同步的
* @param {object}opt.data 发送的参数,格式为对象类型
* @param {function}opt.success ajax发送并接收成功调用的回调函数
*/
function ajax(opt) {
opt = opt || {};
opt.method = opt.method.toUpperCase() || 'POST';
opt.url = opt.url || '';
opt.async = opt.async || true;
opt.data = opt.data || null;
opt.success = opt.success || function () {};
var xmlHttp = null;
if (XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
else {
xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
}var params = [];
for (var key in opt.data){
params.push(key + '=' + opt.data[key]);
}
var postData = params.join('&');
if (opt.method.toUpperCase() === 'POST') {
xmlHttp.open(opt.method, opt.url, opt.async);
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
xmlHttp.send(postData);
}
else if (opt.method.toUpperCase() === 'GET') {
xmlHttp.open(opt.method, opt.url + '?' + postData, opt.async);
xmlHttp.send(null);
}
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
opt.success(JSON.parse( xmlHttp.responseText));//如果不是json数据可以去掉json转换
}
};
}
ajax({
method: 'GET',
url: 'https://tuo-site.oss-cn-beijing.aliyuncs.com/data.json?'+ parseInt(Math.random()*10000000000000000),
cache:false,
beforeSend: function(xmlHttp){
xmlHttp.setRequestHeader("If-Modified-Since","0");
xmlHttp.setRequestHeader("Cache-Control","no-cache");
},
success: function (OriginalFromActivity) {
//在这里对获取的数据经常操作
console.log(OriginalFromActivity)
url = window.location.href.split('?')[1]
long = OriginalFromActivity[url]
if(long === undefined) { // 只能用 === 运算来测试某个值是否是未定义的
long = 'https://tuostudy.vercel.app'}
console.log(long)
window.location.replace(long)
}
})
</script>
</body>
</html>