-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path583_dropdown_20210506.js
83 lines (78 loc) · 2.72 KB
/
583_dropdown_20210506.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
javascript:(function() {
var collections = { none:"",
education:"ioe",
instituteofeducation:"ioe",
ioe:"ioe",
slavoniceasteuropeanstudies:"ssees",
ssees:"ssees",
slavonicandeasteuropeanstudies:"ssees",
archaeology:"archaeology",
archeology:"archaeology",
ioa:"archaeology",
instarch:"archaeology",
scand:"scandinavian",
scandi:"scandinavian",
scandinavian:"scandinavian",
scandinavianstudies:"scandinavian",
hebrewjewishstudies:"hebrewandjewish",
hebrewstudies:"hebrewandjewish",
jewishstudies:"hebrewandjewish",
hebrew:"hebrewandjewish",
jewish:"hebrewandjewish",
handj:"hebrewandjewish",
hs:"hebrewandjewish",
poetrystore:"poetrystore",
poetry:"poetrystore",
ps:"poetrystore",
neurology:"neurology",
instituteofneurology:"neurology",
ion:"neurology",
rnid:"rnid",
pharmacy:"pharmacy",
schoolofpharmacy:"pharmacy",
sop:"pharmacy"};
var getActiveElement = function (element = document.activeElement) {
var shadowRoot = element.shadowRoot ;
var contentDocument = element.contentDocument;
if (shadowRoot && shadowRoot.activeElement) {
return getActiveElement(shadowRoot.activeElement);
};
if (contentDocument && contentDocument.activeElement) {
return getActiveElement(contentDocument.activeElement);
};
return element;
};
var activeEl=getActiveElement();
var padding = function (number) {
var strno = "";
if (number < 10) {
strno+= "0" + number.toString();
}
else {
strno+=number.toString();
}
return strno;
};
var five83El = activeEl;
var five83text = five83El.value;
var dateNow = new Date();
var reviewYear = padding(dateNow.getFullYear()+20);
var reviewMonth = padding(dateNow.getMonth()+1);
var reviewDate = " " + reviewYear + reviewMonth;
if (five83text.match (/^\$\$a ?$/)) {
var fieldContents ="$$a NBK-R $$c" + reviewDate + " $$5 UkLUC";
var coll = prompt("Please enter a collection name (e.g. education) or abbreviation (e.g. ioe). Leave blank if no collection is to be assigned.");
coll = coll.toLowerCase();
coll = coll.replace(/[^a-zA-Z]/gi,"");
var thistag = "";
if (collections[coll]) {thistag = collections[coll]};
if (thistag) {
fieldContents+=" $$x "+thistag;
}
var new583text = fieldContents;
five83El.value = new583text;
}
else {alert ("The 583 needs to be blank, starting $$a, with the cursor next to the 533 ["+five83text+"]["+five83El+"].")};
var event = new Event('change');
five83El.dispatchEvent(event);
})();