Remove use of jquery and fix some bugs.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3200 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
577606a0f9
commit
d82fc5cc85
@ -34,13 +34,14 @@ function enter(event) {
|
|||||||
&& !event.altKey
|
&& !event.altKey
|
||||||
&& !event.ctrlKey
|
&& !event.ctrlKey
|
||||||
&& !event.shiftKey) {
|
&& !event.shiftKey) {
|
||||||
var value = $("#input").val();
|
var input = document.getElementById("input");
|
||||||
|
var value = input.value;
|
||||||
if (value && value[value.length - 1] == '\\') {
|
if (value && value[value.length - 1] == '\\') {
|
||||||
$("#input").val(value.substring(0, value.length - 1) + ";");
|
input.value = value.substring(0, value.length - 1) + ";";
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else {
|
} else {
|
||||||
storeTarget(value);
|
storeTarget(value);
|
||||||
$("#input").val("");
|
input.value = "";
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +67,7 @@ function hash() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function storeTarget(target) {
|
function storeTarget(target) {
|
||||||
$("#target").text(target || "");
|
document.getElementById("target").innerText = target || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function split(container, children) {
|
function split(container, children) {
|
||||||
@ -238,7 +239,7 @@ function printStructured(container, data) {
|
|||||||
|
|
||||||
function commandClick() {
|
function commandClick() {
|
||||||
send(this.dataset.command);
|
send(this.dataset.command);
|
||||||
$("#input").focus();
|
document.getElementById("input").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function autoScroll(terminal) {
|
function autoScroll(terminal) {
|
||||||
@ -257,10 +258,10 @@ function setErrorMessage(message) {
|
|||||||
function send(command) {
|
function send(command) {
|
||||||
var value = command;
|
var value = command;
|
||||||
if (!command) {
|
if (!command) {
|
||||||
var target = $("#target").text();
|
var target = document.getElementById("target").innerText;
|
||||||
var prefix = target ? target + " " : "";
|
var prefix = target ? target + " " : "";
|
||||||
value = prefix + $("#input").val();
|
value = prefix + document.getElementById("input").value;
|
||||||
$("#input").val("");
|
document.getElementById("input").value = "";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
gSocket.send(JSON.stringify({action: "command", command: value}));
|
gSocket.send(JSON.stringify({action: "command", command: value}));
|
||||||
@ -305,15 +306,16 @@ var gOriginalInput;
|
|||||||
function dragHover(event) {
|
function dragHover(event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
var input = document.getElementById("input");
|
||||||
if (event.type == "dragover") {
|
if (event.type == "dragover") {
|
||||||
if (!$("#input").hasClass("drop")) {
|
if (!input.classList.contains("drop")) {
|
||||||
$("#input").addClass("drop");
|
input.classList.add("drop");
|
||||||
gOriginalInput = $("#input").val();
|
gOriginalInput = input.value;
|
||||||
$("#input").val("drop file to upload");
|
input.value = "drop file to upload";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$("#input").removeClass("drop");
|
input.classList.remove("drop");
|
||||||
$("#input").val(gOriginalInput);
|
input.value = gOriginalInput;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,12 +413,13 @@ function onMessage(event) {
|
|||||||
|
|
||||||
var gSocket;
|
var gSocket;
|
||||||
|
|
||||||
$(document).ready(function() {
|
window.addEventListener("load", function() {
|
||||||
if (Notification) {
|
if (Notification) {
|
||||||
Notification.requestPermission();
|
Notification.requestPermission();
|
||||||
}
|
}
|
||||||
$("#input").keydown(enter);
|
var input = document.getElementById("input");
|
||||||
$("#input").focus();
|
input.addEventListener("keydown", enter);
|
||||||
|
input.focus();
|
||||||
window.addEventListener("hashchange", hashChange);
|
window.addEventListener("hashchange", hashChange);
|
||||||
window.addEventListener("focus", focus);
|
window.addEventListener("focus", focus);
|
||||||
window.addEventListener("blur", blur);
|
window.addEventListener("blur", blur);
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
<button onclick="addLicense()"><img src="/terminal/agplv3-88x31.png" width="34" height="12"> Add License Header</button>
|
<button onclick="addLicense()"><img src="/terminal/agplv3-88x31.png" width="34" height="12"> Add License Header</button>
|
||||||
</div>
|
</div>
|
||||||
<textarea id="editor" class="main">$(SOURCE)</textarea>
|
<textarea id="editor" class="main">$(SOURCE)</textarea>
|
||||||
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
|
|
||||||
<script src="/terminal/editor.js"></script>
|
<script src="/terminal/editor.js"></script>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
var gBackup;
|
var gBackup;
|
||||||
var gEditor;
|
var gEditor;
|
||||||
|
|
||||||
$(document).ready(function() {
|
window.addEventListener("load", function() {
|
||||||
gEditor = CodeMirror.fromTextArea(document.getElementById("editor"), {
|
gEditor = CodeMirror.fromTextArea(document.getElementById("editor"), {
|
||||||
'theme': 'base16-dark',
|
'theme': 'base16-dark',
|
||||||
'lineNumbers': true,
|
'lineNumbers': true,
|
||||||
@ -40,22 +40,39 @@ function save(newName) {
|
|||||||
var contents = gEditor.getValue();
|
var contents = gEditor.getValue();
|
||||||
var run = document.getElementById("run").checked;
|
var run = document.getElementById("run").checked;
|
||||||
|
|
||||||
return $.ajax({
|
var request = new XMLHttpRequest();
|
||||||
type: "POST",
|
|
||||||
url: newName ? "../" + newName + "/save" : "save",
|
var always = function() {
|
||||||
data: contents,
|
|
||||||
dataType: "text",
|
|
||||||
}).done(function(uri) {
|
|
||||||
gBackup = contents;
|
|
||||||
if (run) {
|
|
||||||
back(uri);
|
|
||||||
}
|
|
||||||
}).fail(function(xhr, status, error) {
|
|
||||||
alert("Unable to save: " + xhr.responseText);
|
|
||||||
}).always(function() {
|
|
||||||
document.getElementById("save").disabled = false;
|
document.getElementById("save").disabled = false;
|
||||||
document.getElementById("saveAs").disabled = false;
|
document.getElementById("saveAs").disabled = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
request.addEventListener("error", function() {
|
||||||
|
alert("Error saving: " + request.responseText);
|
||||||
|
always();
|
||||||
});
|
});
|
||||||
|
request.addEventListener("loadend", function() {
|
||||||
|
if (request.status == 200) {
|
||||||
|
gBackup = contents;
|
||||||
|
if (run) {
|
||||||
|
back(request.responseText);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert("Unable to save: " + request.responseText);
|
||||||
|
}
|
||||||
|
always();
|
||||||
|
});
|
||||||
|
request.addEventListener("timeout", function() {
|
||||||
|
alert("Timed out saving: " + request.responseText);
|
||||||
|
always();
|
||||||
|
});
|
||||||
|
request.addEventListener("abort", function() {
|
||||||
|
alert("Save aborted: " + request.responseText);
|
||||||
|
always();
|
||||||
|
});
|
||||||
|
request.open("POST", newName ? "../" + newName + "/save" : "save", true);
|
||||||
|
request.setRequestHeader("Content-Type", "text/plain");
|
||||||
|
request.send(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveAs() {
|
function saveAs() {
|
||||||
|
@ -361,7 +361,9 @@ function handleConnection(client) {
|
|||||||
lineByLine = false;
|
lineByLine = false;
|
||||||
body = "";
|
body = "";
|
||||||
return true;
|
return true;
|
||||||
} else if (headers["connection"].toLowerCase().split(",").map(x => x.trim()).indexOf("upgrade") != -1
|
} else if (headers["connection"]
|
||||||
|
&& headers["connection"].toLowerCase().split(",").map(x => x.trim()).indexOf("upgrade") != -1
|
||||||
|
&& headers["upgrade"]
|
||||||
&& headers["upgrade"].toLowerCase() == "websocket") {
|
&& headers["upgrade"].toLowerCase() == "websocket") {
|
||||||
var requestObject = new Request(request[0], request[1], request[2], headers, body, client);
|
var requestObject = new Request(request[0], request[1], request[2], headers, body, client);
|
||||||
var response = new Response(requestObject, client);
|
var response = new Response(requestObject, client);
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
<span id="prompt">></span>
|
<span id="prompt">></span>
|
||||||
<input type='text' id='input'></input>
|
<input type='text' id='input'></input>
|
||||||
</div>
|
</div>
|
||||||
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
|
|
||||||
<script src="/terminal/client.js"></script>
|
<script src="/terminal/client.js"></script>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
@ -7,6 +7,8 @@ let kDocumentation = {
|
|||||||
"core.getUser": ["", "Gets information about the current user."],
|
"core.getUser": ["", "Gets information about the current user."],
|
||||||
"core.getUsers": ["packageOwner, packageName", "Get a list of all online users, restricted to a package if specified."],
|
"core.getUsers": ["packageOwner, packageName", "Get a list of all online users, restricted to a package if specified."],
|
||||||
"core.register": ["eventName, handlerFunction", "Register a callback function for the given event."],
|
"core.register": ["eventName, handlerFunction", "Register a callback function for the given event."],
|
||||||
|
"core.unregister": ["eventName, handlerFunction", "Unregister a callback function for the given event."],
|
||||||
|
"core.user.postMessage": ["message", "Send a message to the process for the given user session."],
|
||||||
"database.get": ["key", "Retrieve the database value associated with the given key."],
|
"database.get": ["key", "Retrieve the database value associated with the given key."],
|
||||||
"database.set": ["key, value", "Sets the database value for the given key, overwriting any existing value."],
|
"database.set": ["key, value", "Sets the database value for the given key, overwriting any existing value."],
|
||||||
"database.getAll": ["", "Retrieve a list of all key names."],
|
"database.getAll": ["", "Retrieve a list of all key names."],
|
||||||
@ -25,6 +27,10 @@ let kDocumentation = {
|
|||||||
"terminal.setHash": ["hash", "Sets the URL #hash, typically so that the user can copy / bookmark it and return to a similar state."],
|
"terminal.setHash": ["hash", "Sets the URL #hash, typically so that the user can copy / bookmark it and return to a similar state."],
|
||||||
"terminal.postMessageToIframe": ["name, message", "Sends the message to the iframe that was created with the given name using window.postMessage."],
|
"terminal.postMessageToIframe": ["name, message", "Sends the message to the iframe that was created with the given name using window.postMessage."],
|
||||||
"terminal.notify": ["body, {title, icon}", ["Produces an ", {href: "https://developer.mozilla.org/en-US/docs/Web/API/notification", value: "HTML5 Notification"}, ". Arguments are the same as the Notification constructor."]],
|
"terminal.notify": ["body, {title, icon}", ["Produces an ", {href: "https://developer.mozilla.org/en-US/docs/Web/API/notification", value: "HTML5 Notification"}, ". Arguments are the same as the Notification constructor."]],
|
||||||
|
"terminal.cork": ["", "Stop sending updates to the terminal until uncork() is called. Can be used to prevent flickering when clearing and redrawing."],
|
||||||
|
"terminal.uncork": ["", "Resume sending updates to the terminal."],
|
||||||
|
"terminal.split": ["terminalList", "Reconfigures the terminal layout (often into multiple split panes)."],
|
||||||
|
"terminal.select": ["name", "Directs subsequent output to the named terminal."],
|
||||||
};
|
};
|
||||||
|
|
||||||
terminal.print("V8 Version ", version);
|
terminal.print("V8 Version ", version);
|
||||||
|
@ -123,7 +123,6 @@ function editPage(event) {
|
|||||||
</html>`, name: "iframe", style: "flex: 1 1 auto; border: 0; width: 100%"});
|
</html>`, name: "iframe", style: "flex: 1 1 auto; border: 0; width: 100%"});
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: Why do I need .js?
|
|
||||||
require("ui").fileList({
|
require("ui").fileList({
|
||||||
title: "Live Markdeep Editor",
|
title: "Live Markdeep Editor",
|
||||||
edit: editPage,
|
edit: editPage,
|
||||||
|
@ -783,7 +783,7 @@ function schedulePing(socket) {
|
|||||||
terminal.split([
|
terminal.split([
|
||||||
{type: "horizontal", children: [
|
{type: "horizontal", children: [
|
||||||
{name: "terminal", grow: 1},
|
{name: "terminal", grow: 1},
|
||||||
{name: "users", grow: 0},
|
{name: "users", basis: "2in", grow: 0, shrink: 0},
|
||||||
]},
|
]},
|
||||||
]);
|
]);
|
||||||
terminal.select("terminal");
|
terminal.select("terminal");
|
||||||
|
Loading…
Reference in New Issue
Block a user