4 function oilsNextId() {
5 return 'oils_'+ (oilsRptID++);
8 function oilsNextNumericId() {
12 function oilsRptNextParam() {
13 return '::PARAM'+ (oilsRptID2++);
18 function oilsRptCacheObject(obj) {
19 var id = oilsNextId();
20 oilsRptObjectCache[id] = obj;
24 function oilsRptFindObject(id) {
25 return oilsRptObjectCache[id];
29 function oilsRptCacheObject(type, obj, id) {
30 if( !oilsRptObjectCache[type] )
31 oilsRptObjectCache[type] = {};
32 oilsRptObjectCache[type][id] = obj;
35 function oilsRptGetCache(type, id) {
36 if( !oilsRptObjectCache[type] )
38 return oilsRptObjectCache[type][i];
42 /* -------------------------------------------- */
43 function oilsRptObject() {}
44 oilsRptObject.prototype.init = function() {
45 oilsRptObject.cache(this);
47 oilsRptObject.objectCache = {};
48 oilsRptObject.find = function(id) {
49 return oilsRptObject.objectCache[id];
51 oilsRptObject.cache = function(obj) {
52 obj.id = oilsNextNumericId();
53 oilsRptObject.objectCache[obj.id] = obj;
56 /* -------------------------------------------- */
59 /* returns just the column name */
60 function oilsRptPathCol(path) {
61 var parts = path.split(/-/);
65 /* returns the IDL class of the selected column */
66 function oilsRptPathClass(path) {
67 var parts = path.split(/-/);
72 /* returns everything prior to the column name */
73 function oilsRptPathRel(path) {
74 var parts = path.split(/-/);
76 return parts.join('-');
79 /* creates a label "path" based on the column path */
80 function oilsRptMakeLabel(path) {
81 var parts = path.split(/-/);
83 for( var i = 0; i < parts.length; i++ ) {
86 str += oilsIDL[parts[i]].label;
88 var f = oilsRptFindField(oilsIDL[parts[i-1]], parts[i]);
98 function oilsRptResetParams() {
102 function nodeText(id) {
104 return $(id).innerHTML;
108 function print_tabs(t) {
110 for (var j = 0; j < t; j++ ) { r = r + " "; }
115 function oilsRptDebug() {
116 _debug("\n-------------------------------------\n");
117 _debug(oilsRpt.toString());
118 _debug("\n-------------------------------------\n");
119 if(!oilsRptDebugEnabled) return;
120 if(!oilsRptDebugWindow)
121 oilsRptDebugWindow = window.open('','Debug','resizable,width=700,height=500,scrollbars=1');
123 oilsRptDebugWindow.document.body.innerHTML = oilsRpt.toHTMLString();
126 /* pretty print JSON */
127 function formatJSON(s) {
128 var r = ''; var t = 0;
130 if (s[i] == '{' || s[i] == '[' ) {
131 r = r + s[i] + "\n" + print_tabs(++t);
132 } else if (s[i] == '}' || s[i] == ']') {
133 t--; r = r + "\n" + print_tabs(t) + s[i];
134 } else if (s[i] == ',') {
135 r = r + s[i] + "\n" + print_tabs(t);
144 function print_tabs_html(t) {
146 for (var j = 0; j < t; j++ ) { r = r + " "; }
150 function formatJSONHTML(s) {
151 var r = ''; var t = 0;
153 if (s[i] == '{' || s[i] == '[') {
154 r = r + s[i] + "<br/>" + print_tabs_html(++t);
155 } else if (s[i] == '}' || s[i] == ']') {
156 t--; r = r + "<br/>" + print_tabs_html(t) + s[i];
157 } else if (s[i] == ',') {
159 r = r + "<br/>" + print_tabs_html(t);
167 function setMousePos(e) {
170 oilsPageXMid = parseInt(window.innerHeight / 2);
171 oilsPageYMid = parseInt(window.innerWidth / 2);
174 function buildFloatingDiv(div, width) {
175 var left = parseInt((window.innerWidth / 2) - (width/2));
176 var halfh = parseInt(div.clientHeight / 2);
177 var top = oilsMouseY - halfh + 50;
178 var dbot = top + halfh;
179 if( dbot > window.innerHeight ) {
180 top = oilsMouseY - div.clientHeight - 10;
182 div.setAttribute('style', 'left:'+left+'px; top:'+top+'px; width:'+width+'px');
186 function mergeObjects( src, obj ) {
187 for( var i in obj ) {
188 if( typeof obj[i] == 'string' ) {
191 if(src[i]) mergeObjects(src[i], obj[i]);
192 else src[i] = obj[i];
198 /* scours the doc for elements with IDs. When it finds one,
199 it grabs the dom node and sets a reference to the node at DOM[id]; */
200 function oilsRptIdObjects(node) {
201 if(!node) node = document.documentElement;
202 if( node.nodeType != 1 ) return;
203 var id = node.getAttribute('id');
204 if( id ) eval("DOM."+id+"=$('"+id+"');");
205 var children = node.childNodes;
206 for( var c = 0; c < children.length; c++ )
207 oilsRptIdObjects(children[c]);
211 function oilsRptObjectKeys(obj) {
213 for( var i in obj ) k.push(i);
218 /* makes cls a subclass of parent */
219 function oilsRptSetSubClass(cls, parent) {
220 var str = cls+'.prototype = new '+parent+'();\n';
221 str += cls+'.prototype.constructor = '+cls+';\n';
222 str += cls+'.baseClass = '+parent+'.prototype.constructor;\n';
223 str += cls+'.prototype.super = '+parent+'.prototype;\n';
228 function oilsRptUpdateFolder(folder, type, callback) {
230 _debug("updating folder " + folder.id() + ' : ' + folder.name());
232 var req = new Request(OILS_RPT_UPDATE_FOLDER, SESSION, type, folder);
236 if( r.getResultObject() == 1 )
238 else callback(false);
248 function oilsRptCreateFolder(folder, type, callback) {
249 _debug("creating folder "+ folder.name());
250 var req = new Request(OILS_RPT_CREATE_FOLDER, SESSION, type, folder);
254 if( r.getResultObject() > 0 )
256 else callback(false);
266 function oilsRptAlertSuccess() { alertId('oils_rpt_generic_success'); }