4 function oilsNextId() {
5 return 'oils_'+ (oilsRptID++);
8 function oilsNextNumericId() {
12 function oilsRptNextParam() {
13 return '::PARAM'+ (oilsRptID2++);
17 function oilsRptCacheObject(obj) {
18 var id = oilsNextId();
19 oilsRptObjectCache[id] = obj;
23 function oilsRptFindObject(id) {
24 return oilsRptObjectCache[id];
27 function oilsRptCacheObject(type, obj, id) {
28 if( !oilsRptObjectCache[type] )
29 oilsRptObjectCache[type] = {};
30 oilsRptObjectCache[type][id] = obj;
33 function oilsRptGetCache(type, id) {
34 if( !oilsRptObjectCache[type] )
36 return oilsRptObjectCache[type][i];
40 /* -------------------------------------------- */
41 function oilsRptObject() {}
42 oilsRptObject.prototype.init = function() {
43 oilsRptObject.cache(this);
45 oilsRptObject.objectCache = {};
46 oilsRptObject.find = function(id) {
47 return oilsRptObject.objectCache[id];
49 oilsRptObject.cache = function(obj) {
50 obj.id = oilsNextNumericId();
51 oilsRptObject.objectCache[obj.id] = obj;
54 /* -------------------------------------------- */
57 /* returns just the column name */
58 function oilsRptPathCol(path) {
59 var parts = path.split(/-/);
63 /* returns the IDL class of the selected column */
64 function oilsRptPathClass(path) {
65 var parts = path.split(/-/);
70 /* returns everything prior to the column name */
71 function oilsRptPathRel(path) {
72 var parts = path.split(/-/);
74 return parts.join('-');
79 function oilsRptResetParams() {
83 function nodeText(id) {
85 return $(id).innerHTML;
89 function print_tabs(t) {
91 for (var j = 0; j < t; j++ ) { r = r + " "; }
96 function oilsRptDebug() {
97 _debug("\n-------------------------------------\n");
98 _debug(oilsRpt.toString());
99 _debug("\n-------------------------------------\n");
100 if(!oilsRptDebugEnabled) return;
101 if(!oilsRptDebugWindow)
102 oilsRptDebugWindow = window.open('','Debug','resizable,width=700,height=500,scrollbars=1');
104 oilsRptDebugWindow.document.body.innerHTML = oilsRpt.toHTMLString();
107 /* pretty print JSON */
108 function formatJSON(s) {
109 var r = ''; var t = 0;
111 if (s[i] == '{' || s[i] == '[' ) {
112 r = r + s[i] + "\n" + print_tabs(++t);
113 } else if (s[i] == '}' || s[i] == ']') {
114 t--; r = r + "\n" + print_tabs(t) + s[i];
115 } else if (s[i] == ',') {
116 r = r + s[i] + "\n" + print_tabs(t);
125 function print_tabs_html(t) {
127 for (var j = 0; j < t; j++ ) { r = r + " "; }
131 function formatJSONHTML(s) {
132 var r = ''; var t = 0;
134 if (s[i] == '{' || s[i] == '[') {
135 r = r + s[i] + "<br/>" + print_tabs_html(++t);
136 } else if (s[i] == '}' || s[i] == ']') {
137 t--; r = r + "<br/>" + print_tabs_html(t) + s[i];
138 } else if (s[i] == ',') {
140 r = r + "<br/>" + print_tabs_html(t);
148 function setMousePos(e) {
151 oilsPageXMid = parseInt(window.innerHeight / 2);
152 oilsPageYMid = parseInt(window.innerWidth / 2);
155 function buildFloatingDiv(div, width) {
156 var left = parseInt((window.innerWidth / 2) - (width/2));
157 var halfh = parseInt(div.clientHeight / 2);
158 var top = oilsMouseY - halfh + 50;
159 var dbot = top + halfh;
160 if( dbot > window.innerHeight ) {
161 top = oilsMouseY - div.clientHeight - 10;
163 div.setAttribute('style', 'left:'+left+'px; top:'+top+'px; width:'+width+'px');
167 function mergeObjects( src, obj ) {
168 for( var i in obj ) {
169 if( typeof obj[i] == 'string' ) {
172 if(src[i]) mergeObjects(src[i], obj[i]);
173 else src[i] = obj[i];
179 /* scours the doc for elements with IDs. When it finds one,
180 it grabs the dom node and sets a reference to the node at DOM[id]; */
181 function oilsRptIdObjects(node) {
182 if(!node) node = document.documentElement;
183 if( node.nodeType != 1 ) return;
184 var id = node.getAttribute('id');
185 if( id ) eval("DOM."+id+"=$('"+id+"');");
186 var children = node.childNodes;
187 for( var c = 0; c < children.length; c++ )
188 oilsRptIdObjects(children[c]);
192 function oilsRptObjectKeys(obj) {
194 for( var i in obj ) k.push(i);
199 /* makes cls a subclass of parent */
200 function oilsRptSetSubClass(cls, parent) {
201 var str = cls+'.prototype = new '+parent+'();\n';
202 str += cls+'.prototype.constructor = '+cls+';\n';
203 str += cls+'.baseClass = '+parent+'.prototype.constructor;\n';
204 str += cls+'.prototype.super = '+parent+'.prototype;\n';