diff --git a/static/application.js b/static/application.js
index 2ea8610..e1c4183 100644
--- a/static/application.js
+++ b/static/application.js
@@ -219,27 +219,36 @@ haste.prototype.lookupTypeByExtension = function(ext) {
// Add line numbers to the document
// For the specified number of lines
-haste.prototype.addLineNumbers = function(lineCount) {
- var h = '';
+haste.prototype.addLineNumbers = function (lineCount) {
+ var container = document.getElementById("linenos");
+ container.innerHTML = "";
for (var i = 0; i < lineCount; i++) {
- h +=
- '' +
- (i + 1) +
- "
";
+ var span = document.createElement("span");
+ span.id = "line-number-" + (i + 1);
+ span.textContent = (i + 1);
+ span.addEventListener("mouseenter",(function (index) {
+ return function () {
+ handleMouseEnter(index);
+ };
+ })(i));
+ span.addEventListener("mouseleave",(function (index) {
+ return function () {
+ handleMouseLeave(index);
+ };
+ })(i));
+ span.addEventListener("mousedown",(function (index) {
+ return function () {
+ handleMouseDown(index);
+ };
+ })(i));
+ span.addEventListener("mouseup",(function (index) {
+ return function () {
+ handleMouseUp(index);
+ };
+ })(i));
+ container.appendChild(span);
+ container.appendChild(document.createElement("br"));
}
- $('#linenos').html(h);
};
// Remove the line numbers
diff --git a/static/index.html b/static/index.html
index c98b3bf..3beeda7 100644
--- a/static/index.html
+++ b/static/index.html
@@ -128,11 +128,26 @@
updateWindowLineHash(lineId);
isDragging = false;
}
+
+ document.addEventListener('DOMContentLoaded', function() {
+ // Handle MouseUp Event for Body
+ document.body.addEventListener("mouseup", function() {
+ handleMouseUp(NaN);
+ });
+ // Handle MouseUp Event for Linenos
+ document.getElementById('linenos').addEventListener("mouseup", function() {
+ handleMouseUp(NaN);
+ });
+ // Handle MouseUp Event for Pre Element
+ document.getElementById('box').addEventListener("mouseup", function() {
+ handleMouseUp(NaN);
+ });
+ });
-