Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function dump_r(obj, levelmax, level) {
- level = level || 0;
- if(levelmax != 0 && level >= levelmax) return;
- var out = '';
- if(typeof(obj) == "object" || typeof(obj) == "array") {
- for (var i in obj) {
- for(var j=0; j<level; j++) {
- out += " ";
- }
- if(typeof(obj[i]) == "object" || typeof(obj[i]) == "array") {
- out += i + ": (" + typeof(obj[i]) + ")\n";
- out += dump_r(obj[i], levelmax, level+1) || '';
- }
- else {
- out += i + ": (" + typeof(obj[i]) +") " + obj[i] + "\n";
- }
- }
- }
- else {
- out += "(" + typeof(obj) + ") " + obj;
- }
- return out;
- }
- function dump(obj, inalert, levelmax) {
- levelmax = levelmax || 3;
- level_max = levelmax;
- inalert = inalert || false;
- if(!inalert) {
- var pop = document.createElement('pre');
- pop.style.position = "fixed";
- pop.style.left = "0";
- pop.style.top = "0";
- pop.style.zIndex = "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999";
- pop.style.fontSize = "0.8em";
- pop.style.fontFamily = "Consolas";
- pop.style.width = (window.innerWidth - 10)+"px";
- pop.style.height = (window.innerHeight - 10)+"px";
- pop.style.overflow = "auto";
- pop.style.padding = "5px";
- pop.style.background = "white";
- pop.style.color = "black";
- pop.style.margin = "0";
- pop.ondblclick = function() {
- document.body.removeChild(this);
- };
- pop.innerHTML = dump_r(obj, levelmax).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'") + '<p style="position:absolute; right:20px;top:0;position:fixed;">Double-cliquez pour fermer</p>';
- document.body.appendChild(pop);
- }
- else {
- alert(dump_r(obj, levelmax));
- }
- }
Add Comment
Please, Sign In to add comment