-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathon_load.js
More file actions
51 lines (44 loc) · 1.67 KB
/
on_load.js
File metadata and controls
51 lines (44 loc) · 1.67 KB
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
document.addEventListener('DOMContentLoaded', function () {
createInstCodesDropdown();
loadFormWithUrlParams();
try {
contact();
} catch {
console.log('No contact info found.');
}
function createInstCodesDropdown() {
for (inst in instCodes) {
var option = document.createElement("option");
var optionText = document.createTextNode(instCodes[inst]);
option.appendChild(optionText);
option.setAttribute("value", inst);
var select = document.getElementById("alma-inst-id");
select.appendChild(option);
}
}
function loadFormWithUrlParams() {
const url = new URL(window.location.href);
const params = url.searchParams;
const bibidInput = document.getElementById('bibid');
const institutionInput = document.getElementById('alma-inst-id');
const submitButton = document.getElementById('submit');
try {
const bibid = params.get('bibid') || params.get('acnum');
const instId = params.get('alma_inst_id');
if (bibid && instId) {
console.log("Setting form input from URL params.");
bibidInput.value = bibid;
institutionInput.value = instId;
submitButton.click();
}
} catch (error) {
// console.log(error)
}
}
function contact() {
contactNode = document.getElementById("contact");
contactNodeText = contactNode.getAttribute("href");
contactNodeTextNew = atob(contactNodeText);
contactNode.setAttribute("href", contactNodeTextNew);
}
});