/
online.html
executable file
·166 lines (166 loc) · 5.5 KB
/
online.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<html>
<!--
/**
* 迷你云网页版版本检测入口
*
* @author app <app@miniyun.cn>
* @link http://www.miniyun.cn
* @copyright 2014 Chengdu MiniYun Technology Co. Ltd.
* @license http://www.miniyun.cn/license.html
* @since 1.6
*/
-->
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<meta name='renderer' content='webkit'/>
<meta http-equiv='X-UA-Compatible' content='IE=edge'/>
<script>
/**
* 设置cookie
*/
function setCookie(name,value,expireDays)
{
if(expireDays>0){
var exDate=new Date()
exDate.setDate(exDate.getDate()+expireDays)
document.cookie=name+"="+encodeURI(value)+((expireDays==null) ? "" : ";path=/;expires="+exDate.toGMTString())
}else{
document.cookie=name+"="+encodeURI(value)+";path=/;";
}
}
/**
* 判断是否是IE浏览器
*/
function isIE(){
var userAgent = navigator.userAgent.toLowerCase();
var value = (userAgent.indexOf('trident') != -1) ?true:false;
return value;
}
/**
* 获得cookie
* @param name
*/
function getCookie(name)
{
var cookie = document.cookie;
if (cookie.length>0){
var key = name + "=";
var start=cookie.indexOf(key);
if (start!=-1){
start = start+key.length;
var end=cookie.indexOf(";",start);
if (end==-1){
end=cookie.length;
}
var value = cookie.substring(start,end);
return decodeURI(value);
}
}
return "";
}
/**
*获得url地址里面的参数
*/
function getParameter(name){
var currLocation = window.location.search;
if(currLocation!=""){
var parameters = currLocation.split("?")[1].split("&");
for(var i = 0; i < parameters.length; i++){
var item = parameters[i].split("=");
if(item[0] == name){
var value = decodeURIComponent(item[1]);
return value.replace("#","");
}
}
}else{
var info = window.location.href.split("index.php");
if(typeof info[1] !== 'undefined'){
var parameters = info[1].split("/");
for(var i = 0; i < parameters.length; i++){
if(parameters[i] == name && (i+1)<=parameters.length){
var value = decodeURIComponent(parameters[i+1]);
return value.replace("#","");
}
}
}
}
return "";
}
/**
* 访问static.miniyun.cn成功,跳转回去
*/
function online(text){
var data = eval("(" + text + ")");
var language = getCookie("language");
if(language==""){
setCookie("language","zh_cn");
}
//上次更新时间
setCookie("syncTime",getParameter("t"));
//云端版本
setCookie("cloudVersion",data.version);
var accessToken = getCookie("accessToken");
if(accessToken==""){
var backUrl = getParameter("back");
backUrlArr = backUrl.split('/');
if(backUrlArr[2]=="chooser"){
window.location.href = decodeURIComponent(backUrl);
return;
}
window.location.href = "index.php/site/login";
}else{
var backUrl = getParameter("back");
window.location.href = decodeURIComponent(backUrl);
}
}
/**
* 无法访问static.miniyun.cn
*/
function offline(){
setCookie("syncTime","-1");
window.location.href = "index.php/netdisk/index";
}
/**
* 判断是否在线
*/
function judgeOnline(){
var host = getParameter("staticServerHost");
var url = host+"index.php/client/web";
var xdr;
var oAjax;
try{
xdr = new XDomainRequest();
}catch(e){
oAjax = new XMLHttpRequest();
}
if(!xdr){
oAjax.open('GET', url, true);
oAjax.send();
oAjax.onreadystatechange = function(){ //OnReadyStateChange事件
if(oAjax.readyState == 4){ //4为完成
if(oAjax.status == 200){//200为成功
online(oAjax.responseText);
}else{
offline();
}
}
};
}else{
var xdr = new XDomainRequest();
xdr.open("get", url);
xdr.onload = function() {
online(xdr.responseText);
};
xdr.onprogress = function() {};
xdr.onerror = function(){
offline();
};
xdr.send();
}
}
window.onload = judgeOnline;
</script>
</head>
<body>
</body>
</html>