forked from zotero/translators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAPA PsycNET.js
283 lines (278 loc) · 12 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
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
{
"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": "2012-02-24 10:55:04"
}
function detectWeb(doc, url) {
if (url.match(/search\.searchResults/)) {
//permission error
return false;
//return "multiple";
} else if (url.match(/search\.displayRecord|journals\/\S+\/\d+\/\d+\/\d+\//)) {
return "journalArticle";
//for the book database - item IDs ending in 000 are books, everything else chapters)
} else if (url.match(/psycinfo\/[0-9]{4}-[0-9]+-000/)){
return "book";
} else if (url.match(/psycinfo\/[0-9]{4}-[0-9]+-[0-9]{3}/)){
return "bookSection";
}
}
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");
//A2s should be editors here for all practical purposes
text = text.replace(/A2 -/g, "ED -");
translator.setString(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"}];
if (item.itemType== "book" || item.itemType== "bookSection") {
if (item.publisher){
var place = item.publisher.match(/^.+:/)[0];
if (place) {
item.place= place.replace(/:/, "");
}
item.publisher = item.publisher.replace(/^.+:/, "");
}
};
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"
}
]
},
{
"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"
}
]
},
{
"type": "web",
"url": "http://psycnet.apa.org/psycinfo/1992-98221-010",
"items": [
{
"itemType": "bookSection",
"creators": [
{
"lastName": "Gallup Jr.",
"firstName": "Gordon G.",
"creatorType": "author"
},
{
"lastName": "Maser",
"firstName": "Jack D.",
"creatorType": "author"
}
],
"notes": [],
"tags": [
"discusses tonic immobility as an animal model for catatonia & catalepsy"
],
"seeAlso": [],
"attachments": [],
"itemID": "1992-98221-010",
"series": "A series of books in psychology.",
"ISBN": "0-7167-0368-8 (Hardcover); 0-7167-0367-X (Paperback)",
"abstractNote": "tonic immobility [animal hypnosis] might be a useful laboratory analog or research model for catatonia / we have been collaborating on an interdisciplinary program of research in an effort to pinpoint the behavioral antecedents and biological bases for tonic immobility / attempt to briefly summarize our findings, and . . . discuss the implications of these data in terms of the model characteristics of tonic immobility / hypnosis / catatonia, catalepsy, and cataplexy / tonic immobility as a model for catatonia / fear potentiation / fear alleviation / fear or arousal / learned helplessness / neurological correlates / pharmacology and neurochemistry / genetic underpinnings / evolutionary considerations / implications for human psychopathology (PsycINFO Database Record (c) 2010 APA, all rights reserved)",
"place": "New York, NY, US",
"libraryCatalog": "APA PsycNET",
"shortTitle": "Catatonia",
"title": "Catatonia: Tonic immobility: Evolutionary underpinnings of human catalepsy and catatonia",
"pages": "334-357",
"date": "1977",
"publisher": "W H Freeman/Times Books/ Henry Holt & Co",
"bookTitle": "Psychopathology: Experimental models."
}
]
},
{
"type": "web",
"url": "http://psycnet.apa.org/psycinfo/2004-16329-000/",
"items": [
{
"itemType": "book",
"creators": [
{
"lastName": "White",
"firstName": "Robert W.",
"creatorType": "author"
}
],
"notes": [],
"tags": [
"abnormal personality",
"abnormal psychology",
"personality disorders"
],
"seeAlso": [],
"attachments": [],
"itemID": "2004-16329-000",
"title": "The abnormal personality: A textbook",
"pages": "x, 617",
"numPages": "x, 617",
"date": "1948",
"publisher": "Ronald Press Company",
"abstractNote": "The author's intent is to write about abnormal people in a way that will be valuable and interesting to students new to the subject. A first course in abnormal psychology is not intended to train specialists. Its goal is more general: it should provide the student with the opportunity to whet his interest, expand his horizons, register a certain body of new facts, and relate this to the rest of his knowledge about mankind. I have tried to present the subject in such a way as to emphasize its usefulness to all students of human nature. I have tried the experiment of writing two introductory chapters, one historical and the other clinical. This reflects my desire to set the subject-matter in a broad perspective and at the same time to anchor it in concrete fact. Next comes a block of six chapters designed to set forth the topics of maladjustment and neurosis. The two chapters on psychotherapy complete the more purely psychological or developmental part of the work. In the final chapter the problem of disordered personalities is allowed to expand to its full social dimensions. Treatment, care, and prevention call for social effort and social organization. I have sought to show some of the lines, both professional and nonprofessional, along which this effort can be expended. (PsycINFO Database Record (c) 2010 APA, all rights reserved)",
"DOI": "10.1037/10023-000",
"place": "New York, NY, US",
"libraryCatalog": "APA PsycNET",
"shortTitle": "The abnormal personality"
}
]
}
]
/** END TEST CASES **/