diff --git a/CHANGELOG.md b/CHANGELOG.md index 93549a82..831beddd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,9 @@ - messages received almost simultaneously are now bundled before being sent to the clients. This helps preserving their order. - widgets - sliders/pads: when receiving feedback while touched, the widget waits to be released before updating to the latest received value. -- editor +- misc - property fields are now parsed using [JSON5](https://github.com/json5/json5), a more flexible notation. Session files are still written in standard JSON format, this is just a way to avoid typing mistakes when using the editor. + - remote editing also accepts JSON5 notation ## 0.20.3 diff --git a/resources/docs/extras/remote-control.md b/resources/docs/extras/remote-control.md index 0c43a15a..6c3f5073 100644 --- a/resources/docs/extras/remote-control.md +++ b/resources/docs/extras/remote-control.md @@ -10,7 +10,7 @@ Apply a set of options to an existing widget by replacing the old ones with the - `id`: `string`, widget's `id` -- `options`: `string`, JSON stringified object defining the new properties to merge +- `options`: `string`, [JSON5](https://github.com/json5/json5) stringified object defining the new properties to merge - example: `{"label":"New Label", "color":"red"}` !!! warning "" @@ -22,7 +22,7 @@ Apply a set of options to an existing widget by merging them to the widget's opt - `id`: `string`, widget's `id` -- `options`: `string`, JSON stringified object defining the new properties to merge +- `options`: `string`, [JSON5](https://github.com/json5/json5) stringified object defining the new properties to merge - example: `{"label":"New Label", "color":"red"}` !!! warning "" diff --git a/src/browser/js/app/editor/edit-objects.js b/src/browser/js/app/editor/edit-objects.js index f0f9d443..e8c6a434 100644 --- a/src/browser/js/app/editor/edit-objects.js +++ b/src/browser/js/app/editor/edit-objects.js @@ -1,7 +1,6 @@ var updateDom = require('./data-workers').updateDom, {widgets, categories} = require('../widgets'), {icon} = require('../utils'), - JSON5 = require('json5'), defaults = {} for (var k in widgets) { @@ -97,12 +96,12 @@ var editObject = function(container, data, refresh){ } input.on('change',function(){ - // var v = $(this).val()!= '' && $(this).data('type') == 'object'?JSON.parse($(this).val()):$(this).val() + var title = input.attr('title'), v try { - v = JSON5.parse(input.val()) + v = JSON.parseFlex(input.val()) } catch(err) { v = input.val() } diff --git a/src/browser/js/app/remote-control.js b/src/browser/js/app/remote-control.js index 75b6eabc..c134a4c2 100644 --- a/src/browser/js/app/remote-control.js +++ b/src/browser/js/app/remote-control.js @@ -13,7 +13,7 @@ var callbacks = { if (READ_ONLY) return var [id, json] = args, - newdata = JSON.parse(json), + newdata = JSON.parseFlex(json), containers = widgetManager.getWidgetById(id) if (!containers.length) return @@ -32,7 +32,7 @@ var callbacks = { if (READ_ONLY) return var [id, json] = args, - newdata = JSON.parse(json), + newdata = JSON.parseFlex(json), containers = widgetManager.getWidgetById(id) if (!containers.length) return @@ -54,7 +54,7 @@ var callbacks = { $(`.tablink[data-widget="${w.hash}"]`).trigger('fake-click') } } - + } } diff --git a/src/browser/js/browser.js b/src/browser/js/browser.js index 2deac84d..326a7440 100644 --- a/src/browser/js/browser.js +++ b/src/browser/js/browser.js @@ -53,6 +53,10 @@ request.send() /////////////////////// +window.JSON.parseFlex = require('json5').parse + +/////////////////////// + window.$ = require('jquery/dist/jquery.slim.min.js') require('./libs/jquery.ui') require('./libs/jquery.drag')