nopaque/app/static/js/app.js
2024-12-02 09:34:17 +01:00

34 lines
1.2 KiB
JavaScript

nopaque.App = class App {
constructor() {
this.data = {};
this.socket = io({transports: ['websocket'], upgrade: false});
this.ui = new nopaque.UIExtension(this);
this.users = new nopaque.UsersExtension(this);
}
// onPatch(patch) {
// // Filter Patch to only include operations on users that are initialized
// let regExp = new RegExp(`^/users/(${Object.keys(this.data.users).join('|')})`);
// let filteredPatch = patch.filter(operation => regExp.test(operation.path));
// // Handle job status updates
// let subRegExp = new RegExp(`^/users/([A-Za-z0-9]*)/jobs/([A-Za-z0-9]*)/status$`);
// let subFilteredPatch = filteredPatch
// .filter((operation) => {return operation.op === 'replace';})
// .filter((operation) => {return subRegExp.test(operation.path);});
// for (let operation of subFilteredPatch) {
// let [match, userId, jobId] = operation.path.match(subRegExp);
// this.flash(`[<a href="/jobs/${jobId}">${this.data.users[userId].jobs[jobId].title}</a>] New status: <span class="job-status-text" data-job-status="${operation.value}"></span>`, 'job');
// }
// // Apply Patch
// jsonpatch.applyPatch(this.data, filteredPatch);
// }
init() {
this.ui.init();
}
};