See other users' cursor position

This commit is contained in:
yflory
2018-12-04 17:18:42 +01:00
parent 60e7011adc
commit 1ba80a344b
10 changed files with 165 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ define([
'/common/sframe-common-history.js',
'/common/sframe-common-file.js',
'/common/sframe-common-codemirror.js',
'/common/sframe-common-cursor.js',
'/common/metadata-manager.js',
'/customize/application_config.js',
@@ -31,6 +32,7 @@ define([
History,
File,
CodeMirror,
Cursor,
MetadataMgr,
AppConfig,
CommonRealtime,
@@ -106,6 +108,9 @@ define([
// Title module
funcs.createTitle = callWithCommon(Title.create);
// Cursor
funcs.createCursor = callWithCommon(Cursor.create);
// Files
funcs.uploadFile = callWithCommon(File.uploadFile);
funcs.createFileManager = callWithCommon(File.create);
@@ -180,6 +185,24 @@ define([
});
};
var cursorChannel;
funcs.getCursorChannel = function () {
return cursorChannel;
};
funcs.openCursorChannel = function (saveChanges) {
var md = JSON.parse(JSON.stringify(ctx.metadataMgr.getMetadata()));
var channel = md.cursor || Hash.createChannelId();
if (!md.cursor) {
md.cursor = channel;
ctx.metadataMgr.updateMetadata(md);
setTimeout(saveChanges);
}
cursorChannel = channel;
ctx.sframeChan.query('Q_CURSOR_OPENCHANNEL', channel, function (err, obj) {
if (err || (obj && obj.error)) { console.error(err || (obj && obj.error)); }
});
};
// CodeMirror
funcs.initCodeMirrorApp = callWithCommon(CodeMirror.create);