diff options
author | Alex Yatskov <alex@foosoft.net> | 2017-05-24 19:13:56 -0700 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2017-05-24 19:13:56 -0700 |
commit | 0efab9773d0cc6586eb4a1f271821795b6d07f5c (patch) | |
tree | e9a06728d9e2ab5f51e055f75ec3cc88c182df71 /ext | |
parent | b2833891f9b5d0ceaebc26586b02120bacec68be (diff) |
options debugging code
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bg/js/options.js | 9 | ||||
-rw-r--r-- | ext/bg/js/util.js | 6 | ||||
-rw-r--r-- | ext/bg/options.html | 3 |
3 files changed, 17 insertions, 1 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 1b675da2..4eafd9ef 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -86,6 +86,15 @@ function updateVisibility(options) { } else { advanced.hide(); } + + const debug = $('#debug'); + if (options.general.debugInfo) { + const text = JSON.stringify(options, null, 4); + debug.html(handlebarsEscape(text)); + debug.show(); + } else { + debug.hide(); + } } function onOptionsChanged(e) { diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index 64c79ab5..593e7d03 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -504,9 +504,13 @@ function jsonLoadDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded) { * Helpers */ +function handlebarsEscape(text) { + return Handlebars.Utils.escapeExpression(text); +} + function handlebarsDumpObject(options) { const dump = JSON.stringify(options.fn(this), null, 4); - return Handlebars.Utils.escapeExpression(dump); + return handlebarsEscape(dump); } function handlebarsKanjiLinks(options) { diff --git a/ext/bg/options.html b/ext/bg/options.html index 434241e3..8281c317 100644 --- a/ext/bg/options.html +++ b/ext/bg/options.html @@ -8,6 +8,7 @@ <style> #anki-spinner, #anki-general, #anki-error, #dict-spinner, #dict-error, #dict-warning, #dict-purge-progress, #dict-import-progress, + #debug, .options-advanced { display: none; } @@ -272,6 +273,8 @@ <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4DBTN9A3CUAFN"><img src="/bg/img/paypal.gif" alt></a> </p> </div> + + <pre id="debug"></pre> </div> <div class="pull-right"> |