-
Notifications
You must be signed in to change notification settings - Fork 0
/
cybrary.js
59 lines (51 loc) · 1.94 KB
/
cybrary.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
var timefromitems = ['fromday','frommonth','fromyear','fromhour', 'fromminute'];
var timetoitems = ['today','tomonth','toyear','tohour','tominute'];
function cybrary_produce_subscribe_link(cybraryid, backtoindex, ltext, ltitle) {
var elementid = "subscriptionlink";
var subs_link = document.getElementById(elementid);
if(subs_link){
subs_link.innerHTML = "<a title='"+ltitle+"' href='"+M.cfg.wwwroot+"/mod/cybrary/subscribe.php?id="+cybraryid+backtoindex+"&sesskey="+M.cfg.sesskey+"'>"+ltext+"<\/a>";
}
}
function cybrary_produce_tracking_link(cybraryid, ltext, ltitle) {
var elementid = "trackinglink";
var subs_link = document.getElementById(elementid);
if(subs_link){
subs_link.innerHTML = "<a title='"+ltitle+"' href='"+M.cfg.wwwroot+"/mod/cybrary/settracking.php?id="+cybraryid+"&sesskey="+M.cfg.sesskey+"'>"+ltext+"<\/a>";
}
}
function lockoptions_timetoitems() {
lockoptions('searchform','timefromrestrict', timefromitems);
}
function lockoptions_timefromitems() {
lockoptions('searchform','timetorestrict', timetoitems);
}
function lockoptions(formid, master, subitems) {
// Subitems is an array of names of sub items.
// Optionally, each item in subitems may have a
// companion hidden item in the form with the
// same name but prefixed by "h".
var form = document.forms[formid], i;
if (form[master].checked) {
for (i=0; i<subitems.length; i++) {
unlockoption(form, subitems[i]);
}
} else {
for (i=0; i<subitems.length; i++) {
lockoption(form, subitems[i]);
}
}
return(true);
}
function lockoption(form,item) {
form[item].setAttribute('disabled', 'disabled');
if (form.elements['h'+item]) {
form.elements['h'+item].value=1;
}
}
function unlockoption(form,item) {
form[item].removeAttribute('disabled');
if (form.elements['h'+item]) {
form.elements['h'+item].value=0;
}
}