|
|
@ -37,7 +37,7 @@ define([
|
|
|
|
secret.keys = secret.key;
|
|
|
|
secret.keys = secret.key;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var onConnectError = function (info) {
|
|
|
|
var onConnectError = function () {
|
|
|
|
Cryptpad.errorLoadingScreen(Messages.websocketError);
|
|
|
|
Cryptpad.errorLoadingScreen(Messages.websocketError);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -50,7 +50,6 @@ define([
|
|
|
|
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
|
|
|
|
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
|
|
|
|
var parsedHash = Cryptpad.parsePadUrl(window.location.href);
|
|
|
|
var parsedHash = Cryptpad.parsePadUrl(window.location.href);
|
|
|
|
var defaultName = Cryptpad.getDefaultName(parsedHash);
|
|
|
|
var defaultName = Cryptpad.getDefaultName(parsedHash);
|
|
|
|
var initialState = Messages.codeInitialState;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var isHistoryMode = false;
|
|
|
|
var isHistoryMode = false;
|
|
|
|
|
|
|
|
|
|
|
@ -172,10 +171,10 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var isDefaultTitle = function () {
|
|
|
|
/* var isDefaultTitle = function () {
|
|
|
|
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
|
|
|
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
|
|
|
return Cryptpad.isDefaultName(parsed, document.title);
|
|
|
|
return Cryptpad.isDefaultName(parsed, document.title);
|
|
|
|
};
|
|
|
|
};*/
|
|
|
|
|
|
|
|
|
|
|
|
var initializing = true;
|
|
|
|
var initializing = true;
|
|
|
|
|
|
|
|
|
|
|
@ -226,7 +225,7 @@ define([
|
|
|
|
uid: Cryptpad.getUid(),
|
|
|
|
uid: Cryptpad.getUid(),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
addToUserData(myData);
|
|
|
|
addToUserData(myData);
|
|
|
|
Cryptpad.setAttribute('username', myUserName, function (err, data) {
|
|
|
|
Cryptpad.setAttribute('username', myUserName, function (err) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
console.log("Couldn't set username");
|
|
|
|
console.log("Couldn't set username");
|
|
|
|
console.error(err);
|
|
|
|
console.error(err);
|
|
|
@ -378,7 +377,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var onInit = config.onInit = function (info) {
|
|
|
|
config.onInit = function (info) {
|
|
|
|
userList = info.userList;
|
|
|
|
userList = info.userList;
|
|
|
|
|
|
|
|
|
|
|
|
var configTb = {
|
|
|
|
var configTb = {
|
|
|
@ -407,12 +406,9 @@ define([
|
|
|
|
toolbar = module.toolbar = Toolbar.create(configTb);
|
|
|
|
toolbar = module.toolbar = Toolbar.create(configTb);
|
|
|
|
|
|
|
|
|
|
|
|
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
|
|
|
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
|
|
|
var $userBlock = $bar.find('.' + Toolbar.constants.username);
|
|
|
|
module.$userNameButton = $($bar.find('.' + Toolbar.constants.changeUsername));
|
|
|
|
var $usernameButton = module.$userNameButton = $($bar.find('.' + Toolbar.constants.changeUsername));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var editHash;
|
|
|
|
var editHash;
|
|
|
|
var viewHash = Cryptpad.getViewHashFromKeys(info.channel, secret.keys);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!readOnly) {
|
|
|
|
if (!readOnly) {
|
|
|
|
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
|
|
|
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -475,7 +471,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* add a forget button */
|
|
|
|
/* add a forget button */
|
|
|
|
var forgetCb = function (err, title) {
|
|
|
|
var forgetCb = function (err) {
|
|
|
|
if (err) { return; }
|
|
|
|
if (err) { return; }
|
|
|
|
setEditable(false);
|
|
|
|
setEditable(false);
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -502,9 +498,7 @@ define([
|
|
|
|
isSelect: true,
|
|
|
|
isSelect: true,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var $block = module.$language = Cryptpad.createDropdown(dropdownConfig);
|
|
|
|
var $block = module.$language = Cryptpad.createDropdown(dropdownConfig);
|
|
|
|
var $button = $block.find('.buttonTitle');
|
|
|
|
$block.find('a').click(function () {
|
|
|
|
|
|
|
|
|
|
|
|
$block.find('a').click(function (e) {
|
|
|
|
|
|
|
|
setMode($(this).attr('data-value'), $block);
|
|
|
|
setMode($(this).attr('data-value'), $block);
|
|
|
|
onLocal();
|
|
|
|
onLocal();
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -537,11 +531,10 @@ define([
|
|
|
|
initialValue: lastTheme
|
|
|
|
initialValue: lastTheme
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var $block = module.$theme = Cryptpad.createDropdown(dropdownConfig);
|
|
|
|
var $block = module.$theme = Cryptpad.createDropdown(dropdownConfig);
|
|
|
|
var $button = $block.find('.buttonTitle');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTheme(lastTheme, $block);
|
|
|
|
setTheme(lastTheme, $block);
|
|
|
|
|
|
|
|
|
|
|
|
$block.find('a').click(function (e) {
|
|
|
|
$block.find('a').click(function () {
|
|
|
|
var theme = $(this).attr('data-value');
|
|
|
|
var theme = $(this).attr('data-value');
|
|
|
|
setTheme(theme, $block);
|
|
|
|
setTheme(theme, $block);
|
|
|
|
localStorage.setItem(themeKey, theme);
|
|
|
|
localStorage.setItem(themeKey, theme);
|
|
|
@ -579,7 +572,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var onReady = config.onReady = function (info) {
|
|
|
|
config.onReady = function (info) {
|
|
|
|
module.users = info.userList.users;
|
|
|
|
module.users = info.userList.users;
|
|
|
|
if (module.realtime !== info.realtime) {
|
|
|
|
if (module.realtime !== info.realtime) {
|
|
|
|
var realtime = module.realtime = info.realtime;
|
|
|
|
var realtime = module.realtime = info.realtime;
|
|
|
@ -693,7 +686,7 @@ define([
|
|
|
|
return cursor;
|
|
|
|
return cursor;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var onRemote = config.onRemote = function () {
|
|
|
|
config.onRemote = function () {
|
|
|
|
if (initializing) { return; }
|
|
|
|
if (initializing) { return; }
|
|
|
|
if (isHistoryMode) { return; }
|
|
|
|
if (isHistoryMode) { return; }
|
|
|
|
var scroll = editor.getScrollInfo();
|
|
|
|
var scroll = editor.getScrollInfo();
|
|
|
@ -748,14 +741,14 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var onAbort = config.onAbort = function (info) {
|
|
|
|
config.onAbort = function () {
|
|
|
|
// inform of network disconnect
|
|
|
|
// inform of network disconnect
|
|
|
|
setEditable(false);
|
|
|
|
setEditable(false);
|
|
|
|
toolbar.failed();
|
|
|
|
toolbar.failed();
|
|
|
|
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
|
|
|
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var onConnectionChange = config.onConnectionChange = function (info) {
|
|
|
|
config.onConnectionChange = function (info) {
|
|
|
|
setEditable(info.state);
|
|
|
|
setEditable(info.state);
|
|
|
|
toolbar.failed();
|
|
|
|
toolbar.failed();
|
|
|
|
if (info.state) {
|
|
|
|
if (info.state) {
|
|
|
@ -767,9 +760,9 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var onError = config.onError = onConnectError;
|
|
|
|
config.onError = onConnectError;
|
|
|
|
|
|
|
|
|
|
|
|
var realtime = module.realtime = Realtime.start(config);
|
|
|
|
module.realtime = Realtime.start(config);
|
|
|
|
|
|
|
|
|
|
|
|
editor.on('change', onLocal);
|
|
|
|
editor.on('change', onLocal);
|
|
|
|
|
|
|
|
|
|
|
@ -779,7 +772,7 @@ define([
|
|
|
|
var interval = 100;
|
|
|
|
var interval = 100;
|
|
|
|
|
|
|
|
|
|
|
|
var second = function (CM) {
|
|
|
|
var second = function (CM) {
|
|
|
|
Cryptpad.ready(function (err, env) {
|
|
|
|
Cryptpad.ready(function () {
|
|
|
|
andThen(CM);
|
|
|
|
andThen(CM);
|
|
|
|
Cryptpad.reportAppUsage();
|
|
|
|
Cryptpad.reportAppUsage();
|
|
|
|
});
|
|
|
|
});
|
|
|
|