mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 09:15:41 +00:00
58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
var subscribers = {"corpora": [], "jobs": []};
|
|
|
|
|
|
function getCorpora() {
|
|
fetch("/api/v1.0/corpora")
|
|
.then(function(response) {
|
|
if (response.status >= 200 && response.status < 300) {
|
|
return Promise.resolve(response);
|
|
} else {
|
|
return Promise.reject(new Error(response.statusText));
|
|
}
|
|
})
|
|
.then(function(response) {
|
|
return response.json();
|
|
})
|
|
.then(function(data) {
|
|
if (JSON.stringify(corpora) != JSON.stringify(data)) {
|
|
corpora = data;
|
|
for (subscriber of subscribers.corpora) {
|
|
subscriber();
|
|
}
|
|
}
|
|
})
|
|
.catch(function(error) {
|
|
console.log('Request failed', error);
|
|
});
|
|
}
|
|
|
|
|
|
function getJobs() {
|
|
fetch("/api/v1.0/jobs")
|
|
.then(function(response) {
|
|
if (response.status >= 200 && response.status < 300) {
|
|
return Promise.resolve(response);
|
|
} else {
|
|
return Promise.reject(new Error(response.statusText));
|
|
}
|
|
})
|
|
.then(function(response) {
|
|
return response.json();
|
|
})
|
|
.then(function(data) {
|
|
if (JSON.stringify(jobs) != JSON.stringify(data)) {
|
|
jobs = data;
|
|
for (subscriber of subscribers.jobs) {
|
|
subscriber();
|
|
}
|
|
}
|
|
})
|
|
.catch(function(error) {
|
|
console.log('Request failed', error);
|
|
});
|
|
}
|
|
|
|
|
|
setInterval(getCorpora, 5000);
|
|
setInterval(getJobs, 5000);
|