mirror of
https://github.com/seejohnrun/haste-server
synced 2025-08-20 21:34:20 -07:00
removed inline functions and unknown function
This commit is contained in:
parent
e58dfc8074
commit
d88afda8f2
2 changed files with 46 additions and 22 deletions
|
@ -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 +=
|
||||
'<span onclick="handleLineClick(' +
|
||||
i.toString() +
|
||||
')" onmouseenter="handleMouseEnter(' +
|
||||
i.toString() +
|
||||
')" onmouseleave="handleMouseLeave(' +
|
||||
i.toString() +
|
||||
')" onmousedown="handleMouseDown(' +
|
||||
i.toString() +
|
||||
')" onmouseup="handleMouseUp(' +
|
||||
i.toString() +
|
||||
')" id="line-number-' +
|
||||
(i + 1) +
|
||||
'">' +
|
||||
(i + 1) +
|
||||
"</span><br/>";
|
||||
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
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onmouseup="handleMouseUp(NaN)">
|
||||
<body>
|
||||
<ul id="messages"></ul>
|
||||
|
||||
<div id="key">
|
||||
|
@ -153,8 +168,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="linenos" onmouseup="handleMouseUp(NaN)"></div>
|
||||
<pre id="box" onmouseup="handleMouseUp(NaN)" style="display:none;" class="hljs" tabindex="0"><code></code></pre>
|
||||
<div id="linenos"></div>
|
||||
<pre id="box" style="display:none;" class="hljs" tabindex="0"><code></code></pre>
|
||||
<textarea spellcheck="false" style="display:none;"></textarea>
|
||||
|
||||
</body>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue