options debugging code

This commit is contained in:
Alex Yatskov 2017-05-24 19:13:56 -07:00
parent b2833891f9
commit 0efab9773d
3 changed files with 17 additions and 1 deletions

View File

@ -86,6 +86,15 @@ function updateVisibility(options) {
} else { } else {
advanced.hide(); 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) { function onOptionsChanged(e) {

View File

@ -504,9 +504,13 @@ function jsonLoadDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded) {
* Helpers * Helpers
*/ */
function handlebarsEscape(text) {
return Handlebars.Utils.escapeExpression(text);
}
function handlebarsDumpObject(options) { function handlebarsDumpObject(options) {
const dump = JSON.stringify(options.fn(this), null, 4); const dump = JSON.stringify(options.fn(this), null, 4);
return Handlebars.Utils.escapeExpression(dump); return handlebarsEscape(dump);
} }
function handlebarsKanjiLinks(options) { function handlebarsKanjiLinks(options) {

View File

@ -8,6 +8,7 @@
<style> <style>
#anki-spinner, #anki-general, #anki-error, #anki-spinner, #anki-general, #anki-error,
#dict-spinner, #dict-error, #dict-warning, #dict-purge-progress, #dict-import-progress, #dict-spinner, #dict-error, #dict-warning, #dict-purge-progress, #dict-import-progress,
#debug,
.options-advanced { .options-advanced {
display: none; 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> <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> </p>
</div> </div>
<pre id="debug"></pre>
</div> </div>
<div class="pull-right"> <div class="pull-right">