2 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
5 return data.session.authtime;
9 return data.session.key;
14 function font_helper() {
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);
28 alert("Error with adjusting the font size: " + E);
32 function update_modal_xulG(v) {
34 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
35 var key = location.pathname + location.search + location.hash;
36 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
37 data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ] = v;
38 data.stash('modal_xulG_stack');
41 alert('FIXME: update_modal_xulG => ' + E);
45 function xul_param(param_name,_params) {
46 /* By default, this function looks for a CGI-style query param identified by param_name. If one isn't found, it then looks in xulG. If one still isn't found, and _params.stash_name is true, it looks in the global xpcom stash for the field identified by stash_name. If _params.concat is true, then it looks in all these places and concatenates the results. There are also options for converting JSON to javascript objects, and clearing the xpcom stash_name field after retrieval. Also added, ability to search a specific spot in the xpcom stash that implements a stack to hold xulG's for modal windows */
48 dump('xul_param('+param_name+','+js2JSON(_params)+')\n');
49 var value = undefined; if (!_params) _params = {};
50 if (typeof _params.no_cgi == 'undefined') {
52 if (cgi.param(param_name)) {
53 var x = cgi.param(param_name);
54 dump('\tfound via location.href = ' + x + '\n');
55 if (typeof _params.JSON2js_if_cgi != 'undefined') {
57 dump('\tJSON2js = ' + x + '\n');
59 if (typeof _params.concat == 'undefined') {
60 //alert(param_name + ' x = ' + x);
64 if (value.constructor != Array) value = [ value ];
65 value = value.concat(x);
72 if (typeof _params.no_xulG == 'undefined') {
73 if (typeof _params.modal_xulG != 'undefined') {
74 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
75 var key = location.pathname + location.search + location.hash;
76 dump('xul_param, considering modal key = ' + key + '\n');
77 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
78 xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ];
81 if (typeof xulG == 'object' && typeof xulG[ param_name ] != 'undefined') {
82 var x = xulG[ param_name ];
83 dump('\tfound via xulG = ' + x + '\n');
84 if (typeof _params.JSON2js_if_xulG != 'undefined') {
86 dump('\tJSON2js = ' + x + '\n');
88 if (typeof _params.concat == 'undefined') {
89 //alert(param_name + ' x = ' + x);
93 if (value.constructor != Array) value = [ value ];
94 value = value.concat(x);
101 if (typeof _params.no_xpcom == 'undefined') {
102 /* the field names used for temp variables in the global stash tend to be more unique than xuLG or CGI param names, to avoid collisions */
103 if (typeof _params.stash_name != 'undefined') {
104 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
105 if (typeof data[ _params.stash_name ] != 'undefined') {
106 var x = data[ _params.stash_name ];
107 dump('\tfound via xpcom = ' + x + '\n');
108 if (typeof _params.JSON2js_if_xpcom != 'undefined') {
110 dump('\tJSON2js = ' + x + '\n');
112 if (_params.clear_xpcom) {
113 data[ _params.stash_name ] = undefined; data.stash( _params.stash_name );
115 if (typeof _params.concat == 'undefined') {
116 //alert(param_name + ' x = ' + x);
120 if (value.constructor != Array) value = [ value ];
121 value = value.concat(x);
129 //alert(param_name + ' value = ' + value);
132 dump('xul_param error: ' + E + '\n');
136 function get_bool(a) {
137 // Normal javascript interpretation except 'f' == false, per postgres, and 'F' == false
138 // So false includes 'f', '', 0, null, and undefined
139 if (a == 'f') return false;
140 if (a == 'F') return false;
141 if (a) return true; else return false;
144 function get_db_true() {
148 function get_db_false() {
152 function copy_to_clipboard(ev) {
154 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
156 if (typeof ev == 'object') {
157 if (typeof ev.target != 'undefined') {
158 if (typeof ev.target.textContent != 'undefined') if (ev.target.textContent) text = ev.target.textContent;
159 if (typeof ev.target.value != 'undefined') if (ev.target.value) text = ev.target.value;
161 } else if (typeof ev == 'string') {
164 const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
165 .getService(Components.interfaces.nsIClipboardHelper);
166 gClipboardHelper.copyString(text);
167 alert('Copied "'+text+'" to clipboard.');
169 alert('Clipboard action failed: ' + E);
173 function clear_the_cache() {
175 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
176 var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
177 var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
178 cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
179 cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
181 alert('Problem clearing the cache: ' + E);