-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
225 lines (218 loc) · 10.4 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
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
<html>
<head>
<meta charset="UTF-8">
<title>Papago</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" crossorigin="anonymous"/>
</head>
<body>
<script>
// *** parameters start ***
//default language
var lang = "fr";
//URL for Papago content tree
var papagoUrl = "https://raw.githubusercontent.com/micaelacq/Papago/master/trees/";
//URL for information pdf sheets (including trailing slash)
var pdfUrl = "https://webapps.unifr.ch/papago/pdf/";
//URL for Read & Publish Agreements API
var rapapi = "https://webapps.unifr.ch/papago/rapapi/";
//suffix for pdf sheets (including ".")
var pdfSuffix = ".pdf";
//default institution (for institutional personalization, with preceeding underscore)
var inst = '_unil';
// *** parameters end **
var jSearch = ["111A","1111A","1111B","E2111A","E2111B","E21111","E21112Ap","E21112Bp","E2112As","E2112Ah","E21122As","E21122Ah","E21122Bs","E21122Bh","S22111A","S22111B","S21112Ap","S21112Bp","S22112A","S22112B"];
var translate = {
"fr" : {
"Fiche": "Fiche",
"text" : "La fiche ci-dessous vous fournira des conseils sur les possibilit\u00e9s de financement ainsi que sur vos droits et obligations concernant cette publication.",
"error" : "Papago n\'est pas accessible pour le moment.",
"jSearch" : "Nom de la revue o\u00f9 votre article est ou sera publi\u00e9<br><em>Veuillez saisir le nom de la revue, appuyer sur le bouton vert et patienter que la liste des r\u00e9sultats s'affiche (cela peut prendre quelques secondes).</em>",
"jTitle" : "Titre de la revue",
"jDefault" : "Revue pas trouvé"},
"de" : {
"Fiche": "Infoblatt",
"text" : "Folgendes Infoblatt enthält Ratschläge zu Finanzierungsmöglichkeiten sowie zu Ihren Rechten und Pflichten in Bezug auf diese Publikation.",
"error" : "Papago ist zur Zeit nicht erreichbar.",
"jSearch" : "In welcher Zeitschrift wird oder wurde der Artikel veröffentlicht?<br><em>Geben Sie bitte den Namen der Zeitschrift ein und klicken Sie auf den grünen Knopf. Die Anzeige der Ergebnisse dauert unter Umständen einige Sekunden.</em>",
"jTitle" : "Titel der Zeitschrift",
"jDefault" : "Zeitschrift nicht gefunden"},
"en" : {
"Fiche": "Information Sheet",
"text" : "The following factsheet contains further advice on financing options and on your rights and obligations in relation to this publication.",
"error" : "Papago is not available at the moment.",
"jSearch" : "In which journal was or will be published your article?<br><em>Please, entre the name of the journal and click the green button. The result will be displayed in a few seconds at latest.</em>",
"jTitle" : "Journal title",
"jDefault" : "Journal not found"},
"it" : {
"Fiche": "Scheda Informativa",
"text" : "La seguente scheda informativa contiene ulteriori consigli sulle possibilità di finanziamento e sui diritti e obblighi relativi a questa pubblicazione.",
"error" : "Papago non è disponibile per il momento.",
"jSearch" : "In quale rivista sarà pubblicato o è stato pubblicato l'articolo ?<br><em>Inserire il nome della rivista, premere il pulsante verde e attendere che appaia la lista dei risultati (potrebbe richiedere qualche secondo).</em>",
"jTitle" : "Titolo della rivista",
"jDefault" : "Rivista non trovata"},
}
var parent = oldItem = sheet = jList = "";
function format(item) {
if (item.substr(0,5) == 'Fiche') {
parent = oldItem;
item.replace("Fiche", translate[lang]["Fiche"]);
url = item.split(' ');
if ($.inArray(item.substr(6), jSearch) != -1 && item.indexOf(':') == -1) {
code = '<p>' + translate[lang]['jSearch'] + '</p><form class="form-inline" id="jForm"><input type="text" id="jsearch" name="jsearch" class="form-control" placeholder="' + translate[lang]['jTitle'] + '"> <button id="sherpa" class="btn btn-success" style="padding:10px"><i class="fa fa-search"></i></button></form>';
sheet = item;
if (jList) {
code = code + jList;
}
}
else {
parts = item.split(':');
if (parts.length > 1) {
if (parts[1] == '') {
item = parts[0];
url[1] = url[1].substr(0, url[1].length-1);
}
parent = parts[0];
}
code = '<p>' + translate[lang]['text'] + '</p><a class="btn btn-success btn-lg" target="_blank" href="' + pdfUrl + lang + "/" + url[1] + inst + pdfSuffix + '"><i class="fa fa-download"></i> ' + item + '</a></p>';
}
$('#submit').hide();
$('#restart').show();
}
else {
jList = '';
$('#restart').hide();
code = '<p>' + papago[item]['label'] + '</p><div class="list-group btn-group-vertical" role="group" style="max-width:1000px; width:100%">';
$.each(papago[item]['options'], function(index,value) {
code = code+'<a class="list-group-item list-group-item-action btn" style="text-align:left; text-decoration:none; white-space:normal;" href="javascript:format(\'' + value['value'] +'\')"><i class="fa fa-arrow-right"></i> ' + value['option'] + '</a>';
});
code = code + '</div>';
if (papago[item]['parent']) {
$('#back').show();
}
else {
$('#back').hide();
}
parent = papago[item]['parent'];
oldItem = item;
}
$('#question').html(code);
}
function reformat (){
value = $("input[name='option']:checked").val();
if(value) {
format(value);
}
else {
window.alert(translate[lang]['select']);
}
return false;
}
function goback() {
format(parent);
}
$(document).ready(function(){
param = {};
str = window.location.search.substr(1);
if(str) {
pairs = str.split('&');
for (i=0; i<pairs.length; i++) {
part = pairs[i].split('=');
param[part[0]] = part[1];
}
}
if(param['lang'] && translate[param['lang']]) {
lang = param['lang'];
}
if(param['inst']) {
inst = '_' + param['inst'];
}
if(param['notitle'] && param['notitle']=='true') {
$('h1').hide();
}
$.getJSON( papagoUrl + "papago-" + lang + ".json")
.done(function( data ) {
papago = data;
$('#buttons').show();
format("0");
})
.fail(function(xhr, status, error) {
$('form').html(translate[lang]['error']);
console.log( error );
});
$('#question').on('click', '#sherpa', function() {
jTitle = $('#jsearch').val();
if (jTitle != '') {
sTitle = jTitle.replace('&','and');
$.ajax({
type: "GET",
crossDomain: true,
url: rapapi + 'title/' +jTitle})
.done(function(data) {
pattern = new RegExp(jTitle, 'gi');
jList = '<div class="list-group btn-group-vertical" role="group" style="max-width:1000px; width:100%">';
journals = data;
if (journals.length > 0) {
$.each( journals, function(index, journal){
issn = journal.issn;
if(issn) {
title = journal.title;
match = title.match(pattern);
if (match) {
title = title.replace(match[0], '<b>' + match +'</b>');
}
jList = jList + '<a class="list-group-item list-group-item-action btn" style="text-align:left; text-decoration:none; white-space:normal;" href="javascript:format(\'' + sheet + ':' + issn +'\')"><i class="fa fa-arrow-right"></i> ' + title + ' (ISSN: ' + issn + ')</a>';
}
});
jList = jList + '<a class="list-group-item list-group-item-action btn" style="text-align:left; text-decoration:none; white-space:normal;" href="javascript:format(\'' + sheet + ':jna\')"><i class="fa fa-arrow-right"></i> ' + translate[lang]['jDefault'] + '</a></div>';
$('div.list-group').remove();
$('#question').append(jList);
}
else {
$.ajax({
tpye: "GET",
crossDomain:true,
url: 'https://v2.sherpa.ac.uk/cgi/retrieve?item-type=publication&api-key=FF5C7B90-1032-11EA-9359-7FE62A6A9D3C&format=Json&filter=[["title","contains word","' + sTitle + '*"]]'})
.done(function(data) {
//jList = '<div class="list-group btn-group-vertical" role="group" style="max-width:1000px; width:100%">';
journals = data.items;
if(journals.length > 0) {
pattern = new RegExp(jTitle, 'gi');
$.each(journals, function(index, journal){
issn = journal['issns'][0]['issn'];
if (issn) {
title = journal['title'][0]['title'];
match = title.match(pattern);
if (match) {
title = title.replace(match[0], '<b>' + match +'</b>');
}
jList = jList + '<a class="list-group-item list-group-item-action btn" style="text-align:left; text-decoration:none; white-space:normal;" href="javascript:format(\'' + sheet + ':' + issn +'\')"><i class="fa fa-arrow-right"></i> ' + title + ' (ISSN: ' + issn + ')</a>';
}
});
}
jList = jList + '<a class="list-group-item list-group-item-action btn" style="text-align:left; text-decoration:none; white-space:normal;" href="javascript:format(\'' + sheet + ':jna\')"><i class="fa fa-arrow-right"></i> ' + translate[lang]['jDefault'] + '</a></div>';
$('div.list-group').remove();
$('#question').append(jList);
});
}
})
.fail(function(){
format(sheet + ':');
});
}
return false;
});
});
</script>
<div style="margin: 1rem">
<h1>Papago</h1>
<div id="question" style="margin-bottom: 1rem">
</div>
<div id="buttons" style="display:none">
<a id="back" href="javascript:goback();" class="btn btn-secondary btn-default" style="display:none; text-decoration:none"><i class="fa fa-chevron-left"></i> back</a>
<a id="restart" href="javascript:location.reload()" class="btn btn-secondary btn-default" style="display:none; text-decoration:none"><i class="fa fa-arrow-circle-o-left"></i> restart</a>
</div>
</div>
</body>
</html>