1 function $(id) { return document.getElementById(id); }
4 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
7 return data.session.authtime;
11 return data.session.key;
16 function font_helper() {
18 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
19 removeCSSClass(document.documentElement,'ALL_FONTS_LARGER');
20 removeCSSClass(document.documentElement,'ALL_FONTS_SMALLER');
21 removeCSSClass(document.documentElement,'ALL_FONTS_XX_SMALL');
22 removeCSSClass(document.documentElement,'ALL_FONTS_X_SMALL');
23 removeCSSClass(document.documentElement,'ALL_FONTS_SMALL');
24 removeCSSClass(document.documentElement,'ALL_FONTS_MEDIUM');
25 removeCSSClass(document.documentElement,'ALL_FONTS_LARGE');
26 removeCSSClass(document.documentElement,'ALL_FONTS_X_LARGE');
27 removeCSSClass(document.documentElement,'ALL_FONTS_XX_LARGE');
28 addCSSClass(document.documentElement,data.global_font_adjust);
30 alert("Error with adjusting the font size: " + E);
36 for (var k in o) keys.push(k);
40 function get_contentWindow(frame) {
42 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
43 if (frame && frame.contentWindow) {
45 if (typeof frame.contentWindow.wrappedJSObject != 'undefined') return frame.contentWindow.wrappedJSObject;
47 alert("Error with get_contentWindow("+frame+") and wrappedJSObject:" + E);
49 return frame.contentWindow;
54 alert("Error with get_contentWindow("+frame+"): " + E);
58 function update_modal_xulG(v) {
60 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
61 var key = location.pathname + location.search + location.hash;
62 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
63 data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ] = v;
64 data.stash('modal_xulG_stack');
67 alert('FIXME: update_modal_xulG => ' + E);
71 function xul_param(param_name,_params) {
72 /* 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 */
74 //dump('xul_param('+param_name+','+js2JSON(_params)+')\n');
75 var value = undefined; if (!_params) _params = {};
76 if (typeof _params.no_cgi == 'undefined') {
78 if (cgi.param(param_name)) {
79 var x = cgi.param(param_name);
80 //dump('\tfound via location.href = ' + x + '\n');
81 if (typeof _params.JSON2js_if_cgi != 'undefined') {
83 //dump('\tJSON2js = ' + x + '\n');
85 if (typeof _params.concat == 'undefined') {
86 //alert(param_name + ' x = ' + x);
90 if (value.constructor != Array) value = [ value ];
91 value = value.concat(x);
98 if (typeof _params.no_xulG == 'undefined') {
99 if (typeof _params.modal_xulG != 'undefined') {
100 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
101 var key = location.pathname + location.search + location.hash;
102 //dump('xul_param, considering modal key = ' + key + '\n');
103 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
104 xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ];
107 if (typeof xulG == 'object' && typeof xulG[ param_name ] != 'undefined') {
108 var x = xulG[ param_name ];
109 //dump('\tfound via xulG = ' + x + '\n');
110 if (typeof _params.JSON2js_if_xulG != 'undefined') {
112 //dump('\tJSON2js = ' + x + '\n');
114 if (typeof _params.concat == 'undefined') {
115 //alert(param_name + ' x = ' + x);
119 if (value.constructor != Array) value = [ value ];
120 value = value.concat(x);
127 if (typeof _params.no_xpcom == 'undefined') {
128 /* 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 */
129 if (typeof _params.stash_name != 'undefined') {
130 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
131 if (typeof data[ _params.stash_name ] != 'undefined') {
132 var x = data[ _params.stash_name ];
133 //dump('\tfound via xpcom = ' + x + '\n');
134 if (typeof _params.JSON2js_if_xpcom != 'undefined') {
136 //dump('\tJSON2js = ' + x + '\n');
138 if (_params.clear_xpcom) {
139 data[ _params.stash_name ] = undefined; data.stash( _params.stash_name );
141 if (typeof _params.concat == 'undefined') {
142 //alert(param_name + ' x = ' + x);
146 if (value.constructor != Array) value = [ value ];
147 value = value.concat(x);
155 //alert(param_name + ' value = ' + value);
158 dump('xul_param error: ' + E + '\n');
162 function get_bool(a) {
163 // Normal javascript interpretation except 'f' == false, per postgres, and 'F' == false
164 // So false includes 'f', '', 0, null, and undefined
165 if (a == 'f') return false;
166 if (a == 'F') return false;
167 if (a) return true; else return false;
170 function get_db_true() {
174 function get_db_false() {
178 function copy_to_clipboard(ev) {
180 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
182 if (typeof ev == 'object') {
183 if (typeof ev.target != 'undefined') {
184 if (typeof ev.target.textContent != 'undefined') if (ev.target.textContent) text = ev.target.textContent;
185 if (typeof ev.target.value != 'undefined') if (ev.target.value) text = ev.target.value;
187 } else if (typeof ev == 'string') {
190 const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
191 .getService(Components.interfaces.nsIClipboardHelper);
192 gClipboardHelper.copyString(text);
193 alert('Copied "'+text+'" to clipboard.');
195 alert('Clipboard action failed: ' + E);
199 function clear_the_cache() {
201 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
202 var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
203 var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
204 cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
205 cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
207 alert('Problem clearing the cache: ' + E);
211 function toOpenWindowByType(inType, uri) {
212 var winopts = "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar";
213 window.open(uri, "_blank", winopts);