|
|
@ -33,7 +33,7 @@ define([
|
|
|
|
var warn = function (x) { };
|
|
|
|
var warn = function (x) { };
|
|
|
|
var debug = function (x) { };
|
|
|
|
var debug = function (x) { };
|
|
|
|
//debug = function (x) { console.log(x) };
|
|
|
|
//debug = function (x) { console.log(x) };
|
|
|
|
warn = function (x) { console.log(x) };
|
|
|
|
warn = function (x) { console.log(x); };
|
|
|
|
var setStyle = function () {
|
|
|
|
var setStyle = function () {
|
|
|
|
$('head').append([
|
|
|
|
$('head').append([
|
|
|
|
'<style>',
|
|
|
|
'<style>',
|
|
|
@ -70,6 +70,11 @@ define([
|
|
|
|
return 'rtwiki-uid-' + String(Math.random()).substring(2);
|
|
|
|
return 'rtwiki-uid-' + String(Math.random()).substring(2);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// only used within updateUserList so far
|
|
|
|
|
|
|
|
var decodeUser = function (all, one) {
|
|
|
|
|
|
|
|
return decodeURIComponent(one);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var updateUserList = function (myUserName, listElement, userList, messages) {
|
|
|
|
var updateUserList = function (myUserName, listElement, userList, messages) {
|
|
|
|
var meIdx = userList.indexOf(myUserName);
|
|
|
|
var meIdx = userList.indexOf(myUserName);
|
|
|
|
if (meIdx === -1) {
|
|
|
|
if (meIdx === -1) {
|
|
|
@ -79,6 +84,7 @@ define([
|
|
|
|
var userMap = {};
|
|
|
|
var userMap = {};
|
|
|
|
userMap[messages.myself] = 1;
|
|
|
|
userMap[messages.myself] = 1;
|
|
|
|
userList.splice(meIdx, 1);
|
|
|
|
userList.splice(meIdx, 1);
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < userList.length; i++) {
|
|
|
|
for (var i = 0; i < userList.length; i++) {
|
|
|
|
var user;
|
|
|
|
var user;
|
|
|
|
if (userList[i].indexOf('xwiki:XWiki.XWikiGuest') === 0) {
|
|
|
|
if (userList[i].indexOf('xwiki:XWiki.XWikiGuest') === 0) {
|
|
|
@ -88,9 +94,7 @@ define([
|
|
|
|
user = messages.guest;
|
|
|
|
user = messages.guest;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
user = userList[i].replace(/^.*-([^-]*)%2d[0-9]*$/, function(all, one) {
|
|
|
|
user = userList[i].replace(/^.*-([^-]*)%2d[0-9]*$/, decodeUser);
|
|
|
|
return decodeURIComponent(one);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
userMap[user] = userMap[user] || 0;
|
|
|
|
userMap[user] = userMap[user] || 0;
|
|
|
|
if (user === messages.guest && userMap[user] > 0) {
|
|
|
|
if (user === messages.guest && userMap[user] > 0) {
|
|
|
@ -232,7 +236,7 @@ define([
|
|
|
|
$(textArea).scrollTop(heightOne - heightTwo);
|
|
|
|
$(textArea).scrollTop(heightOne - heightTwo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
andThen();
|
|
|
|
andThen();
|
|
|
|
})
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var saveDocument = function (textArea, language, andThen) {
|
|
|
|
var saveDocument = function (textArea, language, andThen) {
|
|
|
@ -771,20 +775,20 @@ define([
|
|
|
|
var newCursor;
|
|
|
|
var newCursor;
|
|
|
|
var newSelection;
|
|
|
|
var newSelection;
|
|
|
|
if(oldCursorCMStart !== oldCursorCMEnd) { // Selection
|
|
|
|
if(oldCursorCMStart !== oldCursorCMEnd) { // Selection
|
|
|
|
if (op.toRemove > 0) {
|
|
|
|
if (op.toRemove > 0) {
|
|
|
|
var newSelection = [transformCursorCMRemove(oldValue, oldCursorCMStart, op.offset, op.toRemove), transformCursorCMRemove(oldValue, oldCursorCMEnd, op.offset, op.toRemove)];
|
|
|
|
newSelection = [transformCursorCMRemove(oldValue, oldCursorCMStart, op.offset, op.toRemove), transformCursorCMRemove(oldValue, oldCursorCMEnd, op.offset, op.toRemove)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (op.toInsert.length > 0) {
|
|
|
|
if (op.toInsert.length > 0) {
|
|
|
|
var newSelection = [transformCursorCMInsert(oldValue, oldCursorCMStart, op.offset, op.toInsert), transformCursorCMInsert(oldValue, oldCursorCMEnd, op.offset, op.toInsert)];
|
|
|
|
newSelection = [transformCursorCMInsert(oldValue, oldCursorCMStart, op.offset, op.toInsert), transformCursorCMInsert(oldValue, oldCursorCMEnd, op.offset, op.toInsert)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // Cursor
|
|
|
|
else { // Cursor
|
|
|
|
if (op.toRemove > 0) {
|
|
|
|
if (op.toRemove > 0) {
|
|
|
|
var newCursor = transformCursorCMRemove(oldValue, oldCursor, op.offset, op.toRemove);
|
|
|
|
newCursor = transformCursorCMRemove(oldValue, oldCursor, op.offset, op.toRemove);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (op.toInsert.length > 0) {
|
|
|
|
if (op.toInsert.length > 0) {
|
|
|
|
var newCursor = transformCursorCMInsert(oldValue, oldCursor, op.offset, op.toInsert);
|
|
|
|
newCursor = transformCursorCMInsert(oldValue, oldCursor, op.offset, op.toInsert);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$(textArea).val(newValue);
|
|
|
|
$(textArea).val(newValue);
|
|
|
|
cmEditor.setValue(newValue);
|
|
|
|
cmEditor.setValue(newValue);
|
|
|
@ -861,10 +865,10 @@ define([
|
|
|
|
messages,
|
|
|
|
messages,
|
|
|
|
cryptkey);
|
|
|
|
cryptkey);
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
onEvent: function() {
|
|
|
|
onEvent: function() {
|
|
|
|
socket.onEvent();
|
|
|
|
socket.onEvent();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var start = module.exports.start = function (window, websocketUrl,
|
|
|
|
var start = module.exports.start = function (window, websocketUrl,
|
|
|
|