From f6a11f3a21e2336a370543f255ab22d44ddb2e93 Mon Sep 17 00:00:00 2001 From: mirrt Date: Sat, 27 Feb 2016 19:31:42 +0200 Subject: [PATCH] debug tab | show encrypted data file contents --- iguana/index.html | 6 +++++- iguana/js/debugJson.js | 43 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/iguana/index.html b/iguana/index.html index 0b20ebc67..50efa9c89 100755 --- a/iguana/index.html +++ b/iguana/index.html @@ -426,7 +426,11 @@ data-path="{tc}/{config}">
JSON response
- + + +
encrypted file content
+ +
diff --git a/iguana/js/debugJson.js b/iguana/js/debugJson.js index 1cc3bf7a2..422101969 100644 --- a/iguana/js/debugJson.js +++ b/iguana/js/debugJson.js @@ -68,11 +68,37 @@ dJson.decrypt = function(credentials, cb) { ); }; +// Read file contents from html5 file system +var readJsonEncryptedFile = function(filename,callback){ + + fileSystem.root.getFile(filename, {}, function(fileEntry) { + + fileEntry.file(function(file) { + var reader = new FileReader(); + + reader.onloadend = function(e) { + console.log("file content " + filename, this.result.toString()); + callback(this.result.toString()); + }; + + reader.readAsText(file); + }, function(e){ + errorHandler(e); + callback(e.message); + }); + + }, function(e){ + errorHandler(e); + callback(e.message); + }); +}; + $(document).ready(function() { var encryptBtn = $('#debug_json_encrypt'), decryptBtn = $('#debug_json_decrypt'), debugJsonResult = $('#debug_json_result'), + debugFileResult = $('#debug_json_file'), pass = $('#debug_passphrase'), permFile = $('#debug_permanentfile'), jsonSrc = $('#debug_json_src'); @@ -88,6 +114,15 @@ $(document).ready(function() { jsonSrc.val(), function(response) { debugJsonResult.text(response || 'wrong json'); + + // Get file contents + var resObj = dJson._checkJson(response); + if(resObj && resObj.filename) { + readJsonEncryptedFile(resObj.filename, function(filedata) { + //console.log('returned filedata', filedata); + debugFileResult.text(filedata); + }); + } }); }); @@ -106,7 +141,13 @@ $(document).ready(function() { }, function(response) { debugJsonResult.text(response); }); - }); + }); + + $("#debug_clear_response").click(function(e) { + e.preventDefault(); + debugJsonResult.text("JSON response"); + debugFileResult.text("encrypted file content"); + }); });