From 3e18d13c523b9c537eb53f9b926ce9f2ff201fd9 Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Thu, 5 Feb 2015 17:40:53 +0100 Subject: Examples --- templates/home.hamlet | 7 ++++++- templates/home.julius | 19 +++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'templates') diff --git a/templates/home.hamlet b/templates/home.hamlet index 9b429b5..6eb2991 100644 --- a/templates/home.hamlet +++ b/templates/home.hamlet @@ -1,7 +1,12 @@
Some examples: #
+ Hello, #
+ Unary substraction (5-2)
diff --git a/templates/home.julius b/templates/home.julius
index e679e40..b8c4231 100644
--- a/templates/home.julius
+++ b/templates/home.julius
@@ -5,7 +5,9 @@ $(function() {
bTogglePlay : $("##{rawJS butTogglePlay}"),
bForward : $("##{rawJS butForward}"),
prTape : $("##{rawJS prTape}"),
- prTrans : $("##{rawJS prTrans}")
+ prTrans : $("##{rawJS prTrans}"),
+ eHello : $("##{rawJS eHello}"),
+ eSub : $("##{rawJS eSub}"),
};
var pollInterval = 10000;
var playing = false;
@@ -32,6 +34,7 @@ $(function() {
};
function togglePlay() {
var btns = [ui.bBeginning, ui.bBackward, ui.bForward];
+ ui.bTogglePlay.children().toggleClass("glyphicon-play glyphicon-stop");
playing = !playing;
if (playing === true) {
disableButtons(btns);
@@ -47,13 +50,18 @@ $(function() {
sock.send("Backward");
});
ui.bTogglePlay.on("click", function () {
- ui.bTogglePlay.children().toggleClass("glyphicon-play glyphicon-stop");
togglePlay();
});
ui.bForward.on("click", function () {
sock.send("Forward");
});
sock = new WebSocket("wss://" + window.location.host);
+ ui.eHello.on("click", function () {
+ sock.send("MHello");
+ });
+ ui.eSub.on("click", function () {
+ sock.send("MSub");
+ });
sock.onopen = function (e) {
enableButtons([ui.bBeginning, ui.bBackward,
ui.bTogglePlay, ui.bForward]);
@@ -62,7 +70,8 @@ $(function() {
sock.onclose = function (e) {
disableButtons([ui.bBeginning, ui.bBackward,
ui.bTogglePlay, ui.bForward]);
- alert("SOCKET CLOSED! D: (" + e.code + ")");
+ alert("WEBSOCKET CLOSED. At this point, reloading the page " +
+ "is probably the wise thing to do.");
};
sock.onmessage = function (e) {
var data = JSON.parse(e.data);
@@ -70,9 +79,11 @@ $(function() {
ui.prTape.html(data["value"]);
} else if (data["type"] === "trans") {
ui.prTrans.html(data["value"]);
+ } else if (data["type"] === "stop") {
+ togglePlay();
}
};
sock.onerror = function (e) {
- alert("ERROR! D: (" + e + ")");
+ console.debug("ERROR: " + e.data);
};
});
--
cgit v1.2.3