-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsearch.html
More file actions
158 lines (147 loc) · 5.97 KB
/
search.html
File metadata and controls
158 lines (147 loc) · 5.97 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- Vue -->
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<style>
table {
border-collapse: collapse;
border: 2px solid rgb(140 140 140);
font-family: sans-serif;
font-size: 0.8rem;
letter-spacing: 1px;
}
th,
td {
border: 1px solid rgb(160 160 160);
padding: 8px 10px;
}
input {
margin: 0.4rem;
}
fieldset {
border: 1px solid gray;
margin: 0.3em;
}
</style>
<title></title>
</head>
<body>
<div id="app" class="container">
<h1>PanDefenseProject 检索</h1>
<form>
<fieldset>
<legend>输入查询条件:</legend>
机构名称:<input v-model="institudeName">
机构地点:<input v-model="institudeLocation">
</fieldset>
</form>
<table>
<thead>
<th>名称</th>
<th>网站</th>
<th>位置</th>
<th>存在迫害?</th>
<th>来源</th>
<th>已检查</th>
</thead>
<tbody>
<tr v-for="row in data">
<td>
<span v-for="name in row.names">{{ name }}<br/></span>
</td>
<td>
<span v-for="site in row.sites"><a :href="site" target="_blank">{{ site }}</a><br/></span>
</td>
<td>
<span v-for="location in row.locations">{{ location }}<br/></span>
</td>
<td>
<span v-if="row.persecution.known"><input type="checkbox" disabled checked ><br/></span>
<input type="checkbox" disabled v-else>
<span v-for="evidence in row.persecution.evidences"><a :href="evidence" target="_blank">{{ evidence }}</a><br/></span>
</td>
<td>
<span v-for="source in row.sources">{{ source }}<br/></span>
</td>
<td>
<input type="checkbox" disabled checked v-if="row.checked">
<input type="checkbox" disabled v-else>
</td>
</tr>
</tbody>
</table>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>
<script>
const {createApp, ref, computed, reactive} = Vue;
const data = computed(() => {
var result = rawContent.value;
const name = institudeName.value;
const location = institudeLocation.value;
if(name.trim() != "") {
result = result.filter((x) => {
var flag = false;
x.names.forEach((n) => {
if(n.includes(name)) flag = true;
});
return flag;
});
}
if(location.trim() != "") {
result = result.filter((x) => {
var flag = false;
x.locations.forEach((l) => {
if(l.includes(location)) flag = true;
});
return flag;
});
}
return result;
});
const institudeName = ref("");
const institudeLocation = ref("");
var rawContent = ref({});
createApp({
setup() {
return {
data,
institudeName,
institudeLocation
};
}
}).mount('#app');
const dataSource = "https://functionsir.github.io/PanDefenseProject/institute_list.json";
const dataSource2 = "https://raw.githubusercontent.com/FunctionSir/PanDefenseProject/master/institute_list.json";
fetch(dataSource)
.then((rep) => {
if(!rep.ok) {
throw new Error("Use backup source");
}
return rep.json()
})
.then((data_) => {
console.log(data_);
rawContent.value = data_.content;
})
.catch((error) => {
fetch(dataSource2)
.then((rep) => {
if(!rep.ok) {
throw new Error("No available source");
}
return rep.json()
})
.then((data_) => {
console.log(data_);
rawContent.value = data_.content;
});
});
</script>
</body>
</html>