forked from zotero/translators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Access Engineering.js
384 lines (373 loc) · 14.1 KB
/
Access Engineering.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
{
"translatorID": "d120a8a7-9d45-446e-8c18-ad9ef0a6bf47",
"label": "Access Engineering",
"creator": "Vinoth K - highwirepress.com",
"target": "^https?://www\\.accessengineeringlibrary\\.com/",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2023-09-09 09:42:36"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2020-2021 Vinoth K - highwirepress.com
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 <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
function detectWeb(doc, url) {
let title = attr(doc, 'meta[name="citation_title"]', 'content');
if (title) {
if (doc.querySelector('meta[name="citation_isbn"]')) {
let bookTitle = attr(doc, 'meta[name="citation_book_title"]', 'content');
if (!bookTitle || title == bookTitle) {
return "book";
}
else {
return "bookSection";
}
}
else if (url.includes('content/video/')) {
return 'videoRecording';
}
else {
return "journalArticle";
}
}
else if (getSearchResults(doc, true)) {
return "multiple";
}
return false;
}
function getSearchResults(doc, checkOnly) {
var items = {};
var found = false;
var rows = doc.querySelectorAll('.results-item a[href]');
for (let row of rows) {
let href = row.href;
let title = ZU.trimInternal(row.textContent);
if (!href || !title) continue;
if (checkOnly) return true;
found = true;
items[href] = title;
}
return found ? items : false;
}
function doWeb(doc, url) {
if (detectWeb(doc, url) == "multiple") {
Zotero.selectItems(getSearchResults(doc, false), function (items) {
if (items) ZU.processDocuments(Object.keys(items), scrape);
});
}
else {
scrape(doc, url);
}
}
function scrape(doc, url) {
// Missing editions for books and books chapter page
// Removed html element in abstract for video and tutorial page
// Author not updating in metatag correctly from data and read
// client advised to split and handled through custom data attr/obj
// - so we'll fill those in manually.
var translator = Zotero.loadTranslator('web');
// Embedded Metadata
translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48');
translator.setDocument(doc);
translator.setHandler('itemDone', function (obj, item) {
// Edition
let edition = ZU.xpathText(doc, '//meta[@name="citation_edition"]/@content');
if (edition) item.edition = edition;
// Author
// Some of old pages not having firstname, lastname seperation in markup and ignore if not
let author = doc.querySelectorAll("ul.contributor-list > [data-firstnames]");
item.creators = [];
for (let i = 0; i < author.length; i++) {
let creatorData = author[i].dataset;
item.creators.push({
firstName: creatorData.firstnames,
lastName: creatorData.surname,
creatorType: creatorData.authortype
});
}
// Abstract
let abstractNote = ZU.xpathText(doc, '//meta[@name="citation_abstract"]/@content');
if (abstractNote) item.abstractNote = ZU.cleanTags(abstractNote);
item.complete();
});
translator.getTranslatorObject(function (trans) {
// Detect web not get trigger for scape EM translator
// - so wll fill those in manually.
trans.itemType = detectWeb(doc, url);
trans.doWeb(doc, url);
});
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "https://www.accessengineeringlibrary.com/content/book/9781259860225",
"items": [
{
"itemType": "book",
"title": "Handbook of Environmental Engineering",
"creators": [
{
"firstName": "Rao Y.",
"lastName": "Surampalli",
"creatorType": "editor"
},
{
"firstName": "Tian C.",
"lastName": "Zhang",
"creatorType": "editor"
},
{
"firstName": "Satinder Kaur",
"lastName": "Brar",
"creatorType": "editor"
},
{
"firstName": "Krishnamoorthy",
"lastName": "Hegde",
"creatorType": "editor"
},
{
"firstName": "Rama",
"lastName": "Pulicharla",
"creatorType": "editor"
},
{
"firstName": "Mausam",
"lastName": "Verma",
"creatorType": "editor"
}
],
"date": "2018",
"ISBN": "9781259860225",
"abstractNote": "A complete guide to environmental regulations and remediation.This practical resource offers thorough coverage of current environmental issues and policies along with step-by-step remediation procedures. With contributions from dozens of industry-recognized experts, Handbook of Environmental Engineering features information on all segments of the market—including water and air quality and hazardous waste—and enables you to ensure compliance with all applicable regulations. You will get details about sensors, monitoring, and toxicity treatment and controls as well as waste management and safe disposal. Real-world examples demonstrate how to apply techniques and achieve compliance, while environmental impact assessments and measurement data enhance the book9s utility.Coverage includes:• Environmental legislation• Environmental impact assessments• Air pollution control and management• Potable water treatment• Wastewater treatment and reuse• Solid waste management• Hazardous waste management• Emerging wastes in the environment• Environmental monitoring and measurements",
"edition": "1st Edition",
"language": "en",
"libraryCatalog": "www.accessengineeringlibrary.com",
"publisher": "McGraw-Hill Education",
"url": "https://www.accessengineeringlibrary.com/content/book/9781259860225",
"attachments": [
{
"title": "Full Text PDF",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.accessengineeringlibrary.com/content/book/9781259860225/toc-chapter/chapter3/section/section1",
"items": [
{
"itemType": "bookSection",
"title": "CHAPTER PRELIMINARIES",
"creators": [
{
"firstName": "Ashok",
"lastName": "Kumar",
"creatorType": "author"
},
{
"firstName": "Hamid",
"lastName": "Omidvarborna",
"creatorType": "author"
},
{
"firstName": "Rao Y.",
"lastName": "Surampalli",
"creatorType": "editor"
},
{
"firstName": "Tian C.",
"lastName": "Zhang",
"creatorType": "editor"
},
{
"firstName": "Satinder Kaur",
"lastName": "Brar",
"creatorType": "editor"
},
{
"firstName": "Krishnamoorthy",
"lastName": "Hegde",
"creatorType": "editor"
},
{
"firstName": "Rama",
"lastName": "Pulicharla",
"creatorType": "editor"
},
{
"firstName": "Mausam",
"lastName": "Verma",
"creatorType": "editor"
}
],
"date": "2018",
"ISBN": "9781259860225",
"abstractNote": "A complete guide to environmental regulations and remediation.This practical resource offers thorough coverage of current environmental issues and policies along with step-by-step remediation procedures. With contributions from dozens of industry-recognized experts, Handbook of Environmental Engineering features information on all segments of the market—including water and air quality and hazardous waste—and enables you to ensure compliance with all applicable regulations. You will get details about sensors, monitoring, and toxicity treatment and controls as well as waste management and safe disposal. Real-world examples demonstrate how to apply techniques and achieve compliance, while environmental impact assessments and measurement data enhance the book's utility.Coverage includes:• Environmental legislation• Environmental impact assessments• Air pollution control and management• Potable water treatment• Wastewater treatment and reuse• Solid waste management• Hazardous waste management• Emerging wastes in the environment• Environmental monitoring and measurements",
"bookTitle": "Handbook of Environmental Engineering",
"language": "en",
"libraryCatalog": "www.accessengineeringlibrary.com",
"publisher": "McGraw-Hill Education",
"url": "https://www.accessengineeringlibrary.com/content/book/9781259860225/toc-chapter/chapter3/section/section1",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.accessengineeringlibrary.com/content/video/V4005352521001",
"items": [
{
"itemType": "videoRecording",
"title": "123D Design: Cut Text Through a Plane",
"creators": [],
"date": "2014",
"abstractNote": "This video shows how to cut text through a plane with Combine/Subtract.",
"language": "en",
"libraryCatalog": "www.accessengineeringlibrary.com",
"shortTitle": "123D Design",
"studio": "McGraw-Hill Education",
"url": "https://www.accessengineeringlibrary.com/content/video/V4005352521001",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.accessengineeringlibrary.com/content/calculator/S0071_Basic_Transformer_Calculations",
"items": [
{
"itemType": "journalArticle",
"title": "Basic Transformer Calculations",
"creators": [
{
"firstName": "Bhagyalakshmi",
"lastName": "Kerekare",
"creatorType": "author"
}
],
"date": "2022/06/25/",
"abstractNote": "This Excel workbook contains four worksheets. The first worksheet covers the basic concepts of single phase transformer such as turns ratio, primary current, secondary current, primary voltage, secondary voltage, and transformer ratio calculations. The second worksheet covers the basic concepts of power, efficiency, primary/secondary EMF and transformer rating calculations. The third worksheet covers the basic concepts of three phase transformers, highlighting the star and delta connections. Calculations are done for phase voltage, phase current, line voltage, and line current for star and delta connections. The fourth worksheet covers the basic concepts kVA Ratings, 3-phase primary, and secondary full load current 3-phase voltage calculations.",
"language": "en",
"libraryCatalog": "www.accessengineeringlibrary.com",
"url": "https://www.accessengineeringlibrary.com/content/calculator/S0071_Basic_Transformer_Calculations",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.accessengineeringlibrary.com/content/case-study/CS0004_Atrial_Fibrillation",
"items": [
{
"itemType": "journalArticle",
"title": "Atrial Fibrillation: Improving Therapy via Engineering Advancements",
"creators": [
{
"firstName": "Michael J.",
"lastName": "Rust",
"creatorType": "author"
}
],
"date": "2020-04-23",
"abstractNote": "This case will explore atrial fibrillation from several perspectives, including the underlying physiology, clinical relevance, and instrumentation used for diagnosis and therapy. Students will identify and investigate unmet clinical needs that led to recent developments in technologies to treat atrial fibrillation.",
"language": "en",
"libraryCatalog": "www.accessengineeringlibrary.com",
"shortTitle": "Atrial Fibrillation",
"url": "https://www.accessengineeringlibrary.com/content/case-study/CS0004_Atrial_Fibrillation",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.accessengineeringlibrary.com/content/tutorial/T0004_Partially_Full_Pipe_Flow_Calculations_Using_Excel_Spreadsheets",
"items": [
{
"itemType": "journalArticle",
"title": "Partially Full Pipe Flow Calculations Using Excel Spreadsheets",
"creators": [
{
"firstName": "Harlan H.",
"lastName": "Bengtson",
"creatorType": "author"
}
],
"date": "2014/02/01/",
"abstractNote": "This tutorial provides discussion of, and illustration by, examples for use of an Excel spreadsheet for making a variety of calculations for the flow of water in a partially full circular pipe using the Manning Equation. Equations for calculating area, wetted perimeter, and hydraulic radius for partially full pipe flow are included in this tutorial along with a brief review of the Manning Equation and discussion of its use to calculate a) the flow rate in a given pipe (given diameter, slope, & Manning roughness) at a specified depth of flow, b) the required diameter for a specified flow rate at a target percent full in a given pipe, and c) the normal depth (depth of flow) for a specified flow rate in a given pipe. This includes presentation and discussion of the equations for the calculations, example calculations, and screenshots of spreadsheets to facilitate the calculations.",
"language": "en",
"libraryCatalog": "www.accessengineeringlibrary.com",
"url": "https://www.accessengineeringlibrary.com/content/tutorial/T0004_Partially_Full_Pipe_Flow_Calculations_Using_Excel_Spreadsheets",
"attachments": [
{
"title": "Snapshot",
"mimeType": "text/html"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.accessengineeringlibrary.com/search?query=&f%5B0%5D=content_type%3ABooks&f%5B1%5D=book_component%3ATitles",
"items": "multiple"
}
]
/** END TEST CASES **/