|
|
|
@ -72,6 +72,23 @@ define([
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var getLastName = module.getLastName = function (cb) {
|
|
|
|
|
Cryptpad.getAttribute('username', function (err, userName) {
|
|
|
|
|
cb(err, userName || '');
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var setName = module.setName = function (uname, cb) {
|
|
|
|
|
if (typeof(uname) !== 'string') {
|
|
|
|
|
return void cb(new Error('expected string'));
|
|
|
|
|
}
|
|
|
|
|
uname = Cryptpad.fixHTML(uname.trim()).slice(0, 32);
|
|
|
|
|
Cryptpad.setAttribute('username', uname, function (err, data) {
|
|
|
|
|
if (err) { return void cb(err); }
|
|
|
|
|
cb(void 0, uname);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.Wizard = Wizard;
|
|
|
|
|
|
|
|
|
|
// special UI elements
|
|
|
|
@ -825,6 +842,10 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setEditable(true);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// shortcircuiting before all of this code since it's not quite the
|
|
|
|
|
// behaviour we want, and it's a bit of work to make it Do The Right Thing
|
|
|
|
|
|
|
|
|
|
if (First) {
|
|
|
|
|
// assume the first user to the poll wants to be the administrator...
|
|
|
|
@ -840,39 +861,33 @@ define([
|
|
|
|
|
|
|
|
|
|
module.activeColumn = '';
|
|
|
|
|
var promptForName = function () {
|
|
|
|
|
// HERE
|
|
|
|
|
Cryptpad.prompt(Messages.promptName, "", function (name, ev) {
|
|
|
|
|
if (name === null) {
|
|
|
|
|
name = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!module.isEditable) { return; }
|
|
|
|
|
var followUp = function (name) {
|
|
|
|
|
if (!name) { return; }
|
|
|
|
|
var id = module.activeColumn = coluid();
|
|
|
|
|
|
|
|
|
|
Cryptpad.setPadAttribute('column', id, function (err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
console.error("Couldn't remember your column id");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(id);
|
|
|
|
|
if (err) { return void console.error("Couldn't remember your column id"); }
|
|
|
|
|
makeUser(module.rt.proxy, id, name).focus().val(name);
|
|
|
|
|
makeUserEditable(id, true);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (column === null) {
|
|
|
|
|
//console.log("Looks like you're new to this poll, why don't you make a column");
|
|
|
|
|
promptForName();
|
|
|
|
|
return;
|
|
|
|
|
getLastName(function (err, uname) {
|
|
|
|
|
if (!uname) {
|
|
|
|
|
return void Cryptpad.prompt(Messages.promptName, "", function (name, ev) {
|
|
|
|
|
if (!(name || module.isEditable)) { return; }
|
|
|
|
|
followUp(name);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
followUp(uname);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (column === null) { return void promptForName(); }
|
|
|
|
|
|
|
|
|
|
// column might be defined, but that column might have been deleted...
|
|
|
|
|
if (proxy.table.colsOrder.indexOf(column) === -1) {
|
|
|
|
|
promptForName();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (proxy.table.colsOrder.indexOf(column) === -1) { return void promptForName(); }
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|