Gracias, Wikipedia.
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

1 var data1 = {'boolean':true,'boolean2':false,'text':'holaa tioo'};2 3 4 window.addEventListener('load', function(event) {5  logger.log(window);6  logger.log(data1);7 }, true);8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 (function(window){26  27  var counter = 0;28 29  window.logger = {30  'clear':function() {31  var l = document.getElementById('logger');32  l.innerHTML = '';33  counter = 0;34  },35  'log':function(o) {36  counter++;37  var l = document.getElementById('logger');38  var entry = document.createElement('div');39  entry.className = 'log';40  41  var entry_counter = document.createElement('div');42  entry_counter.className = 'entry-counter';43  entry_counter.innerHTML = counter;44  entry.appendChild(entry_counter);45  46  var entry_content = document.createElement('div');47  entry_content.className = 'entry-content';48  entry.appendChild(entry_content);49  50  if (typeof o == 'string') {51  entry_content.innerHTML = o;52  } else {53  var f = null;54  var fa = null;55  var fb = null;56  57  var k;58  var ko=null;59  for (k in o) {60  ko = o[k];61  62  f = document.createElement('div');63  f.className = 'log-line';64  65  fa = document.createElement('span');66  fa.className = 'log-line-a';67  fa.innerHTML = k+' = ';68  f.appendChild(fa);69  70  fb = document.createElement('span');71  fb.className = 'log-line-b';72  if (typeof ko == 'object') {73  var a = document.createElement('span');74  a.className = 'log-inspect';75  a.innerHTML = ''+ko+'';76  if (ko != null) {77  a.ko = ko;78  a.addEventListener('click', function(event){79  logger.log(this.ko);80  }, true);81  }82  fb.appendChild(a);83  } else if (typeof ko == 'string') {84  var a = document.createElement('textarea');85  a.className = 'log-string';86  a.k = k;87  a.o = o;88  a.addEventListener('keyup', function(event){89  this.o[this.k] = this.value;90  }, true);91  a.value = ko;92  fb.appendChild(a);93  } else if (typeof ko == 'number') {94  var a = document.createElement('span');95  a.className = 'log-number';96  a.setAttribute('contentEditable', true);97  a.innerHTML = ko;98  a.k = k;99  a.o = o;100  a.addEventListener('keyup', function(event){101  alert(this.o[this.k]);102  this.o[this.k] = this.value;103  104  }, true);105  fb.appendChild(a);106  } else if (typeof ko == 'boolean') {107  var a = document.createElement('input');108  a.setAttribute('type', 'checkbox');109  a.className = 'log-boolean';110  a.checked = ko;111  a.k = k;112  a.o = o;113  a.addEventListener('click', function(event) {114  this.o[this.k] = this.checked;115  }, true);116  fb.appendChild(a);117  } else if (typeof ko == 'function') {118  var a = document.createElement('pre');119  a.className = 'log-function';120  a.innerHTML = 'function';121  a.ko = ko;122  a.addEventListener('click', function(event){123  this.innerHTML = this.ko;124  this.innerHTML = a.classList.add('log-function-opened');125  }, true);126  127  fb.appendChild(a);128  } else {129  fb.innerHTML = typeof(ko);130  }131  f.appendChild(fb);132  133  entry_content.appendChild(f);134  135  l.scrollTop = 0;136  }137  }138  139  if (l.firstChild == null) {140  l.appendChild(entry);141  } else {142  l.insertBefore(entry, l.firstChild);143  }144  145  return entry_content;146  }147  }148 149 }(this))


Este ShareCode tiene versiones:
  1. LOggER ... (07/11/2012)
Enlace
El enlace para compartir es:

Powered by TreeWeb
© TreeWeb 2010. Todos los derechos reservados