fix jshint complaints in codemirror directory

pull/1/head
ansuz 9 years ago
parent 2c5a2b6023
commit fe3917c0f1

@ -282,18 +282,18 @@ console.log(new Error().stack);
var newSelection;
if(oldCursorCMStart !== oldCursorCMEnd) { // Selection
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) {
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
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) {
var newCursor = transformCursorCMInsert(oldValue, oldCursor, op.offset, op.toInsert);
newCursor = transformCursorCMInsert(oldValue, oldCursor, op.offset, op.toInsert);
}
}
$(doc).val(newValue);

@ -33,7 +33,7 @@ define([
var warn = function (x) { };
var debug = function (x) { };
//debug = function (x) { console.log(x) };
warn = function (x) { console.log(x) };
warn = function (x) { console.log(x); };
var setStyle = function () {
$('head').append([
'<style>',
@ -70,6 +70,11 @@ define([
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 meIdx = userList.indexOf(myUserName);
if (meIdx === -1) {
@ -79,6 +84,7 @@ define([
var userMap = {};
userMap[messages.myself] = 1;
userList.splice(meIdx, 1);
for (var i = 0; i < userList.length; i++) {
var user;
if (userList[i].indexOf('xwiki:XWiki.XWikiGuest') === 0) {
@ -88,9 +94,7 @@ define([
user = messages.guest;
}
} else {
user = userList[i].replace(/^.*-([^-]*)%2d[0-9]*$/, function(all, one) {
return decodeURIComponent(one);
});
user = userList[i].replace(/^.*-([^-]*)%2d[0-9]*$/, decodeUser);
}
userMap[user] = userMap[user] || 0;
if (user === messages.guest && userMap[user] > 0) {
@ -232,7 +236,7 @@ define([
$(textArea).scrollTop(heightOne - heightTwo);
}
andThen();
})
});
};
var saveDocument = function (textArea, language, andThen) {
@ -772,18 +776,18 @@ define([
var newSelection;
if(oldCursorCMStart !== oldCursorCMEnd) { // Selection
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) {
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
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) {
var newCursor = transformCursorCMInsert(oldValue, oldCursor, op.offset, op.toInsert);
newCursor = transformCursorCMInsert(oldValue, oldCursor, op.offset, op.toInsert);
}
}
$(textArea).val(newValue);
@ -864,7 +868,7 @@ define([
onEvent: function() {
socket.onEvent();
}
}
};
};
var start = module.exports.start = function (window, websocketUrl,

@ -93,13 +93,14 @@ var attachTextarea = function(elem, ctx, cmElem) {
// Replace the content of the text area with newText, and transform the
// current cursor by the specified function.
var replaceText = function(newText, transformCursor, transformCursorCM) {
var newCursor;
var newSelection;
if(cmElem) {
// Fix cursor here?
var cursorCM = cmElem.getCursor();
var cursorCMStart = cmElem.getCursor('from');
var cursorCMEnd = cmElem.getCursor('to');
var newCursor;
var newSelection;
if(cursorCMStart !== cursorCMEnd) {
newSelection = [transformCursorCM(elem.value, cursorCMStart), transformCursorCM(elem.value, cursorCMEnd)];
}
@ -109,7 +110,7 @@ var attachTextarea = function(elem, ctx, cmElem) {
}
if (transformCursor && !cmElem) {
var newSelection = [transformCursor(elem.selectionStart), transformCursor(elem.selectionEnd)];
newSelection = [transformCursor(elem.selectionStart), transformCursor(elem.selectionEnd)];
}
// Fixate the window's scroll while we set the element's value. Otherwise

Loading…
Cancel
Save