]> git.proxmox.com Git - mirror_xterm.js.git/blame - lib/index.js
move lib/term.js to src/term.js.
[mirror_xterm.js.git] / lib / index.js
CommitLineData
91273161
CJ
1/**
2 * term.js - an xterm emulator
14248234 3 * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
6cc8b3cd 4 * https://github.com/chjj/term.js
91273161
CJ
5 */
6
7function term(options) {
8 return new term.Terminal(options);
9}
10
11term.middleware = function(options) {
12 var url = require('url');
13 return function(req, res, next) {
14 if (url.parse(req.url).pathname !== '/term.js') {
15 return next();
16 }
17
18 if (+new Date(req.headers['if-modified-since']) === term.last) {
19 res.statusCode = 304;
20 res.end();
21 return;
22 }
23
24 res.writeHead(200, {
25 'Content-Type': 'application/javascript; charset=utf-8',
26 'Content-Length': Buffer.byteLength(term.script),
27 'Last-Modified': term.last
28 });
29
30 res.end(term.script);
31 };
32};
33
6e375ccc 34term.path = __dirname + '/../src/term.js';
91273161
CJ
35
36term.__defineGetter__('script', function() {
37 if (term._script) return term._script;
38 term.last = +new Date;
39 return term._script = require('fs').readFileSync(term.path, 'utf8');
40});
41
42term.__defineGetter__('Terminal', function() {
43 if (term._Terminal) return term._Terminal;
6e375ccc 44 return term._Terminal = require('../src/term');
91273161
CJ
45});
46
47/**
48 * Expose
49 */
50
51module.exports = term;