summaryrefslogtreecommitdiff
path: root/Pion Journals.js
blob: 49317d438fd95d3b92e865516705c862bc790014 (plain)
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
{
	"translatorID": "291934d5-36ec-4b81-ac9c-c5ad5313dba4",
	"label": "Pion Journals",
	"creator": "Michael Berkowitz",
	"target": "http://(www.)?(hthpweb|envplan|perceptionweb)\\.com/",
	"minVersion": "1.0.0b4.r5",
	"maxVersion": "",
	"priority": 100,
	"inRepository": true,
	"translatorType": 4,
	"browserSupport": "gcsibv",
	"lastUpdated": "2014-02-09 12:26:39"
}

function detectWeb(doc, url) {
	if (url.match(/search\.cgi/) || url.match(/ranking/) || url.match(/volume=/)) {
		return "multiple";
	} else if (url.match(/abstract\.cgi/)) {
		return "journalArticle";
	}
}

function doWeb(doc, url) {
	if (detectWeb(doc, url) == "multiple") {
		var items = Zotero.Utilities.getItemArray(doc, doc, "abstract.cgi\\?id=");
		var arts = new Array();	
		
		Zotero.selectItems(items, function (items) {
			if (!items) {
				return true;
			}
			for (var i in items) {
				arts.push(i);
			}
			Zotero.Utilities.processDocuments(arts, scrape, function () {
				Zotero.done();
			});
			Zotero.wait();	
		});
	}
		 else {
		scrape(doc, url)
	}
}
function scrape(doc, url){
		var item = new Zotero.Item("journalArticle");
		item.publicationTitle = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="footer"]/div[@class="left"]/i', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
		item.title = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="total"]/p[2]//b', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
		var authors = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="total"]/p[3]/b', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent).split(/,\s*/);
		for each (var aut in authors) {
			item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author"));
		}
		if (doc.evaluate('//div[@id="title"]/div[@class="left"]/font', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/\d+/)) {
			var voliss = doc.evaluate('//div[@id="title"]/div[@class="left"]/font', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/(\d+)\s+volume\s+(\d+)\s*\((\d+)\)\s+(pages\s+(.*))?$/);
			//Zotero.debug(voliss);
			item.date = voliss[1];
			item.volume = voliss[2];
			item.issue = voliss[3];
			if (voliss[5]) item.pages = voliss[5];
		} else {
			item.date = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="total"]/p[4]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent).match(/(\d+)$/)[1];
		}
		item.DOI = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="title"]/div[@class="right"]/font', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent).substr(4);
		
		if (doc.evaluate('//a[contains(@href, ".pdf")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) var pdfurl = doc.evaluate('//a[contains(@href, ".pdf")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href;
		item.url = doc.location.href;
		var pub = item.publicationTitle;
		item.attachments = [{url:item.url, title:pub + " Snapshot", mimeType:"text/html"}];
		if (pdfurl) item.attachments.push({url:pdfurl, title:pub + " Full Text PDF", mimeType:"application/pdf"});
		item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="total"]/p[5]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent).substr(10);
		item.complete();
	}
/** BEGIN TEST CASES **/
var testCases = [
	{
		"type": "web",
		"url": "http://www.perceptionweb.com/abstract.cgi?id=p6018",
		"items": [
			{
				"itemType": "journalArticle",
				"creators": [
					{
						"firstName": "Sven",
						"lastName": "Vrins",
						"creatorType": "author"
					},
					{
						"firstName": "Tessa C. J. de",
						"lastName": "Wit",
						"creatorType": "author"
					},
					{
						"firstName": "Rob van",
						"lastName": "Lier",
						"creatorType": "author"
					}
				],
				"notes": [],
				"tags": [],
				"seeAlso": [],
				"attachments": [
					{
						"title": "Perception Snapshot",
						"mimeType": "text/html"
					},
					{
						"title": "Perception Full Text PDF",
						"mimeType": "application/pdf"
					}
				],
				"publicationTitle": "Perception",
				"title": "Bricks, butter, and slices of cucumber: Investigating semantic influences in amodal completion",
				"date": "2009",
				"volume": "38",
				"issue": "1",
				"pages": "17 – 29",
				"DOI": "10.1068/p6018",
				"url": "http://www.perceptionweb.com/abstract.cgi?id=p6018",
				"abstractNote": "Objects in our world are partly occluded by other objects or sometimes even partly by themselves. Amodal completion is a visual process that enables us to perceive these objects as complete and is influenced by both local object information, present at contour intersections, and overall (global) object shape. In contrast, object semantics have been demonstrated to play no role in amodal completion but do so only by means of subjective methods. In the present study, object semantics were operationalised by material hardness of familiar objects which was varied to test whether it leaves amodal completion unaffected. Specifically, we investigated the perceived form of joined naturalistic objects that differ in perceived material hardness, employing the primed matching paradigm. In experiments 1 and 2, probing three different prime durations, amodal completion of a notched circular object changes systematically with the hardness of the object it was joined to. These results are in line with the view that amodal completion is inseparable from general object interpretation, during which object semantics may dominate.",
				"libraryCatalog": "Pion Journals",
				"accessDate": "CURRENT_TIMESTAMP",
				"shortTitle": "Bricks, butter, and slices of cucumber"
			}
		]
	},
	{
		"type": "web",
		"url": "http://www.envplan.com/abstract.cgi?id=a311901",
		"items": [
			{
				"itemType": "journalArticle",
				"creators": [
					{
						"firstName": "P. J.",
						"lastName": "Taylor",
						"creatorType": "author"
					}
				],
				"notes": [],
				"tags": [],
				"seeAlso": [],
				"attachments": [
					{
						"title": "Environment and Planning A Snapshot",
						"mimeType": "text/html"
					},
					{
						"title": "Environment and Planning A Full Text PDF",
						"mimeType": "application/pdf"
					}
				],
				"publicationTitle": "Environment and Planning A",
				"title": "CommentarySo-called 'world cities': the evidential structure within a literature",
				"date": "1999",
				"volume": "31",
				"issue": "11",
				"pages": "1901 – 1904",
				"DOI": "10.1068/a311901",
				"url": "http://www.envplan.com/abstract.cgi?id=a311901",
				"abstractNote": "b = 'pion';",
				"libraryCatalog": "Pion Journals",
				"accessDate": "CURRENT_TIMESTAMP",
				"shortTitle": "CommentarySo-called 'world cities'"
			}
		]
	}
]
/** END TEST CASES **/