Use JSON patch the correct way!

This commit is contained in:
Patrick Jentsch
2019-08-30 13:31:00 +02:00
parent 7702de8770
commit 8f3c53dad2
7 changed files with 158 additions and 5035 deletions

View File

@@ -11,9 +11,8 @@
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='fonts/material-icons/material-icons.css') }}">
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/materialize.min.css') }}" media="screen,projection"/>
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/opaque.css') }}" media="screen,projection"/>
<script src="{{ url_for('static', filename='js/socket.io.js') }}"></script>
<script src="{{ url_for('static', filename='js/jsonpatch.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/jsondiffpatch.umd.js') }}"></script>
<script src="{{ url_for('static', filename='js/socket.io.js') }}"></script>
<script src="{{ url_for('static', filename='js/list.js') }}"></script>
<script src="{{ url_for('static', filename='js/list.utils.js') }}"></script>
<script src="{{ url_for('static', filename='js/CorpusList.js') }}"></script>
@@ -29,7 +28,7 @@
var subscriber;
corpora = JSON.parse(msg);
for (subscriber of corporaSubscribers) {subscriber.init();}
for (subscriber of corporaSubscribers) {subscriber._init();}
});
@@ -37,7 +36,7 @@
var subscriber;
jobs = JSON.parse(msg);
for (subscriber of jobsSubscribers) {subscriber.init();}
for (subscriber of jobsSubscribers) {subscriber._init();}
});
@@ -45,12 +44,8 @@
var patch, patchedCorpora, subscriber;
patch = JSON.parse(msg);
patchedCorpora = jsonpatch.apply_patch(corpora, patch);
delta = jsondiffpatch.diff(corpora, patchedCorpora);
corpora = patchedCorpora;
for (subscriber of corporaSubscribers) {
subscriber.updateWithPatch(delta);
}
corpora = jsonpatch.apply_patch(corpora, patch);
for (subscriber of corporaSubscribers) {subscriber._update(patch);}
});
@@ -58,12 +53,8 @@
var patch, patchedJobs, subscriber;
patch = JSON.parse(msg);
patchedJobs = jsonpatch.apply_patch(jobs, patch);
delta = jsondiffpatch.diff(jobs, patchedJobs);
jobs = patchedJobs;
for (subscriber of jobsSubscribers) {
subscriber.updateWithPatch(delta);
}
jobs = jsonpatch.apply_patch(jobs, patch);
for (subscriber of jobsSubscribers) {subscriber._update(patch);}
});