This repository has been archived by the owner on Jan 3, 2020. It is now read-only.
forked from zotero/translators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJurPC.js
274 lines (250 loc) · 6.4 KB
/
JurPC.js
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
{
"translatorID": "b662c6eb-e478-46bd- bad4-23cdfd0c9d67",
"label": "JurPC",
"creator": "Oliver Vivell and Michael Berkowitz",
"target": "^https?://www\\.jurpc\\.de/jurpc/show\\?id=",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2015-01-02 18:03:03"
}
function detectWeb(doc, url) {
//prevent Zotero from throwing an error here
var firstLine = ZU.xpathText(doc, '//h2[1]');
if (firstLine.indexOf("Urteil vom") != -1 || firstLine.indexOf("Beschluss vom")!=-1) {
return "case";
}
else {
return "journalArticle";
}
}
function doWeb(doc, url) {
var articles = new Array();
if (detectWeb(doc, url) == "journalArticle") {
// Aufsatz gefunden
var item = new Zotero.Item('journalArticle');
// Authors and title are in h2-elements
var information = ZU.xpath(doc, '//h2');
var aus = information[0].textContent.split("/");
for (var i=0; i< aus.length ; i++) {
aus[i] = aus[i].replace(/\*/, "").trim();
item.creators.push(ZU.cleanAuthor(aus[i], "author"));
}
item.title = ZU.trimInternal(information[1].textContent);
var webdoktext = ZU.xpathText(doc, '//h3');
var year = webdoktext.match(/\/(\d{4}),/);
var webdok = webdoktext.match(/Dok. (\d+)\//);
if (year) item.year = year[1];
if (webdok && year) {
item.volume = "WebDok " + webdok[1] + "/" + year[1];
}
var doi = ZU.xpathText(doc, '//span[@class="resultinfo left"]')
if (doi != null) {
item.DOI = ZU.cleanDOI(doi);
}
item.journal = "JurPC";
item.url = url;
item.language = "de-DE";
item.attachments = [{
title: "JurPC Snapshot",
document: doc
}];
item.complete();
} else {
//Case
var item = new Zotero.Item('case');
// all information about the case are stored in h2-elements.
var information = doc.getElementsByTagName('h2');
var caseInformation = [];
for (var i=0; i<information.length; i++) {
caseInformation[i] = information[i].textContent;
}
// does the first row contain court, type of decision and date? Then clean up data!
var i = caseInformation[0].indexOf("Urteil vom");
if (i == -1) i = caseInformation[0].indexOf("Beschluss vom")
if (i != -1) {
caseInformation.splice(1, 0, caseInformation[0].substr(i));
caseInformation[0] = caseInformation[0].substring(0, i);
}
item.title = caseInformation[3];
item.court = caseInformation[0];
item.docketNumber = caseInformation[2];
item.reporter = "JurPC WebDok";
var cite = ZU.xpathText(doc, '//h3');
var year = cite.match(/\/(\d{4})/);
var webdok = cite.match(/Dok. (\d+)\//);
if (webdok && year) {
item.reporterVolume = " " + webdok[1] + "/" + year[1];
}
item.url = url;
var date = caseInformation[1].match(/\b(\d{1,2})\.\s*(\d{1,2})\.\s*(\d{4})\b/);
if (date) {
item.dateDecided = date[3] + "-" + date[2] + "-" + date[1];
}
// store type of decision
if (/Beschluss./i.test(caseInformation[1])) {
item.extra = "{:genre: Beschl.}";
}
else if (/Urteil/i.test(caseInformation[1])) {
item.extra = "{:genre: Urt.}";
}
var doi = ZU.xpathText(doc, '//span[@class="resultinfo left"]')
if (doi) {
item.DOI = ZU.cleanDOI(doi);
}
item.language = "de-DE";
item.attachments = [{
title: "JurPC Snapshot",
document: doc
}];
item.complete();
}
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "http://www.jurpc.de/jurpc/show?id=20110132",
"items": [
{
"itemType": "journalArticle",
"title": "Die datenschutzrechtliche Einwilligung des Beschäftigten",
"creators": [
{
"firstName": "Johannes",
"lastName": "Habermalz",
"creatorType": "author"
}
],
"DOI": "10.7328/jurpcb/2011268130",
"language": "de-DE",
"libraryCatalog": "JurPC",
"url": "http://www.jurpc.de/jurpc/show?id=20110132",
"volume": "WebDok 132/2011",
"attachments": [
{
"title": "JurPC Snapshot"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://www.jurpc.de/jurpc/show?id=20000220",
"items": [
{
"itemType": "case",
"caseName": "OEM-Version",
"creators": [],
"dateDecided": "2000-07-06",
"court": "BGH",
"docketNumber": "I ZR 244/97",
"extra": "{:genre: Urt.}",
"language": "de-DE",
"reporter": "JurPC WebDok",
"reporterVolume": "220/2000",
"url": "http://www.jurpc.de/jurpc/show?id=20000220",
"attachments": [
{
"title": "JurPC Snapshot"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://www.jurpc.de/jurpc/show?id=20140193",
"items": [
{
"itemType": "case",
"caseName": "Zur Haftung des Domainregistrars für Domaininhalte",
"creators": [],
"dateDecided": "2014-10-22",
"court": "Saarländisches Oberlandesgericht",
"docketNumber": "1 U 25/14",
"extra": "{:genre: Urt.}",
"language": "de-DE",
"reporter": "JurPC WebDok",
"reporterVolume": "193/2014",
"url": "http://www.jurpc.de/jurpc/show?id=20140193",
"attachments": [
{
"title": "JurPC Snapshot"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://www.jurpc.de/jurpc/show?id=20140165",
"items": [
{
"itemType": "case",
"caseName": "Deus Ex",
"creators": [],
"dateDecided": "2014-05-15",
"court": "BGH",
"docketNumber": "I ZB 71/13",
"extra": "{:genre: Beschl.}",
"language": "de-DE",
"reporter": "JurPC WebDok",
"reporterVolume": "165/2014",
"url": "http://www.jurpc.de/jurpc/show?id=20140165",
"attachments": [
{
"title": "JurPC Snapshot"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://www.jurpc.de/jurpc/show?id=20140194",
"items": [
{
"itemType": "journalArticle",
"title": "Tagungsbericht über den 3. IT-Rechtstag in Frankfurt am Main",
"creators": [
{
"firstName": "Wolfgang",
"lastName": "Kuntz",
"creatorType": "author"
}
],
"DOI": "10.7328/jurpcb20142912190",
"language": "de-DE",
"libraryCatalog": "JurPC",
"url": "http://www.jurpc.de/jurpc/show?id=20140194",
"volume": "WebDok 194/2014",
"attachments": [
{
"title": "JurPC Snapshot"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
}
]
/** END TEST CASES **/