mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-06-18 04:04:50 -04:00
lint: pad prefix files (#4577)
* lint: pad_connectionstatus * lint: pad_utils * lint: pad_userlist.js -- still WIP * shift underscore not to be in require but to be used from window * lint: pad_modals * pad_impexp.js * lint: more errors done * lint: auto reconn * lint: pad_editor * lint: finish auto reconn * lint: imp exp rework * lint: import * lint: pad.js nearly done but pizza here... * lint: clientVars global query * put clientVars in window * Revert incorrect lint fixes * Properly fix guard-for-in lint errors * Properly fix no-unused-vars error regarding `gritter` * Refine lint fixes Co-authored-by: Richard Hansen <rhansen@rhansen.org>
This commit is contained in:
parent
34ee77993f
commit
0362d3b05d
11 changed files with 512 additions and 459 deletions
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* This code is mostly from the old Etherpad. Please help us to comment this code.
|
||||
* This helps other people to understand this code better and helps them to improve it.
|
||||
|
@ -22,13 +24,12 @@
|
|||
|
||||
const padutils = require('./pad_utils').padutils;
|
||||
const hooks = require('./pluginfw/hooks');
|
||||
const browser = require('./browser');
|
||||
|
||||
let myUserInfo = {};
|
||||
|
||||
let colorPickerOpen = false;
|
||||
let colorPickerSetup = false;
|
||||
let previousColorId = 0;
|
||||
|
||||
|
||||
const paduserlist = (function () {
|
||||
const rowManager = (function () {
|
||||
|
@ -36,9 +37,7 @@ const paduserlist = (function () {
|
|||
// their insertion, removal, and reordering. It manipulates TD height
|
||||
// and TD opacity.
|
||||
|
||||
function nextRowId() {
|
||||
return `usertr${nextRowId.counter++}`;
|
||||
}
|
||||
const nextRowId = () => `usertr${nextRowId.counter++}`;
|
||||
nextRowId.counter = 1;
|
||||
// objects are shared; fields are "domId","data","animationStep"
|
||||
const rowsFadingOut = []; // unordered set
|
||||
|
@ -47,20 +46,67 @@ const paduserlist = (function () {
|
|||
const ANIMATION_START = -12; // just starting to fade in
|
||||
const ANIMATION_END = 12; // just finishing fading out
|
||||
|
||||
const animateStep = () => {
|
||||
// animation must be symmetrical
|
||||
for (let i = rowsFadingIn.length - 1; i >= 0; i--) { // backwards to allow removal
|
||||
const row = rowsFadingIn[i];
|
||||
const step = ++row.animationStep;
|
||||
const animHeight = getAnimationHeight(step, row.animationPower);
|
||||
const node = rowNode(row);
|
||||
const baseOpacity = (row.opacity === undefined ? 1 : row.opacity);
|
||||
if (step <= -OPACITY_STEPS) {
|
||||
node.find('td').height(animHeight);
|
||||
} else if (step === -OPACITY_STEPS + 1) {
|
||||
node.empty().append(createUserRowTds(animHeight, row.data))
|
||||
.find('td').css('opacity', baseOpacity * 1 / OPACITY_STEPS);
|
||||
} 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);
|
||||
rowsFadingIn.splice(i, 1); // remove from set
|
||||
}
|
||||
}
|
||||
for (let i = rowsFadingOut.length - 1; i >= 0; i--) { // backwards to allow removal
|
||||
const row = rowsFadingOut[i];
|
||||
const step = ++row.animationStep;
|
||||
const node = rowNode(row);
|
||||
const animHeight = getAnimationHeight(step, row.animationPower);
|
||||
const baseOpacity = (row.opacity === undefined ? 1 : row.opacity);
|
||||
if (step < OPACITY_STEPS) {
|
||||
node.find('td').css('opacity', baseOpacity * (OPACITY_STEPS - step) / OPACITY_STEPS)
|
||||
.height(animHeight);
|
||||
} else if (step === OPACITY_STEPS) {
|
||||
node.empty().append(createEmptyRowTds(animHeight));
|
||||
} else if (step <= ANIMATION_END) {
|
||||
node.find('td').height(animHeight);
|
||||
} else {
|
||||
rowsFadingOut.splice(i, 1); // remove from set
|
||||
node.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function getAnimationHeight(step, power) {
|
||||
handleOtherUserInputs();
|
||||
|
||||
return (rowsFadingIn.length > 0) || (rowsFadingOut.length > 0); // is more to do
|
||||
};
|
||||
|
||||
const getAnimationHeight = (step, power) => {
|
||||
let a = Math.abs(step / 12);
|
||||
if (power == 2) a *= a;
|
||||
else if (power == 3) a = a * a * a;
|
||||
else if (power == 4) a = a * a * a * a;
|
||||
else if (power >= 5) a = a * a * a * a * a;
|
||||
if (power === 2) a **= 2;
|
||||
else if (power === 3) a **= 3;
|
||||
else if (power === 4) a **= 4;
|
||||
else if (power >= 5) a **= 5;
|
||||
return Math.round(26 * (1 - a));
|
||||
}
|
||||
};
|
||||
const OPACITY_STEPS = 6;
|
||||
|
||||
const ANIMATION_STEP_TIME = 20;
|
||||
const LOWER_FRAMERATE_FACTOR = 2;
|
||||
const scheduleAnimation = padutils.makeAnimationScheduler(animateStep, ANIMATION_STEP_TIME, LOWER_FRAMERATE_FACTOR).scheduleAnimation;
|
||||
const {scheduleAnimation} =
|
||||
padutils.makeAnimationScheduler(animateStep, ANIMATION_STEP_TIME, LOWER_FRAMERATE_FACTOR);
|
||||
|
||||
const NUMCOLS = 4;
|
||||
|
||||
|
@ -72,11 +118,9 @@ const paduserlist = (function () {
|
|||
.css('border', 0)
|
||||
.css('height', `${height}px`);
|
||||
|
||||
function isNameEditable(data) {
|
||||
return (!data.name) && (data.status != 'Disconnected');
|
||||
}
|
||||
const isNameEditable = (data) => (!data.name) && (data.status !== 'Disconnected');
|
||||
|
||||
function replaceUserRowContents(tr, height, data) {
|
||||
const replaceUserRowContents = (tr, height, data) => {
|
||||
const tds = createUserRowTds(height, data);
|
||||
if (isNameEditable(data) && tr.find('td.usertdname input:enabled').length > 0) {
|
||||
// preserve input field node
|
||||
|
@ -93,7 +137,7 @@ const paduserlist = (function () {
|
|||
tr.empty().append(tds);
|
||||
}
|
||||
return tr;
|
||||
}
|
||||
};
|
||||
|
||||
const createUserRowTds = (height, data) => {
|
||||
let name;
|
||||
|
@ -105,7 +149,7 @@ const paduserlist = (function () {
|
|||
.attr('type', 'text')
|
||||
.addClass('editempty')
|
||||
.addClass('newinput')
|
||||
.attr('value', _('pad.userlist.unnamed'));
|
||||
.attr('value', html10n.get('pad.userlist.unnamed'));
|
||||
if (isNameEditable(data)) name.attr('disabled', 'disabled');
|
||||
}
|
||||
return $()
|
||||
|
@ -131,19 +175,17 @@ const paduserlist = (function () {
|
|||
.attr('id', id)
|
||||
.append(contents);
|
||||
|
||||
function rowNode(row) {
|
||||
return $(`#${row.domId}`);
|
||||
}
|
||||
const rowNode = (row) => $(`#${row.domId}`);
|
||||
|
||||
function handleRowData(row) {
|
||||
if (row.data && row.data.status == 'Disconnected') {
|
||||
const handleRowData = (row) => {
|
||||
if (row.data && row.data.status === 'Disconnected') {
|
||||
row.opacity = 0.5;
|
||||
} else {
|
||||
delete row.opacity;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function handleOtherUserInputs() {
|
||||
const handleOtherUserInputs = () => {
|
||||
// handle 'INPUT' elements for naming other unnamed users
|
||||
$('#otheruserstable input.newinput').each(function () {
|
||||
const input = $(this);
|
||||
|
@ -156,12 +198,12 @@ const paduserlist = (function () {
|
|||
}
|
||||
}
|
||||
}).removeClass('newinput');
|
||||
}
|
||||
};
|
||||
|
||||
// animationPower is 0 to skip animation, 1 for linear, 2 for quadratic, etc.
|
||||
|
||||
|
||||
function insertRow(position, data, animationPower) {
|
||||
const insertRow = (position, data, animationPower) => {
|
||||
position = Math.max(0, Math.min(rowsPresent.length, position));
|
||||
animationPower = (animationPower === undefined ? 4 : animationPower);
|
||||
|
||||
|
@ -177,7 +219,7 @@ const paduserlist = (function () {
|
|||
handleRowData(row);
|
||||
rowsPresent.splice(position, 0, row);
|
||||
let tr;
|
||||
if (animationPower == 0) {
|
||||
if (animationPower === 0) {
|
||||
tr = createRow(domId, createUserRowTds(getAnimationHeight(0), data), authorId);
|
||||
row.animationStep = 0;
|
||||
} else {
|
||||
|
@ -185,41 +227,43 @@ const paduserlist = (function () {
|
|||
tr = createRow(domId, createEmptyRowTds(getAnimationHeight(ANIMATION_START)), authorId);
|
||||
}
|
||||
$('table#otheruserstable').show();
|
||||
if (position == 0) {
|
||||
if (position === 0) {
|
||||
$('table#otheruserstable').prepend(tr);
|
||||
} else {
|
||||
rowNode(rowsPresent[position - 1]).after(tr);
|
||||
}
|
||||
|
||||
if (animationPower != 0) {
|
||||
if (animationPower !== 0) {
|
||||
scheduleAnimation();
|
||||
}
|
||||
|
||||
handleOtherUserInputs();
|
||||
|
||||
return row;
|
||||
}
|
||||
};
|
||||
|
||||
function updateRow(position, data) {
|
||||
const updateRow = (position, data) => {
|
||||
const row = rowsPresent[position];
|
||||
if (row) {
|
||||
row.data = data;
|
||||
handleRowData(row);
|
||||
if (row.animationStep == 0) {
|
||||
if (row.animationStep === 0) {
|
||||
// not currently animating
|
||||
const tr = rowNode(row);
|
||||
replaceUserRowContents(tr, getAnimationHeight(0), row.data).find('td').css('opacity', (row.opacity === undefined ? 1 : row.opacity));
|
||||
replaceUserRowContents(tr, getAnimationHeight(0), row.data)
|
||||
.find('td')
|
||||
.css('opacity', (row.opacity === undefined ? 1 : row.opacity));
|
||||
handleOtherUserInputs();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function removeRow(position, animationPower) {
|
||||
const removeRow = (position, animationPower) => {
|
||||
animationPower = (animationPower === undefined ? 4 : animationPower);
|
||||
const row = rowsPresent[position];
|
||||
if (row) {
|
||||
rowsPresent.splice(position, 1); // remove
|
||||
if (animationPower == 0) {
|
||||
if (animationPower === 0) {
|
||||
rowNode(row).remove();
|
||||
} else {
|
||||
row.animationStep = -row.animationStep; // use symmetry
|
||||
|
@ -231,65 +275,20 @@ const paduserlist = (function () {
|
|||
if (rowsPresent.length === 0) {
|
||||
$('table#otheruserstable').hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// newPosition is position after the row has been removed
|
||||
|
||||
|
||||
function moveRow(oldPosition, newPosition, animationPower) {
|
||||
const moveRow = (oldPosition, newPosition, animationPower) => {
|
||||
animationPower = (animationPower === undefined ? 1 : animationPower); // linear is best
|
||||
const row = rowsPresent[oldPosition];
|
||||
if (row && oldPosition != newPosition) {
|
||||
if (row && oldPosition !== newPosition) {
|
||||
const rowData = row.data;
|
||||
removeRow(oldPosition, animationPower);
|
||||
insertRow(newPosition, rowData, animationPower);
|
||||
}
|
||||
}
|
||||
|
||||
function animateStep() {
|
||||
// animation must be symmetrical
|
||||
for (var i = rowsFadingIn.length - 1; i >= 0; i--) { // backwards to allow removal
|
||||
var row = rowsFadingIn[i];
|
||||
var step = ++row.animationStep;
|
||||
var animHeight = getAnimationHeight(step, row.animationPower);
|
||||
var node = rowNode(row);
|
||||
var baseOpacity = (row.opacity === undefined ? 1 : row.opacity);
|
||||
if (step <= -OPACITY_STEPS) {
|
||||
node.find('td').height(animHeight);
|
||||
} else if (step == -OPACITY_STEPS + 1) {
|
||||
node.empty().append(createUserRowTds(animHeight, row.data))
|
||||
.find('td').css('opacity', baseOpacity * 1 / OPACITY_STEPS);
|
||||
} 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);
|
||||
rowsFadingIn.splice(i, 1); // remove from set
|
||||
}
|
||||
}
|
||||
for (var i = rowsFadingOut.length - 1; i >= 0; i--) { // backwards to allow removal
|
||||
var row = rowsFadingOut[i];
|
||||
var step = ++row.animationStep;
|
||||
var node = rowNode(row);
|
||||
var animHeight = getAnimationHeight(step, row.animationPower);
|
||||
var baseOpacity = (row.opacity === undefined ? 1 : row.opacity);
|
||||
if (step < OPACITY_STEPS) {
|
||||
node.find('td').css('opacity', baseOpacity * (OPACITY_STEPS - step) / OPACITY_STEPS).height(animHeight);
|
||||
} else if (step == OPACITY_STEPS) {
|
||||
node.empty().append(createEmptyRowTds(animHeight));
|
||||
} else if (step <= ANIMATION_END) {
|
||||
node.find('td').height(animHeight);
|
||||
} else {
|
||||
rowsFadingOut.splice(i, 1); // remove from set
|
||||
node.remove();
|
||||
}
|
||||
}
|
||||
|
||||
handleOtherUserInputs();
|
||||
|
||||
return (rowsFadingIn.length > 0) || (rowsFadingOut.length > 0); // is more to do
|
||||
}
|
||||
};
|
||||
|
||||
const self = {
|
||||
insertRow,
|
||||
|
@ -302,7 +301,7 @@ const paduserlist = (function () {
|
|||
const otherUsersInfo = [];
|
||||
const otherUsersData = [];
|
||||
|
||||
function rowManagerMakeNameEditor(jnode, userId) {
|
||||
const rowManagerMakeNameEditor = (jnode, userId) => {
|
||||
setUpEditable(jnode, () => {
|
||||
const existingIndex = findExistingIndex(userId);
|
||||
if (existingIndex >= 0) {
|
||||
|
@ -313,26 +312,26 @@ const paduserlist = (function () {
|
|||
}, (newName) => {
|
||||
if (!newName) {
|
||||
jnode.addClass('editempty');
|
||||
jnode.val(_('pad.userlist.unnamed'));
|
||||
jnode.val(html10n.get('pad.userlist.unnamed'));
|
||||
} else {
|
||||
jnode.attr('disabled', 'disabled');
|
||||
pad.suggestUserName(userId, newName);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function findExistingIndex(userId) {
|
||||
const findExistingIndex = (userId) => {
|
||||
let existingIndex = -1;
|
||||
for (let i = 0; i < otherUsersInfo.length; i++) {
|
||||
if (otherUsersInfo[i].userId == userId) {
|
||||
if (otherUsersInfo[i].userId === userId) {
|
||||
existingIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return existingIndex;
|
||||
}
|
||||
};
|
||||
|
||||
function setUpEditable(jqueryNode, valueGetter, valueSetter) {
|
||||
const setUpEditable = (jqueryNode, valueGetter, valueSetter) => {
|
||||
jqueryNode.bind('focus', (evt) => {
|
||||
const oldValue = valueGetter();
|
||||
if (jqueryNode.val() !== oldValue) {
|
||||
|
@ -350,16 +349,18 @@ const paduserlist = (function () {
|
|||
jqueryNode.val(valueGetter()).blur();
|
||||
});
|
||||
jqueryNode.removeAttr('disabled').addClass('editable');
|
||||
}
|
||||
};
|
||||
|
||||
var pad = undefined;
|
||||
var self = {
|
||||
let pad = undefined;
|
||||
const self = {
|
||||
init(myInitialUserInfo, _pad) {
|
||||
pad = _pad;
|
||||
|
||||
self.setMyUserInfo(myInitialUserInfo);
|
||||
|
||||
if ($('#online_count').length === 0) $('#editbar [data-key=showusers] > a').append('<span id="online_count">1</span>');
|
||||
if ($('#online_count').length === 0) {
|
||||
$('#editbar [data-key=showusers] > a').append('<span id="online_count">1</span>');
|
||||
}
|
||||
|
||||
$('#otheruserstable tr').remove();
|
||||
|
||||
|
@ -388,23 +389,24 @@ const paduserlist = (function () {
|
|||
});
|
||||
//
|
||||
},
|
||||
usersOnline() {
|
||||
usersOnline: () => {
|
||||
// Returns an object of users who are currently online on this pad
|
||||
const userList = [].concat(otherUsersInfo); // Make a copy of the otherUsersInfo, otherwise every call to users modifies the referenced array
|
||||
// Make a copy of the otherUsersInfo, otherwise every call to users
|
||||
// modifies the referenced array
|
||||
const userList = [].concat(otherUsersInfo);
|
||||
// Now we need to add ourselves..
|
||||
userList.push(myUserInfo);
|
||||
return userList;
|
||||
},
|
||||
users() {
|
||||
users: () => {
|
||||
// Returns an object of users who have been on this pad
|
||||
const userList = self.usersOnline();
|
||||
|
||||
// Now we add historical authors
|
||||
const historical = clientVars.collab_client_vars.historicalAuthorData;
|
||||
for (const key in historical) {
|
||||
var userId = historical[key].userId;
|
||||
for (const [key, {userId}] of Object.entries(historical)) {
|
||||
// Check we don't already have this author in our array
|
||||
var exists = false;
|
||||
let exists = false;
|
||||
|
||||
userList.forEach((user) => {
|
||||
if (user.userId === userId) exists = true;
|
||||
|
@ -416,7 +418,7 @@ const paduserlist = (function () {
|
|||
}
|
||||
return userList;
|
||||
},
|
||||
setMyUserInfo(info) {
|
||||
setMyUserInfo: (info) => {
|
||||
// translate the colorId
|
||||
if (typeof info.colorId === 'number') {
|
||||
info.colorId = clientVars.colorPalette[info.colorId];
|
||||
|
@ -427,8 +429,8 @@ const paduserlist = (function () {
|
|||
|
||||
self.renderMyUserInfo();
|
||||
},
|
||||
userJoinOrUpdate(info) {
|
||||
if ((!info.userId) || (info.userId == myUserInfo.userId)) {
|
||||
userJoinOrUpdate: (info) => {
|
||||
if ((!info.userId) || (info.userId === myUserInfo.userId)) {
|
||||
// not sure how this would happen
|
||||
return;
|
||||
}
|
||||
|
@ -438,7 +440,8 @@ const paduserlist = (function () {
|
|||
});
|
||||
|
||||
const userData = {};
|
||||
userData.color = typeof info.colorId === 'number' ? clientVars.colorPalette[info.colorId] : info.colorId;
|
||||
userData.color = typeof info.colorId === 'number'
|
||||
? clientVars.colorPalette[info.colorId] : info.colorId;
|
||||
userData.name = info.name;
|
||||
userData.status = '';
|
||||
userData.activity = '';
|
||||
|
@ -460,12 +463,12 @@ const paduserlist = (function () {
|
|||
const nameThis = (info.name || '').toLowerCase();
|
||||
const idN = infoN.userId;
|
||||
const idThis = info.userId;
|
||||
return (nameN > nameThis) || (nameN == nameThis && idN > idThis);
|
||||
return (nameN > nameThis) || (nameN === nameThis && idN > idThis);
|
||||
});
|
||||
|
||||
if (existingIndex >= 0) {
|
||||
// update
|
||||
if (existingIndex == newIndex) {
|
||||
if (existingIndex === newIndex) {
|
||||
otherUsersInfo[existingIndex] = info;
|
||||
otherUsersData[existingIndex] = userData;
|
||||
rowManager.updateRow(existingIndex, userData);
|
||||
|
@ -485,10 +488,10 @@ const paduserlist = (function () {
|
|||
|
||||
self.updateNumberOfOnlineUsers();
|
||||
},
|
||||
updateNumberOfOnlineUsers() {
|
||||
updateNumberOfOnlineUsers: () => {
|
||||
let online = 1; // you are always online!
|
||||
for (let i = 0; i < otherUsersData.length; i++) {
|
||||
if (otherUsersData[i].status == '') {
|
||||
if (otherUsersData[i].status === '') {
|
||||
online++;
|
||||
}
|
||||
}
|
||||
|
@ -497,7 +500,7 @@ const paduserlist = (function () {
|
|||
|
||||
return online;
|
||||
},
|
||||
userLeave(info) {
|
||||
userLeave: (info) => {
|
||||
const existingIndex = findExistingIndex(info.userId);
|
||||
if (existingIndex >= 0) {
|
||||
const userData = otherUsersData[existingIndex];
|
||||
|
@ -510,11 +513,12 @@ const paduserlist = (function () {
|
|||
// joins, or updates happen for this user in the
|
||||
// next N seconds, to remove the user from the list.
|
||||
const thisUserId = info.userId;
|
||||
var thisLeaveTimer = window.setTimeout(() => {
|
||||
const thisLeaveTimer = window.setTimeout(() => {
|
||||
const newExistingIndex = findExistingIndex(thisUserId);
|
||||
if (newExistingIndex >= 0) {
|
||||
const newUserData = otherUsersData[newExistingIndex];
|
||||
if (newUserData.status == 'Disconnected' && newUserData.leaveTimer == thisLeaveTimer) {
|
||||
if (newUserData.status === 'Disconnected' &&
|
||||
newUserData.leaveTimer === thisLeaveTimer) {
|
||||
otherUsersInfo.splice(newExistingIndex, 1);
|
||||
otherUsersData.splice(newExistingIndex, 1);
|
||||
rowManager.removeRow(newExistingIndex);
|
||||
|
@ -529,7 +533,7 @@ const paduserlist = (function () {
|
|||
|
||||
self.updateNumberOfOnlineUsers();
|
||||
},
|
||||
renderMyUserInfo() {
|
||||
renderMyUserInfo: () => {
|
||||
if (myUserInfo.name) {
|
||||
$('#myusernameedit').removeClass('editempty').val(myUserInfo.name);
|
||||
} else {
|
||||
|
@ -549,23 +553,20 @@ const paduserlist = (function () {
|
|||
return self;
|
||||
}());
|
||||
|
||||
function getColorPickerSwatchIndex(jnode) {
|
||||
// return Number(jnode.get(0).className.match(/\bn([0-9]+)\b/)[1])-1;
|
||||
return $('#colorpickerswatches li').index(jnode);
|
||||
}
|
||||
const getColorPickerSwatchIndex = (jnode) => $('#colorpickerswatches li').index(jnode);
|
||||
|
||||
function closeColorPicker(accept) {
|
||||
const closeColorPicker = (accept) => {
|
||||
if (accept) {
|
||||
var newColor = $('#mycolorpickerpreview').css('background-color');
|
||||
let newColor = $('#mycolorpickerpreview').css('background-color');
|
||||
const parts = newColor.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
||||
// parts now should be ["rgb(0, 70, 255", "0", "70", "255"]
|
||||
if (parts) {
|
||||
delete (parts[0]);
|
||||
for (let i = 1; i <= 3; ++i) {
|
||||
parts[i] = parseInt(parts[i]).toString(16);
|
||||
if (parts[i].length == 1) parts[i] = `0${parts[i]}`;
|
||||
if (parts[i].length === 1) parts[i] = `0${parts[i]}`;
|
||||
}
|
||||
var newColor = `#${parts.join('')}`; // "0070ff"
|
||||
newColor = `#${parts.join('')}`; // "0070ff"
|
||||
}
|
||||
myUserInfo.colorId = newColor;
|
||||
pad.notifyChangeColor(newColor);
|
||||
|
@ -577,10 +578,9 @@ function closeColorPicker(accept) {
|
|||
|
||||
colorPickerOpen = false;
|
||||
$('#mycolorpicker').removeClass('popup-show');
|
||||
}
|
||||
};
|
||||
|
||||
function showColorPicker() {
|
||||
previousColorId = myUserInfo.colorId;
|
||||
const showColorPicker = () => {
|
||||
$.farbtastic('#colorpicker').setColor(myUserInfo.colorId);
|
||||
|
||||
if (!colorPickerOpen) {
|
||||
|
@ -613,6 +613,6 @@ function showColorPicker() {
|
|||
$('#colorpickerswatches li').removeClass('picked');
|
||||
$($('#colorpickerswatches li')[myUserInfo.colorId]).addClass('picked'); // seems weird
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.paduserlist = paduserlist;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue