diff --git a/butterfly/__init__.py b/butterfly/__init__.py
index 16f0980..065bc60 100644
--- a/butterfly/__init__.py
+++ b/butterfly/__init__.py
@@ -14,7 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-__version__ = '1.1.1'
+__version__ = '1.1.2'
import os
diff --git a/butterfly/static/coffees/main.coffee b/butterfly/static/coffees/main.coffee
index e941bbb..c3c75ff 100644
--- a/butterfly/static/coffees/main.coffee
+++ b/butterfly/static/coffees/main.coffee
@@ -30,24 +30,30 @@ ctl = (type, args...) ->
ws_url = 'ws://' + document.location.host + '/ws' + location.pathname
ws = new WebSocket ws_url
-term = new Terminal $('#wrapper')[0], send, ctl
-ws.onopen = ->
+ws.addEventListener 'open', ->
console.log "WebSocket open", arguments
ws.send 'R' + term.cols + ',' + term.rows
+ if location.hash
+ setTimeout ->
+ ws.send 'S' + location.hash.slice(1) + '\n'
+ , 100
-ws.onerror = -> console.log "WebSocket error", arguments
-ws.onmessage = (e) ->
+ws.addEventListener 'error', ->
+ console.log "WebSocket error", arguments
+
+ws.addEventListener 'message', (e) ->
setTimeout ->
term.write e.data
, 1
-
-ws.onclose = ->
+ws.addEventListener 'close', ->
console.log "WebSocket closed", arguments
quit = true
open('','_self').close()
+
+term = new Terminal $('#wrapper')[0], send, ctl
addEventListener 'beforeunload', ->
if not quit
'This will exit the terminal session'
diff --git a/butterfly/static/coffees/virtual_input.coffee b/butterfly/static/coffees/virtual_input.coffee
index 9d0bd62..0f8a4ab 100644
--- a/butterfly/static/coffees/virtual_input.coffee
+++ b/butterfly/static/coffees/virtual_input.coffee
@@ -15,14 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-try
- document.createEvent("TouchEvent")
- virtual_input = true
-catch e
- virtual_input = false
-
-if virtual_input
+if /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test navigator.userAgent
ctrl = false
alt = false
first = true
diff --git a/butterfly/static/javascripts/main.js b/butterfly/static/javascripts/main.js
index e10dfe7..0130c11 100644
--- a/butterfly/static/javascripts/main.js
+++ b/butterfly/static/javascripts/main.js
@@ -1,5 +1,5 @@
// Generated by CoffeeScript 1.6.3
-var $, State, Terminal, alt, bench, cancel, cbench, cols, ctl, ctrl, e, first, quit, rows, s, send, state, term, virtual_input, ws, ws_url,
+var $, State, Terminal, alt, bench, cancel, cbench, cols, ctl, ctrl, first, quit, rows, s, send, state, term, virtual_input, ws, ws_url,
__slice = [].slice;
cancel = function(ev) {
@@ -2450,15 +2450,7 @@ document.addEventListener('keydown', function(e) {
}
});
-try {
- document.createEvent("TouchEvent");
- virtual_input = true;
-} catch (_error) {
- e = _error;
- virtual_input = false;
-}
-
-if (virtual_input) {
+if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
ctrl = false;
alt = false;
first = true;
@@ -2548,28 +2540,33 @@ ws_url = 'ws://' + document.location.host + '/ws' + location.pathname;
ws = new WebSocket(ws_url);
-term = new Terminal($('#wrapper')[0], send, ctl);
-
-ws.onopen = function() {
+ws.addEventListener('open', function() {
console.log("WebSocket open", arguments);
- return ws.send('R' + term.cols + ',' + term.rows);
-};
+ ws.send('R' + term.cols + ',' + term.rows);
+ if (location.hash) {
+ return setTimeout(function() {
+ return ws.send('S' + location.hash.slice(1) + '\n');
+ }, 100);
+ }
+});
-ws.onerror = function() {
+ws.addEventListener('error', function() {
return console.log("WebSocket error", arguments);
-};
+});
-ws.onmessage = function(e) {
+ws.addEventListener('message', function(e) {
return setTimeout(function() {
return term.write(e.data);
}, 1);
-};
+});
-ws.onclose = function() {
+ws.addEventListener('close', function() {
console.log("WebSocket closed", arguments);
quit = true;
return open('', '_self').close();
-};
+});
+
+term = new Terminal($('#wrapper')[0], send, ctl);
addEventListener('beforeunload', function() {
if (!quit) {
diff --git a/butterfly/templates/index.html b/butterfly/templates/index.html
index 2982aac..15063a8 100644
--- a/butterfly/templates/index.html
+++ b/butterfly/templates/index.html
@@ -12,7 +12,7 @@
-
+
diff --git a/dev.py b/dev.py
index ccb06f8..c47f43a 100755
--- a/dev.py
+++ b/dev.py
@@ -12,6 +12,8 @@ commands = [
'butterfly/static/coffees/backsel.coffee ' +
'butterfly/static/coffees/virtual_input.coffee ' +
'butterfly/static/coffees/main.coffee ',
+ 'coffee -wcb -o butterfly/static/javascripts/ ' +
+ 'butterfly/static/coffees/worker.coffee',
'compass watch butterfly/static',
'python butterfly.server.py ' + ' '.join(sys.argv[1:])
]