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

ep_cursortrace

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ep_cursortrace - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

2

package.json
{
"name": "ep_cursortrace",
"description": "Show cursor/caret movements of other users in real time",
"version": "2.0.2",
"version": "2.0.3",
"author": "RedHog (Egil Moeller) <egil.moller@freecode.no>",

@@ -6,0 +6,0 @@ "contributors": [{

@@ -120,2 +120,3 @@ var initiated = false;

// Measure the new width -- This gives us the offset without modifying the ACE Dom
// Due to IE sucking this doesn't work in IE....

@@ -174,3 +175,3 @@ // Get the HTML

// Remove the element
$('iframe[name="ace_outer"]').contents().find('#outerdocbody').contents().remove("#" + authorWorker);
// $('iframe[name="ace_outer"]').contents().find('#outerdocbody').contents().remove("#" + authorWorker);

@@ -231,63 +232,68 @@ // Author color

function html_substr( str, count ) {
if( $.browser.msie ) return ""; // IE can't handle processing any of the X position stuff so just return a blank string
// Basically the recursion makes IE run out of memory and slows a pad right down, I guess a way to fix this would be to
// only wrap the target / last span or something or stop it destroying and recreating on each change..
// Also IE can often inherit the wrong font face IE bold but not apply that to the whole document ergo getting teh width wrong
var div = document.createElement('div');
div.innerHTML = str;
var div = document.createElement('div');
div.innerHTML = str;
walk( div, track );
walk( div, track );
function track( el ) {
if( count > 0 ) {
var len = el.data.length;
count -= len;
if( count <= 0 ) {
el.data = el.substringData( 0, el.data.length + count );
}
} else {
el.data = '';
}
function track( el ) {
if( count > 0 ) {
var len = el.data.length;
count -= len;
if( count <= 0 ) {
el.data = el.substringData( 0, el.data.length + count );
}
} else {
el.data = '';
}
}
function walk( el, fn ) {
var node = el.firstChild;
do {
if( node.nodeType === 3 ) {
fn(node);
// Added this >>------------------------------------<<
} else if( node.nodeType === 1 && node.childNodes && node.childNodes[0] ) {
walk( node, fn );
}
} while( node = node.nextSibling );
}
return div.innerHTML;
function walk( el, fn ) {
var node = el.firstChild;
if(!node) return;
do {
if( node.nodeType === 3 ) {
fn(node);
// Added this >>------------------------------------<<
} else if( node.nodeType === 1 && node.childNodes && node.childNodes[0] ) {
walk( node, fn );
}
} while( node = node.nextSibling );
}
return div.innerHTML;
}
function wrap(target, key) { // key can probably be removed here..
var newtarget = $("<div></div>");
nodes = target.contents().clone(); // the clone is critical!
if(key === true){ // We can probably remove all of thise..
var key = 0; // Key allows us to increemnt an index inside recursion
}
nodes.each(function() {
if (this.nodeType == 3) { // text
var newhtml = "";
var text = this.wholeText; // maybe "textContent" is better?
for (var i=0; i < text.length; i++) {
if (text[i] == ' '){
newhtml += "<span data-key="+globalKey+"> </span>";
}
else
{
newhtml += "<span data-key="+globalKey+">" + text[i] + "</span>";
}
key++;
globalKey++;
}
newtarget.append($(newhtml));
var newtarget = $("<div></div>");
nodes = target.contents().clone(); // the clone is critical!
if(key === true){ // We can probably remove all of thise..
var key = 0; // Key allows us to increemnt an index inside recursion
}
nodes.each(function() {
if (this.nodeType == 3) { // text
var newhtml = "";
var text = this.wholeText; // maybe "textContent" is better?
for (var i=0; i < text.length; i++) {
if (text[i] == ' '){
newhtml += "<span data-key="+globalKey+"> </span>";
}
else { // recursion FTW!
$(this).html(wrap($(this), key)); // This really hurts doing any sort of count..
newtarget.append($(this));
else
{
newhtml += "<span data-key="+globalKey+">" + text[i] + "</span>";
}
});
return newtarget.html();
key++;
globalKey++;
}
newtarget.append($(newhtml));
}
else { // recursion FTW!
console.log("recursion"); // IE handles recursion badly
$(this).html(wrap($(this), key)); // This really hurts doing any sort of count..
newtarget.append($(this));
}
});
return newtarget.html();
}
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