Skip to content

Commit

Permalink
Bugfix (#3)
Browse files Browse the repository at this point in the history
* Remove language from bilingual cases

* Bugfix
  • Loading branch information
sam-gagnon authored Sep 29, 2021
1 parent f570e2f commit b16cdfd
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions CanLII.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2021-07-09 20:04:55"
"lastUpdated": "2021-09-20 13:59:26"
}

/*
Expand Down Expand Up @@ -753,7 +753,7 @@ function caseBilingual(item,bilingual) {
altCitationString = createMainCitationString(altDoc);
altOtherCitationString = createOtherCitationString(altDoc);
altCaseName = caseTitle(altCitationString);
ZU.setMultiField(item,"caseName", altCaseName,altLang,item.language)
ZU.setMultiField(item,"caseName", altCaseName,altLang,item.language);
if (item.itemID && item.reporter) {
var referenceArray = [];
buildReferenceArray(altCitationString,referenceArray);
Expand All @@ -764,6 +764,7 @@ function caseBilingual(item,bilingual) {
altReporter = altReference.match(referenceRegex)[4];
ZU.setMultiField(item,"reporter", altReporter,altLang,item.language)
}
item.language = "";
item.complete();
});
}
Expand Down Expand Up @@ -917,15 +918,15 @@ function statuteReference(doc, url) {
// 1 : nameOfAct
// 2 : code
// 3 : dateEnacted
// 4 : publicLawNumber
// 5 : codeNumber
// 4 : codeNumber
// 5 : publicLawNumber

var infoParts = metaInfo.match(statuteRegex);
ZU.setMultiField(item,"nameOfAct", infoParts[1],item.language,item.language);
ZU.setMultiField(item,"code", infoParts[2],item.language,item.language);
if (infoParts[3]) item.dateEnacted = infoParts[3];
item.publicLawNumber = infoParts[4];
if (infoParts[5]) item.codeNumber = infoParts[5];
item.codeNumber = infoParts[4];
if (infoParts[5]) item.publicLawNumber = infoParts[5];
item.url = doc.querySelector('.documentStaticUrl a');
item.jurisdiction = findJurisdiction(url);
var bilingual = doc.getElementById('languageSwitch');
Expand All @@ -941,12 +942,12 @@ function statuteBilingual(item,bilingual) {
var altLang = caseAltLang(item);
var altLangUrl = 'https://www.canlii.org/'+attr(bilingual, '.canlii', 'href', 0);
Zotero.Utilities.processDocuments(altLangUrl, function(altDoc) {
var statuteRegex = /^([\s\S]+?)\,\s(\w+)(?:\s(\d+)\,)?\sc\s([\s\S]+?)?(?:\s\((\d)\w+\s\w+\))?$/;
var statuteRegex = /^([\s\S]+?)\,\s([\w\-]+)(?:\s(\d+)\,)?\sc\s([\s\S]+?)?(?:\s\((\d)\w+\s\w+\))?$/
// 1 : nameOfAct
// 2 : code
// 3 : dateEnacted
// 4 : publicLawNumber
// 5 : codeNumber
// 4 : codeNumber
// 5 : publiclawNumber

var altMetaInfo = ZU.trimInternal(ZU.xpathText(altDoc, '//*[@id="documentContainer"]/div[2]/h2'))
var altInfoParts = altMetaInfo.match(statuteRegex);
Expand Down Expand Up @@ -1020,6 +1021,7 @@ function regulationBilingual(item,bilingual) {




/** BEGIN TEST CASES **/
var testCases = [
{
Expand Down

0 comments on commit b16cdfd

Please sign in to comment.