]>
git.proxmox.com Git - mirror_xterm.js.git/blob - lib/index.js
4a18fc2d624e11ec5f46c71355ad2f29aab328dc
2 * term.js - an xterm emulator
3 * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
4 * https://github.com/chjj/term.js
7 function term(options
) {
8 return new term
.Terminal(options
);
11 term
.middleware = function(options
) {
12 var url
= require('url');
14 options
= options
|| {};
15 options
.path
= options
.path
|| '/term.js';
17 return function(req
, res
, next
) {
18 if (url
.parse(req
.url
).pathname
!== options
.path
) {
22 if (+new Date(req
.headers
['if-modified-since']) === term
.last
) {
29 'Content-Type': 'application/javascript; charset=utf-8',
30 'Content-Length': Buffer
.byteLength(term
.script
),
31 'Last-Modified': term
.last
38 term
.path
= __dirname
+ '/../src/term.js';
40 term
.__defineGetter__('script', function() {
41 if (term
._script
) return term
._script
;
42 term
.last
= +new Date
;
43 return term
._script
= require('fs').readFileSync(term
.path
, 'utf8');
46 term
.__defineGetter__('Terminal', function() {
47 if (term
._Terminal
) return term
._Terminal
;
48 return term
._Terminal
= require('../src/term');
55 module
.exports
= term
;