forked from xiangyuecn/AreaCity-JsSpider-StatsGov
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
79 lines (66 loc) · 1.9 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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>测试和WEB数据格式转换工具</title>
</head>
<body>
<script src="测试和WEB数据格式转换工具.js"></script>
<style>
body{
word-wrap: break-word;
}
pre{
white-space:pre-wrap;
}
</style>
<script src="https://xiangyuecn.github.io/BuildHTML/buildhtml.js"></script>
<script>
function el(cls){
return document.querySelector(cls);
};
if(/^file:/.test(location.href)){
FormatLog("浏览器直接打开的html文件,不加载演示数据,请手动操作",1);
}else{
el(".AreaFormatFrom").innerHTML=BuildHTML(`
<select class="AreaFormatFromSelect" onchange="swapFrom()">
{{::
;BuildHTMLArray('<option value="{fn:BuildHTMLArray.index+1}">{fn::AllowAccessFolder}/{fn::o}</option>',AllowAccessFiles)
}}
<\/select>`);
var swapFrom=function(){
var from=+el(".AreaFormatFromSelect").value-1;
var path=AllowAccessFolder+"/"+AllowAccessFiles[from];
FormatLog("【"+path+"】数据加载中...请稍后");
var ajax=new XMLHttpRequest();
ajax.open("GET",path.replace(/\(.+\)/,""));
ajax.onreadystatechange=function(){
if(ajax.readyState==4){
if(ajax.status==200){
var input=el(".AreaFormatInput");
input.value=ajax.responseText;
FormatLog(`成功加载【${path}】数据。
<hr>
<div>输入框中本来的提示信息:</div>
<pre>${input.placeholder}</pre>
<hr>
<div class='initTest1'></div>
<hr>
<div class='initTest2'></div>
<hr>
<div class='initTest3'></div>`);//<script>
TestClick("js",".initTest1");
TestClick("jsonObject",".initTest2",460204);//选中 三亚 天涯
TestClick("jsonArray",".initTest3",11);//选中 北京
}else{
FormatLog("【"+path+"】数据加载失败");
}
}
}
ajax.send();
};
swapFrom();
};
</script>
</body>
</html>