Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ep_author_hover

Package Overview
Dependencies
Maintainers
6
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ep_author_hover - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

.github/workflows/npmpublish.yml

12

index.js

@@ -1,13 +0,13 @@

var eejs = require('ep_etherpad-lite/node/eejs/');
var settings = require('ep_etherpad-lite/node/utils/Settings');
const eejs = require('ep_etherpad-lite/node/eejs/');
const settings = require('ep_etherpad-lite/node/utils/Settings');
exports.eejsBlock_mySettings = function (hook_name, args, cb) {
checked_state = 'checked';
if (settings.ep_author_hover){
if (settings.ep_author_hover.disabledByDefault == true){
if (settings.ep_author_hover) {
if (settings.ep_author_hover.disabledByDefault == true) {
checked_state = '';
}
}
args.content = args.content + eejs.require('ep_author_hover/templates/settings.ejs', {checked : checked_state});
args.content += eejs.require('ep_author_hover/templates/settings.ejs', {checked: checked_state});
return cb();
}
};

@@ -9,3 +9,3 @@ {

"description": "Adds author names to span titles (shows on hover), works as authors change their name. Hover includes author color and fast switching between author spans. Hat tip to Martyn York for the initial work on this.",
"version": "0.3.2",
"version": "0.3.3",
"repository": {

@@ -18,3 +18,22 @@ "type": "git",

"url": "http://etherpad.org/"
},
"devDependencies": {
"eslint": "^7.14.0",
"eslint-config-etherpad": "^1.0.8",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prefer-arrow": "^1.2.2",
"eslint-plugin-promise": "^4.2.1"
},
"eslintConfig": {
"root": true,
"extends": "etherpad/plugin"
},
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint --fix ."
},
"engines": {
"lint": "eslint ."
}
}

@@ -6,15 +6,15 @@ var _ = require('ep_etherpad-lite/static/js/underscore');

