forked from zotero/translators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAPA PsycNET.js
194 lines (190 loc) · 7.48 KB
/
APA PsycNET.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
{
"translatorID": "1e1e35be-6264-45a0-ad2e-7212040eb984",
"label": "APA PsycNET",
"creator": "Michael Berkowitz",
"target": "^http://psycnet\\.apa\\.org/",
"minVersion": "2.1",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcs",
"lastUpdated": "2011-09-10 14:58:04"
}
function detectWeb(doc, url) {
if (url.match(/search\.searchResults/)) {
return false;
//return "multiple";
} else if (url.match(/search\.displayRecord|journals\/\S+\/\d+\/\d+\/\d+\//)) {
return "journalArticle";
}
}
function associateXPath(xpath, doc, ns) {
return Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
}
function doWeb(doc, url) {
var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) {
if (prefix == 'x') return namespace; else return null;
} : null;
var arts = new Array();
if (detectWeb(doc, url) == "multiple") {
var items = new Object();
var titles = doc.evaluate('//div[@class="srhcTitle"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
var title;
while (title = titles.iterateNext()) {
items[title.href] = title.textContent;
}
items = Zotero.selectItems(items);
for (var i in items) {
arts.push(i);
}
Zotero.Utilities.processDocuments(arts, scrape, function() {Zotero.done();});
} else {
scrape(doc);
}
Zotero.wait();
}
function scrape (doc) {
var namespace = null;
var newurl = doc.location.href;
if (doc.evaluate('//input[@name="id"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
var id = doc.evaluate('//input[@name="id"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().value;
var lstSelectedUIDs = doc.evaluate('//input[@name="lstUIDs"][@id="srhLstUIDs"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().value;
var get = 'http://psycnet.apa.org/index.cfm?fa=search.export'
var post = 'id=' + id + '&lstUIDs=' + lstSelectedUIDs + '&lstSelectedUIDs=&records=records&displayFormat=&exportFormat=referenceSoftware&printDoc=0';
// http://psycnet.apa.org/index.cfm?fa=search.exportFormat&singlerecord=1
// id=&lstSelectedUIDs=&lstUIDs=2004-16644-010&records=records&displayFormat=&exportFormat=referenceSoftware&printDoc=0
//Zotero.debug(get);
Zotero.Utilities.HTTP.doPost(get, post, function(text) {
// http://psycnet.apa.org/index.cfm?fa=search.export
var translator = Zotero.loadTranslator("import");
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
translator.setString(text);
//Z.debug(text);
translator.setHandler("itemDone", function(obj, item) {
//item.url = newurl;
item.title = item.title.replace(/\.$/,'');
//item.attachments = [{url:newurl, title:"APA PsycNET Snapshot", mimeType:"text/html"}];
item.complete();
});
translator.translate();
});
} else {
var item = new Zotero.Item("journalArticle");
item.title = associateXPath('//div[@id="rdcTitle"]', doc, nsResolver);
var authors = associateXPath('//div[@id="rdcAuthors"]', doc, nsResolver).split(/;\s+/);
for each (var aut in authors) {
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author", true));
}
var voliss = associateXPath('//div[@id="rdcSource"]', doc, nsResolver).match(/^([^\.]+)\.\s+(\d+\s+\w+)\s+Vol\s+(\d+)\((\d+)\)\s+(.*)$/);
item.publicationTitle = voliss[1];
item.date = voliss[2];
item.volume = voliss[3];
item.issue = voliss[4];
item.pages = voliss[5];
item.abstractNote = associateXPath('//div[@id="rdRecord"]/div[@class="rdRecordSection"][2]', doc, nsResolver);
item.complete();
}
}/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "http://psycnet.apa.org/index.cfm?fa=search.displayRecord&uid=2004-16644-010",
"items": [
{
"itemType": "journalArticle",
"creators": [
{
"lastName": "Hervey",
"firstName": "Aaron S.",
"creatorType": "author"
},
{
"lastName": "Epstein",
"firstName": "Jeffery N.",
"creatorType": "author"
},
{
"lastName": "Curry",
"firstName": "John F.",
"creatorType": "author"
}
],
"notes": [],
"tags": [
"attention-deficit/hyperactivity disorder",
"adults",
"behavioral inhibition",
"neuropsychological performance",
"developmental considerations",
"neuropsychological deficits",
"empirical methods"
],
"seeAlso": [],
"attachments": [],
"itemID": "2004-16644-010",
"title": "Neuropsychology of Adults With Attention-Deficit/Hyperactivity Disorder: A Meta-Analytic Review",
"publicationTitle": "Neuropsychology",
"volume": "18",
"issue": "3",
"pages": "485-503",
"date": "2004",
"publisher": "US: American Psychological Association",
"ISBN": "1931-1559 (Electronic); 0894-4105 (Print)",
"ISSN": "1931-1559 (Electronic); 0894-4105 (Print)",
"abstractNote": "A comprehensive, empirically based review of the published studies addressing neuropsychological performance in adults diagnosed with attention-deficit/hyperactivity disorder (ADHD) was conducted to identify patterns of performance deficits. Findings from 33 published studies were submitted to a meta-analytic procedure producing sample-size-weighted mean effect sizes across test measures. Results suggest that neuropsychological deficits are expressed in adults with ADHD across multiple domains of functioning, with notable impairments in attention, behavioral inhibition, and memory, whereas normal performance is noted in simple reaction time. Theoretical and developmental considerations are discussed, including the role of behavioral inhibition and working memory impairment. Future directions for research based on these findings are highlighted, including further exploration of specific impairments and an emphasis on particular tests and testing conditions. (PsycINFO Database Record (c) 2010 APA, all rights reserved)",
"DOI": "10.1037/0894-4105.18.3.485",
"libraryCatalog": "APA PsycNET",
"shortTitle": "Neuropsychology of Adults With Attention-Deficit/Hyperactivity Disorder",
"checkFields": "title"
}
]
},
{
"type": "web",
"url": "http://psycnet.apa.org/journals/xge/50/5/325/",
"items": [
{
"itemType": "journalArticle",
"creators": [
{
"lastName": "Osgood",
"firstName": "Charles E.",
"creatorType": "author"
},
{
"lastName": "Suci",
"firstName": "George J.",
"creatorType": "author"
}
],
"notes": [],
"tags": [
"factor analysis",
"evaluation",
"potency",
"activity",
"semantic"
],
"seeAlso": [],
"attachments": [],
"itemID": "1956-05944-001",
"title": "Factor analysis of meaning",
"publicationTitle": "Journal of Experimental Psychology",
"volume": "50",
"issue": "5",
"pages": "325-338",
"date": "1955",
"publisher": "US: American Psychological Association",
"ISBN": "0022-1015 (Print)",
"ISSN": "0022-1015 (Print)",
"abstractNote": "Two factor analytic studies of meaningful judgments based upon the same sample of 50 bipolar descriptive scales are reported. Both analyses reveal three major connotative factors: evaluation, potency, and activity. These factors appear to be independent dimensions of the semantic space within which the meanings of concepts may be specified. (PsycINFO Database Record (c) 2010 APA, all rights reserved)",
"DOI": "10.1037/h0043965",
"libraryCatalog": "APA PsycNET",
"checkFields": "title"
}
]
}
]
/** END TEST CASES **/