|
|
@ -7,7 +7,7 @@ define([
|
|
|
|
'/common/cryptget.js',
|
|
|
|
'/common/cryptget.js',
|
|
|
|
'/bower_components/hyperjson/hyperjson.js',
|
|
|
|
'/bower_components/hyperjson/hyperjson.js',
|
|
|
|
'render.js',
|
|
|
|
'render.js',
|
|
|
|
'/common/toolbar.js',
|
|
|
|
'/common/toolbar2.js',
|
|
|
|
'/common/visible.js',
|
|
|
|
'/common/visible.js',
|
|
|
|
'/common/notify.js',
|
|
|
|
'/common/notify.js',
|
|
|
|
'/bower_components/file-saver/FileSaver.min.js'
|
|
|
|
'/bower_components/file-saver/FileSaver.min.js'
|
|
|
@ -442,47 +442,7 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var userData = APP.userData = {}; // List of pretty names for all users (mapped with their ID)
|
|
|
|
var UserList;
|
|
|
|
var userList; // List of users still connected to the channel (server IDs)
|
|
|
|
|
|
|
|
var addToUserData = function(data) {
|
|
|
|
|
|
|
|
var users = userList ? userList.users : undefined;
|
|
|
|
|
|
|
|
//var userData = APP.proxy.info.userData;
|
|
|
|
|
|
|
|
for (var attrname in data) { userData[attrname] = data[attrname]; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (users && users.length) {
|
|
|
|
|
|
|
|
for (var userKey in userData) {
|
|
|
|
|
|
|
|
if (users.indexOf(userKey) === -1) { delete userData[userKey]; }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(userList && typeof userList.onChange === "function") {
|
|
|
|
|
|
|
|
userList.onChange(userData);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
APP.proxy.info.userData = userData;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var setName = APP.setName = function (newName) {
|
|
|
|
|
|
|
|
if (typeof(newName) !== 'string') { return; }
|
|
|
|
|
|
|
|
var myUserNameTemp = newName.trim();
|
|
|
|
|
|
|
|
if(myUserNameTemp.length > 32) {
|
|
|
|
|
|
|
|
myUserNameTemp = myUserNameTemp.substr(0, 32);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var myUserName = myUserNameTemp;
|
|
|
|
|
|
|
|
var myID = APP.myID;
|
|
|
|
|
|
|
|
var myData = {};
|
|
|
|
|
|
|
|
myData[myID] = {
|
|
|
|
|
|
|
|
name: myUserName,
|
|
|
|
|
|
|
|
uid: Cryptpad.getUid(),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
addToUserData(myData);
|
|
|
|
|
|
|
|
Cryptpad.setAttribute('username', newName, function (err) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
console.error("Couldn't set username");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var updateTitle = function (newTitle) {
|
|
|
|
var updateTitle = function (newTitle) {
|
|
|
|
if (newTitle === document.title) { return; }
|
|
|
|
if (newTitle === document.title) { return; }
|
|
|
@ -526,248 +486,229 @@ define([
|
|
|
|
// special UI elements
|
|
|
|
// special UI elements
|
|
|
|
var $description = $('#description').attr('placeholder', Messages.poll_descriptionHint || 'description');
|
|
|
|
var $description = $('#description').attr('placeholder', Messages.poll_descriptionHint || 'description');
|
|
|
|
|
|
|
|
|
|
|
|
var ready = function (info, userid, readOnly) {
|
|
|
|
var ready = function (info, userid, readOnly) {
|
|
|
|
debug("READY");
|
|
|
|
debug("READY");
|
|
|
|
debug('userid: %s', userid);
|
|
|
|
debug('userid: %s', userid);
|
|
|
|
|
|
|
|
|
|
|
|
var proxy = APP.proxy;
|
|
|
|
var proxy = APP.proxy;
|
|
|
|
|
|
|
|
|
|
|
|
var isNew = false;
|
|
|
|
var isNew = false;
|
|
|
|
var userDoc = JSON.stringify(proxy);
|
|
|
|
var userDoc = JSON.stringify(proxy);
|
|
|
|
if (userDoc === "" || userDoc === "{}") { isNew = true; }
|
|
|
|
if (userDoc === "" || userDoc === "{}") { isNew = true; }
|
|
|
|
|
|
|
|
|
|
|
|
var uncommitted = APP.uncommitted = {};
|
|
|
|
var uncommitted = APP.uncommitted = {};
|
|
|
|
prepareProxy(proxy, copyObject(Render.Example));
|
|
|
|
prepareProxy(proxy, copyObject(Render.Example));
|
|
|
|
prepareProxy(uncommitted, copyObject(Render.Example));
|
|
|
|
prepareProxy(uncommitted, copyObject(Render.Example));
|
|
|
|
if (!readOnly && proxy.table.colsOrder.indexOf(userid) === -1 &&
|
|
|
|
if (!readOnly && proxy.table.colsOrder.indexOf(userid) === -1 &&
|
|
|
|
uncommitted.table.colsOrder.indexOf(userid) === -1) {
|
|
|
|
uncommitted.table.colsOrder.indexOf(userid) === -1) {
|
|
|
|
uncommitted.table.colsOrder.unshift(userid);
|
|
|
|
uncommitted.table.colsOrder.unshift(userid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var displayedObj = mergeUncommitted(proxy, uncommitted, false);
|
|
|
|
var displayedObj = mergeUncommitted(proxy, uncommitted, false);
|
|
|
|
|
|
|
|
|
|
|
|
var colsOrder = sortColumns(displayedObj.table.colsOrder, userid);
|
|
|
|
var colsOrder = sortColumns(displayedObj.table.colsOrder, userid);
|
|
|
|
|
|
|
|
|
|
|
|
var $table = APP.$table = $(Render.asHTML(displayedObj, null, colsOrder, readOnly));
|
|
|
|
var $table = APP.$table = $(Render.asHTML(displayedObj, null, colsOrder, readOnly));
|
|
|
|
APP.$createRow = $('#create-option').click(function () {
|
|
|
|
APP.$createRow = $('#create-option').click(function () {
|
|
|
|
//console.error("BUTTON CLICKED! LOL");
|
|
|
|
//console.error("BUTTON CLICKED! LOL");
|
|
|
|
Render.createRow(proxy, function (empty, id) {
|
|
|
|
Render.createRow(proxy, function (empty, id) {
|
|
|
|
change(null, null, null, null, function() {
|
|
|
|
change(null, null, null, null, function() {
|
|
|
|
$('.edit[data-rt-id="' + id + '"]').click();
|
|
|
|
$('.edit[data-rt-id="' + id + '"]').click();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
APP.$createCol = $('#create-user').click(function () {
|
|
|
|
APP.$createCol = $('#create-user').click(function () {
|
|
|
|
Render.createColumn(proxy, function (empty, id) {
|
|
|
|
Render.createColumn(proxy, function (empty, id) {
|
|
|
|
change(null, null, null, null, function() {
|
|
|
|
change(null, null, null, null, function() {
|
|
|
|
$('.edit[data-rt-id="' + id + '"]').click();
|
|
|
|
$('.edit[data-rt-id="' + id + '"]').click();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Commit button
|
|
|
|
// Commit button
|
|
|
|
APP.$commit = $('#commit').click(function () {
|
|
|
|
APP.$commit = $('#commit').click(function () {
|
|
|
|
var uncommittedCopy = JSON.parse(JSON.stringify(APP.uncommitted));
|
|
|
|
var uncommittedCopy = JSON.parse(JSON.stringify(APP.uncommitted));
|
|
|
|
APP.uncommitted = {};
|
|
|
|
APP.uncommitted = {};
|
|
|
|
prepareProxy(APP.uncommitted, copyObject(Render.Example));
|
|
|
|
prepareProxy(APP.uncommitted, copyObject(Render.Example));
|
|
|
|
mergeUncommitted(proxy, uncommittedCopy, true);
|
|
|
|
mergeUncommitted(proxy, uncommittedCopy, true);
|
|
|
|
APP.$commit.hide();
|
|
|
|
APP.$commit.hide();
|
|
|
|
change();
|
|
|
|
change();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// #publish button is removed in readonly
|
|
|
|
// #publish button is removed in readonly
|
|
|
|
APP.$publish = $('#publish')
|
|
|
|
APP.$publish = $('#publish')
|
|
|
|
.click(function () {
|
|
|
|
.click(function () {
|
|
|
|
publish(true);
|
|
|
|
publish(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// #publish button is removed in readonly
|
|
|
|
// #publish button is removed in readonly
|
|
|
|
APP.$admin = $('#admin')
|
|
|
|
APP.$admin = $('#admin')
|
|
|
|
.click(function () {
|
|
|
|
.click(function () {
|
|
|
|
publish(false);
|
|
|
|
publish(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// Title
|
|
|
|
// Title
|
|
|
|
if (APP.proxy.info.defaultTitle) {
|
|
|
|
if (APP.proxy.info.defaultTitle) {
|
|
|
|
updateDefaultTitle(APP.proxy.info.defaultTitle);
|
|
|
|
updateDefaultTitle(APP.proxy.info.defaultTitle);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
APP.proxy.info.defaultTitle = defaultName;
|
|
|
|
APP.proxy.info.defaultTitle = defaultName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Cryptpad.initialName && !APP.proxy.info.title) {
|
|
|
|
if (Cryptpad.initialName && !APP.proxy.info.title) {
|
|
|
|
APP.proxy.info.title = Cryptpad.initialName;
|
|
|
|
APP.proxy.info.title = Cryptpad.initialName;
|
|
|
|
updateTitle(Cryptpad.initialName);
|
|
|
|
updateTitle(Cryptpad.initialName);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
updateTitle(APP.proxy.info.title || defaultName);
|
|
|
|
updateTitle(APP.proxy.info.title || defaultName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Description
|
|
|
|
// Description
|
|
|
|
var resize = function () {
|
|
|
|
var resize = function () {
|
|
|
|
var lineCount = $description.val().split('\n').length;
|
|
|
|
var lineCount = $description.val().split('\n').length;
|
|
|
|
$description.css('height', lineCount + 'rem');
|
|
|
|
$description.css('height', lineCount + 'rem');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
$description.on('change keyup', function () {
|
|
|
|
$description.on('change keyup', function () {
|
|
|
|
var val = $description.val();
|
|
|
|
var val = $description.val();
|
|
|
|
proxy.info.description = val;
|
|
|
|
proxy.info.description = val;
|
|
|
|
resize();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
resize();
|
|
|
|
resize();
|
|
|
|
if (typeof(proxy.info.description) !== 'undefined') {
|
|
|
|
});
|
|
|
|
$description.val(proxy.info.description);
|
|
|
|
resize();
|
|
|
|
}
|
|
|
|
if (typeof(proxy.info.description) !== 'undefined') {
|
|
|
|
|
|
|
|
$description.val(proxy.info.description);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$('#tableScroll').html('').prepend($table);
|
|
|
|
$('#tableScroll').html('').prepend($table);
|
|
|
|
updateDisplayedTable();
|
|
|
|
updateDisplayedTable();
|
|
|
|
|
|
|
|
|
|
|
|
$table
|
|
|
|
$table
|
|
|
|
.click(handleClick)
|
|
|
|
.click(handleClick)
|
|
|
|
.on('keyup', function (e) { handleClick(e, true); });
|
|
|
|
.on('keyup', function (e) { handleClick(e, true); });
|
|
|
|
|
|
|
|
|
|
|
|
proxy
|
|
|
|
proxy
|
|
|
|
.on('change', ['info'], function (o, n, p) {
|
|
|
|
.on('change', ['info'], function (o, n, p) {
|
|
|
|
if (p[1] === 'title') {
|
|
|
|
if (p[1] === 'title') {
|
|
|
|
updateTitle(n);
|
|
|
|
updateTitle(n);
|
|
|
|
notify();
|
|
|
|
notify();
|
|
|
|
} else if (p[1] === "userData") {
|
|
|
|
} else if (p[1] === "userData") {
|
|
|
|
addToUserData(APP.proxy.info.userData);
|
|
|
|
UserList.addToUserData(APP.proxy.info.userData);
|
|
|
|
} else if (p[1] === 'description') {
|
|
|
|
} else if (p[1] === 'description') {
|
|
|
|
var op = TextPatcher.diff(o, n);
|
|
|
|
var op = TextPatcher.diff(o, n);
|
|
|
|
var el = $description[0];
|
|
|
|
var el = $description[0];
|
|
|
|
|
|
|
|
|
|
|
|
var selects = ['selectionStart', 'selectionEnd'].map(function (attr) {
|
|
|
|
var selects = ['selectionStart', 'selectionEnd'].map(function (attr) {
|
|
|
|
return TextPatcher.transformCursor(el[attr], op);
|
|
|
|
return TextPatcher.transformCursor(el[attr], op);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$description.val(n);
|
|
|
|
$description.val(n);
|
|
|
|
if (op) {
|
|
|
|
if (op) {
|
|
|
|
el.selectionStart = selects[0];
|
|
|
|
el.selectionStart = selects[0];
|
|
|
|
el.selectionEnd = selects[1];
|
|
|
|
el.selectionEnd = selects[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
notify();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
notify();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
debug("change: (%s, %s, [%s])", o, n, p.join(', '));
|
|
|
|
debug("change: (%s, %s, [%s])", o, n, p.join(', '));
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.on('change', ['table'], change)
|
|
|
|
.on('change', ['table'], change)
|
|
|
|
.on('remove', [], change);
|
|
|
|
.on('remove', [], change);
|
|
|
|
|
|
|
|
|
|
|
|
addToUserData(APP.proxy.info.userData);
|
|
|
|
UserList.addToUserData(APP.proxy.info.userData);
|
|
|
|
|
|
|
|
|
|
|
|
if (Visible.isSupported()) {
|
|
|
|
if (Visible.isSupported()) {
|
|
|
|
Visible.onChange(function (yes) {
|
|
|
|
Visible.onChange(function (yes) {
|
|
|
|
if (yes) { unnotify(); }
|
|
|
|
if (yes) { unnotify(); }
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Cryptpad.getLastName(function (err, lastName) {
|
|
|
|
APP.ready = true;
|
|
|
|
APP.ready = true;
|
|
|
|
if (!proxy.published) {
|
|
|
|
|
|
|
|
publish(false);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
publish(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Cryptpad.removeLoadingScreen();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (readOnly) { return; }
|
|
|
|
|
|
|
|
UserList.getLastName(APP.toolbar.$userNameButton, isNew);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var disconnect = function () {
|
|
|
|
|
|
|
|
//setEditable(false); // TODO
|
|
|
|
|
|
|
|
APP.toolbar.failed();
|
|
|
|
|
|
|
|
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var reconnect = function (info) {
|
|
|
|
|
|
|
|
//setEditable(true); // TODO
|
|
|
|
|
|
|
|
APP.toolbar.reconnecting(info.myId);
|
|
|
|
|
|
|
|
Cryptpad.findOKButton().click();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var create = function (info) {
|
|
|
|
|
|
|
|
APP.myID = info.myID;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var editHash;
|
|
|
|
|
|
|
|
if (!readOnly) {
|
|
|
|
|
|
|
|
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!proxy.published) {
|
|
|
|
if (APP.realtime !== info.realtime) {
|
|
|
|
publish(false);
|
|
|
|
APP.realtime = info.realtime;
|
|
|
|
} else {
|
|
|
|
APP.patchText = TextPatcher.create({
|
|
|
|
publish(true);
|
|
|
|
realtime: info.realtime,
|
|
|
|
}
|
|
|
|
logging: true,
|
|
|
|
Cryptpad.removeLoadingScreen();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Update the toolbar list:
|
|
|
|
|
|
|
|
// Add the current user in the metadata if he has edit rights
|
|
|
|
|
|
|
|
if (readOnly) { return; }
|
|
|
|
|
|
|
|
if (typeof(lastName) === 'string') {
|
|
|
|
|
|
|
|
setName(lastName);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
var myData = {};
|
|
|
|
|
|
|
|
myData[info.myId] = {
|
|
|
|
|
|
|
|
name: "",
|
|
|
|
|
|
|
|
uid: Cryptpad.getUid(),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
addToUserData(myData);
|
|
|
|
|
|
|
|
APP.$userNameButton.click();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isNew) {
|
|
|
|
|
|
|
|
Cryptpad.selectTemplate('poll', info.realtime, Cryptget);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var disconnect = function () {
|
|
|
|
|
|
|
|
//setEditable(false); // TODO
|
|
|
|
|
|
|
|
APP.realtime.toolbar.failed();
|
|
|
|
|
|
|
|
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var reconnect = function (info) {
|
|
|
|
var onLocal = function () {
|
|
|
|
//setEditable(true); // TODO
|
|
|
|
APP.proxy.info.userData = UserList.userData;
|
|
|
|
APP.realtime.toolbar.reconnecting(info.myId);
|
|
|
|
};
|
|
|
|
Cryptpad.findOKButton().click();
|
|
|
|
UserList = Cryptpad.createUserList(info, onLocal, Cryptget, Cryptpad);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var configTb = {
|
|
|
|
|
|
|
|
displayed: ['title', 'useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad', 'limit'],
|
|
|
|
|
|
|
|
userList: UserList.getToolbarConfig(),
|
|
|
|
|
|
|
|
share: {
|
|
|
|
|
|
|
|
secret: secret,
|
|
|
|
|
|
|
|
channel: info.channel
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
title: {
|
|
|
|
|
|
|
|
onRename: renameCb,
|
|
|
|
|
|
|
|
defaultName: defaultName,
|
|
|
|
|
|
|
|
suggestName: suggestName
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
common: Cryptpad,
|
|
|
|
|
|
|
|
readOnly: readOnly,
|
|
|
|
|
|
|
|
ifrw: window,
|
|
|
|
|
|
|
|
realtime: info.realtime,
|
|
|
|
|
|
|
|
network: info.network,
|
|
|
|
|
|
|
|
$container: APP.$bar
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
APP.toolbar = Toolbar.create(configTb);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $rightside = APP.toolbar.$rightside;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* add a forget button */
|
|
|
|
|
|
|
|
var forgetCb = function (err) {
|
|
|
|
|
|
|
|
if (err) { return; }
|
|
|
|
|
|
|
|
disconnect();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb);
|
|
|
|
|
|
|
|
$rightside.append($forgetPad);
|
|
|
|
|
|
|
|
|
|
|
|
var create = function (info) {
|
|
|
|
// set the hash
|
|
|
|
APP.myID = info.myID;
|
|
|
|
if (!readOnly) { Cryptpad.replaceHash(editHash); }
|
|
|
|
|
|
|
|
|
|
|
|
var editHash;
|
|
|
|
|
|
|
|
if (!readOnly) {
|
|
|
|
|
|
|
|
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (APP.realtime !== info.realtime) {
|
|
|
|
|
|
|
|
APP.realtime = info.realtime;
|
|
|
|
|
|
|
|
APP.patchText = TextPatcher.create({
|
|
|
|
|
|
|
|
realtime: info.realtime,
|
|
|
|
|
|
|
|
logging: true,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
userList = APP.userList = info.userList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var config = {
|
|
|
|
/* save as template */
|
|
|
|
displayed: ['useradmin', 'spinner', 'lag', 'state', 'share', 'userlist', 'newpad', 'limit'],
|
|
|
|
if (!Cryptpad.isTemplate(window.location.href)) {
|
|
|
|
userData: userData,
|
|
|
|
var templateObj = {
|
|
|
|
readOnly: readOnly,
|
|
|
|
rt: info.realtime,
|
|
|
|
share: {
|
|
|
|
Crypt: Cryptget,
|
|
|
|
secret: secret,
|
|
|
|
getTitle: function () { return document.title; }
|
|
|
|
channel: info.channel
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
title: {
|
|
|
|
|
|
|
|
onRename: renameCb,
|
|
|
|
|
|
|
|
defaultName: defaultName,
|
|
|
|
|
|
|
|
suggestName: suggestName
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
ifrw: window,
|
|
|
|
|
|
|
|
common: Cryptpad,
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
info.realtime.toolbar = Toolbar.create(APP.$bar, info.myID, info.realtime, info.getLag, userList, config);
|
|
|
|
var $templateButton = Cryptpad.createButton('template', true, templateObj);
|
|
|
|
|
|
|
|
$rightside.append($templateButton);
|
|
|
|
var $bar = APP.$bar;
|
|
|
|
}
|
|
|
|
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
|
|
|
};
|
|
|
|
$bar.find('.' + Toolbar.constants.username);
|
|
|
|
|
|
|
|
$bar.find('.' + Toolbar.constants.editShare);
|
|
|
|
|
|
|
|
$bar.find('.' + Toolbar.constants.viewShare);
|
|
|
|
|
|
|
|
APP.$userNameButton = $($bar.find('.' + Toolbar.constants.changeUsername));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* add a forget button */
|
|
|
|
|
|
|
|
var forgetCb = function (err) {
|
|
|
|
|
|
|
|
if (err) { return; }
|
|
|
|
|
|
|
|
disconnect();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb);
|
|
|
|
|
|
|
|
$rightside.append($forgetPad);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// set the hash
|
|
|
|
|
|
|
|
if (!readOnly) { Cryptpad.replaceHash(editHash); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* save as template */
|
|
|
|
|
|
|
|
if (!Cryptpad.isTemplate(window.location.href)) {
|
|
|
|
|
|
|
|
var templateObj = {
|
|
|
|
|
|
|
|
rt: info.realtime,
|
|
|
|
|
|
|
|
Crypt: Cryptget,
|
|
|
|
|
|
|
|
getTitle: function () { return document.title; }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var $templateButton = Cryptpad.createButton('template', true, templateObj);
|
|
|
|
|
|
|
|
$rightside.append($templateButton);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Cryptpad.onDisplayNameChanged(setName);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// don't initialize until the store is ready.
|
|
|
|
// don't initialize until the store is ready.
|
|
|
|
Cryptpad.ready(function () {
|
|
|
|
Cryptpad.ready(function () {
|
|
|
|