forked from bpiwowar/papercite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbibfilterForm.html
More file actions
78 lines (68 loc) · 2.05 KB
/
Copy pathbibfilterForm.html
File metadata and controls
78 lines (68 loc) · 2.05 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
<script>
function fillAuthors(auth, sort) {
if (sort == 1) {
console.log(auth);
auth.sort();
}
// get selector for authors in the form
var x = document.getElementById("author");
// add custom authors to the form
for ( var i = 0; i < auth.length; i++) {
var option = document.createElement("option");
option.text = auth[i];
option.value = auth[i];
x.add(option, null);
}
document.getElementById('author').value = "<?php echo $_POST['only_author'];?>";
}
/*
This function expects array of publication types in the following form:
-either string (text and value will be the same)
-two strings separated by "-" where first part is value, second part is menu text
-note: all "_" are replaced by whitespace
*/
function fillTypes(types) {
// get selector for publicaton type
var x = document.getElementById("type");
// add custom types
for ( var i = 0; i < types.length; i++) {
tt = types[i].replace('_', ' ');
t = tt.split("-");
var option = document.createElement("option");
option.value = t[0];
// if not optional text to menu defined, just use the field
if (t.length < 2) {
option.text = t[0];
} else {
option.text = t[1];
}
x.add(option, null);
}
document.getElementById('type').value = "<?php echo $_POST['only_entrytype'];?>";
}
</script>
<form action="" target="" method="POST">
<table border="1" style="width: 100%">
<tr>
<td>Authors:</td>
<td><select name="only_author" id="author">
<option value="">ALL</option>
</select></td>
<td>Type:</td>
<td><select name="only_entrytype" id=type>
<option value="">ALL</option>
</select></td>
<td><input type="submit" value="Filter" /></td>
</tr>
</table>
</form>
<script>
// get list of authors separated by |, parse to array and fill the form
var auth = <?php echo json_encode($authors); ?>;
var authors = auth.split('|');
var typ = <?php echo json_encode($types); ?>;
var sort = <?php echo json_encode($sortmenu); ?>;
var types = typ.split('|');
fillAuthors(authors, sort);
fillTypes(types);
</script>