From fad236b16e5e65820e63b602a27f56dbcf02545e Mon Sep 17 00:00:00 2001 From: Rece Date: Sun, 25 Aug 2013 21:33:31 -0500 Subject: [PATCH] added sloppy object functionality added todo's added minimal classes --- collapse.js | 32 +++++++++++--------------------- content.js | 21 +++++++++++---------- textParser.js | 1 + 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/collapse.js b/collapse.js index e345193..9e527e2 100644 --- a/collapse.js +++ b/collapse.js @@ -1,37 +1,28 @@ // modified from JSONviewer // jsonview.com -// This used to use jQuery, but was rewritten in plan DOM for speed and to get rid of the jQuery dependency. -document.addEventListener('DOMContentLoaded', function() { - // Click handler for collapsing and expanding objects and arrays - function collapse(evt) { - var collapser = evt.target; +// Click handler for collapsing and expanding objects and arrays +function collapse(evt) { + var collapser = evt.target; - var target = collapser.parentNode.getElementsByClassName('collapsible'); + var target = collapser.parentNode.getElementsByClassName('collapsible'); - if ( ! target.length ) { + if ( ! target.length ) { return; } target = target[0]; if ( target.style.display == 'none' ) { - var ellipsis = target.parentNode.getElementsByClassName('ellipsis')[0]; - target.parentNode.removeChild(ellipsis); target.style.display = ''; collapser.innerHTML = '-'; } else { target.style.display = 'none'; - - var ellipsis = document.createElement('span'); - ellipsis.className = 'ellipsis'; - ellipsis.innerHTML = ' … '; - target.parentNode.insertBefore(ellipsis, target); collapser.innerHTML = '+'; } - } +} - function addCollapser(item) { +function addCollapser(item) { // This mainly filters out the root object (which shouldn't be collapsible) if ( item.nodeName != 'LI' ) { return; @@ -42,10 +33,9 @@ document.addEventListener('DOMContentLoaded', function() { collapser.innerHTML = '-'; collapser.addEventListener('click', collapse, false); item.insertBefore(collapser, item.firstChild); - } +} - var items = document.getElementsByClassName('collapsible'); - for( var i = 0; i < items.length; i++) { +var items = document.getElementsByClassName('collapsible'); +for( var i = 0; i < items.length; i++) { addCollapser(items[i].parentNode); - } -}, false); +} diff --git a/content.js b/content.js index c6dea85..3c5b6e2 100644 --- a/content.js +++ b/content.js @@ -13,7 +13,8 @@ function ContentItem(data, caller) { closingQ = data.indexOf("\"", openingQ + 1), openingP = data.indexOf("("), closingP = data.indexOf(")"); - + //TODO: make sure that (, ) dont appear inside quotes + //http://www.php.net/manual/en/language.types.intro.php //check primitive scalar types if (data.substring(0, 4) == "bool") { @@ -42,9 +43,9 @@ function ContentItem(data, caller) { this.compound = true; this.extraInfo.push("Number of Elements: " + data.substring(6, closingP)); } else if (data.substring(0, 6) == "object") { - this.type = "object { "; + this.type = "object"; this.compound = true; - this.html = data.substring(8, data.length); + this.html = data.substring(6, data.length); //TODO: Don't think this is complete } @@ -75,28 +76,28 @@ ContentItem.prototype.printOpening = function () { switch(this.type) { case "object": if(this.node.parent.content.compound) {toPrint += '
  • ';} - toPrint += "