minor changes

This commit is contained in:
coderaiser 2012-11-09 07:43:48 -05:00
parent c671ea973b
commit ad87f4ff6b
6 changed files with 119 additions and 98 deletions

View file

@ -242,7 +242,11 @@ CloudClient._loadDir = function(pLink,pNeedRefresh){
* onclick
*/
pEvent.returnValue = false;
Util.setValue({
object : pEvent,
property: 'returnValue',
value : false
});
return lRet;
};
@ -585,11 +589,7 @@ CloudClient._changeLinks = function(pPanelID){
/* устанавливаем обработчики на строку на одинарное и *
* двойное нажатие на левую кнопку мышки */
else{
var lLi;
try{
lLi = a[i].parentElement.parentElement;
}catch(error){console.log(error);}
var lLi = a[i].parentElement.parentElement;
/* if we in path changing onclick events */
if (lLi.className === 'path') {
@ -597,9 +597,7 @@ CloudClient._changeLinks = function(pPanelID){
}
else {
lLi.onclick = CloudClient._setCurrent();
lLi.onmousedown = lSetCurrentFile_f;
a[i].ondragstart = lOnDragStart_f;
/* if right button clicked menu will
@ -611,10 +609,11 @@ CloudClient._changeLinks = function(pPanelID){
if(a[i].target !== '_blank'){
lLi.ondblclick = CloudClient._loadDir(link);
if(lLi.addEventListener)
var lListener = lLi.addEventListener;
if(lListener)
lLi.addEventListener('touchend',
CloudClient._loadDir(link),
false);
false);
}
lLi.id = (a[i].title ? a[i].title : a[i].textContent) +
@ -654,20 +653,21 @@ CloudClient._ajaxLoad = function(path, pNeedRefresh){
/* опредиляем в какой мы панели:
* правой или левой
*/
var lPanel = DOM.getPanel().id;
var lPanel = DOM.getPanel().id,
lError;
if(pNeedRefresh === undefined && lPanel){
var lJSON = CloudClient.Cache.get(lPath);
if (lJSON !== null){
/* переводим из текста в JSON */
if(window && !window.JSON){
try{
lError = Util.tryCatchLog(function(){
lJSON = eval('('+lJSON+')');
}catch(err){
console.log(err);
}
}else lJSON = JSON.parse(lJSON);
});
}else
lJSON = JSON.parse(lJSON);
CloudClient._createFileTable(lPanel, lJSON);
CloudClient._changeLinks(lPanel);
@ -677,7 +677,7 @@ CloudClient._ajaxLoad = function(path, pNeedRefresh){
}
/* ######################## */
try{
Util.tryCatchLog(function(){
DOM.ajax({
url: path,
error: DOM.Images.showError,
@ -708,7 +708,7 @@ CloudClient._ajaxLoad = function(path, pNeedRefresh){
CloudClient.Cache.set(lPath,lJSON_s);
}
});
}catch(err){console.log(err);}
});
};
/**
@ -771,18 +771,18 @@ CloudClient._getJSONfromFileTable = function(){
for(; i <lLI.length;i++)
{
var lChildren = lLI[i].children;
var lChildren = lLI[i].children,
/* file attributes */
lAttr = {};
/* file attributes */
var lAttr = {};
/* getting all elements to lAttr object */
for(var l = 0; l < lChildren.length; l++)
lAttr[lChildren[l].className] = lChildren[l];
/* mini-icon */
var lIsDir = lAttr['mini-icon directory'] ? true : false;
var lIsDir = lAttr['mini-icon directory'] ? true : false,
var lName = lAttr.name;
lName = lAttr.name;
lName &&
(lName = lName.getElementsByTagName('a'));
@ -800,10 +800,9 @@ CloudClient._getJSONfromFileTable = function(){
(lName = lName.title) ||
(lName = lName.textContent);
/* если это папка - выводим слово dir вместо размера*/
var lSize = lIsDir ? 'dir' : lAttr.size.textContent;
var lMode = lAttr.mode.textContent;
/* если это папка - выводим слово dir вместо размера*/
var lSize = lIsDir ? 'dir' : lAttr.size.textContent,
lMode = lAttr.mode.textContent;
/* переводим права доступа в цыфровой вид
* для хранения в localStorage
@ -822,15 +821,12 @@ CloudClient._getJSONfromFileTable = function(){
return CloudClient;
})();
try{
window.onload = function(){
'use strict';
/* базовая инициализация*/
CloudCommander.init();
/* загружаем Google Analytics */
CloudCommander.GoogleAnalytics();
};
}
catch(err){}
window.onload = function(){
'use strict';
/* базовая инициализация*/
CloudCommander.init();
/* загружаем Google Analytics */
CloudCommander.GoogleAnalytics();
};

View file

@ -89,7 +89,7 @@ var CloudCommander, Util, DOM;
else if(lKeyCode === KEY.TAB){
console.log('Tab pressed');
var lResult = Util.tryCatch(function(){
Util.tryCatchLog(function(){
/* changing parent panel of curent-file */
var lPanel = DOM.getPanel(),
lId = lPanel.id;
@ -108,9 +108,6 @@ var CloudCommander, Util, DOM;
}
});
if(lResult)
console.log(lResult);
event.preventDefault();//запрет на дальнейшее действие
}
/* if f2 pressed */
@ -237,24 +234,26 @@ var CloudCommander, Util, DOM;
/* если нажали клавишу page up
* проматываем экран
*/
else if(lKeyCode === KEY.PAGE_UP){
DOM.getPanel().scrollByPages(-1);
else if(lKeyCode === KEY.PAGE_UP){
DOM.getPanel().scrollByPages(-1);
for(i=0; i<30; i++){
if(!lCurrentFile.previousSibling) break;
else try{
lCurrentFile
.previousSibling
var lC = lCurrentFile,
tryCatch = function(pCurrentFile){
Util.tryCatch(function(){
pCurrentFile
.previousSibling
.previousSibling
.previousSibling;
}
catch(pError){
break;
}
lCurrentFile = lCurrentFile.previousSibling;
.previousSibling
.previousSibling;
});
};
for(i=0; i<30; i++){
if(!lC.previousSibling || tryCatch(lC) ) break;
lC = lC.previousSibling;
}
DOM.setCurrentFile(lCurrentFile);
DOM.setCurrentFile(lC);
event.preventDefault();//запрет на дальнейшее действие
}
@ -318,10 +317,8 @@ var CloudCommander, Util, DOM;
* ссылку, на которую повешен eventHandler
* onclick
*/
lRefreshIcon.onclick();
lRefreshIcon.onclick();
cloudcmd._currentToParent(lSelectedName);
event.preventDefault();//запрет на дальнейшее действие
}
}
@ -363,17 +360,16 @@ var CloudCommander, Util, DOM;
* устанавливаем все обработчики
* нажатий клавиш
*/
else if(lKeyCode === KEY.S &&
event.altKey){
/* обрабатываем нажатия на клавиши*/
keyBinded = true;
console.log('<alt>+s pressed');
console.log('<ctrl>+r reload key-handerl - set');
console.log('<ctrl>+s clear cache key-handler - set');
console.log('press <alt>+q to remove them');
event.preventDefault();//запрет на дальнейшее действие
else if(event.keyCode === KEY.S && event.altKey){
/* обрабатываем нажатия на клавиши*/
keyBinded = true;
console.log('<alt>+s pressed');
console.log('<ctrl>+r reload key-handerl - set');
console.log('<ctrl>+s clear cache key-handler - set');
console.log('press <alt>+q to remove them');
event.preventDefault();//запрет на дальнейшее действие
}
return false;

View file

@ -1,7 +1,7 @@
/* object contains jQuery-contextMenu
* https://github.com/medialize/jQuery-contextMenu
*/
var CloudCommander, Util, DOM, $;
var CloudCommander, Util, DOM, CloudFunc, $;
(function(){
"use strict";
@ -203,8 +203,7 @@ var CloudCommander, Util, DOM, $;
var lFunc = document.oncontextmenu;
document.oncontextmenu = function(){
if(typeof lFunc === 'function')
lFunc();
Util.exec(lFunc);
return Menu.ENABLED;
};
@ -224,18 +223,13 @@ var CloudCommander, Util, DOM, $;
});
/* добавляем обработчик клавишь */
if (document.addEventListener)
if (document.addEventListener)
document.addEventListener('keydown', key_event.bind(this),false);
else{
lFunc;
if(typeof document.onkeydown === 'function')
lFunc = document.onkeydown;
lFunc = document.onkeydown;
document.onkeydown = function(){
if(lFunc)
lFunc();
Util.exec(lFunc);
key_event();
};

View file

@ -21,9 +21,10 @@
/* Native Modules*/
exports.child_process = require('child_process'),
exports.fs = require('fs'),
exports.http = require('http'),
exports.https = require('https'),
exports.path = require('path'),
exports.querystring = require('querystring'),
exports.path = require('path'),
exports.querystring = require('querystring'),
/* Needed Modules */
exports.util = Util = require(LIBDIR + 'util'),

View file

@ -46,6 +46,18 @@ var Util, exports;
pStr1.indexOf(pStr2) >= 0;
};
/**
* function log pArg if it's not empty
* @param pArg
*/
Util.log = function(pArg){
var lRet = pArg;
if(pArg)
console.log(pArg);
return lRet;
};
/**
* function remove substring from string
* @param pStr
@ -115,14 +127,25 @@ var Util, exports;
};
};
Util.ExecOnExec = function(pCallBacks){
if(Util.isArray(pCallBacks)){
for(var i = 0, n = pCallBacks.length; i < n; i++){
var lFunc = pCallBacks.pop();
Util.execOnExec( Util.retExec(lFunc, pCallBacks) );
/**
* set value to property of object, if object exist
* @param pArgs {object, property, value}
*/
Util.setValue = function(pArgs){
var lRet = false;
if( Util.isObject(pArgs) ){
var lObj = pArgs.object,
lProp = pArgs.property,
lVal = pArgs.lVal;
if(lObj){
lObj[lProp] = lVal;
lRet = true;
}
}
return lRet;
};
/**
@ -131,7 +154,7 @@ var Util, exports;
*
* @param pCallBack
*/
Util.tryCatch = function(pCallBack){
Util.tryCatch = function(pCallBack){
var lRet;
try{
lRet = pCallBack();
@ -143,6 +166,19 @@ var Util, exports;
return lRet;
};
/**
* function execute param function in
* try...catch block and log result
*
* @param pCallBack
*/
Util.tryCatchLog = function(pCallBack){
var lRet;
lRet = Util.tryCatch(pCallBack);
return Util.log(lRet);
};
/**
* function do save exec
*/

View file

@ -171,9 +171,8 @@ CloudServer.start = function (pConfig, pIndexProcessing, pAppCachProcessing) {
/* server mode or testing mode */
if (lConfig.server) {
var http = require('http');
try {
var http = main.http,
lError = Util.tryCatchLog(function(){
this.Server = http.createServer(this._controller);
this.Server.listen(this.Port, this.IP);
@ -186,10 +185,9 @@ CloudServer.start = function (pConfig, pIndexProcessing, pAppCachProcessing) {
console.log('Cloud Commander server running at http://' +
this.IP + ':' + this.Port);
}catch(pError){
});
if(lError)
console.log('Cloud Commander server could not started');
console.log(pError);
}
}else
console.log('Cloud Commander testing mode');
};