Skip to content

Commit

Permalink
fix nested json + option to render if big json
Browse files Browse the repository at this point in the history
  • Loading branch information
dardesantis committed Jun 24, 2017
1 parent da8ebb1 commit 935efbc
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Features
* You can inspect the JSON by typing `djson` in the console
* Counts items and properties in a collection
* Show JSON path of the elements on hover and copy it with the context menu
* Option to start with JSON collapsed
* Option to start with JSON collapsed (always or if the file is big)
* Recognize nested JSON strings in properties value

A background worker is used to prevent the UI freezing when processing very long JSON pages.
Expand Down
Binary file modified djson-viewer.crx
Binary file not shown.
8 changes: 7 additions & 1 deletion extension/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
<h1><img src="icons/128.png" alt="djson logo" style="width: 32px; vertical-align: bottom;"> DJSON - ChangeLog</h1>
<h2 style="color: green">We just updated the extension... check out what's new!!!</h2>
<hr>
<h2>v0.4.3 (latest) - 05/06/2017</h2>
<h2>v0.4.4 (latest) - 24/06/2017</h2>
<ul>
<li>Option to start with collapsed JSON if the file is big (>1MB)</li>
<li>Fixed slashed encoding in recognized nested JSON strings in properties value</li>
<li>Collapse All button will start from the first tree level</li>
</ul>
<h2>v0.4.3 - 05/06/2017</h2>
<ul>
<li>Simplified the view json flow. Now it will always open a new tab</li>
<li>Recognize nested JSON strings in properties value</li>
Expand Down
2 changes: 1 addition & 1 deletion extension/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,6 @@
prop = prop.substring(1);
}
var result = Object.byString(msg.obj, prop);
result = result.replace(/\\(.)/mg, "$1");
openJsonTab(result);
}

Expand Down Expand Up @@ -647,6 +646,7 @@
port.postMessage(['FORMATTING', JSON.stringify(localStorage)]);

// Do formatting
var startCollapsed = localStorage.getItem('startCollapsed') || (localStorage.getItem('startCollapsedIfBig') && text.length > 1000000)
var html = jsonObjToHTML(obj, jsonpFunctionName, localStorage.getItem('startCollapsed'));

// Post the HTML string to the content script
Expand Down
5 changes: 4 additions & 1 deletion extension/js/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@
buttonCollapse.addEventListener(
'click',
function () {
collapse([document.getElementsByClassName('expander')[0].parentNode], true);
var firstBlockInner = document.querySelector(".rootDObj > .blockInner");
if (firstBlockInner !== null) {
collapse(firstBlockInner.children, true);
}
}
);

Expand Down
3 changes: 3 additions & 0 deletions extension/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
// start JSON collapsed
optionInit("startCollapsedCheckbox");

// start JSON collapsed if big json
optionInit("startCollapsedIfBigCheckbox");

// show always count of children
optionInit("showAlwaysCountCheckbox");

Expand Down
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "DJSON. JSON Viewer & Formatter",
"short_name": "DJSON Viewer",
"version": "0.4.3",
"version": "0.4.4",
"manifest_version": 2,
"description": "Extension to format and view JSON, from Web, Input or File.",
"homepage_url": "https://github.com/dardesantis/DJSON-Viewer",
Expand Down
4 changes: 3 additions & 1 deletion extension/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ <h2>Theme</h2>
</div>

<h2>Preferences</h2>
<input id="startCollapsedCheckbox" type="checkbox" name="collapsed"> Format JSON with collapsed children
<input id="startCollapsedCheckbox" type="checkbox" name="collapsed"> Format JSON with collapsed children (always)
<br>
<input id="startCollapsedIfBigCheckbox" type="checkbox" name="collapsed"> Format JSON with collapsed children if is a big JSON (>1MB)
<br>
<input id="showAlwaysCountCheckbox" type="checkbox" name="collapsed"> Show always the numbers of items in Objects and Arrays (not only when collapsed)

Expand Down

0 comments on commit 935efbc

Please sign in to comment.