mirror of
https://github.com/seejohnrun/haste-server
synced 2025-08-21 06:23:11 -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
|
@ -220,26 +220,35 @@ 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
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue