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 get_contentWindow(frame) {
33 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
34 if (frame && frame.contentWindow) {
35 if (typeof frame.contentWindow.wrappedJSObject != 'undefined') return frame.contentWindow.wrappedJSObject;
36 return frame.contentWindow;
42 function update_modal_xulG(v) {
44 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
45 var key = location.pathname + location.search + location.hash;
46 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
47 data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ] = v;
48 data.stash('modal_xulG_stack');
51 alert('FIXME: update_modal_xulG => ' + E);
55 function xul_param(param_name,_params) {
56 /* 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 */
58 dump('xul_param('+param_name+','+js2JSON(_params)+')\n');
59 var value = undefined; if (!_params) _params = {};
60 if (typeof _params.no_cgi == 'undefined') {
62 if (cgi.param(param_name)) {
63 var x = cgi.param(param_name);
64 dump('\tfound via location.href = ' + x + '\n');
65 if (typeof _params.JSON2js_if_cgi != 'undefined') {
67 dump('\tJSON2js = ' + x + '\n');
69 if (typeof _params.concat == 'undefined') {
70 //alert(param_name + ' x = ' + x);
74 if (value.constructor != Array) value = [ value ];
75 value = value.concat(x);
82 if (typeof _params.no_xulG == 'undefined') {
83 if (typeof _params.modal_xulG != 'undefined') {
84 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
85 var key = location.pathname + location.search + location.hash;
86 dump('xul_param, considering modal key = ' + key + '\n');
87 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
88 xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ];
91 if (typeof xulG == 'object' && typeof xulG[ param_name ] != 'undefined') {
92 var x = xulG[ param_name ];
93 dump('\tfound via xulG = ' + x + '\n');
94 if (typeof _params.JSON2js_if_xulG != 'undefined') {
96 dump('\tJSON2js = ' + x + '\n');
98 if (typeof _params.concat == 'undefined') {
99 //alert(param_name + ' x = ' + x);
103 if (value.constructor != Array) value = [ value ];
104 value = value.concat(x);
111 if (typeof _params.no_xpcom == 'undefined') {
112 /* 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 */
113 if (typeof _params.stash_name != 'undefined') {
114 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
115 if (typeof data[ _params.stash_name ] != 'undefined') {
116 var x = data[ _params.stash_name ];
117 dump('\tfound via xpcom = ' + x + '\n');
118 if (typeof _params.JSON2js_if_xpcom != 'undefined') {
120 dump('\tJSON2js = ' + x + '\n');
122 if (_params.clear_xpcom) {
123 data[ _params.stash_name ] = undefined; data.stash( _params.stash_name );
125 if (typeof _params.concat == 'undefined') {
126 //alert(param_name + ' x = ' + x);
130 if (value.constructor != Array) value = [ value ];
131 value = value.concat(x);
139 //alert(param_name + ' value = ' + value);
142 dump('xul_param error: ' + E + '\n');
146 function get_bool(a) {
147 // Normal javascript interpretation except 'f' == false, per postgres, and 'F' == false
148 // So false includes 'f', '', 0, null, and undefined
149 if (a == 'f') return false;
150 if (a == 'F') return false;
151 if (a) return true; else return false;
154 function get_db_true() {
158 function get_db_false() {
162 function copy_to_clipboard(ev) {
164 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
166 if (typeof ev == 'object') {
167 if (typeof ev.target != 'undefined') {
168 if (typeof ev.target.textContent != 'undefined') if (ev.target.textContent) text = ev.target.textContent;
169 if (typeof ev.target.value != 'undefined') if (ev.target.value) text = ev.target.value;
171 } else if (typeof ev == 'string') {
174 const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
175 .getService(Components.interfaces.nsIClipboardHelper);
176 gClipboardHelper.copyString(text);
177 alert('Copied "'+text+'" to clipboard.');
179 alert('Clipboard action failed: ' + E);
183 function clear_the_cache() {
185 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
186 var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
187 var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
188 cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
189 cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
191 alert('Problem clearing the cache: ' + E);