{
"translatorID": "d541622d-09c3-4e20-b010-c506b2d01151",
"label": "HUDOC",
"creator": "Jonas Skorzak",
"target": "^https?://hudoc\\.echr\\.coe\\.int",
"minVersion": "4.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2021-07-19 21:19:21"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2020 JONAS SKORZAK
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see .
***** END LICENSE BLOCK *****
*/
/*
Key guides for citation:
- French: https://www.echr.coe.int/documents/note_citation_fra.pdf
- English: https://www.echr.coe.int/documents/note_citation_eng.pdf
- OSCOLA: https://www.law.ox.ac.uk/sites/files/oxlaw/oscola_4th_edn_hart_2012.pdf#page=37&zoom=auto,-270,529
*/
/*
TODO:
- Handle friendly settlements (the addition to the case name)
- Handle more than judgments or decisions (summaries, translations, search results)
- Handle reports
- Handle resolutions and advisory opinions properly (esp. title)
- Handle different types of documents via the API.
- Use keywords for tags
- Use references to create "related" entries if they exist
- Put in short titles
=> All relate to one thing: This translator is currently unable to access the API
to query it for the taxonomies/thesauruses used for decision type ("typedescription"),
decision-making body ("originatingbody"), keywords ("kpthesaurus"), ...
Check compiled.js on the HUDOC website in order to learn how to query these aspects.
Search for "// ###..//sites/echr/echr.js ###"" in compiled.js to find most API fields.
*/
// After removing text(), eslint complains
/* eslint-disable no-undef */
// Scrapes some metadata from the document
// TODO: integrate function into scrape
function scrapeMetaData(doc, detail) { // Only scrapes the header of the main page
switch (detail) {
case "appno": return text(doc, "span.column01");
case "typedescription": return text(doc, "span.column02");
case "originatingbody": return text(doc, "span.column03");
case "judgementdate": return text(doc, "span.column04");
default: return null;
}
}
// Gets the itemid of the document
function getItemID(url) {
var urlRegex = /%22itemid%22:\[%22([\d-]*)%22]|\?i=([\d-]*)/i;
var id = url.match(urlRegex);
return id[1];
}
// Adds the type of judgment at the end of the name
function getTypeBit(doc, url) { // TODO: Switch to 'url' once we use the API instead
var description = scrapeMetaData(doc, "typedescription");
// The logic assumes the user wants French descriptors if they use the French website
if (url.includes("hudoc.echr.coe.int/fre#")) {
if (description.includes("Arrêt")) {
if (description.includes("satisfaction équitable") && !description.includes("au principal")) {
return " (satisfaction équitable)"; // Some papers use "(arrêt satisfaction équitable)"
}
if (description.includes("exception préliminaire") || description.includes("incompétence")) {
return " (exception préliminaire)";
}
if (description.includes("radiation du rôle")) return " (radiation)";
if (description.includes("interprétation")) return " (interprétation)";
if (description.includes("révision")) return " (révision)";
}
if (description.includes("Décision")) return " (déc.)";
if (description.includes("Affaire Communiquée")) return " (communiquée)"; // TODO: Rather use abbreviation?
if (description.includes("Révision")) return " (déc. de révision)"; // TODO: Rather use abbreviation?
return "";
// return " (" + description.split("(")[0].toLowerCase() + ")";
}
if (description.includes("Judgment")) {
if (description.includes("Just Satisfaction") && !description.includes("Merits")) {
return " (just satisfaction)";
}
if (description.includes("Objection") || description.includes("Jurisdiction")) {
return " (preliminary objections)";
}
// TODO: Distinguish " (friendly settlement)" and " (striking out)"
// Requires a queryMetaData function
if (description.includes("Struck out")) return " (striking out)";
if (description.includes("Interpretation")) return " (interpretation)";
if (description.includes("Revision")) return " (revision)";
return "";
}
if (description.includes("Decision")) return " (dec.)";
if (description.includes("Communicated")) return " (communicated)"; // TODO: Rather use abbreviation?
if (description.includes("Revision")) return " (dec. on revision)"; // TODO: Rather use abbreviation?
return "";
}
// Downloads the legal summary in HUDOC
function getLegalSummary(item, appno) {
var appnoString = appno.join(" AND appno:");
// Save the French version if user visited the French version of the judgment
var doctypeString = "";
if (item.language == "fre") {
doctypeString = "doctype:CLINF";
}
else {
doctypeString = "doctype:CLIN";
}
var summaryUrl = "https://hudoc.echr.coe.int/app/query/results?query=contentsitename=ECHR "
+ appnoString + " AND "
+ doctypeString + " AND "
+ "(kpdate=\"" + item.dateDecided + "\")"
+ "&select=itemid"
+ "&sort=&start=0&length=500";
// Request id of legal summary
ZU.doGet(summaryUrl, function (json) {
json = JSON.parse(json);
if (json.resultcount >= 1) {
var textUrl = "https://hudoc.echr.coe.int/app/conversion/docx/html/body?library=ECHR&id="
+ json.results[0].columns.itemid;
Zotero.debug("Getting text of legal summary at: " + textUrl);
// Request text of legal summary
ZU.doGet(textUrl, function (text) {
// Remove styles and span tags
text = text
.replace(/