9
9
"inRepository" : true ,
10
10
"translatorType" : 4 ,
11
11
"browserSupport" : "gcsib" ,
12
- "lastUpdated" : "2014-06-24 10:16:52 "
12
+ "lastUpdated" : "2014-07-01 19:40:02 "
13
13
}
14
- /*
15
14
15
+ /*
16
16
Publications du Québec Translator
17
17
Copyright (C) 2014 Marc Lajoie
18
18
@@ -28,72 +28,68 @@ GNU General Public License for more details.
28
28
29
29
You should have received a copy of the GNU General Public License
30
30
along with this program. If not, see <http://www.gnu.org/licenses/>.
31
-
32
- +*/
33
-
34
- var pubqcRegexp = / h t t p s ? : \/ \/ (?: w w w 2 \. ) ? p u b l i c a t i o n s d u q u e b e c \. g o u v \. q c \. c a \/ d y n a m i c S e a r c h \/ t e l e c h a r g e \. p h p \? / ;
31
+ */
35
32
36
33
function getMultiple ( doc , checkOnly ) {
37
- var res = ZU . xpath ( doc , '//span[@class="texteNormalBleuB"]/a[2]' ) ;
38
- if ( ! res . length ) return false ;
39
- if ( checkOnly ) return true ;
34
+ var res = ZU . xpath ( doc , '//span[@class="texteNormalBleuB"]/a[2]' ) ;
35
+ if ( ! res . length ) return false ;
36
+ if ( checkOnly ) return true ;
40
37
41
- var items = { } ;
42
- for ( var i = 0 ; i < res . length ; i ++ ) {
43
- items [ res [ i ] . href ] = ZU . trimInternal ( res [ i ] . textContent ) ;
44
- }
38
+ var items = { } ;
39
+ for ( var i = 0 ; i < res . length ; i ++ ) {
40
+ items [ res [ i ] . href ] = ZU . trimInternal ( res [ i ] . textContent ) ;
41
+ }
45
42
46
- return items ;
43
+ return items ;
47
44
}
48
45
49
46
function detectWeb ( doc , url ) {
50
- if ( pubqcRegexp . test ( url ) ) {
47
+ if ( url . indexOf ( '/dynamicSearch/telecharge.php?' ) != - 1 ) {
51
48
return "statute" ;
52
49
} else if ( getMultiple ( doc , true ) ) {
53
- return "multiple" ;
54
- }
55
-
50
+ return "multiple" ;
56
51
}
57
52
53
+ }
58
54
59
55
function scrape ( doc , url ) {
60
-
61
56
var newItem = new Zotero . Item ( "statute" ) ;
57
+
58
+ var titleloi = doc . getElementsByClassName ( 'Titreloi' ) [ 0 ]
59
+ || doc . getElementsByClassName ( 'Titrereg' ) [ 0 ] ;
60
+ titleloi = ZU . trimInternal ( titleloi . textContent ) ;
62
61
63
- var titleloi = doc . getElementsByClassName ( 'Titreloi' ) [ 0 ] || doc . getElementsByClassName ( 'Titrereg' ) [ 0 ] ;
64
- titleloi = ZU . trimInternal ( titleloi . textContent ) ;
65
- var codeloi = doc . getElementsByClassName ( 'Alpha' ) [ 0 ] || doc . getElementsByClassName ( 'Libelle' ) [ 0 ] ;
62
+ var codeloi = doc . getElementsByClassName ( 'Alpha' ) [ 0 ]
63
+ || doc . getElementsByClassName ( 'Libelle' ) [ 0 ] ;
66
64
codeloi = ZU . trimInternal ( codeloi . textContent ) ;
67
-
68
- newItem . title = titleloi ;
69
-
70
- if ( codeloi . indexOf ( "chapitre" ) != - 1 ) {
71
- newItem . language = "fr-CA" ;
72
- codeloi = codeloi . replace ( "chapitre" , "c" ) ;
73
- newItem . code = "RLRQ " + codeloi ;
65
+
66
+ newItem . title = titleloi ;
67
+
68
+ if ( codeloi . indexOf ( "chapitre" ) != - 1 ) {
69
+ newItem . language = "fr-CA" ;
70
+ codeloi = codeloi . replace ( "chapitre" , "c" ) ;
71
+ newItem . code = "RLRQ " + codeloi ;
74
72
} else {
75
- newItem . language = "en-CA" ;
76
- codeloi = codeloi . replace ( "chapter" , "c" ) ;
77
- newItem . code = "CQLR " + codeloi ;
73
+ newItem . language = "en-CA" ;
74
+ codeloi = codeloi . replace ( "chapter" , "c" ) ;
75
+ newItem . code = "CQLR " + codeloi ;
78
76
}
79
-
80
- newItem . rights = "© Éditeur officiel du Québec" ;
81
-
82
- newItem . jurisdiction = "Québec, Canada" ;
83
- newItem . url = url ;
77
+
78
+ newItem . rights = "© Éditeur officiel du Québec" ;
79
+
80
+ newItem . jurisdiction = "Québec, Canada" ;
81
+ newItem . url = url ;
84
82
85
83
newItem . attachments . push ( {
86
84
document : doc ,
87
85
title : "Snapshot"
88
86
} ) ;
89
-
90
87
91
-
92
88
newItem . complete ( ) ;
93
89
}
94
90
95
91
function doWeb ( doc , url ) {
96
- if ( pubqcRegexp . test ( url ) ) {
92
+ if ( url . indexOf ( '/dynamicSearch/telecharge.php?' ) != - 1 ) {
97
93
scrape ( doc , url ) ;
98
94
} else {
99
95
var items = getMultiple ( doc ) ;
@@ -113,7 +109,7 @@ function doWeb(doc, url) {
113
109
var testCases = [
114
110
{
115
111
"type" : "web" ,
116
- "url" : "http://www2.publicationsduquebec.gouv.qc.ca/home .php" ,
112
+ "url" : "http://www2.publicationsduquebec.gouv.qc.ca/lois_et_reglements/liste_alpha .php" ,
117
113
"items" : "multiple"
118
114
} ,
119
115
{
@@ -122,23 +118,20 @@ var testCases = [
122
118
"items" : [
123
119
{
124
120
"itemType" : "statute" ,
121
+ "nameOfAct" : "Loi sur le Barreau" ,
125
122
"creators" : [ ] ,
126
- "notes" : [ ] ,
127
- "tags" : [ ] ,
128
- "seeAlso" : [ ] ,
123
+ "code" : "RLRQ c B-1" ,
124
+ "language" : "fr-CA" ,
125
+ "rights" : "© Éditeur officiel du Québec" ,
126
+ "url" : "http://www2.publicationsduquebec.gouv.qc.ca/dynamicSearch/telecharge.php?type=2&file=/B_1/B1.html" ,
129
127
"attachments" : [
130
128
{
131
129
"title" : "Snapshot"
132
130
}
133
131
] ,
134
- "language" : "fr-CA" ,
135
- "title" : "Loi sur le Barreau" ,
136
- "code" : "RLRQ c B-1" ,
137
- "rights" : "© Éditeur officiel du Québec" ,
138
- "jurisdiction" : "Québec, Canada" ,
139
- "url" : "http://www2.publicationsduquebec.gouv.qc.ca/dynamicSearch/telecharge.php?type=2&file=/B_1/B1.html" ,
140
- "libraryCatalog" : "PublicationsduQuébec" ,
141
- "accessDate" : "CURRENT_TIMESTAMP"
132
+ "tags" : [ ] ,
133
+ "notes" : [ ] ,
134
+ "seeAlso" : [ ]
142
135
}
143
136
]
144
137
} ,
@@ -148,23 +141,20 @@ var testCases = [
148
141
"items" : [
149
142
{
150
143
"itemType" : "statute" ,
144
+ "nameOfAct" : "An Act respecting the Barreau du Québec" ,
151
145
"creators" : [ ] ,
152
- "notes" : [ ] ,
153
- "tags" : [ ] ,
154
- "seeAlso" : [ ] ,
146
+ "code" : "CQLR c B-1" ,
147
+ "language" : "en-CA" ,
148
+ "rights" : "© Éditeur officiel du Québec" ,
149
+ "url" : "http://www2.publicationsduquebec.gouv.qc.ca/dynamicSearch/telecharge.php?type=2&file=/B_1/B1_A.html" ,
155
150
"attachments" : [
156
151
{
157
152
"title" : "Snapshot"
158
153
}
159
154
] ,
160
- "language" : "en-CA" ,
161
- "title" : "An Act respecting the Barreau du Québec" ,
162
- "code" : "CQLR c B-1" ,
163
- "rights" : "© Éditeur officiel du Québec" ,
164
- "jurisdiction" : "Québec, Canada" ,
165
- "url" : "http://www2.publicationsduquebec.gouv.qc.ca/dynamicSearch/telecharge.php?type=2&file=/B_1/B1_A.html" ,
166
- "libraryCatalog" : "PublicationsduQuébec" ,
167
- "accessDate" : "CURRENT_TIMESTAMP"
155
+ "tags" : [ ] ,
156
+ "notes" : [ ] ,
157
+ "seeAlso" : [ ]
168
158
}
169
159
]
170
160
} ,
@@ -174,23 +164,20 @@ var testCases = [
174
164
"items" : [
175
165
{
176
166
"itemType" : "statute" ,
167
+ "nameOfAct" : "Code de déontologie des avocats" ,
177
168
"creators" : [ ] ,
178
- "notes" : [ ] ,
179
- "tags" : [ ] ,
180
- "seeAlso" : [ ] ,
169
+ "code" : "RLRQ c B-1, r. 3" ,
170
+ "language" : "fr-CA" ,
171
+ "rights" : "© Éditeur officiel du Québec" ,
172
+ "url" : "http://www2.publicationsduquebec.gouv.qc.ca/dynamicSearch/telecharge.php?type=3&file=/B_1/B1R3.HTM" ,
181
173
"attachments" : [
182
174
{
183
175
"title" : "Snapshot"
184
176
}
185
177
] ,
186
- "language" : "fr-CA" ,
187
- "title" : "Code de déontologie des avocats" ,
188
- "code" : "RLRQ c B-1, r. 3" ,
189
- "rights" : "© Éditeur officiel du Québec" ,
190
- "jurisdiction" : "Québec, Canada" ,
191
- "url" : "http://www2.publicationsduquebec.gouv.qc.ca/dynamicSearch/telecharge.php?type=3&file=/B_1/B1R3.HTM" ,
192
- "libraryCatalog" : "PublicationsduQuébec" ,
193
- "accessDate" : "CURRENT_TIMESTAMP"
178
+ "tags" : [ ] ,
179
+ "notes" : [ ] ,
180
+ "seeAlso" : [ ]
194
181
}
195
182
]
196
183
} ,
@@ -200,25 +187,22 @@ var testCases = [
200
187
"items" : [
201
188
{
202
189
"itemType" : "statute" ,
190
+ "nameOfAct" : "Code of ethics of advocates" ,
203
191
"creators" : [ ] ,
204
- "notes" : [ ] ,
205
- "tags" : [ ] ,
206
- "seeAlso" : [ ] ,
192
+ "code" : "CQLR c B-1, r. 3" ,
193
+ "language" : "en-CA" ,
194
+ "rights" : "© Éditeur officiel du Québec" ,
195
+ "url" : "http://www2.publicationsduquebec.gouv.qc.ca/dynamicSearch/telecharge.php?type=3&file=/B_1/B1R3_A.HTM" ,
207
196
"attachments" : [
208
197
{
209
198
"title" : "Snapshot"
210
199
}
211
200
] ,
212
- "language" : "en-CA" ,
213
- "title" : "Code of ethics of advocates" ,
214
- "code" : "CQLR c B-1, r. 3" ,
215
- "rights" : "© Éditeur officiel du Québec" ,
216
- "jurisdiction" : "Québec, Canada" ,
217
- "url" : "http://www2.publicationsduquebec.gouv.qc.ca/dynamicSearch/telecharge.php?type=3&file=/B_1/B1R3_A.HTM" ,
218
- "libraryCatalog" : "PublicationsduQuébec" ,
219
- "accessDate" : "CURRENT_TIMESTAMP"
201
+ "tags" : [ ] ,
202
+ "notes" : [ ] ,
203
+ "seeAlso" : [ ]
220
204
}
221
205
]
222
206
}
223
207
]
224
- /** END TEST CASES **/
208
+ /** END TEST CASES **/
0 commit comments