Creo en nosotros. Wikipedia.
ShareCode
Permalink: http://www.treeweb.es/u/974/ 01/02/2011

ShareCode

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


Este ShareCode tiene versiones:
  1. Cargando...... (24/04/2013)
  2. Cargando...... (24/04/2013)
  3. Cargando...... (24/04/2013)
  4. Cargando...... (24/04/2013)
Enlace
El enlace para compartir es: