reformat code for jshint compliance

pull/1/head
ansuz 9 years ago
parent baf523e9a5
commit 297d8c2d44

@ -76,6 +76,41 @@ define([
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 buttonElmt = $container.find('#'+id)[0];
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 $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
toolbarList = info.userList;
@ -130,7 +150,7 @@ define([
// Update the local user data
addToUserList(userData);
}
}
};
var onReady = config.onReady = function (info) {
var realtime = module.realtime = info.realtime;
@ -170,7 +190,7 @@ define([
}
}
return pos;
}
};
var posToCursor = function(position, newText) {
var cursor = {
@ -181,7 +201,7 @@ define([
cursor.line = textLines.length - 1;
cursor.ch = textLines[cursor.line].length;
return cursor;
}
};
var onRemote = config.onRemote = function (info) {
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) {
// inform of network disconnect
setEditable(false);

@ -33,7 +33,7 @@ define([
var uid = module.uid = Formula.uid;
var getInputType = Formula.getInputType;
var $elements = module.elements = $('input, select, textarea')
var $elements = module.elements = $('input, select, textarea');
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 () {
if (initializing) { return; }
/* serialize local changes */
@ -135,12 +141,6 @@ define([
module.patchText(Sortify(Map));
};
var readValues = function () {
UI.each(function (ui, i, list) {
Map[ui.id] = ui.value();
});
};
var updateValues = function () {
var userDoc = module.realtime.getUserDoc();
var parsed = JSON.parse(userDoc);
@ -162,10 +162,11 @@ define([
if (newval === oldval) { return; }
var op;
var selects;
var element = ui.element;
if (ui.preserveCursor) {
op = TextPatcher.diff(oldval, newval);
var selects = ['selectionStart', 'selectionEnd'].map(function (attr) {
selects = ['selectionStart', 'selectionEnd'].map(function (attr) {
var before = element[attr];
var after = TextPatcher.transformCursor(element[attr], op);
return after;
@ -175,8 +176,8 @@ define([
ui.value(newval);
ui.update();
if (op) {
console.log(selects);
if (op && ui.preserveCursor) {
//console.log(selects);
element.selectionStart = selects[0];
element.selectionEnd = selects[1];
}

@ -295,7 +295,7 @@ define([
addToUserList(userData);
hjson.pop();
}
}
};
var onRemote = realtimeOptions.onRemote = function (info) {
if (initializing) { return; }

Loading…
Cancel
Save