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($('offlineStrings').getFormattedString('openils.global_util.font_size.error', [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') {
46 return frame.contentWindow.wrappedJSObject;
49 alert($('offlineStrings').getFormattedString('openils.global_util.content_window_jsobject.error', [frame, E]));
51 return frame.contentWindow;
56 alert($('offlineStrings').getFormattedString('openils.global_util.content_window.error', [frame, E]));
60 function update_modal_xulG(v) {
62 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
63 var key = location.pathname + location.search + location.hash;
64 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
65 data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ] = v;
66 data.stash('modal_xulG_stack');
69 alert('FIXME: update_modal_xulG => ' + E);
73 function xul_param(param_name,_params) {
74 /* 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 */
76 //dump('xul_param('+param_name+','+js2JSON(_params)+')\n');
77 var value = undefined; if (!_params) _params = {};
78 if (typeof _params.no_cgi == 'undefined') {
80 if (cgi.param(param_name)) {
81 var x = cgi.param(param_name);
82 //dump('\tfound via location.href = ' + x + '\n');
83 if (typeof _params.JSON2js_if_cgi != 'undefined') {
85 //dump('\tJSON2js = ' + x + '\n');
87 if (typeof _params.concat == 'undefined') {
88 //alert(param_name + ' x = ' + x);
92 if (value.constructor != Array) value = [ value ];
93 value = value.concat(x);
100 if (typeof _params.no_xulG == 'undefined') {
101 if (typeof _params.modal_xulG != 'undefined') {
102 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
103 var key = location.pathname + location.search + location.hash;
104 //dump('xul_param, considering modal key = ' + key + '\n');
105 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
106 xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ];
109 if (typeof xulG == 'object' && typeof xulG[ param_name ] != 'undefined') {
110 var x = xulG[ param_name ];
111 //dump('\tfound via xulG = ' + x + '\n');
112 if (typeof _params.JSON2js_if_xulG != 'undefined') {
114 //dump('\tJSON2js = ' + x + '\n');
116 if (typeof _params.concat == 'undefined') {
117 //alert(param_name + ' x = ' + x);
121 if (value.constructor != Array) value = [ value ];
122 value = value.concat(x);
129 if (typeof _params.no_xpcom == 'undefined') {
130 /* 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 */
131 if (typeof _params.stash_name != 'undefined') {
132 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
133 if (typeof data[ _params.stash_name ] != 'undefined') {
134 var x = data[ _params.stash_name ];
135 //dump('\tfound via xpcom = ' + x + '\n');
136 if (typeof _params.JSON2js_if_xpcom != 'undefined') {
138 //dump('\tJSON2js = ' + x + '\n');
140 if (_params.clear_xpcom) {
141 data[ _params.stash_name ] = undefined; data.stash( _params.stash_name );
143 if (typeof _params.concat == 'undefined') {
144 //alert(param_name + ' x = ' + x);
148 if (value.constructor != Array) value = [ value ];
149 value = value.concat(x);
157 //alert(param_name + ' value = ' + value);
160 dump('xul_param error: ' + E + '\n');
164 function get_bool(a) {
165 // Normal javascript interpretation except 'f' == false, per postgres, and 'F' == false
166 // So false includes 'f', '', 0, null, and undefined
167 if (a == 'f') return false;
168 if (a == 'F') return false;
169 if (a) return true; else return false;
172 function get_db_true() {
176 function get_db_false() {
180 function copy_to_clipboard(ev) {
182 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
184 if (typeof ev == 'object') {
185 if (typeof ev.target != 'undefined') {
186 if (typeof ev.target.textContent != 'undefined') if (ev.target.textContent) text = ev.target.textContent;
187 if (typeof ev.target.value != 'undefined') if (ev.target.value) text = ev.target.value;
189 } else if (typeof ev == 'string') {
192 const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
193 .getService(Components.interfaces.nsIClipboardHelper);
194 gClipboardHelper.copyString(text);
195 alert($('offlineStrings').getFormattedString('openils.global_util.clipboard', [text]));
197 alert($('offlineStrings').getFormattedString('openils.global_util.clipboard.error', [E]));
201 function clear_the_cache() {
203 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
204 var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
205 var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
206 cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
207 cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
209 alert($('offlineStrings').getFormattedString('openils.global_util.clear_cache.error', [E]));
213 function toOpenWindowByType(inType, uri) {
214 var winopts = "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar";
215 window.open(uri, "_blank", winopts);
218 function url_prefix(url) {
219 if (url.match(/^\//)) url = urls.remote + url;
220 if (! url.match(/^(http|chrome):\/\//) && ! url.match(/^data:/) ) url = 'http://' + url;
221 dump('url_prefix = ' + url + '\n');