mirror of
https://github.com/paradoxxxzero/butterfly.git
synced 2026-05-26 07:08:08 +00:00
Run location.hash at start + fix weird browser with TouchEvent + remove spellcheck in ff
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
__version__ = '1.1.1'
|
||||
__version__ = '1.1.2'
|
||||
|
||||
|
||||
import os
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -15,14 +15,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<link href="{{ static_url('stylesheets/main.css') }}" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body spellcheck="false">
|
||||
<main id="wrapper"> </main>
|
||||
<script src="{{ static_url('javascripts/main.js') }}"></script>
|
||||
</body>
|
||||
|
||||
2
dev.py
2
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:])
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user