pad: Delete unused `ip` and `userAgent` client vars
parent
98066184b2
commit
750c7cb1cf
|
@ -133,9 +133,7 @@ exports.handleDisconnect = async (socket) => {
|
|||
data: {
|
||||
type: 'USER_LEAVE',
|
||||
userInfo: {
|
||||
ip: '127.0.0.1',
|
||||
colorId: color,
|
||||
userAgent: 'Anonymous',
|
||||
userId: session.author,
|
||||
},
|
||||
},
|
||||
|
@ -489,8 +487,6 @@ async function handleUserInfoUpdate(socket, message) {
|
|||
// set a null name, when there is no name set. cause the client wants it null
|
||||
name: message.data.userInfo.name || null,
|
||||
colorId: message.data.userInfo.colorId,
|
||||
userAgent: 'Anonymous',
|
||||
ip: '127.0.0.1',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -1095,9 +1091,7 @@ async function handleClientReady(socket, message, authorID) {
|
|||
data: {
|
||||
type: 'USER_NEWINFO',
|
||||
userInfo: {
|
||||
ip: '127.0.0.1',
|
||||
colorId: authorColorId,
|
||||
userAgent: 'Anonymous',
|
||||
userId: authorID,
|
||||
},
|
||||
},
|
||||
|
@ -1146,10 +1140,8 @@ async function handleClientReady(socket, message, authorID) {
|
|||
data: {
|
||||
type: 'USER_NEWINFO',
|
||||
userInfo: {
|
||||
ip: '127.0.0.1',
|
||||
colorId: authorInfo.colorId,
|
||||
name: authorInfo.name,
|
||||
userAgent: 'Anonymous',
|
||||
userId: authorId,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -234,8 +234,6 @@ function handshake() {
|
|||
|
||||
// set some client vars
|
||||
clientVars = obj.data;
|
||||
clientVars.userAgent = 'Anonymous';
|
||||
clientVars.collab_client_vars.clientAgent = 'Anonymous';
|
||||
|
||||
// initalize the pad
|
||||
pad._afterHandshake();
|
||||
|
@ -333,9 +331,6 @@ var pad = {
|
|||
getColorPalette() {
|
||||
return clientVars.colorPalette;
|
||||
},
|
||||
getDisplayUserAgent() {
|
||||
return padutils.uaDisplay(clientVars.userAgent);
|
||||
},
|
||||
getIsDebugEnabled() {
|
||||
return clientVars.debugEnabled;
|
||||
},
|
||||
|
@ -427,7 +422,6 @@ var pad = {
|
|||
name: clientVars.userName,
|
||||
ip: pad.getClientIp(),
|
||||
colorId: clientVars.userColor,
|
||||
userAgent: pad.getDisplayUserAgent(),
|
||||
};
|
||||
|
||||
padimpexp.init(this);
|
||||
|
|
|
@ -143,17 +143,6 @@ const paduserlist = (function () {
|
|||
}
|
||||
}
|
||||
|
||||
function handleRowNode(tr, data) {
|
||||
if (data.titleText) {
|
||||
const titleText = data.titleText;
|
||||
window.setTimeout(() => {
|
||||
/* tr.attr('title', titleText)*/
|
||||
}, 0);
|
||||
} else {
|
||||
tr.removeAttr('title');
|
||||
}
|
||||
}
|
||||
|
||||
function handleOtherUserInputs() {
|
||||
// handle 'INPUT' elements for naming other unnamed users
|
||||
$('#otheruserstable input.newinput').each(function () {
|
||||
|
@ -195,7 +184,6 @@ const paduserlist = (function () {
|
|||
rowsFadingIn.push(row);
|
||||
tr = createRow(domId, createEmptyRowTds(getAnimationHeight(ANIMATION_START)), authorId);
|
||||
}
|
||||
handleRowNode(tr, data);
|
||||
$('table#otheruserstable').show();
|
||||
if (position == 0) {
|
||||
$('table#otheruserstable').prepend(tr);
|
||||
|
@ -221,7 +209,6 @@ const paduserlist = (function () {
|
|||
// not currently animating
|
||||
const tr = rowNode(row);
|
||||
replaceUserRowContents(tr, getAnimationHeight(0), row.data).find('td').css('opacity', (row.opacity === undefined ? 1 : row.opacity));
|
||||
handleRowNode(tr, data);
|
||||
handleOtherUserInputs();
|
||||
}
|
||||
}
|
||||
|
@ -272,14 +259,12 @@ const paduserlist = (function () {
|
|||
} else if (step == -OPACITY_STEPS + 1) {
|
||||
node.empty().append(createUserRowTds(animHeight, row.data))
|
||||
.find('td').css('opacity', baseOpacity * 1 / OPACITY_STEPS);
|
||||
handleRowNode(node, row.data);
|
||||
} else if (step < 0) {
|
||||
node.find('td').css('opacity', baseOpacity * (OPACITY_STEPS - (-step)) / OPACITY_STEPS).height(animHeight);
|
||||
} else if (step == 0) {
|
||||
// set HTML in case modified during animation
|
||||
node.empty().append(createUserRowTds(animHeight, row.data))
|
||||
.find('td').css('opacity', baseOpacity * 1).height(animHeight);
|
||||
handleRowNode(node, row.data);
|
||||
rowsFadingIn.splice(i, 1); // remove from set
|
||||
}
|
||||
}
|
||||
|
@ -480,8 +465,6 @@ const paduserlist = (function () {
|
|||
userData.status = '';
|
||||
userData.activity = '';
|
||||
userData.id = info.userId;
|
||||
// Firefox ignores \n in title text; Safari does a linebreak
|
||||
userData.titleText = [info.userAgent || '', info.ip || ''].join(' \n');
|
||||
|
||||
const existingIndex = findExistingIndex(info.userId);
|
||||
|
||||
|
|
|
@ -50,62 +50,6 @@ var padutils = {
|
|||
}
|
||||
return [pad.getClientIp(), encodeNum(+new Date(), 7), encodeNum(Math.floor(Math.random() * 1e9), 4)].join('.');
|
||||
},
|
||||
uaDisplay(ua) {
|
||||
let m;
|
||||
|
||||
function clean(a) {
|
||||
const maxlen = 16;
|
||||
a = a.replace(/[^a-zA-Z0-9\.]/g, '');
|
||||
if (a.length > maxlen) {
|
||||
a = a.substr(0, maxlen);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
function checkver(name) {
|
||||
const m = ua.match(RegExp(`${name}\\/([\\d\\.]+)`));
|
||||
if (m && m.length > 1) {
|
||||
return clean(name + m[1]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// firefox
|
||||
if (checkver('Firefox')) {
|
||||
return checkver('Firefox');
|
||||
}
|
||||
|
||||
// misc browsers, including IE
|
||||
m = ua.match(/compatible; ([^;]+);/);
|
||||
if (m && m.length > 1) {
|
||||
return clean(m[1]);
|
||||
}
|
||||
|
||||
// iphone
|
||||
if (ua.match(/\(iPhone;/)) {
|
||||
return 'iPhone';
|
||||
}
|
||||
|
||||
// chrome
|
||||
if (checkver('Chrome')) {
|
||||
return checkver('Chrome');
|
||||
}
|
||||
|
||||
// safari
|
||||
m = ua.match(/Safari\/[\d\.]+/);
|
||||
if (m) {
|
||||
let v = '?';
|
||||
m = ua.match(/Version\/([\d\.]+)/);
|
||||
if (m && m.length > 1) {
|
||||
v = m[1];
|
||||
}
|
||||
return clean(`Safari${v}`);
|
||||
}
|
||||
|
||||
// everything else
|
||||
const x = ua.split(' ')[0];
|
||||
return clean(x);
|
||||
},
|
||||
// e.g. "Thu Jun 18 2009 13:09"
|
||||
simpleDateTime(date) {
|
||||
const d = new Date(+date); // accept either number or date
|
||||
|
|
Loading…
Reference in New Issue