Get rid of unused debug scripts

This commit is contained in:
Mathieu Agopian 2016-01-14 12:17:27 +01:00
Родитель 7e999fd938
Коммит e55fcd724c
4 изменённых файлов: 0 добавлений и 339 удалений

Просмотреть файл

@ -1,26 +0,0 @@
now.ready(function () {
var oldConsole = window.console.log;
window.console.log = function() {
now.log.apply(now, arguments);
oldConsole.apply(this, arguments);
};
window.onerror = function(m,f,l) {
now.logError(m, f, l);
};
now.doEval = function(code) {
var out;
try {
out = window.eval(code);
}
catch (e) {
now.logError(e.message, 0, 0);
return;
}
now.evalResp(out);
};
now.registerRemoteServer(window.navigator.platform, window.outerWidth, window.outerHeight);
$.ajaxPrefilter(function(opts) {
now.async(opts.url);
});
});

Просмотреть файл

@ -1,58 +0,0 @@
var fs = require('fs')
var http = require('http');
var url = require('url');
var now = require("now");
var port = +process.argv[2] || 37767;
var server = http.createServer(function(req, res){
res.end(fs.readFileSync(__dirname+'/remote_debug_viewer.html'));
}).listen(port);;
console.log('logging to port ' + port);
var everyone = now.initialize(server);
var serverId = 0;
var servers = {};
everyone.now.servers = servers;
everyone.now.logError = function(m,f,l) {
now.getGroup('dbg').now.showError(m,f,l);
};
everyone.now.log = function(msg) {
now.getGroup('dbg').now.showLog(msg);
};
everyone.now.registerRemoteDebugger = function(username) {
console.log('registered remote debugger');
this.now.username = username;
var that = this;
now.getGroup('target').count(function (n) {that.now.showMsg(n + ' clients connected')});
now.getGroup('dbg').addUser(this.user.clientId);
now.getGroup('dbg').now.showMsg('new debugger online: ' + this.now.username);
};
everyone.now.registerRemoteServer = function(p, w, h) {
var sname = '[' + p + ', ' + [w,h].join('x') + ']';
var out = 'new server online ' + sname;
this.now.target = true;
this.now.id = serverId++;
now.getGroup('target').addUser(this.user.clientId);
now.getGroup('dbg').now.showMsg(out);
servers[this.now.id] = sname;
// everyone.now.servers[this.now.id] = sname;
};
everyone.now.msg = function(msg) {
now.getGroup('dbg').now.showMsg(msg);
};
everyone.now.async = function(url) {
now.getGroup('dbg').now.showAsync(url);
};
everyone.now.repl = function(code) {
now.getGroup('target').now.doEval(code);
};
everyone.now.evalResp = function(msg) {
now.getGroup('dbg').now.replBack(msg);
};

Просмотреть файл

@ -1,165 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>remote error log</title>
<style>
* {
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body, html {
height: 100%;
margin: 0;
padding: 0;
font-family: Helvetica;
font-size: 14px;
}
li {
font-family: monospace;
clear: both;
list-style-type: none;
padding: 4px 1em;
margin: 0;
}
ul {
padding: 0;
}
li:nth-child(even) {
background: #eee;
}
li .meta {
float: right;
}
.error {
color: #c00;
}
.log {
color: #666;
}
.async {
color: #00c;
}
.msg {
text-align: left;
}
.msg:before {
content: '<msg> ';
}
#repl {
font: 14px monospace;
display: block;
width: 100%;
}
.repl {
color: #080;
}
.repl:before {
content: '> ';
}
.repl.back:before {
content: '';
}
#console {
width: 50%;
height: 100%;
padding: 4px;
border-right: 1px solid black;
overflow: auto;
float: left;
}
#inspect {
width: 50%;
float: right;
height: 100%;
}
</style>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script src="/nowjs/now.js"></script>
<script>
var format = (function() {
var re = /\{([^}]+)\}/g;
return function(s, args) {
if (!args) return;
if (!(args instanceof Array || args instanceof Object))
args = Array.prototype.slice.call(arguments, 1);
return s.replace(re, function(_, match){ return args[match]; });
};
})();
function pretty(val) {
if (val === undefined) {
return 'undefined';
}
if (val === null) {
return 'null';
}
return val;
}
now.ready(function(){
now.showLog = function(msg) {
var el = $('<li class="log">');
el.append(msg);
$('ul').prepend(el);
}
now.showAsync = function(msg) {
var el = $('<li class="async">');
el.append(msg);
$('ul').prepend(el);
}
now.showError = function(m,f,l) {
var el = $('<li class="error">');
el.append(format('{0}<span class="meta"><a href="{1}">{1}</a>:{2}</span>', [m,f,l]));
$('ul').prepend(el);
};
now.replBack = function(msg) {
var msg = pretty(msg);
var el = $('<li class="repl back">');
el.append(msg);
$('ul').prepend(el);
};
now.showMsg = function(msg) {
var el = $('<li class="msg">');
el.append(msg);
$('ul').prepend(el);
}
var repl = $('#repl');
var commandHistory = [];
var commandIndex = 0;
repl.on('keydown', function(e) {
if (e.which == 40) {
commandIndex--;
if (commandIndex < -1) commandIndex = -1;
repl.val(commandHistory[commandIndex] || '');
}
if (e.which == 38) {
commandIndex++;
if (commandIndex >= commandHistory.length) commandIndex = commandHistory.length - 1;
repl.val(commandHistory[commandIndex]);
}
if (e.which == 13) {
var code = repl.val();
var el = $('<li class="repl">');
el.append(format('{0}', code));
$('ul').prepend(el);
commandHistory.unshift(code);
commandIndex = -1;
now.repl(code);
repl.val('');
}
});
now.registerRemoteDebugger('potch');
});
</script>
</head>
<body>
<section id="console">
<h1>Remote Error Log</h1>
<input id="repl">
<ul>
</ul>
</section>
<section id="inspect">
</section>
</body>
</html>

Просмотреть файл

@ -1,90 +0,0 @@
(function() {
document.body.innerHTML += '<style>#tinytools{-moz-box-sizing:border-box;background:#eee;position:fixed;bottom:0;left:0;width:100%;padding:4px}#tinytools *{margin:0;padding:0}#tinytools pre{overflow:auto;max-height:200px}#tinytools input{font-family:monospace;font-size:13px;-moz-box-sizing:border-box;width:100%;margin-top:4px}#tinytools .out{padding-left:2ch;color:blue}#tinytools .error{color:red}</style><div id="tinytools"><pre id="log"></pre><input type="text"></div>';
var tt = document.querySelector('#tinytools');
var repl = tt.querySelector('input');
var logEl = tt.querySelector('#log');
var old = {
log: window.console.log,
error: window.console.error,
clear: window.console.clear
};
if (sessionStorage.getItem('tt-visible') === 'true') {
tt.style.display = 'block';
}
window.console.log = function() {
append(arguments, 'log');
try {
old.log.apply(window.console, arguments);
} catch(e) {}
};
window.console.error = function() {
append(arguments, 'error');
try {
old.error.apply(window.console, arguments);
} catch(e) {}
};
window.console.clear = function() {
logEl.innerHTML = '';
};
window.console.list = function(o) {
var s = [], v;
for (var p in o) {
v = o[p];
if (v === null || v === undefined) {
v = typeof v;
}
v = v.toString().split('\n')[0];
s.push(p + ': ' + v);
}
append([s.sort().join('\n')], 'out');
};
document.addEventListener('keydown', function(e) {
if (e.which == 82 && e.metaKey) window.location.reload();
if (e.which == 75 && e.metaKey && e.altKey) {
if (tt.style.display != 'block') {
tt.style.display = 'block';
sessionStorage.setItem('tt-visible', true);
} else {
tt.style.display = 'none';
sessionStorage.setItem('tt-visible', false);
}
}
});
window.onerror = function(m, f, l) {
console.error(m, 'in file', f, 'on line', l);
};
function append(args, type) {
var vals = Array.prototype.slice.apply(args);
var out = vals.map(function(v) {
return v && v.toString();
}).join(' ');
if (!out.length) return;
logEl.innerHTML += '<div class="'+type+'">' + out + '</div>';
logEl.scrollTop = logEl.scrollHeight;
}
var lastCommand = '';
repl.addEventListener('keydown', function(e) {
if (e.which == 38) {
repl.value = lastCommand;
}
if (e.which == 13) {
var code = repl.value;
console.log('>', code);
lastCommand = code;
var out;
try {
out = window.eval(code);
}
catch (e) {
console.error(e);
}
finally {
append([out], 'out');
repl.value = '';
}
}
});
})();