exports.postAceInit = function(hook_name, context){
exports.postAceInit = function (hook_name, context) {
showAuthor.enable(context);
clientVars.plugins.plugins.ep_author_hover = {};
/* init */
if (padcookie.getPref("author-hover") === false) {
if (padcookie.getPref('author-hover') === false) {
$('#options-author-hover').val();
$('#options-author-hover').attr('checked','unchecked');
$('#options-author-hover').attr('checked',false);
}else{
$('#options-author-hover').attr('checked','checked');
$('#options-author-hover').attr('checked', 'unchecked');
$('#options-author-hover').attr('checked', false);
} else {
$('#options-author-hover').attr('checked', 'checked');
}
if($('#options-author-hover').is(':checked')) {
if ($('#options-author-hover').is(':checked')) {
clientVars.plugins.plugins.ep_author_hover.enabled = true;

@@ -26,57 +26,53 @@ } else {

/* on click */
$('#options-author-hover').on('click', function() {
if($('#options-author-hover').is(':checked')) {
$('#options-author-hover').on('click', () => {
if ($('#options-author-hover').is(':checked')) {
clientVars.plugins.plugins.ep_author_hover.enabled = true;
padcookie.setPref("author-hover", true)
padcookie.setPref('author-hover', true);
} else {
padcookie.setPref("author-hover", false)
padcookie.setPref('author-hover', false);
clientVars.plugins.plugins.ep_author_hover.enabled = false;
}
});
};
}
var showAuthor = {
enable: function(context){
context.ace.callWithAce(function(ace){
var doc = ace.ace_getDocument();
enable(context) {
context.ace.callWithAce((ace) => {
const doc = ace.ace_getDocument();
$(doc).find('#innerdocbody').mousemove(_(exports.showAuthor.hover).bind(ace));
}, 'showAuthor', true);
},
disable: function(context){
context.ace.callWithAce(function(ace){
var doc = ace.ace_getDocument();
disable(context) {
context.ace.callWithAce((ace) => {
const doc = ace.ace_getDocument();
$(doc).find('#innerdocbody').mousemove(_().bind(ace));
}, 'showAuthor', true);
},
hover: function(span){
if(timer) { // wait a second before showing!
hover(span) {
if (timer) { // wait a second before showing!
clearTimeout(timer);
timer = null;
}
timer = setTimeout(function(){
timer = setTimeout(() => {
showAuthor.show(span);
}, 1000);
},
show: function(span){
if(clientVars.plugins.plugins.ep_author_hover.enabled){
var authorTarget = $(span.target).closest('span')[0];
if (!authorTarget){ return; } // We might not be over a valid target
var authorId = showAuthor.authorIdFromClass(authorTarget.className); // Get the authorId
if(!authorId){ return; } // Default text isn't shown
show(span) {
if (clientVars.plugins.plugins.ep_author_hover.enabled) {
const authorTarget = $(span.target).closest('span')[0];
if (!authorTarget) { return; } // We might not be over a valid target
const authorId = showAuthor.authorIdFromClass(authorTarget.className); // Get the authorId
if (!authorId) { return; } // Default text isn't shown
showAuthor.destroy(); // Destroy existing
var authorNameAndColor = showAuthor.authorNameAndColorFromAuthorId(authorId); // Get the authorName And Color
const authorNameAndColor = showAuthor.authorNameAndColorFromAuthorId(authorId); // Get the authorName And Color
showAuthor.draw(span, authorNameAndColor.name, authorNameAndColor.color);
}
},
authorIdFromClass: function(className){
if (className.substring(0, 7) == "author-") {
className = className.substring(0,49);
return className.substring(7).replace(/[a-y0-9]+|-|z.+?z/g, function(cc) {
if (cc == '-') { return '.'; }
else if (cc.charAt(0) == 'z') {
authorIdFromClass(className) {
if (className.substring(0, 7) == 'author-') {
className = className.substring(0, 49);
return className.substring(7).replace(/[a-y0-9]+|-|z.+?z/g, (cc) => {
if (cc == '-') { return '.'; } else if (cc.charAt(0) == 'z') {
return String.fromCharCode(Number(cc.slice(1, -1)));
}
else {
} else {
return cc;

@@ -87,13 +83,13 @@ }

},
authorNameAndColorFromAuthorId: function(authorId){
var fullAuthorId = authorId; // historical data uses full author id without substing
authorNameAndColorFromAuthorId(authorId) {
const fullAuthorId = authorId; // historical data uses full author id without substing
// todo figure out why we need a substring to fix this
authorId = authorId.substring(0,14); // don't ask.... something appears to be fucked in regex
authorId = authorId.substring(0, 14); // don't ask.... something appears to be fucked in regex
// It could always be me..
var myAuthorId = pad.myUserInfo.userId.substring(0,14);
if(myAuthorId == authorId){
const myAuthorId = pad.myUserInfo.userId.substring(0, 14);
if (myAuthorId == authorId) {
return {
name: window._('ep_author_hover.me'),
color: "#fff"
}
color: '#fff',
};
}

@@ -103,10 +99,10 @@

var authorObj = {};
$('#otheruserstable > tbody > tr').each(function(){
if (authorId == $(this).data("authorid").substring(0,14)){
$(this).find('.usertdname').each( function() {
$('#otheruserstable > tbody > tr').each(function () {
if (authorId == $(this).data('authorid').substring(0, 14)) {
$(this).find('.usertdname').each(function () {
authorObj.name = $(this).text();
if(authorObj.name == "") authorObj.name = window._('ep_author_hover.unknow_author');
if (authorObj.name == '') authorObj.name = window._('ep_author_hover.unknow_author');
});
$(this).find('.usertdswatch > div').each( function() {
authorObj.color = $(this).css("background-color");
$(this).find('.usertdswatch > div').each(function () {
authorObj.color = $(this).css('background-color');
});

@@ -118,38 +114,38 @@ return authorObj;

// Else go historical
if(!authorObj || !authorObj.name){
if (!authorObj || !authorObj.name) {
var authorObj = clientVars.collab_client_vars.historicalAuthorData[fullAuthorId]; // Try to use historical data
}
return authorObj || {name: window._('ep_author_hover.unknow_author'), color: "#fff"};
return authorObj || {name: window._('ep_author_hover.unknow_author'), color: '#fff'};
},
draw: function(target, authorName, authorColor){
if(!authorName){
console.warn("No authorName, I have no idea why! Help me debug this by providing steps to replicate!");
draw(target, authorName, authorColor) {
if (!authorName) {
console.warn('No authorName, I have no idea why! Help me debug this by providing steps to replicate!');
return;
}
var span = target.target;
var fontSize = $(span).parent().css('font-size');
var top = span.offsetTop -14;
if(top < 0) top = $(span).height() +14;
var left = target.clientX +15;
$(span).removeAttr("title");
const span = target.target;
const fontSize = $(span).parent().css('font-size');
let top = span.offsetTop - 14;
if (top < 0) top = $(span).height() + 14;
let left = target.clientX + 15;
$(span).removeAttr('title');
// TODO use qtip, it will handle edge cases better
var outBody = $('iframe[name="ace_outer"]').contents().find("body");
var inFrame = $(outBody).find('iframe[name="ace_inner"]');
var inFramePos = inFrame.position();
const outBody = $('iframe[name="ace_outer"]').contents().find('body');
const inFrame = $(outBody).find('iframe[name="ace_inner"]');
const inFramePos = inFrame.position();
left += inFramePos.left;
top += inFramePos.top;
var $indicator = $("<div>").attr({
const $indicator = $('<div>').attr({
class: 'authortooltip',
title: authorName,
}).css({
"opacity": ".8",
"font-size": "14px",
"padding": "5px 5px 0px 5px",
"position": "absolute",
"left": left + "px",
"top": top + "px",
"background-color": authorColor,
'opacity': '.8',
'font-size': '14px',
'padding': '5px 5px 0px 5px',
'position': 'absolute',
'left': `${left}px`,
'top': `${top}px`,
'background-color': authorColor,
}).text(authorName);

@@ -160,4 +156,4 @@

// After a while, fade out
setTimeout(function(){
$indicator.fadeOut(500, function(){
setTimeout(() => {
$indicator.fadeOut(500, () => {
$indicator.remove();

@@ -167,7 +163,7 @@ });

},
destroy: function(){
$('iframe[name="ace_outer"]').contents().find(".authortooltip").remove();
}
}
destroy() {
$('iframe[name="ace_outer"]').contents().find('.authortooltip').remove();
},
};
exports.showAuthor = showAuthor;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc