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) {
41 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
42 if (frame && frame.contentWindow) {
43 if (typeof frame.contentWindow.wrappedJSObject != 'undefined') return frame.contentWindow.wrappedJSObject;
44 return frame.contentWindow;
50 function update_modal_xulG(v) {
52 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
53 var key = location.pathname + location.search + location.hash;
54 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
55 data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ] = v;
56 data.stash('modal_xulG_stack');
59 alert('FIXME: update_modal_xulG => ' + E);
63 function xul_param(param_name,_params) {
64 /* 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 */
66 //dump('xul_param('+param_name+','+js2JSON(_params)+')\n');
67 var value = undefined; if (!_params) _params = {};
68 if (typeof _params.no_cgi == 'undefined') {
70 if (cgi.param(param_name)) {
71 var x = cgi.param(param_name);
72 //dump('\tfound via location.href = ' + x + '\n');
73 if (typeof _params.JSON2js_if_cgi != 'undefined') {
75 //dump('\tJSON2js = ' + x + '\n');
77 if (typeof _params.concat == 'undefined') {
78 //alert(param_name + ' x = ' + x);
82 if (value.constructor != Array) value = [ value ];
83 value = value.concat(x);
90 if (typeof _params.no_xulG == 'undefined') {
91 if (typeof _params.modal_xulG != 'undefined') {
92 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
93 var key = location.pathname + location.search + location.hash;
94 //dump('xul_param, considering modal key = ' + key + '\n');
95 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
96 xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ];
99 if (typeof xulG == 'object' && typeof xulG[ param_name ] != 'undefined') {
100 var x = xulG[ param_name ];
101 //dump('\tfound via xulG = ' + x + '\n');
102 if (typeof _params.JSON2js_if_xulG != 'undefined') {
104 //dump('\tJSON2js = ' + x + '\n');
106 if (typeof _params.concat == 'undefined') {
107 //alert(param_name + ' x = ' + x);
111 if (value.constructor != Array) value = [ value ];
112 value = value.concat(x);
119 if (typeof _params.no_xpcom == 'undefined') {
120 /* 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 */
121 if (typeof _params.stash_name != 'undefined') {
122 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
123 if (typeof data[ _params.stash_name ] != 'undefined') {
124 var x = data[ _params.stash_name ];
125 //dump('\tfound via xpcom = ' + x + '\n');
126 if (typeof _params.JSON2js_if_xpcom != 'undefined') {
128 //dump('\tJSON2js = ' + x + '\n');
130 if (_params.clear_xpcom) {
131 data[ _params.stash_name ] = undefined; data.stash( _params.stash_name );
133 if (typeof _params.concat == 'undefined') {
134 //alert(param_name + ' x = ' + x);
138 if (value.constructor != Array) value = [ value ];
139 value = value.concat(x);
147 //alert(param_name + ' value = ' + value);
150 dump('xul_param error: ' + E + '\n');
154 function get_bool(a) {
155 // Normal javascript interpretation except 'f' == false, per postgres, and 'F' == false
156 // So false includes 'f', '', 0, null, and undefined
157 if (a == 'f') return false;
158 if (a == 'F') return false;
159 if (a) return true; else return false;
162 function get_db_true() {
166 function get_db_false() {
170 function copy_to_clipboard(ev) {
172 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
174 if (typeof ev == 'object') {
175 if (typeof ev.target != 'undefined') {
176 if (typeof ev.target.textContent != 'undefined') if (ev.target.textContent) text = ev.target.textContent;
177 if (typeof ev.target.value != 'undefined') if (ev.target.value) text = ev.target.value;
179 } else if (typeof ev == 'string') {
182 const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
183 .getService(Components.interfaces.nsIClipboardHelper);
184 gClipboardHelper.copyString(text);
185 alert('Copied "'+text+'" to clipboard.');
187 alert('Clipboard action failed: ' + E);
191 function clear_the_cache() {
193 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
194 var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
195 var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
196 cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
197 cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
199 alert('Problem clearing the cache: ' + E);
203 function toOpenWindowByType(inType, uri) {
204 var winopts = "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar";
205 window.open(uri, "_blank", winopts);