semi-functional
[nodejsws.git] / lib / app.js
1
2 var http = require("http"),
3     url = require("url"),
4     path = require("path"),
5     fs = require("fs"),
6     req = require("./wsrequest.js"),
7     localPort = 8888,
8     defaultLayout = "standard",
9     defaultMain = null,
10     addCss = null,
11     addJs = null;
12
13
14
15
16
17 exports.setPort = function(port) {
18         localPort = port;
19 }
20
21 exports.addCss = function(cssname) {
22         if(addCss == null) {
23                 addCss = new Array();
24                 // turn it into an array;
25                 addCss.push(cssname);
26         } else {
27                 addCss.push(cssname);
28         }
29         
30 }
31
32 exports.addJS = function(js) {
33         if(addJs == null) {
34                 addJs = new Array();
35                 addJs.push(js);
36         } else {
37                 addJs.push(js);
38         }
39 }
40
41 exports.setDefaultLayout = function(layout) {
42         defaultLayout = layout;
43 }
44
45 exports.setDefaultMainPurl = function(main) {
46         defaultMain = main;
47 }
48
49
50 exports.start = function() {
51         // initialise req
52         //req.setDefaultLayout(defaultLayout);
53         //req.setDefaultMain(defaultMain);
54         //req.setExtraCss(addCss);
55         //req.setExtraJs(assJs);
56         
57         
58         http.createServer(req.wsRequest).listen(localPort);
59
60         console.log("Server running on port: ", localPort);
61 }