removed inline functions and unknown function

This commit is contained in:
Colin 2024-08-02 17:17:51 -07:00
commit d88afda8f2
2 changed files with 46 additions and 22 deletions

View file

@ -219,27 +219,36 @@ haste.prototype.lookupTypeByExtension = function(ext) {
// Add line numbers to the document // Add line numbers to the document
// For the specified number of lines // For the specified number of lines
haste.prototype.addLineNumbers = function(lineCount) { haste.prototype.addLineNumbers = function (lineCount) {
var h = ''; var container = document.getElementById("linenos");
container.innerHTML = "";
for (var i = 0; i < lineCount; i++) { for (var i = 0; i < lineCount; i++) {
h += var span = document.createElement("span");
'<span onclick="handleLineClick(' + span.id = "line-number-" + (i + 1);
i.toString() + span.textContent = (i + 1);
')" onmouseenter="handleMouseEnter(' + span.addEventListener("mouseenter",(function (index) {
i.toString() + return function () {
')" onmouseleave="handleMouseLeave(' + handleMouseEnter(index);
i.toString() + };
')" onmousedown="handleMouseDown(' + })(i));
i.toString() + span.addEventListener("mouseleave",(function (index) {
')" onmouseup="handleMouseUp(' + return function () {
i.toString() + handleMouseLeave(index);
')" id="line-number-' + };
(i + 1) + })(i));
'">' + span.addEventListener("mousedown",(function (index) {
(i + 1) + return function () {
"</span><br/>"; 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 // Remove the line numbers

View file

@ -128,11 +128,26 @@
updateWindowLineHash(lineId); updateWindowLineHash(lineId);
isDragging = false; 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);
});
});
</script> </script>
</head> </head>
<body onmouseup="handleMouseUp(NaN)"> <body>
<ul id="messages"></ul> <ul id="messages"></ul>
<div id="key"> <div id="key">
@ -153,8 +168,8 @@
</div> </div>
</div> </div>
<div id="linenos" onmouseup="handleMouseUp(NaN)"></div> <div id="linenos"></div>
<pre id="box" onmouseup="handleMouseUp(NaN)" style="display:none;" class="hljs" tabindex="0"><code></code></pre> <pre id="box" style="display:none;" class="hljs" tabindex="0"><code></code></pre>
<textarea spellcheck="false" style="display:none;"></textarea> <textarea spellcheck="false" style="display:none;"></textarea>
</body> </body>