Permalink
Browse files

new events for connection, start of new sample

  • Loading branch information...
xdenser committed May 18, 2011
1 parent 3eebdf0 commit fb8dc302645f34beb2a4e0be24021c2ced22e7c1
Showing with 5,711 additions and 0 deletions.
  1. +17 −0 firebird.js
  2. +95 −0 samples/fileman/elfinder.js
  3. +35 −0 samples/fileman/fileman.js
  4. BIN samples/fileman/static/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
  5. BIN samples/fileman/static/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
  6. BIN samples/fileman/static/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
  7. BIN samples/fileman/static/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
  8. BIN samples/fileman/static/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png
  9. BIN samples/fileman/static/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
  10. BIN samples/fileman/static/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
  11. BIN samples/fileman/static/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
  12. BIN samples/fileman/static/css/smoothness/images/ui-icons_222222_256x240.png
  13. BIN samples/fileman/static/css/smoothness/images/ui-icons_2e83ff_256x240.png
  14. BIN samples/fileman/static/css/smoothness/images/ui-icons_454545_256x240.png
  15. BIN samples/fileman/static/css/smoothness/images/ui-icons_888888_256x240.png
  16. BIN samples/fileman/static/css/smoothness/images/ui-icons_cd0a0a_256x240.png
  17. +578 −0 samples/fileman/static/css/smoothness/jquery-ui-1.8.12.custom.css
  18. +832 −0 samples/fileman/static/elfinder/css/elfinder.css
  19. +3,331 −0 samples/fileman/static/elfinder/elfinder.full.js
  20. BIN samples/fileman/static/elfinder/images/icons-big.png
  21. BIN samples/fileman/static/elfinder/images/icons-big.psd
  22. BIN samples/fileman/static/elfinder/images/icons-small.png
  23. BIN samples/fileman/static/elfinder/images/ql.png
  24. BIN samples/fileman/static/elfinder/images/spinner.gif
  25. BIN samples/fileman/static/elfinder/images/toolbar.png
  26. +24 −0 samples/fileman/static/index.html
  27. +16 −0 samples/fileman/static/js/jquery-1.6.min.js
  28. +783 −0 samples/fileman/static/js/jquery-ui-1.8.12.custom.min.js
View
@@ -32,6 +32,23 @@ MakeSafe(FBStatement,"exec");
MakeSafe(FBblob,"_read");
MakeSafe(FBblob,"_write");
+var superConnect = Connection.prototype.connect;
+Connection.prototype.connect = function(db,user,pass,role,cb){
+ superConnect.call(this,db,user,pass,role,function (err){
+ if(err) this.emit('error',err);
+ else this.emit('connected');
+ if(cb) cb(err);
+ });
+};
+
+var superQuery = Connection.prototype.query;
+Connection.prototype.query = function(sql,cb){
+ superQuery.call(this,sql,function(err,res){
+ if(err) this.emit('error',err);
+ else this.emit('result',res);
+ if(cb) cb(err,res);
+ });
+};
binding.FBblob.prototype._readAll = function(initialSize, chunkSize, callback){
if(initialSize instanceof Function)
@@ -0,0 +1,95 @@
+var url = require('url');
+var crypto = require('crypto');
+var sys = require('sys');
+
+function _hash(str){
+ var h = crypto.createHash('md5');
+ h.update(str);
+ return h.digest('hex');
+}
+
+function _cwd(obj,name){
+ if(name=='') name = 'root';
+ obj.cwd = {
+ hash: _hash(name),
+ name: name,
+ mime: 'directory',
+ rel : name,
+ size: 0,
+ date: (new Date()).toString(),
+ read: true,
+ write: true,
+ rm: false
+ };
+}
+
+function _cdc(obj,path){
+ obj.cdc = [];
+}
+
+function _tree(path){
+ return {
+ hash:_hash('root'),
+ name: 'root',
+ read: true,
+ write: true,
+ dirs:[]
+ }
+}
+
+function _open(qry,cb){
+ var obj = {};
+ _cwd(obj,'');
+ _cdc(obj,'');
+ if(('tree' in qry)&& qry.tree){
+ obj.tree = _tree('');
+ }
+ cb(obj);
+}
+
+var commands = {
+ open: _open
+}
+
+function extend(obj)
+{
+ for(var f in obj){
+ if(obj.hasOwnProperty(f)) this[f] = obj[f];
+ }
+}
+
+function elfinder(req,res){
+ // console.log('in elfinder');
+ var q = url.parse(req.url,true);
+ var command = 'open';
+ if('cmd' in q.query) command =q.query.cmd;
+
+ var add = {};
+ if('init' in q.query){
+ // console.log(sys.inspect(req.headers));
+ add.disabled = [];
+ add.params = {
+ url : 'http://'+req.headers.host+'/node/elfinder',
+ dotFiles: true,
+ uplMaxSize: '15M',
+ extract: [],
+ archives: []
+ };
+ };
+
+ if(command in commands){
+ commands[command](q.query,function(obj){
+ res.setHeader('Content-Type','application/json');
+ extend.call(obj,add);
+ res.end(JSON.stringify(obj));
+ })
+ }
+ else
+ {
+ res.setHeader('Content-Type','text/html');
+ res.statusCode = 503;
+ res.end('Unknown command!');
+ }
+}
+
+exports.elfinder = elfinder;
View
@@ -0,0 +1,35 @@
+var connect = require('connect');
+var sys = require('sys');
+var elfinder = require('./elfinder').elfinder;
+
+
+connect(
+ function(req,res,next){
+ if(req.url=='/') req.url = '/index.html';
+ next();
+ },
+ connect.favicon(),
+ connect.static(__dirname + '/static'),
+ connect.bodyParser(),
+ function(req,res,next){
+ if(req.url.match(/^\/node/)){
+ var meth = req.url.match(/^\/node\/(.+)[\?\/]/)[1];
+ // console.log('method '+meth);
+ var respObj = {
+ elfinder: function(){
+ elfinder(req, res);
+ }
+ };
+ if(meth in respObj) respObj[meth]();
+ else next();
+ }
+ else next();
+ },
+ function(req,res){
+ res.setHeader('Content-Type','text/html');
+ res.statusCode = 404;
+ res.end("Not Found !");
+ }
+).listen(8080);
+
+console.log('Server is running at http://localhost:8080');
Oops, something went wrong.

0 comments on commit fb8dc30

Please sign in to comment.