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 /* -------------------------------------------- */
48 function oilsRptResetParams() {
52 function nodeText(id) {
54 return $(id).innerHTML;
58 function print_tabs(t) {
60 for (var j = 0; j < t; j++ ) { r = r + " "; }
65 function oilsRptDebug() {
66 _debug("\n-------------------------------------\n");
67 _debug(oilsRpt.toString());
68 _debug("\n-------------------------------------\n");
69 if(!oilsRptDebugEnabled) return;
70 if(!oilsRptDebugWindow)
71 oilsRptDebugWindow = window.open('','Debug','resizable,width=700,height=500,scrollbars=1');
73 oilsRptDebugWindow.document.body.innerHTML = oilsRpt.toHTMLString();
76 /* pretty print JSON */
77 function formatJSON(s) {
78 var r = ''; var t = 0;
80 if (s[i] == '{' || s[i] == '[' ) {
81 r = r + s[i] + "\n" + print_tabs(++t);
82 } else if (s[i] == '}' || s[i] == ']') {
83 t--; r = r + "\n" + print_tabs(t) + s[i];
84 } else if (s[i] == ',') {
85 r = r + s[i] + "\n" + print_tabs(t);
94 function print_tabs_html(t) {
96 for (var j = 0; j < t; j++ ) { r = r + " "; }
100 function formatJSONHTML(s) {
101 var r = ''; var t = 0;
103 if (s[i] == '{' || s[i] == '[') {
104 r = r + s[i] + "<br/>" + print_tabs_html(++t);
105 } else if (s[i] == '}' || s[i] == ']') {
106 t--; r = r + "<br/>" + print_tabs_html(t) + s[i];
107 } else if (s[i] == ',') {
109 r = r + "<br/>" + print_tabs_html(t);
117 function setMousePos(e) {
120 oilsPageXMid = parseInt(window.innerHeight / 2);
121 oilsPageYMid = parseInt(window.innerWidth / 2);
124 function buildFloatingDiv(div, width) {
125 var left = parseInt((window.innerWidth / 2) - (width/2));
126 var halfh = parseInt(div.clientHeight / 2);
127 var top = oilsMouseY - halfh + 50;
128 var dbot = top + halfh;
129 if( dbot > window.innerHeight ) {
130 top = oilsMouseY - div.clientHeight - 10;
132 div.setAttribute('style', 'left:'+left+'px; top:'+top+'px; width:'+width+'px');
136 function mergeObjects( src, obj ) {
137 for( var i in obj ) {
138 if( typeof obj[i] == 'string' ) {
141 if(src[i]) mergeObjects(src[i], obj[i]);
142 else src[i] = obj[i];
148 /* scours the doc for elements with IDs. When it finds one,
149 it grabs the dom node and sets a reference to the node at DOM[id]; */
150 function oilsRptIdObjects(node) {
151 if(!node) node = document.documentElement;
152 if( node.nodeType != 1 ) return;
153 var id = node.getAttribute('id');
154 if( id ) eval("DOM."+id+"=$('"+id+"');");
155 var children = node.childNodes;
156 for( var c = 0; c < children.length; c++ )
157 oilsRptIdObjects(children[c]);
161 function oilsRptObjectKeys(obj) {
163 for( var i in obj ) k.push(i);