To main page | Opera Unite HowTo'sunite_info (a-la php_info)This function is analogous to php_info() or pprint() function unite_info(o, r) {
function out_repr(o, i, ri, app) {
try {
if (ri.toString().match(/^function /)) {
ret = '(...) // function';
} else if (ri.toString().match(/^.object /)) {
ret = ': ';
o.write('<br>');
} else {
ret = ' = "' + ri + '"';
};
} catch(err) {
ret = ' = [null??]';
};
//ret = ret.replace(/..../,'[opera_user_name]')
//ret = ret.replace(/..../,'[device_name]')
//ret = ret.replace(/..../,'[service_path]')
str = '<span style="color: gray;">' + app + '</span>' +
i + ret + '<br>';
if (i.match(/^[0-9]+$/)) {
str = str.replace(/\.<\/span>[0-9]/,'</span>[0]');
};
//str = str.replace(/<br>/,'**<br>');
//str = str.replace(/<\/span>/,'</span>**');
o.write( str );
};
function rec_o(o, obj, app, lev) {
if (app == 'r.connection.request.connection.') { return; };
if (lev>=5) { return; }
if (obj) {
if (obj.toString().match(/object/)) {
for (j in obj) {
out_repr(o, j, obj[j], app);
rec_o(o, obj[j], app+j+'.', lev+1);
};
};
};
};
rec_o(o, r, 'r.', 0);
};
Example usagefunction start_page(r) { var o = r.connection.response; unite_info(o, r); // this will call "o.write" full hierarchy of "r" ...."r" is an instance of "WebServerRequestEvent" class. To avoid cyclic references it would only go 5 levels deep, if you need more, fix "lev>=5" in function above. Example outputSee here | Last updated
|