Use canonical serializer for json serialization
This commit is contained in:
parent
319f5b95f7
commit
ecc41d14af
@ -189,7 +189,7 @@ define([
|
|||||||
// reject patch if it results in invalid JSON
|
// reject patch if it results in invalid JSON
|
||||||
transformFunction : JsonOT.validate,
|
transformFunction : JsonOT.validate,
|
||||||
|
|
||||||
websocketURL: Config.websocketURL,
|
websocketURL: Config.websocketURL+'_old',
|
||||||
|
|
||||||
// username
|
// username
|
||||||
userName: userName,
|
userName: userName,
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
require.config({ paths: { 'json.sortify': '/bower_components/json.sortify/dist/JSON.sortify' } });
|
||||||
define([
|
define([
|
||||||
'/api/config?cb=' + Math.random().toString(16).substring(2),
|
'/api/config?cb=' + Math.random().toString(16).substring(2),
|
||||||
'/common/messages.js',
|
'/common/messages.js',
|
||||||
@ -9,15 +10,20 @@ define([
|
|||||||
'/common/cursor.js',
|
'/common/cursor.js',
|
||||||
'/common/json-ot.js',
|
'/common/json-ot.js',
|
||||||
'/common/TypingTests.js',
|
'/common/TypingTests.js',
|
||||||
|
'json.sortify',
|
||||||
'/bower_components/diff-dom/diffDOM.js',
|
'/bower_components/diff-dom/diffDOM.js',
|
||||||
'/bower_components/jquery/dist/jquery.min.js',
|
'/bower_components/jquery/dist/jquery.min.js',
|
||||||
'/customize/pad.js'
|
'/customize/pad.js'
|
||||||
], function (Config, Messages, Crypto, realtimeInput, Hyperjson, Hyperscript, Toolbar, Cursor, JsonOT, TypingTest) {
|
], function (Config, Messages, Crypto, realtimeInput, Hyperjson, Hyperscript, Toolbar, Cursor, JsonOT, TypingTest, JSONSortify) {
|
||||||
var $ = window.jQuery;
|
var $ = window.jQuery;
|
||||||
var ifrw = $('#pad-iframe')[0].contentWindow;
|
var ifrw = $('#pad-iframe')[0].contentWindow;
|
||||||
var Ckeditor; // to be initialized later...
|
var Ckeditor; // to be initialized later...
|
||||||
var DiffDom = window.diffDOM;
|
var DiffDom = window.diffDOM;
|
||||||
|
|
||||||
|
var stringify = function (obj) {
|
||||||
|
return JSONSortify(obj);
|
||||||
|
};
|
||||||
|
|
||||||
window.Toolbar = Toolbar;
|
window.Toolbar = Toolbar;
|
||||||
window.Hyperjson = Hyperjson;
|
window.Hyperjson = Hyperjson;
|
||||||
|
|
||||||
@ -51,7 +57,7 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
var stringifyDOM = function (dom) {
|
var stringifyDOM = function (dom) {
|
||||||
return JSON.stringify(Hyperjson.fromDOM(dom, isNotMagicLine, brFilter));
|
return stringify(Hyperjson.fromDOM(dom, isNotMagicLine, brFilter));
|
||||||
};
|
};
|
||||||
|
|
||||||
var andThen = function (Ckeditor) {
|
var andThen = function (Ckeditor) {
|
||||||
@ -249,7 +255,7 @@ define([
|
|||||||
applyHjson(shjson);
|
applyHjson(shjson);
|
||||||
|
|
||||||
// Build a new stringified Chainpad hyperjson without metadata to compare with the one build from the dom
|
// Build a new stringified Chainpad hyperjson without metadata to compare with the one build from the dom
|
||||||
shjson = JSON.stringify(hjson);
|
shjson = stringify(hjson);
|
||||||
|
|
||||||
var shjson2 = stringifyDOM(inner);
|
var shjson2 = stringifyDOM(inner);
|
||||||
if (shjson2 !== shjson) {
|
if (shjson2 !== shjson) {
|
||||||
@ -309,7 +315,7 @@ define([
|
|||||||
hjson[hjson.length] = {metadata: userList};
|
hjson[hjson.length] = {metadata: userList};
|
||||||
}
|
}
|
||||||
// stringify the json and send it into chainpad
|
// stringify the json and send it into chainpad
|
||||||
var shjson = JSON.stringify(hjson);
|
var shjson = stringify(hjson);
|
||||||
if (!rti.patchText(shjson)) {
|
if (!rti.patchText(shjson)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user