1 function $(id) { return document.getElementById(id); }
4 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
7 return data.list.au[0].ws_ou();
10 return data.session.authtime;
14 return data.session.key;
19 function font_helper() {
21 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
22 removeCSSClass(document.documentElement,'ALL_FONTS_LARGER');
23 removeCSSClass(document.documentElement,'ALL_FONTS_SMALLER');
24 removeCSSClass(document.documentElement,'ALL_FONTS_XX_SMALL');
25 removeCSSClass(document.documentElement,'ALL_FONTS_X_SMALL');
26 removeCSSClass(document.documentElement,'ALL_FONTS_SMALL');
27 removeCSSClass(document.documentElement,'ALL_FONTS_MEDIUM');
28 removeCSSClass(document.documentElement,'ALL_FONTS_LARGE');
29 removeCSSClass(document.documentElement,'ALL_FONTS_X_LARGE');
30 removeCSSClass(document.documentElement,'ALL_FONTS_XX_LARGE');
31 addCSSClass(document.documentElement,data.global_font_adjust);
33 var Strings = $('offlineStrings') || $('commonStrings');
34 alert(Strings.getFormattedString('openils.global_util.font_size.error', [E]));
40 for (var k in o) keys.push(k);
44 function get_contentWindow(frame) {
46 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
47 if (frame && frame.contentWindow) {
49 if (typeof frame.contentWindow.wrappedJSObject != 'undefined') {
50 return frame.contentWindow.wrappedJSObject;
53 var Strings = $('offlineStrings') || $('commonStrings');
54 alert(Strings.getFormattedString('openils.global_util.content_window_jsobject.error', [frame, E]));
56 return frame.contentWindow;
61 var Strings = $('offlineStrings') || $('commonStrings');
62 alert(Strings.getFormattedString('openils.global_util.content_window.error', [frame, E]));
66 function update_modal_xulG(v) {
68 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
69 var key = location.pathname + location.search + location.hash;
70 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
71 data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ] = v;
72 data.stash('modal_xulG_stack');
75 alert('FIXME: update_modal_xulG => ' + E);
79 function xul_param(param_name,_params) {
80 /* 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 */
82 //dump('xul_param('+param_name+','+js2JSON(_params)+')\n');
83 var value = undefined; if (!_params) _params = {};
84 if (typeof _params.no_cgi == 'undefined') {
86 if (cgi.param(param_name)) {
87 var x = cgi.param(param_name);
88 //dump('\tfound via location.href = ' + x + '\n');
89 if (typeof _params.JSON2js_if_cgi != 'undefined') {
91 //dump('\tJSON2js = ' + x + '\n');
93 if (typeof _params.concat == 'undefined') {
94 //alert(param_name + ' x = ' + x);
98 if (value.constructor != Array) value = [ value ];
99 value = value.concat(x);
106 if (typeof _params.no_xulG == 'undefined') {
107 if (typeof _params.modal_xulG != 'undefined') {
108 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
109 var key = location.pathname + location.search + location.hash;
110 //dump('xul_param, considering modal key = ' + key + '\n');
111 if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
112 xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ];
115 if (typeof xulG == 'object' && typeof xulG[ param_name ] != 'undefined') {
116 var x = xulG[ param_name ];
117 //dump('\tfound via xulG = ' + x + '\n');
118 if (typeof _params.JSON2js_if_xulG != 'undefined') {
120 //dump('\tJSON2js = ' + x + '\n');
122 if (typeof _params.concat == 'undefined') {
123 //alert(param_name + ' x = ' + x);
127 if (value.constructor != Array) value = [ value ];
128 value = value.concat(x);
135 if (typeof _params.no_xpcom == 'undefined') {
136 /* 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 */
137 if (typeof _params.stash_name != 'undefined') {
138 JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
139 if (typeof data[ _params.stash_name ] != 'undefined') {
140 var x = data[ _params.stash_name ];
141 //dump('\tfound via xpcom = ' + x + '\n');
142 if (typeof _params.JSON2js_if_xpcom != 'undefined') {
144 //dump('\tJSON2js = ' + x + '\n');
146 if (_params.clear_xpcom) {
147 data[ _params.stash_name ] = undefined; data.stash( _params.stash_name );
149 if (typeof _params.concat == 'undefined') {
150 //alert(param_name + ' x = ' + x);
154 if (value.constructor != Array) value = [ value ];
155 value = value.concat(x);
163 //alert(param_name + ' value = ' + value);
166 dump('xul_param error: ' + E + '\n');
170 function get_bool(a) {
171 // Normal javascript interpretation except 'f' == false, per postgres, and 'F' == false, and '0' == false (newer JSON is returning '0' instead of 0 in cases)
172 // So false includes 'f', '', '0', 0, null, and undefined
173 if (a == 'f') return false;
174 if (a == 'F') return false;
175 if (a == '0') return false;
176 if (a) return true; else return false;
179 function get_db_true() {
183 function get_db_false() {
187 function copy_to_clipboard(ev) {
189 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
191 if (typeof ev == 'object') {
192 if (typeof ev.target != 'undefined') {
193 if (typeof ev.target.textContent != 'undefined') if (ev.target.textContent) text = ev.target.textContent;
194 if (typeof ev.target.value != 'undefined') if (ev.target.value) text = ev.target.value;
196 } else if (typeof ev == 'string') {
199 const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
200 .getService(Components.interfaces.nsIClipboardHelper);
201 gClipboardHelper.copyString(text);
202 var Strings = $('offlineStrings') || $('commonStrings');
203 alert(Strings.getFormattedString('openils.global_util.clipboard', [text]));
205 var Strings = $('offlineStrings') || $('commonStrings');
206 alert(Strings.getFormattedString('openils.global_util.clipboard.error', [E]));
210 function clear_the_cache() {
212 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
213 var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
214 var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
215 cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
216 cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
218 var Strings = $('offlineStrings') || $('commonStrings');
219 alert(Strings.getFormattedString('openils.global_util.clear_cache.error', [E]));
223 function toOpenWindowByType(inType, uri) {
224 var winopts = "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar";
225 window.open(uri, "_blank", winopts);
228 function url_prefix(url) {
229 if (url.match(/^\//)) url = urls.remote + url;
230 if (! url.match(/^(http|chrome):\/\//) && ! url.match(/^data:/) ) url = 'http://' + url;
231 dump('url_prefix = ' + url + '\n');