-
Notifications
You must be signed in to change notification settings - Fork 1
/
ChinaDataAccessProject.html
364 lines (299 loc) · 14.4 KB
/
ChinaDataAccessProject.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="https://unpkg.com/[email protected]/dist/css/bootstrap/tabulator_bootstrap4.min.css" rel="stylesheet">
<link href="https://unpkg.com/[email protected]/dist/css/materialize/tabulator_materialize.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<style>
.tabulator-edit-select-list{
max-height: none!important;
}
.tabulator-row .tabulator-cell, #gprl-table-mobile .tabulator-row .tabulator-cell{
white-space: normal!important;
}
#observationSelect, #regionSelect, #frequencySelect{
height:36px;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
border-color: rgb(238,238,238);
-webkit-appearance: menulist-button;
}
#resetBtn{
border: none;
font-weight: 600;
border-bottom: 1px dashed #b6acd1;
color: #4e2a84;
padding-bottom: .08rem;
background: transparent;
}
#gprl-table-mobile .tabulator-row .tabulator-cell{
padding-top: 0px;
padding-bottom: 0px;
display: block;
}
#gprl-table-mobile .tabulator-row {
max-width: 95vw!important;
white-space: normal!important;
padding-top: 10px;
}
#gprl-table-mobile .tabulator-header {
max-width: 95vw!important;
white-space: normal!important;
display: block!important;
}
#gprl-table-mobile .tabulator-header .tabulator-col{
display: block!important;
width:95vw!important;;
}
</style>
</head>
<body>
<form style="font-size: 16px!important;">
<div class="container">
<div class="row">
<div class="col-sm-12" >
<p class="col-md-12" style="width:95vw!important;;padding-left: 10px;padding-right: 10px;">The China Data Access Project (CDAP) promotes access to microdata from China by providing the names, basic description and known usage of all large sample microdata that have been used in existing research papers. Researchers are responsible for obtaining the data on their own. Where possible, links to the actual data will be provided.</p>
<br>
<br>
<div id="gprl-table-info" class="col-md-12" style="display: inline-flex; float: left;width:95vw!important;;padding-left: 10px;padding-right: 10px;">
</div><div style="display: inline-flex; float: right; margin-right: 30px;">
<button type="reset" value="Reset" id="resetBtn">Reset Search</button></div><br><br>
<div id="gprl-table" class="d-none d-sm-block"></div>
<div id="gprl-table-mobile" class="d-block d-sm-none"></div>
</div></div></div>
</form>
<script>
var yearEditor = function(cell, onRendered, success, cancel, editorParams){
//create and style inputs
var year = document.createElement("input");
year.setAttribute("type", "search")
year.setAttribute("placeholder", "Enter a Year")
year.maxLength = 4;
year.style.padding = "4px";
year.style.width = "100%";
year.style.boxSizing = "border-box";
year.value = cell.getValue();
return year;
}
var observationEditor = function(cell, onRendered, success, cancel, editorParams){
var editor = $("<select id='observationSelect'>" +
"<option value=''>ALL</option>" +
"<option value='Province'>Province</option>" +
"<option value='Organization'>Organization</option>" +
"<option value='Occupation'>Occupation</option>" +
"<option value='N/A'>N/A</option>" +
"<option value='Institution/Organizations'>Institution; Organizations</option>" +
"<option value='Industry'>Industry</option>" +
"<option value='Individual/Household data'>Individual; Household</option>" +
"<option value='Each incident'>Each Incident</option>" +
"<option value='County'>County</option>" +
"<option value='Country'>Country</option>" +
"<option value='Commodity'>Commodity</option>" +
"<option value='Case'>Case</option>" +
"</select>");
editor.css({
"padding":"5px",
"width":"100%",
"box-sizing":"border-box",
})
onRendered(function(){
editor.focus();
});
editor.on("change blur", function(e){
success(editor.val());
});
editor.on("keydown", function(e){
if(e.keyCode == 13){
success(editor.val());
}
});
//return the editor element
return editor[0];
}
var regionEditor = function(cell, onRendered, success, cancel, editorParams){
var editor = $("<select id='regionSelect'>" +
"<option value=''>ALL</option>" +
"<option value='Africa'>Africa</option>" +
"<option value='East Asia and Pacific'>East Asia and Pacific</option>" +
"<option value='Europe and Central Asia'>Europe and Central Asia</option>" +
"<option value='Latin America and Caribbean'>Latin America and Caribbean</option>" +
"<option value='Middle East and North Africa'>Middle East and North Africa</option>" +
"<option value='North America'>North America</option>" +
"<option value='South Asia'>South Asia</option>" +
"</select>");
editor.css({
"padding":"5px",
"width":"100%",
"box-sizing":"border-box",
})
onRendered(function(){
editor.focus();
});
editor.on("change blur", function(e){
success(editor.val());
});
editor.on("keydown", function(e){
if(e.keyCode == 13){
success(editor.val());
}
});
//return the editor element
return editor[0];
}
var frequencyEditor = function(cell, onRendered, success, cancel, editorParams){
var editor = $("<select id='frequencySelect'>" +
"<option value=''>ALL</option>" +
"<option value='Annual'>Annual</option>" +
"<option value='Daily'>Daily</option>" +
"<option value='Monthly'>Monthly</option>" +
"<option value='N/A'>N/A</option>" +
"<option value='Quarterly'>Quarterly</option>" +
"<option value='Weekly'>Weekly</option>" +
"</select>");
editor.css({
"padding":"5px",
"width":"100%",
"box-sizing":"border-box",
})
onRendered(function(){
editor.focus();
});
editor.on("change blur", function(e){
success(editor.val());
});
editor.on("keydown", function(e){
if(e.keyCode == 13){
success(editor.val());
}
});
//return the editor element
return editor[0];
}
var c = 0;
var div = "";
function display(results) {
function titleFunction(headerValue, rowValue, rowData, filterParams){
var searchStrings= headerValue.split(" ");
var stringPresent = false;
$.each(searchStrings, function (j, searchString) {
if(rowData.datasettitle.toLowerCase().includes(searchString.toLowerCase())){
stringPresent = true;
} else {
stringPresent = false;
return false;
}
});
return stringPresent;
}
function countryFunction(headerValue, rowValue, rowData, filterParams){
var searchStrings= headerValue.split(" ");
var stringPresent = false;
$.each(searchStrings, function (j, searchString) {
if(rowData.countries.toLowerCase().includes(searchString.toLowerCase())){
stringPresent = true;
} else {
stringPresent = false;
return false;
}
});
return stringPresent;
}
function yearFunction(headerValue, rowValue, rowData, filterParams){
if(rowValue){
var years = [];
if (rowValue.includes(';')){
var yearsRanges = rowValue.split('; ');
$.each(yearsRanges, function (j, yearrange) {
if (yearrange.includes('-')){
var yearstartEnd = yearrange.split('-');
if(yearstartEnd[1].toLowerCase() == 'present'){
yearstartEnd[1] = new Date().getFullYear();
}
for (var i= parseInt(yearstartEnd[0]) ; i<=parseInt(yearstartEnd[1]); i++){
years.push(i);
}
}else{
years.push(yearrange);
}
});
}else{
if (rowValue.includes('-')){
var yearstartEnd = rowValue.split('-');
if(yearstartEnd[1].toLowerCase() == 'present'){
yearstartEnd[1] = new Date().getFullYear();
}
for (var i= parseInt(yearstartEnd[0]) ;i<= parseInt(yearstartEnd[1]); i++){
years.push(i);
}
}else{
years.push(rowValue);
}
}
if(years.includes(parseInt(headerValue))){
return true;
}
}
return false; //must return a boolean, true if it passes the filter.
};
var table = new Tabulator("#gprl-table", {
data:results,
pagination:"local",
paginationSize:25,
paginationSizeSelector:[10, 25, 50, 100],
columns:[
{title:"Title", field:"datasettitle", width:'23%', headerFilter:"input",formatter:"link", formatterParams:{urlField:"url", target:"_blank"}, headerFilterFunc: titleFunction, headerFilterPlaceholder: "Search by Title"},
{title:"Time Covered", field:"yearscollected", width:'15%', headerFilter:yearEditor, headerFilterFunc:yearFunction, headerFilterPlaceholder: 'Enter a year',formatter:"textarea" },
{title:"Observation Unit", field:"unitofobservation", width:'16%', formatter:"textarea", headerFilter:observationEditor, headerFilterFunc:"like"},
{title:"Region", field:"regionscovered", width:'13%', headerFilter:regionEditor, formatter:"textarea", headerFilterFunc:"like"},
{title:"Data Frequency", field:"datafrequency", width:'15%', formatter:"textarea", headerFilter:frequencyEditor, headerFilterFunc: "like"},
{title:"Countries", field:"countries", width:"18%", headerFilter:"input", headerFilterFunc: countryFunction, headerFilterPlaceholder: "Search by Country"}
],
dataFiltered:function(filters, rows){
//filters - array of filters currently applied
//rows - array of row components that pass the filters
var div = document.getElementById('gprl-table-info');
div.innerHTML = 'There are ' + rows.length + " data sets available matching your search criteria.";
}
});
var tableMobile = new Tabulator("#gprl-table-mobile", {
data:results,
pagination:"local",
responsiveLayout: "collapse",
paginationSize:25,
paginationSizeSelector:[10, 25, 50, 100],
columns:[
{title:"Title", field:"datasettitle", width:'100%', headerFilter:"input",formatter:"link", formatterParams:{urlField:"url", target:"_blank"}, headerFilterFunc: titleFunction, headerFilterPlaceholder: "Search by Title"},
{title:"Time Covered", field:"yearscollected", headerFilter:yearEditor, headerFilterFunc:yearFunction, headerFilterPlaceholder: 'Enter a year',formatter:"textarea" },
{title:"Observation Unit", field:"unitofobservation", formatter:"textarea", headerFilter:observationEditor, headerFilterFunc:"like"},
{title:"Region", field:"regionscovered", headerFilter:regionEditor, formatter:"textarea", headerFilterFunc:"like"},
{title:"Data Frequency", field:"datafrequency", formatter:"textarea", headerFilter:frequencyEditor, headerFilterFunc: "like"},
{title:"Countries", field:"countries", headerFilter:"input", headerFilterFunc: countryFunction, headerFilterPlaceholder: "Search by Country"}
],
dataFiltered:function(filters, rows){
//filters - array of filters currently applied
//rows - array of row components that pass the filters
var div = document.getElementById('gprl-table-info');
div.innerHTML = 'There are ' + rows.length + " data sets available matching your search criteria.";
}
});
$(document).on("click","#resetBtn", function(){
table.clearHeaderFilter();
tableMobile.clearHeaderFilter();
});
$(window).resize(function() {
table.redraw(true);
});
}
</script>
<script src="https://script.google.com/macros/s/AKfycby69IzgD7RoyhvVdjvae8dNV2eOFPjW48IJaa4oSSjDe3nlIfA/exec?prefix=display">
</script>
</body>
</html>