reformat code for jshint compliance
This commit is contained in:
parent
baf523e9a5
commit
297d8c2d44
@ -76,6 +76,41 @@ define([
|
|||||||
myUserName = myID;
|
myUserName = myID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
//initialState: Messages.codeInitialState,
|
||||||
|
userName: userName,
|
||||||
|
websocketURL: Config.websocketURL,
|
||||||
|
channel: channel,
|
||||||
|
cryptKey: key,
|
||||||
|
crypto: Crypto,
|
||||||
|
setMyID: setMyID,
|
||||||
|
transformFunction: JsonOT.validate
|
||||||
|
};
|
||||||
|
|
||||||
|
var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); };
|
||||||
|
|
||||||
|
var initializing = true;
|
||||||
|
|
||||||
|
var onLocal = config.onLocal = function () {
|
||||||
|
if (initializing) { return; }
|
||||||
|
|
||||||
|
editor.save();
|
||||||
|
var textValue = canonicalize($textarea.val());
|
||||||
|
var obj = {content: textValue};
|
||||||
|
|
||||||
|
// append the userlist to the hyperjson structure
|
||||||
|
obj.metadata = userList;
|
||||||
|
|
||||||
|
// stringify the json and send it into chainpad
|
||||||
|
var shjson = stringify(obj);
|
||||||
|
|
||||||
|
module.patchText(shjson);
|
||||||
|
|
||||||
|
if (module.realtime.getUserDoc() !== shjson) {
|
||||||
|
console.error("realtime.getUserDoc() !== shjson");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var createChangeName = function(id, $container) {
|
var createChangeName = function(id, $container) {
|
||||||
var buttonElmt = $container.find('#'+id)[0];
|
var buttonElmt = $container.find('#'+id)[0];
|
||||||
buttonElmt.addEventListener("click", function() {
|
buttonElmt.addEventListener("click", function() {
|
||||||
@ -95,21 +130,6 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var config = {
|
|
||||||
//initialState: Messages.codeInitialState,
|
|
||||||
userName: userName,
|
|
||||||
websocketURL: Config.websocketURL,
|
|
||||||
channel: channel,
|
|
||||||
cryptKey: key,
|
|
||||||
crypto: Crypto,
|
|
||||||
setMyID: setMyID,
|
|
||||||
transformFunction: JsonOT.validate
|
|
||||||
};
|
|
||||||
|
|
||||||
var canonicalize = function (t) { return t.replace(/\r\n/g, '\n'); };
|
|
||||||
|
|
||||||
var initializing = true;
|
|
||||||
|
|
||||||
var onInit = config.onInit = function (info) {
|
var onInit = config.onInit = function (info) {
|
||||||
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
|
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
|
||||||
toolbarList = info.userList;
|
toolbarList = info.userList;
|
||||||
@ -130,7 +150,7 @@ define([
|
|||||||
// Update the local user data
|
// Update the local user data
|
||||||
addToUserList(userData);
|
addToUserList(userData);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
var onReady = config.onReady = function (info) {
|
var onReady = config.onReady = function (info) {
|
||||||
var realtime = module.realtime = info.realtime;
|
var realtime = module.realtime = info.realtime;
|
||||||
@ -170,7 +190,7 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
}
|
};
|
||||||
|
|
||||||
var posToCursor = function(position, newText) {
|
var posToCursor = function(position, newText) {
|
||||||
var cursor = {
|
var cursor = {
|
||||||
@ -181,7 +201,7 @@ define([
|
|||||||
cursor.line = textLines.length - 1;
|
cursor.line = textLines.length - 1;
|
||||||
cursor.ch = textLines[cursor.line].length;
|
cursor.ch = textLines[cursor.line].length;
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
};
|
||||||
|
|
||||||
var onRemote = config.onRemote = function (info) {
|
var onRemote = config.onRemote = function (info) {
|
||||||
if (initializing) { return; }
|
if (initializing) { return; }
|
||||||
@ -226,26 +246,6 @@ define([
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var onLocal = config.onLocal = function () {
|
|
||||||
if (initializing) { return; }
|
|
||||||
|
|
||||||
editor.save();
|
|
||||||
var textValue = canonicalize($textarea.val());
|
|
||||||
var obj = {content: textValue};
|
|
||||||
|
|
||||||
// append the userlist to the hyperjson structure
|
|
||||||
obj.metadata = userList;
|
|
||||||
|
|
||||||
// stringify the json and send it into chainpad
|
|
||||||
var shjson = stringify(obj);
|
|
||||||
|
|
||||||
module.patchText(shjson);
|
|
||||||
|
|
||||||
if (module.realtime.getUserDoc() !== shjson) {
|
|
||||||
console.error("realtime.getUserDoc() !== shjson");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var onAbort = config.onAbort = function (info) {
|
var onAbort = config.onAbort = function (info) {
|
||||||
// inform of network disconnect
|
// inform of network disconnect
|
||||||
setEditable(false);
|
setEditable(false);
|
||||||
|
|||||||
@ -33,7 +33,7 @@ define([
|
|||||||
var uid = module.uid = Formula.uid;
|
var uid = module.uid = Formula.uid;
|
||||||
|
|
||||||
var getInputType = Formula.getInputType;
|
var getInputType = Formula.getInputType;
|
||||||
var $elements = module.elements = $('input, select, textarea')
|
var $elements = module.elements = $('input, select, textarea');
|
||||||
|
|
||||||
var eventsByType = Formula.eventsByType;
|
var eventsByType = Formula.eventsByType;
|
||||||
|
|
||||||
@ -128,6 +128,12 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var readValues = function () {
|
||||||
|
UI.each(function (ui, i, list) {
|
||||||
|
Map[ui.id] = ui.value();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var onLocal = config.onLocal = function () {
|
var onLocal = config.onLocal = function () {
|
||||||
if (initializing) { return; }
|
if (initializing) { return; }
|
||||||
/* serialize local changes */
|
/* serialize local changes */
|
||||||
@ -135,12 +141,6 @@ define([
|
|||||||
module.patchText(Sortify(Map));
|
module.patchText(Sortify(Map));
|
||||||
};
|
};
|
||||||
|
|
||||||
var readValues = function () {
|
|
||||||
UI.each(function (ui, i, list) {
|
|
||||||
Map[ui.id] = ui.value();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var updateValues = function () {
|
var updateValues = function () {
|
||||||
var userDoc = module.realtime.getUserDoc();
|
var userDoc = module.realtime.getUserDoc();
|
||||||
var parsed = JSON.parse(userDoc);
|
var parsed = JSON.parse(userDoc);
|
||||||
@ -162,10 +162,11 @@ define([
|
|||||||
if (newval === oldval) { return; }
|
if (newval === oldval) { return; }
|
||||||
|
|
||||||
var op;
|
var op;
|
||||||
|
var selects;
|
||||||
var element = ui.element;
|
var element = ui.element;
|
||||||
if (ui.preserveCursor) {
|
if (ui.preserveCursor) {
|
||||||
op = TextPatcher.diff(oldval, newval);
|
op = TextPatcher.diff(oldval, newval);
|
||||||
var selects = ['selectionStart', 'selectionEnd'].map(function (attr) {
|
selects = ['selectionStart', 'selectionEnd'].map(function (attr) {
|
||||||
var before = element[attr];
|
var before = element[attr];
|
||||||
var after = TextPatcher.transformCursor(element[attr], op);
|
var after = TextPatcher.transformCursor(element[attr], op);
|
||||||
return after;
|
return after;
|
||||||
@ -175,8 +176,8 @@ define([
|
|||||||
ui.value(newval);
|
ui.value(newval);
|
||||||
ui.update();
|
ui.update();
|
||||||
|
|
||||||
if (op) {
|
if (op && ui.preserveCursor) {
|
||||||
console.log(selects);
|
//console.log(selects);
|
||||||
element.selectionStart = selects[0];
|
element.selectionStart = selects[0];
|
||||||
element.selectionEnd = selects[1];
|
element.selectionEnd = selects[1];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -295,7 +295,7 @@ define([
|
|||||||
addToUserList(userData);
|
addToUserList(userData);
|
||||||
hjson.pop();
|
hjson.pop();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
var onRemote = realtimeOptions.onRemote = function (info) {
|
var onRemote = realtimeOptions.onRemote = function (info) {
|
||||||
if (initializing) { return; }
|
if (initializing) { return; }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user