fix jshint complaints in codemirror directory

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

@ -281,20 +281,20 @@ console.log(new Error().stack);
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);
} }
} }
$(doc).val(newValue); $(doc).val(newValue);
cmEditor.setValue(newValue); cmEditor.setValue(newValue);

@ -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,

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

Loading…
Cancel
Save