-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
127 lines (118 loc) · 3.65 KB
/
script.js
File metadata and controls
127 lines (118 loc) · 3.65 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
$('#add').on('click', function(){
//$('#contributors-table tr:last').after(tableRow);
//$('#contributors-table').append(tableRow);
/* var table=document.getElementById('contributors-table');
var tableRow = table.rows[1].cloneNode(true);
$('#contributors-table > tbody:last').append(tableRow);
$("#contributors-table tr:last").clone().find('input').val('').end().insertAfter("#contributors-table tr:last"); */
var tableRow = `
<tr>
<td>
<label class="checkbox-label">
<div class="radio">
<input type="radio" name="optradio" class="table-radio">
</div>
</label>
</td>
<td>
<div class="form-group">
<select class="form-control input-sm" class="contributor-select">
<option value="author">Author</option>
<option value="editor">Editor</option>
<option value="translator">Translator</option>
</select>
</div>
</td>
<td>
<div class="form-group">
<input class="form-control input-sm name" type="text">
</div>
</td>
</tr>
`
$('#contributors-table > tbody:last').append(tableRow);
});
$("#delete").click(function () {
$(".selected").remove();
$("#contributors-table tr").each(function () {
$('td', this).each(function () {
if($(this).find("input.name").val()){
console.log($(this).find("input.name").val())
}
})
});
})
$(document).on("click", "#contributors-table tr", function(event) {
if($(event.target).is('[type="radio"]')){
console.log("In this function");
$(this).addClass("selected").siblings().removeClass("selected");
}
});
$("#up").click(function () {
console.log($(".selected").find("input.name").val());
$(".selected").prev().before($(".selected"));
});
$("#down").click(function () {
console.log($(".selected").find("input.name").val());
$(".selected").next().after($(".selected"));
})
$("#templateForm").submit(function () {
var authors = [];
$("#contributors-table tr").each(function () {
$('td', this).each(function () {
if($(this).find("input.name").val()){
// Add authentication to API's
// Brainstorm on Verify button
// Throw error message when there are no required authors
// Check how the editors go to the API
var author = {
// Auto completing,write an API for it
"author_id": "",
// How is the firstname coming from the API
"firstname": "",
"lastname": $(this).find("input.name").val()
}
}
authors.push(author);
})
});
var outputJSON = {
"volume": $("#volume").val(),
"series": $("#series").val(),
"abstract": $("#abstract").val(),
"authors": authors,
"number": "",
"month": $("#month").val(),
"edition": $("#edition").val(),
"year": $("#year").val(),
"keywords": $("#keywords").val(),
"verified": 1,
"title": $("#title").val(),
"booktitle": "",
"citation_id": 43107,
"institution": "",
"note": $("#note").val(),
"editor": "",
"howpublished": "",
"type": "",
"location": $("#city").val(),
"auth_string": "Boorstin, D., ABC, EDF, ",// have to set it
"journal": "",
"entryTime": 1463161832,
"translator": "",
"last_modified": Date.now(),
"address": "",
"pages": "",
"crossref": "",
"chapter": "",
"publisher": $("#publisher").val(),
"school": "",
"doi": $("#doi").val(),
"raw": "Boorstin, D. (1992). The creators: A history of the heroes of the imagination. New York: Random House.",
"url": $("#url").val(),
"bibtex_key": "",
"pubtype": $("#pubtype").val(),
"organization": ""
};
console.log(outputJSON);
});