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);
34 for (var k in o) keys.push(k);
38 function get_contentWindow(frame) {
39 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
40 if (frame && frame.contentWindow) {
41 if (typeof frame.contentWindow.wrappedJSObject != 'undefined') return frame.contentWindow.wrappedJSObject;
42 return frame.contentWindow;
48 function update_modal_xulG(v) {
50 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
51 var key = location.pathname + location.search + location.hash;
52 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
53 data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ] = v;
54 data.stash('modal_xulG_stack');
57 alert('FIXME: update_modal_xulG => ' + E);
61 function xul_param(param_name,_params) {
62 /* 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 */
64 dump('xul_param('+param_name+','+js2JSON(_params)+')\n');
65 var value = undefined; if (!_params) _params = {};
66 if (typeof _params.no_cgi == 'undefined') {
68 if (cgi.param(param_name)) {
69 var x = cgi.param(param_name);
70 dump('\tfound via location.href = ' + x + '\n');
71 if (typeof _params.JSON2js_if_cgi != 'undefined') {
73 dump('\tJSON2js = ' + x + '\n');
75 if (typeof _params.concat == 'undefined') {
76 //alert(param_name + ' x = ' + x);
80 if (value.constructor != Array) value = [ value ];
81 value = value.concat(x);
88 if (typeof _params.no_xulG == 'undefined') {
89 if (typeof _params.modal_xulG != 'undefined') {
90 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
91 var key = location.pathname + location.search + location.hash;
92 dump('xul_param, considering modal key = ' + key + '\n');
93 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
94 xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ];
97 if (typeof xulG == 'object' && typeof xulG[ param_name ] != 'undefined') {
98 var x = xulG[ param_name ];
99 dump('\tfound via xulG = ' + x + '\n');
100 if (typeof _params.JSON2js_if_xulG != 'undefined') {
102 dump('\tJSON2js = ' + x + '\n');
104 if (typeof _params.concat == 'undefined') {
105 //alert(param_name + ' x = ' + x);
109 if (value.constructor != Array) value = [ value ];
110 value = value.concat(x);
117 if (typeof _params.no_xpcom == 'undefined') {
118 /* 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 */
119 if (typeof _params.stash_name != 'undefined') {
120 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
121 if (typeof data[ _params.stash_name ] != 'undefined') {
122 var x = data[ _params.stash_name ];
123 dump('\tfound via xpcom = ' + x + '\n');
124 if (typeof _params.JSON2js_if_xpcom != 'undefined') {
126 dump('\tJSON2js = ' + x + '\n');
128 if (_params.clear_xpcom) {
129 data[ _params.stash_name ] = undefined; data.stash( _params.stash_name );
131 if (typeof _params.concat == 'undefined') {
132 //alert(param_name + ' x = ' + x);
136 if (value.constructor != Array) value = [ value ];
137 value = value.concat(x);
145 //alert(param_name + ' value = ' + value);
148 dump('xul_param error: ' + E + '\n');
152 function get_bool(a) {
153 // Normal javascript interpretation except 'f' == false, per postgres, and 'F' == false
154 // So false includes 'f', '', 0, null, and undefined
155 if (a == 'f') return false;
156 if (a == 'F') return false;
157 if (a) return true; else return false;
160 function get_db_true() {
164 function get_db_false() {
168 function copy_to_clipboard(ev) {
170 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
172 if (typeof ev == 'object') {
173 if (typeof ev.target != 'undefined') {
174 if (typeof ev.target.textContent != 'undefined') if (ev.target.textContent) text = ev.target.textContent;
175 if (typeof ev.target.value != 'undefined') if (ev.target.value) text = ev.target.value;
177 } else if (typeof ev == 'string') {
180 const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
181 .getService(Components.interfaces.nsIClipboardHelper);
182 gClipboardHelper.copyString(text);
183 alert('Copied "'+text+'" to clipboard.');
185 alert('Clipboard action failed: ' + E);
189 function clear_the_cache() {
191 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
192 var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
193 var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
194 cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
195 cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
197 alert('Problem clearing the cache: ' + E);