mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Delete dead SERVER_MESSAGE and guest handling code
None of this code seems to be reachable. Hopefully no plugins expect it to exist.
This commit is contained in:
parent
794dfb1863
commit
7e50fc2ab5
7 changed files with 11 additions and 242 deletions
|
@ -172,9 +172,6 @@
|
||||||
"pad.savedrevs.timeslider": "You can see saved revisions by visiting the timeslider",
|
"pad.savedrevs.timeslider": "You can see saved revisions by visiting the timeslider",
|
||||||
"pad.userlist.entername": "Enter your name",
|
"pad.userlist.entername": "Enter your name",
|
||||||
"pad.userlist.unnamed": "unnamed",
|
"pad.userlist.unnamed": "unnamed",
|
||||||
"pad.userlist.guest": "Guest",
|
|
||||||
"pad.userlist.deny": "Deny",
|
|
||||||
"pad.userlist.approve": "Approve",
|
|
||||||
"pad.editbar.clearcolors": "Clear authorship colors on entire document? This cannot be undone",
|
"pad.editbar.clearcolors": "Clear authorship colors on entire document? This cannot be undone",
|
||||||
|
|
||||||
"pad.impexp.importbutton": "Import Now",
|
"pad.impexp.importbutton": "Import Now",
|
||||||
|
|
|
@ -1013,9 +1013,7 @@ async function handleClientReady(socket, message, authorID) {
|
||||||
},
|
},
|
||||||
automaticReconnectionTimeout: settings.automaticReconnectionTimeout,
|
automaticReconnectionTimeout: settings.automaticReconnectionTimeout,
|
||||||
initialRevisionList: [],
|
initialRevisionList: [],
|
||||||
initialOptions: {
|
initialOptions: {},
|
||||||
guestPolicy: 'deny',
|
|
||||||
},
|
|
||||||
savedRevisions: pad.getSavedRevisions(),
|
savedRevisions: pad.getSavedRevisions(),
|
||||||
collab_client_vars: {
|
collab_client_vars: {
|
||||||
initialAttributedText: atext,
|
initialAttributedText: atext,
|
||||||
|
@ -1028,7 +1026,6 @@ async function handleClientReady(socket, message, authorID) {
|
||||||
},
|
},
|
||||||
colorPalette: authorManager.getColorPalette(),
|
colorPalette: authorManager.getColorPalette(),
|
||||||
clientIp: '127.0.0.1',
|
clientIp: '127.0.0.1',
|
||||||
userIsGuest: true,
|
|
||||||
userColor: authorColorId,
|
userColor: authorColorId,
|
||||||
padId: message.padId,
|
padId: message.padId,
|
||||||
padOptions: settings.padOptions,
|
padOptions: settings.padOptions,
|
||||||
|
|
|
@ -72,7 +72,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
onClientMessage() {},
|
onClientMessage() {},
|
||||||
onInternalAction() {},
|
onInternalAction() {},
|
||||||
onConnectionTrouble() {},
|
onConnectionTrouble() {},
|
||||||
onServerMessage() {},
|
|
||||||
};
|
};
|
||||||
if (browser.firefox) {
|
if (browser.firefox) {
|
||||||
// Prevent "escape" from taking effect and canceling a comet connection;
|
// Prevent "escape" from taking effect and canceling a comet connection;
|
||||||
|
@ -392,8 +391,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
// there are less than 100 messages or we reached the top
|
// there are less than 100 messages or we reached the top
|
||||||
if (chat.historyPointer <= 0) { $('#chatloadmessagesbutton').css('display', 'none'); } else // there are still more messages, re-show the load-button
|
if (chat.historyPointer <= 0) { $('#chatloadmessagesbutton').css('display', 'none'); } else // there are still more messages, re-show the load-button
|
||||||
{ $('#chatloadmessagesbutton').css('display', 'block'); }
|
{ $('#chatloadmessagesbutton').css('display', 'block'); }
|
||||||
} else if (msg.type == 'SERVER_MESSAGE') {
|
|
||||||
callbacks.onServerMessage(msg.payload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACKISH: User messages do not have "payload" but "userInfo", so that all "handleClientMessage_USER_" hooks would work, populate payload
|
// HACKISH: User messages do not have "payload" but "userInfo", so that all "handleClientMessage_USER_" hooks would work, populate payload
|
||||||
|
@ -586,9 +583,6 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
|
||||||
setOnConnectionTrouble(cb) {
|
setOnConnectionTrouble(cb) {
|
||||||
callbacks.onConnectionTrouble = cb;
|
callbacks.onConnectionTrouble = cb;
|
||||||
},
|
},
|
||||||
setOnServerMessage(cb) {
|
|
||||||
callbacks.onServerMessage = cb;
|
|
||||||
},
|
|
||||||
updateUserInfo: defer(updateUserInfo),
|
updateUserInfo: defer(updateUserInfo),
|
||||||
handleMessageFromServer,
|
handleMessageFromServer,
|
||||||
getConnectedUsers,
|
getConnectedUsers,
|
||||||
|
|
|
@ -337,9 +337,6 @@ var pad = {
|
||||||
getPrivilege(name) {
|
getPrivilege(name) {
|
||||||
return clientVars.accountPrivs[name];
|
return clientVars.accountPrivs[name];
|
||||||
},
|
},
|
||||||
getUserIsGuest() {
|
|
||||||
return clientVars.userIsGuest;
|
|
||||||
},
|
|
||||||
getUserId() {
|
getUserId() {
|
||||||
return pad.myUserInfo.userId;
|
return pad.myUserInfo.userId;
|
||||||
},
|
},
|
||||||
|
@ -440,7 +437,6 @@ var pad = {
|
||||||
pad.collabClient.setOnUpdateUserInfo(pad.handleUserUpdate);
|
pad.collabClient.setOnUpdateUserInfo(pad.handleUserUpdate);
|
||||||
pad.collabClient.setOnUserLeave(pad.handleUserLeave);
|
pad.collabClient.setOnUserLeave(pad.handleUserLeave);
|
||||||
pad.collabClient.setOnClientMessage(pad.handleClientMessage);
|
pad.collabClient.setOnClientMessage(pad.handleClientMessage);
|
||||||
pad.collabClient.setOnServerMessage(pad.handleServerMessage);
|
|
||||||
pad.collabClient.setOnChannelStateChange(pad.handleChannelStateChange);
|
pad.collabClient.setOnChannelStateChange(pad.handleChannelStateChange);
|
||||||
pad.collabClient.setOnInternalAction(pad.handleCollabAction);
|
pad.collabClient.setOnInternalAction(pad.handleCollabAction);
|
||||||
|
|
||||||
|
@ -537,18 +533,11 @@ var pad = {
|
||||||
}
|
}
|
||||||
padeditor.setViewOptions(pad.padOptions.view);
|
padeditor.setViewOptions(pad.padOptions.view);
|
||||||
}
|
}
|
||||||
if (opts.guestPolicy) {
|
|
||||||
// order important here
|
|
||||||
pad.padOptions.guestPolicy = opts.guestPolicy;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
getPadOptions() {
|
getPadOptions() {
|
||||||
// caller shouldn't mutate the object
|
// caller shouldn't mutate the object
|
||||||
return pad.padOptions;
|
return pad.padOptions;
|
||||||
},
|
},
|
||||||
isPadPublic() {
|
|
||||||
return pad.getPadOptions().guestPolicy == 'allow';
|
|
||||||
},
|
|
||||||
suggestUserName(userId, name) {
|
suggestUserName(userId, name) {
|
||||||
pad.collabClient.sendClientMessage(
|
pad.collabClient.sendClientMessage(
|
||||||
{
|
{
|
||||||
|
@ -579,9 +568,6 @@ var pad = {
|
||||||
} else if (msg.type == 'padoptions') {
|
} else if (msg.type == 'padoptions') {
|
||||||
const opts = msg.options;
|
const opts = msg.options;
|
||||||
pad.handleOptionsChange(opts);
|
pad.handleOptionsChange(opts);
|
||||||
} else if (msg.type == 'guestanswer') {
|
|
||||||
// someone answered a prompt, remove it
|
|
||||||
paduserlist.removeGuestPrompt(msg.guestId);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dmesg(m) {
|
dmesg(m) {
|
||||||
|
@ -594,21 +580,6 @@ var pad = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleServerMessage(m) {
|
|
||||||
if (m.type == 'NOTICE') {
|
|
||||||
if (m.text) {
|
|
||||||
alertBar.displayMessage((abar) => {
|
|
||||||
abar.find('#servermsgdate').text(` (${padutils.simpleDateTime(new Date())})`);
|
|
||||||
abar.find('#servermsgtext').text(m.text);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (m.js) {
|
|
||||||
window['ev' + 'al'](m.js);
|
|
||||||
}
|
|
||||||
} else if (m.type == 'GUEST_PROMPT') {
|
|
||||||
paduserlist.showGuestPrompt(m.userId, m.displayName);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handleChannelStateChange(newState, message) {
|
handleChannelStateChange(newState, message) {
|
||||||
const oldFullyConnected = !!padconnectionstatus.isFullyConnected();
|
const oldFullyConnected = !!padconnectionstatus.isFullyConnected();
|
||||||
const wasConnecting = (padconnectionstatus.getStatus().what == 'connecting');
|
const wasConnecting = (padconnectionstatus.getStatus().what == 'connecting');
|
||||||
|
@ -695,9 +666,6 @@ var pad = {
|
||||||
padeditbar.setSyncStatus('done');
|
padeditbar.setSyncStatus('done');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hideServerMessage() {
|
|
||||||
alertBar.hideMessage();
|
|
||||||
},
|
|
||||||
asyncSendDiagnosticInfo() {
|
asyncSendDiagnosticInfo() {
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
$.ajax(
|
$.ajax(
|
||||||
|
@ -743,35 +711,6 @@ var pad = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
var alertBar = (function () {
|
|
||||||
const animator = padutils.makeShowHideAnimator(arriveAtAnimationState, false, 25, 400);
|
|
||||||
|
|
||||||
function arriveAtAnimationState(state) {
|
|
||||||
if (state == -1) {
|
|
||||||
$('#alertbar').css('opacity', 0).css('display', 'block');
|
|
||||||
} else if (state == 0) {
|
|
||||||
$('#alertbar').css('opacity', 1);
|
|
||||||
} else if (state == 1) {
|
|
||||||
$('#alertbar').css('opacity', 0).css('display', 'none');
|
|
||||||
} else if (state < 0) {
|
|
||||||
$('#alertbar').css('opacity', state + 1);
|
|
||||||
} else if (state > 0) {
|
|
||||||
$('#alertbar').css('opacity', 1 - state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const self = {
|
|
||||||
displayMessage(setupFunc) {
|
|
||||||
animator.show();
|
|
||||||
setupFunc($('#alertbar'));
|
|
||||||
},
|
|
||||||
hideMessage() {
|
|
||||||
animator.hide();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
return self;
|
|
||||||
}());
|
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
return pad.init();
|
return pad.init();
|
||||||
}
|
}
|
||||||
|
@ -794,4 +733,3 @@ exports.getUrlVars = getUrlVars;
|
||||||
exports.handshake = handshake;
|
exports.handshake = handshake;
|
||||||
exports.pad = pad;
|
exports.pad = pad;
|
||||||
exports.init = init;
|
exports.init = init;
|
||||||
exports.alertBar = alertBar;
|
|
||||||
|
|
|
@ -352,26 +352,6 @@ const paduserlist = (function () {
|
||||||
jqueryNode.removeAttr('disabled').addClass('editable');
|
jqueryNode.removeAttr('disabled').addClass('editable');
|
||||||
}
|
}
|
||||||
|
|
||||||
const knocksToIgnore = {};
|
|
||||||
let guestPromptFlashState = 0;
|
|
||||||
const guestPromptFlash = padutils.makeAnimationScheduler(
|
|
||||||
|
|
||||||
() => {
|
|
||||||
const prompts = $('#guestprompts .guestprompt');
|
|
||||||
if (prompts.length == 0) {
|
|
||||||
return false; // no more to do
|
|
||||||
}
|
|
||||||
|
|
||||||
guestPromptFlashState = 1 - guestPromptFlashState;
|
|
||||||
if (guestPromptFlashState) {
|
|
||||||
prompts.css('background', '#ffa');
|
|
||||||
} else {
|
|
||||||
prompts.css('background', '#ffe');
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
var pad = undefined;
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
init(myInitialUserInfo, _pad) {
|
init(myInitialUserInfo, _pad) {
|
||||||
|
@ -383,18 +363,16 @@ const paduserlist = (function () {
|
||||||
|
|
||||||
$('#otheruserstable tr').remove();
|
$('#otheruserstable tr').remove();
|
||||||
|
|
||||||
if (pad.getUserIsGuest()) {
|
$('#myusernameedit').addClass('myusernameedithoverable');
|
||||||
$('#myusernameedit').addClass('myusernameedithoverable');
|
setUpEditable($('#myusernameedit'), () => myUserInfo.name || '', (newValue) => {
|
||||||
setUpEditable($('#myusernameedit'), () => myUserInfo.name || '', (newValue) => {
|
myUserInfo.name = newValue;
|
||||||
myUserInfo.name = newValue;
|
pad.notifyChangeName(newValue);
|
||||||
pad.notifyChangeName(newValue);
|
// wrap with setTimeout to do later because we get
|
||||||
// wrap with setTimeout to do later because we get
|
// a double "blur" fire in IE...
|
||||||
// a double "blur" fire in IE...
|
window.setTimeout(() => {
|
||||||
window.setTimeout(() => {
|
self.renderMyUserInfo();
|
||||||
self.renderMyUserInfo();
|
}, 0);
|
||||||
}, 0);
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// color picker
|
// color picker
|
||||||
$('#myswatchbox').click(showColorPicker);
|
$('#myswatchbox').click(showColorPicker);
|
||||||
|
@ -551,56 +529,6 @@ const paduserlist = (function () {
|
||||||
|
|
||||||
self.updateNumberOfOnlineUsers();
|
self.updateNumberOfOnlineUsers();
|
||||||
},
|
},
|
||||||
showGuestPrompt(userId, displayName) {
|
|
||||||
if (knocksToIgnore[userId]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const encodedUserId = padutils.encodeUserId(userId);
|
|
||||||
|
|
||||||
const actionName = `hide-guest-prompt-${encodedUserId}`;
|
|
||||||
padutils.cancelActions(actionName);
|
|
||||||
|
|
||||||
let box = $(`#guestprompt-${encodedUserId}`);
|
|
||||||
if (box.length == 0) {
|
|
||||||
// make guest prompt box
|
|
||||||
box = $(`<div id="${padutils.escapeHtml(`guestprompt-${encodedUserId}`)}" class="guestprompt"><div class="choices"><a href="${padutils.escapeHtml(`javascript:void(require(${JSON.stringify(module.id)}).paduserlist.answerGuestPrompt(${JSON.stringify(encodedUserId)},false))`)}">${_('pad.userlist.deny')}</a> <a href="${padutils.escapeHtml(`javascript:void(require(${JSON.stringify(module.id)}).paduserlist.answerGuestPrompt(${JSON.stringify(encodedUserId)},true))`)}">${_('pad.userlist.approve')}</a></div><div class="guestname"><strong>${_('pad.userlist.guest')}:</strong> ${padutils.escapeHtml(displayName)}</div></div>`);
|
|
||||||
$('#guestprompts').append(box);
|
|
||||||
} else {
|
|
||||||
// update display name
|
|
||||||
box.find('.guestname').html(`<strong>${_('pad.userlist.guest')}:</strong> ${padutils.escapeHtml(displayName)}`);
|
|
||||||
}
|
|
||||||
const hideLater = padutils.getCancellableAction(actionName, () => {
|
|
||||||
self.removeGuestPrompt(userId);
|
|
||||||
});
|
|
||||||
window.setTimeout(hideLater, 15000); // time-out with no knock
|
|
||||||
guestPromptFlash.scheduleAnimation();
|
|
||||||
},
|
|
||||||
removeGuestPrompt(userId) {
|
|
||||||
const box = $(`#guestprompt-${padutils.encodeUserId(userId)}`);
|
|
||||||
// remove ID now so a new knock by same user gets new, unfaded box
|
|
||||||
box.removeAttr('id').fadeOut('fast', () => {
|
|
||||||
box.remove();
|
|
||||||
});
|
|
||||||
|
|
||||||
knocksToIgnore[userId] = true;
|
|
||||||
window.setTimeout(() => {
|
|
||||||
delete knocksToIgnore[userId];
|
|
||||||
}, 5000);
|
|
||||||
},
|
|
||||||
answerGuestPrompt(encodedUserId, approve) {
|
|
||||||
const guestId = padutils.decodeUserId(encodedUserId);
|
|
||||||
|
|
||||||
const msg = {
|
|
||||||
type: 'guestanswer',
|
|
||||||
authId: pad.getUserId(),
|
|
||||||
guestId,
|
|
||||||
answer: (approve ? 'approved' : 'denied'),
|
|
||||||
};
|
|
||||||
pad.sendClientMessage(msg);
|
|
||||||
|
|
||||||
self.removeGuestPrompt(guestId);
|
|
||||||
},
|
|
||||||
renderMyUserInfo() {
|
renderMyUserInfo() {
|
||||||
if (myUserInfo.name) {
|
if (myUserInfo.name) {
|
||||||
$('#myusernameedit').removeClass('editempty').val(myUserInfo.name);
|
$('#myusernameedit').removeClass('editempty').val(myUserInfo.name);
|
||||||
|
|
|
@ -247,90 +247,6 @@ const padutils = {
|
||||||
};
|
};
|
||||||
return {scheduleAnimation};
|
return {scheduleAnimation};
|
||||||
},
|
},
|
||||||
makeShowHideAnimator: (funcToArriveAtState, initiallyShown, fps, totalMs) => {
|
|
||||||
let animationState = (initiallyShown ? 0 : -2); // -2 hidden, -1 to 0 fade in, 0 to 1 fade out
|
|
||||||
const animationFrameDelay = 1000 / fps;
|
|
||||||
const animationStep = animationFrameDelay / totalMs;
|
|
||||||
|
|
||||||
const animateOneStep = () => {
|
|
||||||
if (animationState < -1 || animationState === 0) {
|
|
||||||
return false;
|
|
||||||
} else if (animationState < 0) {
|
|
||||||
// animate show
|
|
||||||
animationState += animationStep;
|
|
||||||
if (animationState >= 0) {
|
|
||||||
animationState = 0;
|
|
||||||
funcToArriveAtState(animationState);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
funcToArriveAtState(animationState);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (animationState > 0) {
|
|
||||||
// animate hide
|
|
||||||
animationState += animationStep;
|
|
||||||
if (animationState >= 1) {
|
|
||||||
animationState = 1;
|
|
||||||
funcToArriveAtState(animationState);
|
|
||||||
animationState = -2;
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
funcToArriveAtState(animationState);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const scheduleAnimation =
|
|
||||||
padutils.makeAnimationScheduler(animateOneStep, animationFrameDelay).scheduleAnimation;
|
|
||||||
|
|
||||||
return {
|
|
||||||
show: () => {
|
|
||||||
animationState = -1;
|
|
||||||
funcToArriveAtState(animationState);
|
|
||||||
scheduleAnimation();
|
|
||||||
},
|
|
||||||
quickShow: () => { // start showing without losing any fade-in progress
|
|
||||||
if (animationState < -1) {
|
|
||||||
animationState = -1;
|
|
||||||
} else if (animationState > 0) {
|
|
||||||
animationState = Math.max(-1, Math.min(0, -animationState));
|
|
||||||
}
|
|
||||||
funcToArriveAtState(animationState);
|
|
||||||
scheduleAnimation();
|
|
||||||
},
|
|
||||||
hide: () => {
|
|
||||||
if (animationState >= -1 && animationState <= 0) {
|
|
||||||
animationState = 1e-6;
|
|
||||||
scheduleAnimation();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
_nextActionId: 1,
|
|
||||||
uncanceledActions: {},
|
|
||||||
getCancellableAction: (actionType, actionFunc) => {
|
|
||||||
let o = padutils.uncanceledActions[actionType];
|
|
||||||
if (!o) {
|
|
||||||
o = {};
|
|
||||||
padutils.uncanceledActions[actionType] = o;
|
|
||||||
}
|
|
||||||
const actionId = (padutils._nextActionId++);
|
|
||||||
o[actionId] = true;
|
|
||||||
return () => {
|
|
||||||
const p = padutils.uncanceledActions[actionType];
|
|
||||||
if (p && p[actionId]) {
|
|
||||||
actionFunc();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
cancelActions: (actionType) => {
|
|
||||||
const o = padutils.uncanceledActions[actionType];
|
|
||||||
if (o) {
|
|
||||||
// clear it
|
|
||||||
delete padutils.uncanceledActions[actionType];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
makeFieldLabeledWhenEmpty: (field, labelText) => {
|
makeFieldLabeledWhenEmpty: (field, labelText) => {
|
||||||
field = $(field);
|
field = $(field);
|
||||||
|
|
||||||
|
|
|
@ -353,7 +353,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="otherusers" aria-role="document">
|
<div id="otherusers" aria-role="document">
|
||||||
<div id="guestprompts"></div>
|
|
||||||
<table id="otheruserstable" cellspacing="0" cellpadding="0" border="0">
|
<table id="otheruserstable" cellspacing="0" cellpadding="0" border="0">
|
||||||
<tr><td></td></tr>
|
<tr><td></td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in a new issue