mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-12 09:00:40 +00:00
(Re)Implement live update of corpus and job lists.
This commit is contained in:
@ -12,6 +12,8 @@
|
||||
<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/list.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/list.utils.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/CorpusList.js') }}"></script>
|
||||
@ -21,29 +23,47 @@
|
||||
var corporaSubscribers = [];
|
||||
var jobs;
|
||||
var jobsSubscribers = [];
|
||||
</script>
|
||||
<script>
|
||||
var socket = io();
|
||||
|
||||
socket.on('init-corpora', function(msg) {
|
||||
var subscriber;
|
||||
|
||||
corpora = JSON.parse(msg);
|
||||
for (subscriber of corporaSubscribers) {subscriber.init();}
|
||||
});
|
||||
|
||||
|
||||
socket.on('init-jobs', function(msg) {
|
||||
var subscriber;
|
||||
|
||||
jobs = JSON.parse(msg);
|
||||
for (subscriber of jobsSubscribers) {subscriber.init();}
|
||||
});
|
||||
|
||||
|
||||
socket.on('update-corpora', function(msg) {
|
||||
console.log(msg);
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
socket.on('update-jobs', function(msg) {
|
||||
console.log(msg);
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user