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];
28 /* -------------------------------------------- */
29 function oilsRptObject() {}
30 oilsRptObject.prototype.init = function() {
31 oilsRptObject.cache(this);
33 oilsRptObject.objectCache = {};
34 oilsRptObject.find = function(id) {
35 return oilsRptObject.objectCache[id];
37 oilsRptObject.cache = function(obj) {
38 obj.id = oilsNextNumericId();
39 oilsRptObject.objectCache[obj.id] = obj;
42 /* -------------------------------------------- */
45 /* returns just the column name */
46 function oilsRptPathCol(path) {
47 var parts = path.split(/-/);
51 /* returns the IDL class of the selected column */
52 function oilsRptPathClass(path) {
53 var parts = path.split(/-/);
58 /* returns everything prior to the column name */
59 function oilsRptPathRel(path) {
60 var parts = path.split(/-/);
62 return parts.join('-');
67 function oilsRptResetParams() {
71 function nodeText(id) {
73 return $(id).innerHTML;
77 function print_tabs(t) {
79 for (var j = 0; j < t; j++ ) { r = r + " "; }
84 function oilsRptDebug() {
85 _debug("\n-------------------------------------\n");
86 _debug(oilsRpt.toString());
87 _debug("\n-------------------------------------\n");
88 if(!oilsRptDebugEnabled) return;
89 if(!oilsRptDebugWindow)
90 oilsRptDebugWindow = window.open('','Debug','resizable,width=700,height=500,scrollbars=1');
92 oilsRptDebugWindow.document.body.innerHTML = oilsRpt.toHTMLString();
95 /* pretty print JSON */
96 function formatJSON(s) {
97 var r = ''; var t = 0;
99 if (s[i] == '{' || s[i] == '[' ) {
100 r = r + s[i] + "\n" + print_tabs(++t);
101 } else if (s[i] == '}' || s[i] == ']') {
102 t--; r = r + "\n" + print_tabs(t) + s[i];
103 } else if (s[i] == ',') {
104 r = r + s[i] + "\n" + print_tabs(t);
113 function print_tabs_html(t) {
115 for (var j = 0; j < t; j++ ) { r = r + " "; }
119 function formatJSONHTML(s) {
120 var r = ''; var t = 0;
122 if (s[i] == '{' || s[i] == '[') {
123 r = r + s[i] + "<br/>" + print_tabs_html(++t);
124 } else if (s[i] == '}' || s[i] == ']') {
125 t--; r = r + "<br/>" + print_tabs_html(t) + s[i];
126 } else if (s[i] == ',') {
128 r = r + "<br/>" + print_tabs_html(t);
136 function setMousePos(e) {
139 oilsPageXMid = parseInt(window.innerHeight / 2);
140 oilsPageYMid = parseInt(window.innerWidth / 2);
143 function buildFloatingDiv(div, width) {
144 var left = parseInt((window.innerWidth / 2) - (width/2));
145 var halfh = parseInt(div.clientHeight / 2);
146 var top = oilsMouseY - halfh + 50;
147 var dbot = top + halfh;
148 if( dbot > window.innerHeight ) {
149 top = oilsMouseY - div.clientHeight - 10;
151 div.setAttribute('style', 'left:'+left+'px; top:'+top+'px; width:'+width+'px');
155 function mergeObjects( src, obj ) {
156 for( var i in obj ) {
157 if( typeof obj[i] == 'string' ) {
160 if(src[i]) mergeObjects(src[i], obj[i]);
161 else src[i] = obj[i];
167 /* scours the doc for elements with IDs. When it finds one,
168 it grabs the dom node and sets a reference to the node at DOM[id]; */
169 function oilsRptIdObjects(node) {
170 if(!node) node = document.documentElement;
171 if( node.nodeType != 1 ) return;
172 var id = node.getAttribute('id');
173 if( id ) eval("DOM."+id+"=$('"+id+"');");
174 var children = node.childNodes;
175 for( var c = 0; c < children.length; c++ )
176 oilsRptIdObjects(children[c]);
180 function oilsRptObjectKeys(obj) {
182 for( var i in obj ) k.push(i);
187 /* makes cls a subclass of parent */
188 function oilsRptSetSubClass(cls, parent) {
189 var str = cls+'.prototype = new '+parent+'();\n';
190 str += cls+'.prototype.constructor = '+cls+';\n';
191 str += cls+'.baseClass = '+parent+'.prototype.constructor;\n';
192 str += cls+'.prototype.super = '+parent+'.prototype;\n';