aboutsummaryrefslogtreecommitdiff
path: root/assets/js/worker.js
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2019-01-30 21:15:17 +0100
committervincent-peugnet <v.peugnet@free.fr>2019-01-30 23:16:26 +0100
commit8ac5a09605992f1e434cb793ceca7497c6f46d23 (patch)
tree091f9879f8f94b849300fef2d1a1238f3881f78e /assets/js/worker.js
parent396a5776cd043e899e4897ec50fc8edc52585512 (diff)
downloadwcms-8ac5a09605992f1e434cb793ceca7497c6f46d23.tar.gz
wcms-8ac5a09605992f1e434cb793ceca7497c6f46d23.zip
feat: editBy to store the current editor of an art
Diffstat (limited to 'assets/js/worker.js')
-rw-r--r--assets/js/worker.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/assets/js/worker.js b/assets/js/worker.js
new file mode 100644
index 0000000..846acba
--- /dev/null
+++ b/assets/js/worker.js
@@ -0,0 +1,37 @@
+let arturl;
+
+onmessage = function (e) {
+ switch (e.data.type) {
+ case 'init':
+ arturl = e.data.arturl;
+ break;
+ case 'stillEditing':
+ stillEditing();
+ break;
+ case 'quitEditing':
+ quitEditing();
+ break;
+ };
+}
+
+function stillEditing() {
+ console.log('send still editing');
+ const url = arturl + '/editby';
+ const req = new XMLHttpRequest();
+ req.open('POST', url, false);
+ req.send(null);
+
+ const res = JSON.parse(req.responseText);
+ console.log(res);
+}
+
+function quitEditing() {
+ console.log('send quit editing');
+ const url = arturl + '/removeeditby';
+ const req = new XMLHttpRequest();
+ req.open('POST', url, false);
+ req.send(null);
+
+ const res = JSON.parse(req.responseText);
+ console.log(res);
+} \ No newline at end of file