animal emojis in color-by-author 'written by' tooltips

pull/1/head
ansuz 3 years ago
parent dd8f70d6f4
commit bf02ec7359

@ -3,7 +3,8 @@ define([
'/common/sframe-common-codemirror.js',
'/customize/messages.js',
'/bower_components/chainpad/chainpad.dist.js',
], function (Util, SFCodeMirror, Messages, ChainPad) {
'/common/inner/common-mediatag.js',
], function (Util, SFCodeMirror, Messages, ChainPad, MT) {
var Markers = {};
/* TODO Known Issues
@ -38,7 +39,17 @@ define([
});
}
uid = Number(uid);
var name = Util.fixHTML(author.name || Messages.anonymous);
var name = Util.fixHTML((author.name || "").trim());
var animal;
if ((!name || name === Messages.anonymous) && typeof(author.uid) === 'string') {
animal = MT.getPseudorandomAnimal(author.uid);
if (animal) {
name = animal + ' ' + Messages.anonymous;
} else {
name = Messages.anonymous;
}
}
var col = Util.hexToRGB(author.color);
var rgba = 'rgba('+col[0]+','+col[1]+','+col[2]+','+Env.opacity+');';
return Env.editor.markText(from, to, {
@ -520,7 +531,8 @@ define([
Env.authormarks.authors[Env.myAuthorId] = {
name: userData.name,
curvePublic: userData.curvePublic,
color: userData.color
color: userData.color,
uid: userData.uid,
};
if (!old || (old.name === userData.name && old.color === userData.color)) { return; }
return true;

@ -92,7 +92,7 @@ define([
return ANIMALS[Math.floor(Math.random() * ANIMALS.length)];
};
var getPseudorandomAnimal = function (seed) {
var getPseudorandomAnimal = MT.getPseudorandomAnimal = function (seed) {
if (typeof(seed) !== 'string') { return getRandomAnimal(); }
seed = seed.replace(/\D/g, '').slice(0, 10);
seed = parseInt(seed);

Loading…
Cancel
Save