]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/OpenILS/global_util.js
79bdc6a64b59babee2a129a1006301007529273c
[Evergreen.git] / Open-ILS / xul / staff_client / server / OpenILS / global_util.js
1         function ses(a) {
2                 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
3                 switch(a) {
4                         case 'authtime' :
5                                 return data.session.authtime;
6                         break;
7                         case 'key':
8                         default:
9                                 return data.session.key;
10                         break;
11                 }
12         }
13
14         function font_helper() {
15                 try {
16                         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
17                         removeCSSClass(document.documentElement,'ALL_FONTS_LARGER');
18                         removeCSSClass(document.documentElement,'ALL_FONTS_SMALLER');
19                         removeCSSClass(document.documentElement,'ALL_FONTS_XX_SMALL');
20                         removeCSSClass(document.documentElement,'ALL_FONTS_X_SMALL');
21                         removeCSSClass(document.documentElement,'ALL_FONTS_SMALL');
22                         removeCSSClass(document.documentElement,'ALL_FONTS_MEDIUM');
23                         removeCSSClass(document.documentElement,'ALL_FONTS_LARGE');
24                         removeCSSClass(document.documentElement,'ALL_FONTS_X_LARGE');
25                         removeCSSClass(document.documentElement,'ALL_FONTS_XX_LARGE');
26                         addCSSClass(document.documentElement,data.global_font_adjust);
27                 } catch(E) {
28                         alert("Error with adjusting the font size: " + E);
29                 }
30         }
31
32         function get_bool(a) {
33                 // Normal javascript interpretation except 'f' == false, per postgres, and 'F' == false
34                 // So false includes 'f', '', 0, null, and undefined
35                 if (a == 'f') return false;
36                 if (a == 'F') return false;
37                 if (a) return true; else return false;
38         }
39
40         function get_db_true() {
41                 return 't';
42         }
43
44         function get_db_false() {
45                 return 'f';
46         }
47
48         function copy_to_clipboard(ev) {
49                 try {
50                         netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
51                         var text;
52                         if (typeof ev == 'object') {
53                                 if (typeof ev.target != 'undefined') {
54                                         if (typeof ev.target.textContent != 'undefined') if (ev.target.textContent) text = ev.target.textContent;
55                                         if (typeof ev.target.value != 'undefined') if (ev.target.value) text = ev.target.value;
56                                 }
57                         } else if (typeof ev == 'string') {
58                                 text = ev;
59                         }
60                         const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
61                                 .getService(Components.interfaces.nsIClipboardHelper);
62                         gClipboardHelper.copyString(text);
63                         alert('Copied "'+text+'" to clipboard.');
64                 } catch(E) {
65                         alert('Clipboard action failed: ' + E); 
66                 }
67         }
68