App-screenorama
view release on metacpan or search on metacpan
- Add support for reading parameters from app->config
- Add exit status to browser
- Add support for "\b \b" (backspace)
- Match more color codes
- Fix tabular/multiple spaces output
- Fix parsing @ARGV
0.03 2015-05-03T20:37:57+0200
- Add support for backspace
- Add support for "clear screen" shell command
- Fix failing javascript when "cursor" was not present in DOM
- Remove running command from markup
- Will keep websocket alive from client
0.02 2014-01-22T20:01:07Z
- Fix pod
0.01 2014-01-21T20:56:48Z
- Started project
script/screenorama view on Meta::CPAN
'31': '#c0392b',
'32': '#2ecc71',
'33': '#f1c40f',
'34': '#48a2df',
'35': '#9b59b6',
'36': '#1abc9c',
'37': '#ecf0f1',
};
var screenorama = function() {
var cursor = document.querySelector('.cursor');
var input = document.querySelector('input');
var attach = function(elem, events, cb) {
events = events.split(' ');
for (var i = 0; i < events.length; i++) elem.addEventListener(events[i], cb, false);
};
screenorama.buf = '';
screenorama.ws = new WebSocket('<%= $stream_base %>/stream');
% if (app->config->{stdin}) {
cursor.visible = true;
cursor.style.display = 'inline';
setInterval(
function() {
cursor.style.opacity = cursor.visible ? 0.02 : 1.0;
cursor.visible = !cursor.visible;
},
700
);
var tDown;
attach(document, 'mousedown touchstart', function(e) { tDown = new Date().getTime(); });
attach(document, 'mouseup touchstop', function(e) { if (new Date().getTime() - tDown < 250) input.focus(); });
screenorama.ws.onopen = function() {
input.focus();
script/screenorama view on Meta::CPAN
screenorama.ws.onmessage = function(e) {
if (window.console) console.log(e.data);
var data = JSON.parse(e.data);
if (typeof data.output !== 'undefined') screenorama.printToScreen(data.output.replace(/</g, '<'));
if (typeof data.exit_value !== 'undefined') screenorama.exitStatus(data);
window.scrollTo(0, document.body.scrollHeight);
};
};
screenorama.exitStatus = function(data) {
var cursor = document.querySelector('.cursor');
var shell = document.querySelector('.shell');
var status = document.createElement('div');
cursor.style.display = 'none';
status.className = 'status';
status.innerHTML = '$?=' + data.exit_value;
shell.appendChild(status);
};
screenorama.keydown = function(e) {
var k = e.keyCode || e.which;
if (window.console) console.log('keydown: ' + k);
switch (k) {
case 8: // backspace
script/screenorama view on Meta::CPAN
screenorama.send = function(msg, e) {
if (e) e.preventDefault();
console.log(msg);
screenorama.ws.send(msg);
};
window.onload = screenorama;
% end
</head>
<body>
<div class="shell"><span class="output"></span><span class="cursor" style="display:none">▂</span></div>
<input style="position:absolute;top:-100px">
</body>
</html>
use Mojo::Base -strict;
use Test::More;
use Test::Mojo;
$ENV{SCREENORAMA_COMMAND} = 'ls -l';
plan skip_all => "do script/screenorama: $@" unless do 'script/screenorama';
my $t = Test::Mojo->new;
$t->get_ok('/')->status_is(200)->text_is('title', 'screenorama - ls -l')->element_exists('.shell span.output')
->element_exists('.shell span.cursor');
done_testing;
( run in 0.266 second using v1.01-cache-2.11-cpan-4d50c553e7e )