mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 01:17:18 +00:00
minor changes
This commit is contained in:
parent
37847df395
commit
0db6d3370b
4 changed files with 78 additions and 33 deletions
29
client.js
29
client.js
|
|
@ -758,22 +758,27 @@ CloudClient._createFileTable = function(pElem, pJSON){
|
|||
* используеться при первом заходе в корень
|
||||
*/
|
||||
CloudClient._getJSONfromFileTable = function(){
|
||||
var lLeft = getById('left');
|
||||
var lPath = getByClass('path')[0].textContent;
|
||||
var lFileTable = [{path:lPath,size:'dir'}];
|
||||
var lLI = lLeft.getElementsByTagName('li');
|
||||
var lLeft = getById('left'),
|
||||
lPath = getByClass('path')[0].textContent,
|
||||
|
||||
lFileTable = [{
|
||||
path:lPath,
|
||||
size:'dir'
|
||||
}],
|
||||
|
||||
lLI = lLeft.getElementsByTagName('li'),
|
||||
|
||||
var j=1;/* счётчик реальных файлов */
|
||||
var i=1;/* счётчик элементов файлов в DOM */
|
||||
j = 1; /* счётчик реальных файлов */
|
||||
|
||||
/* счётчик элементов файлов в DOM */
|
||||
/* Если путь отличный от корневного
|
||||
* второй элемент li - это ссылка на верхний
|
||||
* каталог '..'
|
||||
*/
|
||||
i=2; /* пропускам Path и Header*/
|
||||
|
||||
for(; i <lLI.length;i++)
|
||||
{
|
||||
var lChildren = lLI[i].children,
|
||||
|
||||
/* пропускам Path и Header*/
|
||||
for(var i = 2, n = lLI.length; i < n; i++){
|
||||
var lChildren = lLI[i].children,
|
||||
/* file attributes */
|
||||
lAttr = {};
|
||||
|
||||
|
|
@ -809,7 +814,7 @@ CloudClient._getJSONfromFileTable = function(){
|
|||
*/
|
||||
lMode = CloudFunc.convertPermissionsToNumberic(lMode);
|
||||
|
||||
lFileTable[j++]={
|
||||
lFileTable[ j++ ]={
|
||||
name: lName,
|
||||
size: lSize,
|
||||
mode: lMode
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
var CloudCommander, Util, DOM, $, Github, cb;
|
||||
/* temporary callback function for work with github */
|
||||
/* module for work with github */
|
||||
|
||||
(function(){
|
||||
|
|
@ -18,6 +17,7 @@ var CloudCommander, Util, DOM, $, Github, cb;
|
|||
|
||||
cloudcmd.Storage = {};
|
||||
|
||||
/* temporary callback function for work with github */
|
||||
cb = function (err, data){ console.log(err || data);};
|
||||
|
||||
/* PRIVATE FUNCTIONS */
|
||||
|
|
@ -43,15 +43,7 @@ var CloudCommander, Util, DOM, $, Github, cb;
|
|||
}
|
||||
|
||||
function setConfig(pCallBack){
|
||||
/*
|
||||
cloudcmd.loadConfig(function(){
|
||||
var lConfig = cloudcmd.Config;
|
||||
CLIENT_ID = lConfig.oauth_client_id;
|
||||
|
||||
Util.exec(pCallBack);
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
DOM.ajax({
|
||||
url : ClientIdURL,
|
||||
success : function(pData){
|
||||
|
|
@ -122,7 +114,7 @@ var CloudCommander, Util, DOM, $, Github, cb;
|
|||
CLIENT_ID + '&&scope=repo,user,gist';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getUserData(){
|
||||
var lName, lRepoNames,
|
||||
lGetTree = function(pError ,pData){
|
||||
|
|
@ -135,7 +127,7 @@ var CloudCommander, Util, DOM, $, Github, cb;
|
|||
else
|
||||
Util.log(pError);
|
||||
},
|
||||
|
||||
|
||||
lShowRepos = function(pError, pRepos){
|
||||
lRepoNames = pRepos || [];
|
||||
Util.log('Repositories: ');
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@
|
|||
'.mp3' : 'audio/mpeg'
|
||||
};
|
||||
|
||||
/* Global var accessible from any loaded module */
|
||||
global.cloudcmd = {},
|
||||
|
||||
/* Constants */
|
||||
exports.DIR = DIR = process.cwd() + '/',
|
||||
exports.LIBDIR = LIBDIR = DIR + 'lib/',
|
||||
|
|
@ -39,18 +41,27 @@
|
|||
exports.https = require('https'),
|
||||
exports.path = require('path'),
|
||||
exports.url = require('url'),
|
||||
exports.querystring = require('querystring'),
|
||||
exports.querystring = require('querystring'),
|
||||
|
||||
/* Needed Modules */
|
||||
exports.util = Util = require(LIBDIR + 'util'),
|
||||
|
||||
exports.zlib = mrequire('zlib'),
|
||||
|
||||
/* Main Information */
|
||||
exports.config = rootrequire('config');
|
||||
exports.mainpackage = rootrequire('package');
|
||||
|
||||
/* Additional Modules */
|
||||
|
||||
/*
|
||||
* Any of loaded below modules could work with global var so
|
||||
* it should be initialized first. Becouse of almost any of
|
||||
* moudles do not depends on each other all needed information
|
||||
* for all modules is initialized hear.
|
||||
*/
|
||||
global.cloudcmd.main = exports;
|
||||
|
||||
exports.auth = srvrequire('auth').auth,
|
||||
exports.appcache = srvrequire('appcache'),
|
||||
exports.cache = srvrequire('cache').Cache,
|
||||
|
|
@ -58,8 +69,12 @@
|
|||
exports.rest = srvrequire('rest').api,
|
||||
exports.socket = srvrequire('socket'),
|
||||
exports.update = srvrequire('update'),
|
||||
exports.minify = srvrequire('minify').Minify,
|
||||
exports.zlib = mrequire('zlib');
|
||||
exports.minify = srvrequire('minify').Minify;
|
||||
|
||||
/*
|
||||
* second initializing after all modules load, so global var is
|
||||
* totally filled of all information that should know all modules
|
||||
*/
|
||||
global.cloudcmd.main = exports;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
var main = global.cloudcmd.main,
|
||||
Util = main.util,
|
||||
fs = main.fs,
|
||||
zlib = main.zlib,
|
||||
APIURL = '/api/v1',
|
||||
OK = 200,
|
||||
Header = main.generateHeaders('api.json', false);
|
||||
|
|
@ -86,21 +88,24 @@
|
|||
* @param pParams {command, method, body, response}
|
||||
*/
|
||||
function onGET(pParams){
|
||||
var lResult,
|
||||
var lResult = {error: 'command not found'},
|
||||
lCmd = pParams.command;
|
||||
|
||||
switch(lCmd){
|
||||
case '':
|
||||
lResult = {info: 'Cloud Commander API v1'};
|
||||
break;
|
||||
case 'kill':
|
||||
process.exit();
|
||||
break;
|
||||
|
||||
case 'client_id':
|
||||
var lEnv = process.env,
|
||||
lConfig = main.config;
|
||||
|
||||
|
||||
lResult = lEnv.oauth_client_id || lConfig.oauth_client_id;
|
||||
break;
|
||||
|
||||
case 'kill':
|
||||
process.exit();
|
||||
break;
|
||||
}
|
||||
|
||||
return lResult;
|
||||
|
|
@ -112,7 +117,7 @@
|
|||
* @param pParams {command, method, body, response}
|
||||
*/
|
||||
function onPUT(pParams){
|
||||
var lResult,
|
||||
var lResult = {error: 'command not found'},
|
||||
lCmd = pParams.command,
|
||||
lBody = pParams.body,
|
||||
lRes = pParams.response;
|
||||
|
|
@ -124,11 +129,39 @@
|
|||
});
|
||||
lResult = false;
|
||||
break;
|
||||
|
||||
/* Example:
|
||||
* read=[lib/dom.js, lib/cloudfunc.js, client.js]
|
||||
*/
|
||||
case 'read':
|
||||
console.log(lBody);
|
||||
var lFiles = lBody;
|
||||
|
||||
if( Util.isString(lFiles) ){
|
||||
lRes.writeHead(OK, main.generateHeaders(lFiles, true) );
|
||||
|
||||
fs.createReadStream(lFiles, {
|
||||
'bufferSize': 4 * 1024
|
||||
})
|
||||
.pipe( zlib.createGzip() )
|
||||
.pipe(lRes);
|
||||
|
||||
lResult = null;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return lResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* get body of url query
|
||||
*
|
||||
* @param pReq
|
||||
* @param pCallBack
|
||||
*/
|
||||
function getBody(pReq, pCallBack){
|
||||
var lBody = '';
|
||||
pReq.on('data', function(chunk) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue