mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 17:05:17 +00:00
added module dom.js
This commit is contained in:
parent
6c65cafd10
commit
99866c4d95
5 changed files with 854 additions and 92 deletions
124
client.js
124
client.js
|
|
@ -3,7 +3,7 @@
|
|||
* клиентский и серверный
|
||||
*/
|
||||
|
||||
var CloudCommander = (function(){
|
||||
var Util, DOM, CloudCommander = (function(){
|
||||
"use strict";
|
||||
|
||||
/* Клиентский обьект, содержащий функциональную часть*/
|
||||
|
|
@ -28,10 +28,7 @@ var CloudClient = {
|
|||
|
||||
/* ОБЬЕКТЫ */
|
||||
/* Обьект для работы с кэшем */
|
||||
Cache : {},
|
||||
|
||||
/* Object contain additional system functional */
|
||||
Util : {},
|
||||
Cache : {},
|
||||
|
||||
/* ПРИВАТНЫЕ ФУНКЦИИ */
|
||||
/* функция загружает json-данные о файловой системе */
|
||||
|
|
@ -61,7 +58,7 @@ var CloudClient = {
|
|||
var cloudcmd = CloudClient,
|
||||
|
||||
/* глобальные переменные */
|
||||
CloudFunc, $, Util, KeyBinding,
|
||||
CloudFunc, $, KeyBinding,
|
||||
|
||||
/* short names used all the time functions */
|
||||
getByClass, getById;
|
||||
|
|
@ -100,7 +97,7 @@ var loadModule = function(pParams){
|
|||
if( Util.isFunction(lDoBefore) )
|
||||
lDoBefore();
|
||||
|
||||
Util.jsload(cloudcmd.LIBDIRCLIENT + lPath, lFunc ||
|
||||
DOM.jsload(cloudcmd.LIBDIRCLIENT + lPath, lFunc ||
|
||||
function(){
|
||||
cloudcmd[lName].Keys(pArg);
|
||||
});
|
||||
|
|
@ -147,7 +144,7 @@ CloudClient.Cache.isAllowed = (function(){
|
|||
* https://gist.github.com/350433
|
||||
*/
|
||||
/*
|
||||
Util.jsload('https://raw.github.com/gist/350433/c9d3834ace63e5f5d7c8e1f6e3e2874d477cb9c1/gistfile1.js',
|
||||
DOM.jsload('https://raw.github.com/gist/350433/c9d3834ace63e5f5d7c8e1f6e3e2874d477cb9c1/gistfile1.js',
|
||||
function(){CloudClient.Cache._allowed=true;
|
||||
});
|
||||
*/
|
||||
|
|
@ -194,9 +191,9 @@ CloudClient.Util = (function(){
|
|||
LImages_o = {
|
||||
/* Функция создаёт картинку загрузки*/
|
||||
loading : function(){
|
||||
var lE = Util.getById('loading-image');
|
||||
var lE = DOM.getById('loading-image');
|
||||
if (!lE)
|
||||
lE = Util.anyload({
|
||||
lE = DOM.anyload({
|
||||
name : 'span',
|
||||
className : 'icon loading',
|
||||
id : 'loading-image',
|
||||
|
|
@ -549,7 +546,7 @@ CloudClient.Util = (function(){
|
|||
|
||||
this.jqueryLoad = function(pCallBack){
|
||||
/* загружаем jquery: */
|
||||
Util.jsload('//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js',{
|
||||
DOM.jsload('//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js',{
|
||||
onload: function(){
|
||||
$ = window.jQuery;
|
||||
if(typeof pCallBack === 'function')
|
||||
|
|
@ -557,14 +554,14 @@ CloudClient.Util = (function(){
|
|||
},
|
||||
|
||||
onerror: function(){
|
||||
Util.jsload('lib/client/jquery.js');
|
||||
DOM.jsload('lib/client/jquery.js');
|
||||
|
||||
/*
|
||||
* if could not load jquery from google server
|
||||
* maybe we offline, load font from local
|
||||
* directory
|
||||
*/
|
||||
Util.cssSet({id:'local-droids-font',
|
||||
DOM.cssSet({id:'local-droids-font',
|
||||
element : document.head,
|
||||
inner : '@font-face {font-family: "Droid Sans Mono";' +
|
||||
'font-style: normal;font-weight: normal;' +
|
||||
|
|
@ -576,7 +573,7 @@ CloudClient.Util = (function(){
|
|||
};
|
||||
|
||||
this.socketLoad = function(){
|
||||
Util.jsload('lib/client/socket.js');
|
||||
DOM.jsload('lib/client/socket.js');
|
||||
};
|
||||
|
||||
/* DOM */
|
||||
|
|
@ -652,12 +649,12 @@ CloudClient.Util = (function(){
|
|||
lLoadingImage = LImages_o.loading();
|
||||
lErrorImage = LImages_o.error();
|
||||
|
||||
Util.hide(lErrorImage);
|
||||
DOM.hide(lErrorImage);
|
||||
|
||||
var lCurrent;
|
||||
if(pPosition){
|
||||
if(pPosition.top){
|
||||
lCurrent = Util.getRefreshButton();
|
||||
lCurrent = DOM.getRefreshButton();
|
||||
if(lCurrent)
|
||||
lCurrent = lCurrent.parentElement;
|
||||
else
|
||||
|
|
@ -666,7 +663,7 @@ CloudClient.Util = (function(){
|
|||
}
|
||||
else
|
||||
{
|
||||
lCurrent = Util.getCurrentFile();
|
||||
lCurrent = DOM.getCurrentFile();
|
||||
lCurrent = lCurrent.firstChild.nextSibling;
|
||||
}
|
||||
|
||||
|
|
@ -681,7 +678,7 @@ CloudClient.Util = (function(){
|
|||
(lParent && lParent !== lCurrent))
|
||||
lCurrent.appendChild(lLoadingImage);
|
||||
|
||||
Util.show(lLoadingImage); /* показываем загрузку*/
|
||||
DOM.show(lLoadingImage); /* показываем загрузку*/
|
||||
}
|
||||
|
||||
return lRet_b;
|
||||
|
|
@ -689,7 +686,7 @@ CloudClient.Util = (function(){
|
|||
|
||||
hideLoad : function(){
|
||||
lLoadingImage = LImages_o.loading();
|
||||
Util.hide(lLoadingImage);
|
||||
DOM.hide(lLoadingImage);
|
||||
},
|
||||
|
||||
showError : function(jqXHR, textStatus, errorThrown){
|
||||
|
|
@ -711,21 +708,21 @@ CloudClient.Util = (function(){
|
|||
else if(!lText.indexOf('Error: EACCES,'))
|
||||
lText = lText.replace('Error: EACCES, p','P');
|
||||
|
||||
Util.show(lErrorImage);
|
||||
DOM.show(lErrorImage);
|
||||
lErrorImage.title = lText;
|
||||
|
||||
var lParent = lLoadingImage.parentElement;
|
||||
if(lParent)
|
||||
lParent.appendChild(lErrorImage);
|
||||
|
||||
Util.hide(lLoadingImage);
|
||||
DOM.hide(lLoadingImage);
|
||||
|
||||
console.log(lText);
|
||||
}
|
||||
};
|
||||
|
||||
this.getCurrentFile = function(){
|
||||
var lCurrent = Util.getByClass(lCURRENT_FILE)[0];
|
||||
var lCurrent = DOM.getByClass(lCURRENT_FILE)[0];
|
||||
if(!lCurrent)
|
||||
this.addCloudStatus({
|
||||
code : -1,
|
||||
|
|
@ -781,24 +778,24 @@ CloudClient.Util = (function(){
|
|||
this.addClass(pCurrentFile, lCURRENT_FILE);
|
||||
|
||||
/* scrolling to current file */
|
||||
Util.scrollIntoViewIfNeeded(pCurrentFile);
|
||||
DOM.scrollIntoViewIfNeeded(pCurrentFile);
|
||||
|
||||
return lRet_b;
|
||||
};
|
||||
|
||||
var lUnSetCurrentFile = function(pCurrentFile){
|
||||
if(!pCurrentFile)
|
||||
Util.addCloudStatus({
|
||||
DOM.addCloudStatus({
|
||||
code : -1,
|
||||
msg : 'Error pCurrentFile in' +
|
||||
'unSetCurrentFile' +
|
||||
'could not be none'
|
||||
});
|
||||
|
||||
var lRet_b = Util.isCurrentFile(pCurrentFile);
|
||||
var lRet_b = DOM.isCurrentFile(pCurrentFile);
|
||||
|
||||
if(lRet_b)
|
||||
Util.removeClass(pCurrentFile, lCURRENT_FILE);
|
||||
DOM.removeClass(pCurrentFile, lCURRENT_FILE);
|
||||
|
||||
return lRet_b;
|
||||
};
|
||||
|
|
@ -920,7 +917,7 @@ CloudClient.Util = (function(){
|
|||
};
|
||||
|
||||
this.show = function(pElement){
|
||||
Util.removeClass(pElement, 'hidden');
|
||||
DOM.removeClass(pElement, 'hidden');
|
||||
};
|
||||
|
||||
this.showPanel = function(pActive){
|
||||
|
|
@ -974,9 +971,9 @@ CloudClient.Util = (function(){
|
|||
var lNext = pCurrent.nextSibling;
|
||||
var lPrevious = pCurrent.previousSibling;
|
||||
if(lNext)
|
||||
Util.setCurrentFile(lNext);
|
||||
DOM.setCurrentFile(lNext);
|
||||
else if(lPrevious)
|
||||
Util.setCurrentFile(lPrevious);
|
||||
DOM.setCurrentFile(lPrevious);
|
||||
|
||||
lParent.removeChild(pCurrent);
|
||||
}
|
||||
|
|
@ -1014,7 +1011,7 @@ CloudClient.Util = (function(){
|
|||
};
|
||||
});
|
||||
|
||||
CloudClient.Util = new CloudClient.Util();
|
||||
var Util = CloudClient.Util = new CloudClient.Util();
|
||||
|
||||
|
||||
CloudClient.GoogleAnalytics = function(){
|
||||
|
|
@ -1023,7 +1020,7 @@ CloudClient.GoogleAnalytics = function(){
|
|||
|
||||
document.onmousemove = function(){
|
||||
setTimeout(function(){
|
||||
Util.jsload('lib/client/google_analytics.js');
|
||||
DOM.jsload('lib/client/google_analytics.js');
|
||||
},5000);
|
||||
|
||||
if( Util.isFunction(lFunc) )
|
||||
|
|
@ -1046,11 +1043,11 @@ CloudClient._loadDir = function(pLink,pNeedRefresh){
|
|||
/* показываем гиф загрузки возле пути папки сверху*/
|
||||
/* ctrl+r нажата? */
|
||||
|
||||
Util.Images.showLoad(pNeedRefresh ? {top:true} : null);
|
||||
DOM.Images.showLoad(pNeedRefresh ? {top:true} : null);
|
||||
|
||||
var lPanel = Util.getPanel(),
|
||||
var lPanel = DOM.getPanel(),
|
||||
/* получаем имя каталога в котором находимся*/
|
||||
lHref = Util.getByClass('path', lPanel);
|
||||
lHref = DOM.getByClass('path', lPanel);
|
||||
|
||||
lHref = lHref[0].textContent;
|
||||
|
||||
|
|
@ -1066,7 +1063,7 @@ CloudClient._loadDir = function(pLink,pNeedRefresh){
|
|||
* или <Ctrl>+R - ссылок мы ненайдём
|
||||
* и заходить не будем
|
||||
*/
|
||||
var lA = Util.getCurrentLink(this);
|
||||
var lA = DOM.getCurrentLink(this);
|
||||
|
||||
/* если нажали на ссылку на верхний каталог*/
|
||||
if(lA && lA.textContent==='..' && lHref!=='/'){
|
||||
|
|
@ -1095,7 +1092,7 @@ CloudClient._loadDir = function(pLink,pNeedRefresh){
|
|||
* @param pEvent
|
||||
*/
|
||||
CloudClient._editFileName = function(pParent){
|
||||
var lA = Util.getCurrentLink(pParent);
|
||||
var lA = DOM.getCurrentLink(pParent);
|
||||
|
||||
if (lA && lA.textContent !== '..'){
|
||||
|
||||
|
|
@ -1109,7 +1106,7 @@ CloudClient._editFileName = function(pParent){
|
|||
* backs
|
||||
*/
|
||||
document.onclick = (function(){
|
||||
var lA = Util.getCurrentLink(pParent);
|
||||
var lA = DOM.getCurrentLink(pParent);
|
||||
if (lA && lA.textContent !== '..')
|
||||
lA.contentEditable = false;
|
||||
|
||||
|
|
@ -1137,9 +1134,9 @@ CloudClient._setCurrent = function(){
|
|||
* вызоветься _loadDir
|
||||
*/
|
||||
return function(pFromEnter){
|
||||
var lCurrentFile = Util.getCurrentFile();
|
||||
var lCurrentFile = DOM.getCurrentFile();
|
||||
if(lCurrentFile){
|
||||
if (Util.isCurrentFile(this) &&
|
||||
if (DOM.isCurrentFile(this) &&
|
||||
typeof pFromEnter !== 'boolean'){
|
||||
//var lParent = this;
|
||||
|
||||
|
|
@ -1150,14 +1147,14 @@ CloudClient._setCurrent = function(){
|
|||
* in other case
|
||||
* double click event happend
|
||||
*/
|
||||
// if(Util.getCurrentFile() === lParent)
|
||||
// if(DOM.getCurrentFile() === lParent)
|
||||
// CloudClient._editFileName(lParent);
|
||||
// },1000);
|
||||
}
|
||||
else{
|
||||
/* устанавливаем курсор на файл,
|
||||
* на который нажали */
|
||||
Util.setCurrentFile(this);
|
||||
DOM.setCurrentFile(this);
|
||||
}
|
||||
}
|
||||
/* если мы попали сюда с энтера*/
|
||||
|
|
@ -1166,7 +1163,7 @@ CloudClient._setCurrent = function(){
|
|||
this.ondblclick(this);
|
||||
/* enter pressed on file */
|
||||
else{
|
||||
var lA = Util.getCurrentLink(this);
|
||||
var lA = DOM.getCurrentLink(this);
|
||||
|
||||
if( Util.isFunction(lA.ondblclick) )
|
||||
lA.ondblclick(this);
|
||||
|
|
@ -1193,7 +1190,7 @@ CloudClient._currentToParent = function(pDirName){
|
|||
/* опредиляем в какой мы панели:
|
||||
* правой или левой
|
||||
*/
|
||||
var lPanel = Util.getPanel();
|
||||
var lPanel = DOM.getPanel();
|
||||
|
||||
/* убираем слэш с имени каталога*/
|
||||
pDirName = pDirName.replace('/','');
|
||||
|
|
@ -1204,8 +1201,8 @@ CloudClient._currentToParent = function(pDirName){
|
|||
* set it to current file
|
||||
*/
|
||||
if(lRootDir){
|
||||
Util.setCurrentFile(lRootDir);
|
||||
Util.scrollIntoViewIfNeeded(lRootDir, true);
|
||||
DOM.setCurrentFile(lRootDir);
|
||||
DOM.scrollIntoViewIfNeeded(lRootDir, true);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1214,18 +1211,17 @@ CloudClient._currentToParent = function(pDirName){
|
|||
* инициализации
|
||||
*/
|
||||
CloudClient.init = function(){
|
||||
Util = cloudcmd.Util;
|
||||
getByClass = Util.getByClass;
|
||||
getById = Util.getById;
|
||||
getByClass = DOM.getByClass;
|
||||
getById = DOM.getById;
|
||||
|
||||
|
||||
//Util.socketLoad();
|
||||
|
||||
if(!document.body.scrollIntoViewIfNeeded){
|
||||
this.OLD_BROWSER = true;
|
||||
Util.jsload(CloudClient.LIBDIRCLIENT + 'ie.js',
|
||||
DOM.jsload(CloudClient.LIBDIRCLIENT + 'ie.js',
|
||||
function(){
|
||||
Util.jqueryLoad( baseInit );
|
||||
DOM.jqueryLoad( baseInit );
|
||||
});
|
||||
}
|
||||
else baseInit();
|
||||
|
|
@ -1242,7 +1238,7 @@ function initModules(){
|
|||
}
|
||||
});
|
||||
|
||||
Util.ajax({
|
||||
DOM.ajax({
|
||||
url:'/modules.json',
|
||||
success: function(pModules){
|
||||
if( Util.isArray(pModules) )
|
||||
|
|
@ -1266,12 +1262,12 @@ function baseInit(){
|
|||
* если js включен - имена папок отображать необязательно...
|
||||
* а может и обязательно при переходе, можно будет это сделать
|
||||
*/
|
||||
var lTitle = Util.getByTag('title');
|
||||
var lTitle = DOM.getByTag('title');
|
||||
if(lTitle.length > 0)
|
||||
lTitle[0].textContent = 'Cloud Commander';
|
||||
|
||||
/* загружаем общие функции для клиента и сервера */
|
||||
Util.jsload(cloudcmd.LIBDIR + 'cloudfunc.js',function(){
|
||||
DOM.jsload(cloudcmd.LIBDIR + 'cloudfunc.js',function(){
|
||||
/* берём из обьекта window общий с сервером функционал */
|
||||
CloudFunc = window.CloudFunc;
|
||||
|
||||
|
|
@ -1293,7 +1289,7 @@ function baseInit(){
|
|||
/* выделяем строку с первым файлом */
|
||||
var lFmHeader = getByClass('fm_header');
|
||||
if(lFmHeader && lFmHeader[0].nextSibling)
|
||||
Util.setCurrentFile(lFmHeader[0].nextSibling);
|
||||
DOM.setCurrentFile(lFmHeader[0].nextSibling);
|
||||
|
||||
/* показываем элементы, которые будут работать только, если есть js */
|
||||
var lFM = getById('fm');
|
||||
|
|
@ -1312,7 +1308,7 @@ function baseInit(){
|
|||
|
||||
cloudcmd.HEIGHT = lHeight;
|
||||
|
||||
Util.cssSet({id:'cloudcmd',
|
||||
DOM.cssSet({id:'cloudcmd',
|
||||
element:document.head,
|
||||
inner:
|
||||
'.panel{' +
|
||||
|
|
@ -1355,7 +1351,7 @@ CloudClient._changeLinks = function(pPanelID){
|
|||
* target - jquery event
|
||||
*/
|
||||
var lTarget = pEvent.currentTarget || pEvent.target;
|
||||
Util.setCurrentFile(lTarget);
|
||||
DOM.setCurrentFile(lTarget);
|
||||
|
||||
if(Util.isFunction(cloudcmd.Menu) ){
|
||||
cloudcmd.Menu({
|
||||
|
|
@ -1365,7 +1361,7 @@ CloudClient._changeLinks = function(pPanelID){
|
|||
|
||||
/* disabling browsers menu*/
|
||||
lReturn_b = false;
|
||||
Util.Images.showLoad();
|
||||
DOM.Images.showLoad();
|
||||
}
|
||||
|
||||
return lReturn_b;
|
||||
|
|
@ -1403,7 +1399,7 @@ CloudClient._changeLinks = function(pPanelID){
|
|||
lTag = pElement.tagName;
|
||||
}while(lTag !== 'LI');
|
||||
|
||||
Util.setCurrentFile(pElement);
|
||||
DOM.setCurrentFile(pElement);
|
||||
};
|
||||
|
||||
var lLocation = document.location,
|
||||
|
|
@ -1498,7 +1494,7 @@ CloudClient._ajaxLoad = function(path, pNeedRefresh){
|
|||
/* опредиляем в какой мы панели:
|
||||
* правой или левой
|
||||
*/
|
||||
var lPanel = Util.getPanel().id;
|
||||
var lPanel = DOM.getPanel().id;
|
||||
|
||||
if(pNeedRefresh === undefined && lPanel){
|
||||
var lJSON = CloudClient.Cache.get(lPath);
|
||||
|
|
@ -1522,16 +1518,16 @@ CloudClient._ajaxLoad = function(path, pNeedRefresh){
|
|||
|
||||
/* ######################## */
|
||||
try{
|
||||
Util.ajax({
|
||||
DOM.ajax({
|
||||
url: path,
|
||||
error: Util.Images.showError,
|
||||
error: DOM.Images.showError,
|
||||
|
||||
success:function(data, textStatus, jqXHR){
|
||||
/* если такой папки (или файла) нет
|
||||
* прячем загрузку и показываем ошибку
|
||||
*/
|
||||
if(!jqXHR.responseText.indexOf('Error:'))
|
||||
return Util.showError(jqXHR);
|
||||
return DOM.showError(jqXHR);
|
||||
|
||||
CloudClient._createFileTable(lPanel, data);
|
||||
CloudClient._changeLinks(lPanel);
|
||||
|
|
@ -1568,7 +1564,7 @@ CloudClient._createFileTable = function(pElem, pJSON){
|
|||
var lWasRefresh_b = lPath[0].textContent === pJSON[0].path;
|
||||
var lCurrent;
|
||||
if(lWasRefresh_b)
|
||||
lCurrent = Util.getCurrentFile();
|
||||
lCurrent = DOM.getCurrentFile();
|
||||
|
||||
/* говорим построителю,
|
||||
* что бы он в нужный момент
|
||||
|
|
@ -1590,7 +1586,7 @@ CloudClient._createFileTable = function(pElem, pJSON){
|
|||
lCurrent = lElem.childNodes[i];
|
||||
break;
|
||||
}
|
||||
Util.setCurrentFile(lCurrent);
|
||||
DOM.setCurrentFile(lCurrent);
|
||||
//lCurrent.parentElement.focus();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
<button>F8 - remove</button>
|
||||
</div>
|
||||
<script src=lib/util.js></script>
|
||||
<script src=lib/client/dom.js></script>
|
||||
<script src=client.js></script>
|
||||
<!--[if lt IE 9]>
|
||||
<script src=lib/client/ie.js id=ie_js ></script>
|
||||
|
|
|
|||
766
lib/client/dom.js
Normal file
766
lib/client/dom.js
Normal file
|
|
@ -0,0 +1,766 @@
|
|||
var CloudCommander, $, Util, DOM;
|
||||
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
DOM = {};
|
||||
|
||||
function getCurrentFile(){
|
||||
return CloudCommander.CURRENT_FILE;
|
||||
}
|
||||
|
||||
/* private members */
|
||||
var XMLHTTP,
|
||||
LoadingImage,
|
||||
ErrorImage,
|
||||
|
||||
/* Обьект, который содержит
|
||||
* функции для отображения
|
||||
* картинок
|
||||
*/
|
||||
Images_o = {
|
||||
/* Функция создаёт картинку загрузки*/
|
||||
loading : function(){
|
||||
var lE = DOM.getById('loading-image');
|
||||
if (!lE)
|
||||
lE = DOM.anyload({
|
||||
name : 'span',
|
||||
className : 'icon loading',
|
||||
id : 'loading-image',
|
||||
not_append : true
|
||||
});
|
||||
|
||||
LoadingImage = lE;
|
||||
|
||||
return lE;
|
||||
},
|
||||
|
||||
/* Функция создаёт картинку ошибки загрузки*/
|
||||
error : function(){
|
||||
var lE = DOM.getById('error-image');
|
||||
if (!lE)
|
||||
lE = DOM.anyload({
|
||||
name : 'span',
|
||||
className : 'icon error',
|
||||
id : 'error-image',
|
||||
not_append : true
|
||||
});
|
||||
|
||||
return lE;
|
||||
}
|
||||
};
|
||||
|
||||
DOM.addClass = function(pElement, pClass){
|
||||
var lRet_b = true;
|
||||
|
||||
var lClassList = pElement.classList;
|
||||
if(lClassList){
|
||||
if( !lClassList.contains(pClass) )
|
||||
lClassList.add(pClass);
|
||||
else
|
||||
lRet_b = false;
|
||||
}
|
||||
|
||||
return lRet_b;
|
||||
};
|
||||
|
||||
/* Load file countent thrue ajax */
|
||||
DOM.ajax = function(pParams){
|
||||
/* if on webkit */
|
||||
if(window.XMLHttpRequest){
|
||||
if(!XMLHTTP)
|
||||
XMLHTTP = new XMLHttpRequest();
|
||||
|
||||
var lMethod = 'GET';
|
||||
if(pParams.method)
|
||||
lMethod = pParams.method;
|
||||
|
||||
XMLHTTP.open(lMethod, pParams.url, true);
|
||||
XMLHTTP.send(null);
|
||||
|
||||
var lSuccess_f = pParams.success;
|
||||
if(typeof lSuccess_f !== 'function')
|
||||
console.log('error in DOM.ajax onSuccess:', pParams);
|
||||
|
||||
XMLHTTP.onreadystatechange = function(pEvent){
|
||||
if (XMLHTTP.readyState === 4 /* Complete */){
|
||||
var lJqXHR = pEvent.target;
|
||||
var lContentType = XMLHTTP.getResponseHeader('content-type');
|
||||
|
||||
if (XMLHTTP.status === 200 /* OK */){
|
||||
var lData = lJqXHR.response;
|
||||
|
||||
/* If it's json - parse it as json */
|
||||
if(lContentType &&
|
||||
lContentType.indexOf('application/json') === 0){
|
||||
try{
|
||||
lData = JSON.parse(lJqXHR.response);
|
||||
}
|
||||
catch(pError) {
|
||||
/* if could not parse */
|
||||
console.log('Error: could not parse' +
|
||||
'json from server from url: ' +
|
||||
pParams.url);
|
||||
|
||||
lData = lJqXHR.response;
|
||||
}
|
||||
}
|
||||
|
||||
lSuccess_f(lData, lJqXHR.statusText, lJqXHR);
|
||||
}
|
||||
else/* file not found or connection lost */{
|
||||
var lError_f = pParams.error;
|
||||
|
||||
/* if html given or something like it
|
||||
* getBack just status of result
|
||||
*/
|
||||
if(lContentType &&
|
||||
lContentType.indexOf('text/plain') !== 0){
|
||||
lJqXHR.responseText = lJqXHR.statusText;
|
||||
}
|
||||
|
||||
if(typeof lError_f === 'function')
|
||||
lError_f(lJqXHR);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
else $.ajax(pParams);
|
||||
};
|
||||
|
||||
/* setting function context (DOM) */
|
||||
DOM.bind = function(pFunction, pContext){
|
||||
return pFunction.bind(pContext);
|
||||
};
|
||||
|
||||
/*
|
||||
* Function gets id by src
|
||||
* from http://domain.com/1.js to
|
||||
* 1_js
|
||||
*/
|
||||
DOM.getIdBySrc = function(pSrc){
|
||||
var lID = pSrc.replace(pSrc.substr(pSrc,
|
||||
pSrc.lastIndexOf('/')+1),
|
||||
'');
|
||||
|
||||
/* убираем точки */
|
||||
while(lID.indexOf('.') > 0)
|
||||
lID = lID.replace('.','_');
|
||||
|
||||
return lID;
|
||||
},
|
||||
|
||||
DOM.loadOnload = function(pFunc_a){
|
||||
if( Util.isArray(pFunc_a) ) {
|
||||
var lFunc_f = pFunc_a.pop();
|
||||
|
||||
if(typeof lFunc_f === 'function')
|
||||
lFunc_f();
|
||||
|
||||
return DOM.loadOnload(pFunc_a);
|
||||
}
|
||||
else if( Util.isFunction(pFunc_a) )
|
||||
return pFunc_a();
|
||||
};
|
||||
|
||||
DOM.anyLoadOnLoad = function(pParams_a, pFunc){
|
||||
if( Util.isArray(pParams_a) ) {
|
||||
var lParam = pParams_a.pop();
|
||||
|
||||
if(Util.isString(lParam) )
|
||||
lParam = { src : lParam };
|
||||
|
||||
|
||||
if(lParam && !lParam.func){
|
||||
lParam.func = function(){
|
||||
DOM.anyLoadOnLoad(pParams_a, pFunc);
|
||||
};
|
||||
|
||||
DOM.anyload(lParam);
|
||||
|
||||
}else if( Util.isFunction(pFunc) )
|
||||
pFunc();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Функция создаёт элемент и
|
||||
* загружает файл с src.
|
||||
* @pName - название тэга
|
||||
* @pSrc - путь к файлу
|
||||
* @pFunc - обьект, содержаий одну из функций
|
||||
* или сразу две onload и onerror
|
||||
* {onload: function(){}, onerror: function();}
|
||||
* @pStyle - стиль
|
||||
* @pId - id
|
||||
* @pElement - элемент, дочерним которо будет этот
|
||||
* @param pParams_o = {name: '', src: ' ',func: '', style: '', id: '', parent: '',
|
||||
async: false, inner: 'id{color:red, }, class:'', not_append: false}
|
||||
*/
|
||||
DOM.anyload = function(pParams_o){
|
||||
|
||||
if( !pParams_o ) return;
|
||||
|
||||
/* if a couple of params was
|
||||
* processing every of params
|
||||
* and quit
|
||||
*/
|
||||
if( Util.isArray(pParams_o) ){
|
||||
var lElements_a = [];
|
||||
for(var i = 0, n = pParams_o.length; i < n ; i++)
|
||||
lElements_a[i] = DOM.anyload(pParams_o[i]);
|
||||
|
||||
return lElements_a;
|
||||
}
|
||||
|
||||
var lName = pParams_o.name,
|
||||
lID = pParams_o.id,
|
||||
lClass = pParams_o.className,
|
||||
lSrc = pParams_o.src,
|
||||
lFunc = pParams_o.func,
|
||||
lOnError,
|
||||
lAsync = pParams_o.async,
|
||||
lParent = pParams_o.parent,
|
||||
lInner = pParams_o.inner,
|
||||
lNotAppend = pParams_o.not_append;
|
||||
|
||||
if ( Util.isObject(lFunc) ){
|
||||
lOnError = lFunc.onerror;
|
||||
lFunc = lFunc.onload;
|
||||
}
|
||||
/* убираем путь к файлу, оставляя только название файла */
|
||||
if(!lID && lSrc)
|
||||
lID = DOM.getIdBySrc(lSrc);
|
||||
|
||||
var element = DOM.getById(lID);
|
||||
|
||||
/* если скрипт еще не загружен */
|
||||
if(!element){
|
||||
if(!lName && lSrc){
|
||||
|
||||
var lDot = lSrc.lastIndexOf('.'),
|
||||
lExt = lSrc.substr(lDot);
|
||||
switch(lExt){
|
||||
case '.js':
|
||||
lName = 'script';
|
||||
break;
|
||||
case '.css':
|
||||
lName = 'link';
|
||||
lParent = document.head;
|
||||
break;
|
||||
default:
|
||||
return {code: -1, text: 'name can not be empty'};
|
||||
}
|
||||
}
|
||||
element = document.createElement(lName);
|
||||
|
||||
if(lID)
|
||||
element.id = lID;
|
||||
|
||||
if(lClass)
|
||||
element.className = lClass;
|
||||
|
||||
/* if working with external css
|
||||
* using href in any other case
|
||||
* using src
|
||||
*/
|
||||
if(lName === 'link'){
|
||||
element.href = lSrc;
|
||||
element.rel = 'stylesheet';
|
||||
}else
|
||||
element.src = lSrc;
|
||||
|
||||
/*
|
||||
* if passed arguments function
|
||||
* then it's onload by default
|
||||
*
|
||||
* if object - then onload and onerror
|
||||
*/
|
||||
|
||||
if( Util.isFunction(lFunc) )
|
||||
element.onload = lFunc;
|
||||
|
||||
/* if element (js/css) will not loaded
|
||||
* it would be removed from DOM tree
|
||||
* and error image would be shown
|
||||
*/
|
||||
element.onerror = (function(){
|
||||
(pParams_o.parent || document.body)
|
||||
.removeChild(element);
|
||||
|
||||
DOM.Images.showError({
|
||||
responseText: 'file ' +
|
||||
lSrc +
|
||||
' could not be loaded',
|
||||
status : 404
|
||||
});
|
||||
|
||||
if( Util.isFunction(lOnError) )
|
||||
lFunc();
|
||||
});
|
||||
|
||||
if(pParams_o.style){
|
||||
element.style.cssText = pParams_o.style;
|
||||
}
|
||||
|
||||
if(lAsync || lAsync === undefined)
|
||||
element.async = true;
|
||||
|
||||
if(!lNotAppend)
|
||||
(lParent || document.body).appendChild(element);
|
||||
|
||||
if(lInner){
|
||||
element.innerHTML = lInner;
|
||||
}
|
||||
}
|
||||
/* если js-файл уже загружен
|
||||
* запускаем функцию onload
|
||||
*/
|
||||
else if( Util.isFunction(lFunc) ) lFunc();
|
||||
|
||||
return element;
|
||||
},
|
||||
|
||||
/* Функция загружает js-файл */
|
||||
DOM.jsload = function(pSrc, pFunc){
|
||||
if(pSrc instanceof Array){
|
||||
for(var i=0; i < pSrc.length; i++)
|
||||
pSrc[i].name = 'script';
|
||||
|
||||
return DOM.anyload(pSrc);
|
||||
}
|
||||
|
||||
return DOM.anyload({
|
||||
name : 'script',
|
||||
src : pSrc,
|
||||
func : pFunc
|
||||
});
|
||||
},
|
||||
|
||||
/* Функция создаёт елемент style и записывает туда стили
|
||||
* @pParams_o - структура параметров, заполняеться таким
|
||||
* образом: {src: ' ',func: '', id: '', element: '', inner: ''}
|
||||
* все параметры опциональны
|
||||
*/
|
||||
|
||||
DOM.cssSet = function(pParams_o){
|
||||
pParams_o.name = 'style';
|
||||
pParams_o.parent = pParams_o.parent || document.head;
|
||||
|
||||
return DOM.anyload(pParams_o);
|
||||
},
|
||||
|
||||
/* Function loads external css files
|
||||
* @pParams_o - структура параметров, заполняеться таким
|
||||
* образом: {src: ' ',func: '', id: '', element: '', inner: ''}
|
||||
* все параметры опциональны
|
||||
*/
|
||||
DOM.cssLoad = function(pParams_o){
|
||||
if( Util.isArray(pParams_o) ){
|
||||
for(var i = 0, n = pParams_o.length; i < n; i++){
|
||||
pParams_o[i].name = 'link';
|
||||
pParams_o[i].parent = pParams_o.parent || document.head;
|
||||
}
|
||||
|
||||
return DOM.anyload(pParams_o);
|
||||
}
|
||||
|
||||
else if( Util.isString(pParams_o) )
|
||||
pParams_o = { src: pParams_o };
|
||||
|
||||
pParams_o.name = 'link';
|
||||
pParams_o.parent = pParams_o.parent || document.head;
|
||||
|
||||
return DOM.anyload(pParams_o);
|
||||
};
|
||||
|
||||
DOM.jqueryLoad = function(pCallBack){
|
||||
/* загружаем jquery: */
|
||||
DOM.jsload('//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js',{
|
||||
onload: function(){
|
||||
$ = window.jQuery;
|
||||
if(typeof pCallBack === 'function')
|
||||
pCallBack();
|
||||
},
|
||||
|
||||
onerror: function(){
|
||||
DOM.jsload('lib/client/jquery.js');
|
||||
|
||||
/*
|
||||
* if could not load jquery from google server
|
||||
* maybe we offline, load font from local
|
||||
* directory
|
||||
*/
|
||||
DOM.cssSet({id:'local-droids-font',
|
||||
element : document.head,
|
||||
inner : '@font-face {font-family: "Droid Sans Mono";' +
|
||||
'font-style: normal;font-weight: normal;' +
|
||||
'src: local("Droid Sans Mono"), local("DroidSansMono"),'+
|
||||
' url("font/DroidSansMono.woff") format("woff");}'
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
DOM.socketLoad = function(){
|
||||
DOM.jsload('lib/client/socket.js');
|
||||
};
|
||||
|
||||
/* DOM */
|
||||
|
||||
/**
|
||||
* Function search element by tag
|
||||
* @pTag - className
|
||||
* @pElement - element
|
||||
*/
|
||||
DOM.getByTag = function(pTag, pElement){
|
||||
return (pElement || document).getElementsByTagName(pTag);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function search element by id
|
||||
* @Id - className
|
||||
* @pElement - element
|
||||
*/
|
||||
DOM.getById = function(pId, pElement){
|
||||
return (pElement || document).getElementById(pId);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function search element by class name
|
||||
* @pClass - className
|
||||
* @pElement - element
|
||||
*/
|
||||
DOM.getByClass = function(pClass, pElement){
|
||||
return (pElement || document).getElementsByClassName(pClass);
|
||||
};
|
||||
|
||||
|
||||
DOM.Images = {
|
||||
/*
|
||||
* Function shows loading spinner
|
||||
* @pElem - top element of screen
|
||||
* pPosition = {top: true};
|
||||
*/
|
||||
showLoad : function(pPosition){
|
||||
var lRet_b = true;
|
||||
|
||||
LoadingImage = Images_o.loading();
|
||||
ErrorImage = Images_o.error();
|
||||
|
||||
DOM.hide(ErrorImage);
|
||||
|
||||
var lCurrent;
|
||||
if(pPosition){
|
||||
if(pPosition.top){
|
||||
lCurrent = DOM.getRefreshButton();
|
||||
if(lCurrent)
|
||||
lCurrent = lCurrent.parentElement;
|
||||
else
|
||||
lRet_b = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lCurrent = DOM.getCurrentFile();
|
||||
lCurrent = lCurrent.firstChild.nextSibling;
|
||||
}
|
||||
|
||||
/* show loading icon
|
||||
* if it not showed
|
||||
* and if error was not
|
||||
* heppen
|
||||
*/
|
||||
if(lRet_b){
|
||||
var lParent = LoadingImage.parentElement;
|
||||
if(!lParent ||
|
||||
(lParent && lParent !== lCurrent))
|
||||
lCurrent.appendChild(LoadingImage);
|
||||
|
||||
DOM.show(LoadingImage); /* показываем загрузку*/
|
||||
}
|
||||
|
||||
return lRet_b;
|
||||
},
|
||||
|
||||
hideLoad : function(){
|
||||
LoadingImage = Images_o.loading();
|
||||
DOM.hide(LoadingImage);
|
||||
},
|
||||
|
||||
showError : function(jqXHR, textStatus, errorThrown){
|
||||
LoadingImage = Images_o.loading();
|
||||
|
||||
ErrorImage = Images_o.error();
|
||||
|
||||
var lText;
|
||||
if(jqXHR.status === 404)
|
||||
lText = jqXHR.responseText;
|
||||
else
|
||||
lText = jqXHR.statusText;
|
||||
|
||||
/* если файла не существует*/
|
||||
if(!lText.indexOf('Error: ENOENT, '))
|
||||
lText = lText.replace('Error: ENOENT, n','N');
|
||||
|
||||
/* если не хватает прав для чтения файла*/
|
||||
else if(!lText.indexOf('Error: EACCES,'))
|
||||
lText = lText.replace('Error: EACCES, p','P');
|
||||
|
||||
DOM.show(ErrorImage);
|
||||
ErrorImage.title = lText;
|
||||
|
||||
var lParent = LoadingImage.parentElement;
|
||||
if(lParent)
|
||||
lParent.appendChild(ErrorImage);
|
||||
|
||||
DOM.hide(LoadingImage);
|
||||
|
||||
console.log(lText);
|
||||
}
|
||||
};
|
||||
|
||||
DOM.getCurrentFile = function(){
|
||||
var lCurrent = DOM.getByClass(getCurrentFile())[0];
|
||||
if(!lCurrent)
|
||||
DOM.addCloudStatus({
|
||||
code : -1,
|
||||
msg : 'Error: can not find ' +
|
||||
'CurrentFile ' +
|
||||
'in getCurrentFile'
|
||||
});
|
||||
|
||||
return lCurrent;
|
||||
};
|
||||
|
||||
DOM.getRefreshButton = function(){
|
||||
var lPanel = DOM.getPanel(),
|
||||
lRefresh = DOM.getByClass(CloudFunc.REFRESHICON, lPanel);
|
||||
|
||||
if (lRefresh.length)
|
||||
lRefresh = lRefresh[0];
|
||||
else {
|
||||
DOM.addCloudStatus({
|
||||
code : -3,
|
||||
msg : 'Error Refresh icon not found'
|
||||
});
|
||||
lRefresh = false;
|
||||
}
|
||||
|
||||
return lRefresh;
|
||||
};
|
||||
|
||||
DOM.setCurrentFile = function(pCurrentFile){
|
||||
var lRet_b = true;
|
||||
|
||||
if(!pCurrentFile){
|
||||
DOM.addCloudStatus({
|
||||
code : -1,
|
||||
msg : 'Error pCurrentFile in' +
|
||||
'setCurrentFile' +
|
||||
'could not be none'
|
||||
});
|
||||
|
||||
lRet_b = false;
|
||||
}
|
||||
var lCurrentFileWas = DOM.getCurrentFile();
|
||||
|
||||
if (pCurrentFile.className === 'path')
|
||||
pCurrentFile = pCurrentFile.nextSibling;
|
||||
|
||||
if (pCurrentFile.className === 'fm_header')
|
||||
pCurrentFile = pCurrentFile.nextSibling;
|
||||
|
||||
if(lCurrentFileWas)
|
||||
lUnSetCurrentFile(lCurrentFileWas);
|
||||
|
||||
DOM.addClass(pCurrentFile, getCurrentFile());
|
||||
|
||||
/* scrolling to current file */
|
||||
DOM.scrollIntoViewIfNeeded(pCurrentFile);
|
||||
|
||||
return lRet_b;
|
||||
};
|
||||
|
||||
var lUnSetCurrentFile = function(pCurrentFile){
|
||||
if(!pCurrentFile)
|
||||
DOM.addCloudStatus({
|
||||
code : -1,
|
||||
msg : 'Error pCurrentFile in' +
|
||||
'unSetCurrentFile' +
|
||||
'could not be none'
|
||||
});
|
||||
|
||||
var lRet_b = DOM.isCurrentFile(pCurrentFile);
|
||||
|
||||
if(lRet_b)
|
||||
DOM.removeClass(pCurrentFile, getCurrentFile());
|
||||
|
||||
return lRet_b;
|
||||
};
|
||||
|
||||
DOM.isCurrentFile = function(pCurrentFile){
|
||||
if(!pCurrentFile)
|
||||
DOM.addCloudStatus({
|
||||
code : -1,
|
||||
msg : 'Error pCurrentFile in' +
|
||||
'isCurrentFile' +
|
||||
'could not be none'
|
||||
});
|
||||
|
||||
var lCurrentFileClass = pCurrentFile.className,
|
||||
lIsCurrent = lCurrentFileClass.indexOf(getCurrentFile()) >= 0;
|
||||
|
||||
return lIsCurrent;
|
||||
};
|
||||
|
||||
|
||||
DOM.getCurrentLink = function(pCurrentFile){
|
||||
var lLink = DOM.getByTag('a',
|
||||
pCurrentFile || DOM.getCurrentFile()),
|
||||
|
||||
lRet = lLink.length > 0 ? lLink[0] : -1;
|
||||
|
||||
if(!lRet)
|
||||
DOM.addCloudStatus({
|
||||
code : -1,
|
||||
msg : 'Error current element do not contain links'
|
||||
});
|
||||
|
||||
return lRet;
|
||||
};
|
||||
|
||||
DOM.getCurrentName = function(pCurrentFile){
|
||||
var lLink = DOM.getCurrentLink(
|
||||
pCurrentFile || DOM.getCurrentFile());
|
||||
|
||||
if(!lLink)
|
||||
DOM.addCloudStatus({
|
||||
code : -1,
|
||||
msg : 'Error current element do not contain links'
|
||||
});
|
||||
else lLink = lLink.textContent;
|
||||
|
||||
return lLink;
|
||||
};
|
||||
|
||||
/* function getting panel active, or passive
|
||||
* @pPanel_o = {active: true}
|
||||
*/
|
||||
DOM.getPanel = function(pActive){
|
||||
var lPanel = DOM.getCurrentFile().parentElement;
|
||||
|
||||
/* if {active : false} getting passive panel */
|
||||
if(pActive && !pActive.active){
|
||||
var lId = lPanel.id === 'left' ? 'right' : 'left';
|
||||
lPanel = DOM.getById(lId);
|
||||
}
|
||||
|
||||
/* if two panels showed
|
||||
* then always work with passive
|
||||
* panel
|
||||
*/
|
||||
if(window.innerWidth < CloudCommander.MIN_ONE_PANEL_WIDTH)
|
||||
lPanel = DOM.getById('left');
|
||||
|
||||
|
||||
if(!lPanel)
|
||||
console.log('Error can not find Active Panel');
|
||||
|
||||
return lPanel;
|
||||
};
|
||||
|
||||
DOM.show = function(pElement){
|
||||
DOM.removeClass(pElement, 'hidden');
|
||||
};
|
||||
|
||||
DOM.showPanel = function(pActive){
|
||||
var lRet = true,
|
||||
lPanel = DOM.getPanel(pActive);
|
||||
|
||||
if(lPanel)
|
||||
DOM.show(lPanel);
|
||||
else
|
||||
lRet = false;
|
||||
|
||||
return lRet;
|
||||
};
|
||||
|
||||
DOM.hidePanel = function(pActive){
|
||||
var lRet = false,
|
||||
lPanel = DOM.getPanel(pActive);
|
||||
|
||||
if(lPanel)
|
||||
lRet = DOM.hide(lPanel);
|
||||
|
||||
return lRet;
|
||||
};
|
||||
|
||||
DOM.hide = function(pElement){
|
||||
return DOM.addClass(pElement, 'hidden');
|
||||
};
|
||||
|
||||
DOM.removeClass = function(pElement, pClass){
|
||||
var lRet_b = true,
|
||||
lClassList = pElement.classList;
|
||||
|
||||
if(pElement && lClassList)
|
||||
lClassList.remove(pClass);
|
||||
|
||||
else
|
||||
lRet_b = false;
|
||||
|
||||
return lRet_b;
|
||||
};
|
||||
|
||||
DOM.removeCurrent = function(pCurrent){
|
||||
var lParent = pCurrent.parentElement;
|
||||
|
||||
if(!pCurrent)
|
||||
pCurrent = DOM.getCurrentFile();
|
||||
var lName = DOM.getCurrentName(pCurrent);
|
||||
|
||||
if(pCurrent && lParent){
|
||||
if(lName !== '..'){
|
||||
var lNext = pCurrent.nextSibling;
|
||||
var lPrevious = pCurrent.previousSibling;
|
||||
if(lNext)
|
||||
DOM.setCurrentFile(lNext);
|
||||
else if(lPrevious)
|
||||
DOM.setCurrentFile(lPrevious);
|
||||
|
||||
lParent.removeChild(pCurrent);
|
||||
}
|
||||
else
|
||||
DOM.addCloudStatus({
|
||||
code : -1,
|
||||
msg : 'Could not remove parrent dir'
|
||||
});
|
||||
}
|
||||
else
|
||||
DOM.addCloudStatus({
|
||||
code : -1,
|
||||
msg : 'Current file (or parent of current) could not be empty'
|
||||
});
|
||||
|
||||
return pCurrent;
|
||||
};
|
||||
|
||||
DOM.scrollIntoViewIfNeeded = function(pElement){
|
||||
var lRet = true;
|
||||
|
||||
if(pElement && pElement.scrollIntoViewIfNeeded)
|
||||
pElement.scrollIntoViewIfNeeded();
|
||||
else
|
||||
lRet = false;
|
||||
|
||||
return lRet;
|
||||
};
|
||||
|
||||
|
||||
DOM.CloudStatus = [];
|
||||
|
||||
DOM.addCloudStatus = function(pStatus){
|
||||
DOM.CloudStatus[DOM.CloudStatus.length] = pStatus;
|
||||
};
|
||||
})();
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
var CloudCommander;
|
||||
var CloudCommander, Util, DOM;
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
|
|
@ -52,9 +52,7 @@ var CloudCommander;
|
|||
|
||||
KeyBinding.unSet = function(){keyBinded = false;};
|
||||
|
||||
KeyBinding.init = (function(){
|
||||
var Util = cloudcmd.Util;
|
||||
|
||||
KeyBinding.init = (function(){
|
||||
/* saving state of tabs varibles */
|
||||
var lTabPanel = {
|
||||
left : 0,
|
||||
|
|
@ -64,7 +62,7 @@ var CloudCommander;
|
|||
|
||||
var key_event = function(event){
|
||||
/* получаем выдленный файл*/
|
||||
var lCurrentFile = Util.getCurrentFile(),
|
||||
var lCurrentFile = DOM.getCurrentFile(),
|
||||
lName, i;
|
||||
/* если клавиши можно обрабатывать*/
|
||||
if(keyBinded && event){
|
||||
|
|
@ -74,7 +72,7 @@ var CloudCommander;
|
|||
if(lKeyCode === KEY.O && event.altKey){
|
||||
console.log('openning config window...');
|
||||
|
||||
Util.Images.showLoad({top: true});
|
||||
DOM.Images.showLoad({top: true});
|
||||
if ( Util.isFunction(cloudcmd.Config) )
|
||||
cloudcmd.Config();
|
||||
|
||||
|
|
@ -98,21 +96,21 @@ var CloudCommander;
|
|||
|
||||
try{
|
||||
/* changing parent panel of curent-file */
|
||||
var lPanel = Util.getPanel();
|
||||
var lPanel = DOM.getPanel();
|
||||
var lId = lPanel.id;
|
||||
|
||||
lTabPanel[lId] = lCurrentFile;
|
||||
|
||||
lPanel = Util.getPanel({active:false});
|
||||
lPanel = DOM.getPanel({active:false});
|
||||
lId = lPanel.id;
|
||||
|
||||
|
||||
if(lTabPanel[lId])
|
||||
Util.setCurrentFile(lTabPanel[lId]);
|
||||
DOM.setCurrentFile(lTabPanel[lId]);
|
||||
else{
|
||||
var lFirstFileOnList = Util.getByTag('li', lPanel)[2];
|
||||
var lFirstFileOnList = DOM.getByTag('li', lPanel)[2];
|
||||
|
||||
Util.setCurrentFile(lFirstFileOnList);
|
||||
DOM.setCurrentFile(lFirstFileOnList);
|
||||
}
|
||||
|
||||
}catch(error){console.log(error);}
|
||||
|
|
@ -124,11 +122,11 @@ var CloudCommander;
|
|||
|
||||
}
|
||||
else if(lKeyCode === KEY.Delete)
|
||||
Util.removeCurrent(lCurrentFile);
|
||||
DOM.removeCurrent(lCurrentFile);
|
||||
|
||||
/* if f3 or shift+f3 or alt+f3 pressed */
|
||||
else if(lKeyCode === KEY.F3){
|
||||
Util.Images.showLoad();
|
||||
DOM.Images.showLoad();
|
||||
|
||||
var lViewer = cloudcmd.Viewer;
|
||||
var lEditor = cloudcmd.Editor;
|
||||
|
|
@ -144,7 +142,7 @@ var CloudCommander;
|
|||
|
||||
/* if f4 pressed */
|
||||
else if(lKeyCode === KEY.F4) {
|
||||
Util.Images.showLoad();
|
||||
DOM.Images.showLoad();
|
||||
|
||||
if ( Util.isFunction(cloudcmd.Editor) )
|
||||
cloudcmd.Editor();
|
||||
|
|
@ -160,7 +158,7 @@ var CloudCommander;
|
|||
}
|
||||
|
||||
else if (lKeyCode === KEY.TRA){
|
||||
Util.Images.showLoad({top: true});
|
||||
DOM.Images.showLoad({top: true});
|
||||
if( Util.isFunction(cloudcmd.Terminal) )
|
||||
cloudcmd.Terminal();
|
||||
}
|
||||
|
|
@ -177,7 +175,7 @@ var CloudCommander;
|
|||
lCurrentFile = lCurrentFile.previousSibling;
|
||||
if(lCurrentFile){
|
||||
/* выделяем предыдущую строку*/
|
||||
Util.setCurrentFile(lCurrentFile);
|
||||
DOM.setCurrentFile(lCurrentFile);
|
||||
}
|
||||
|
||||
event.preventDefault();//запрет на дальнейшее действие
|
||||
|
|
@ -192,7 +190,7 @@ var CloudCommander;
|
|||
/* если это не последняя строка */
|
||||
if(lCurrentFile){
|
||||
/* выделяем следующую строку*/
|
||||
Util.setCurrentFile(lCurrentFile);
|
||||
DOM.setCurrentFile(lCurrentFile);
|
||||
|
||||
event.preventDefault();//запрет на дальнейшее действие
|
||||
}
|
||||
|
|
@ -213,7 +211,7 @@ var CloudCommander;
|
|||
/* set current file and
|
||||
* move scrollbar to top
|
||||
*/
|
||||
Util.setCurrentFile(lCurrentFile);
|
||||
DOM.setCurrentFile(lCurrentFile);
|
||||
|
||||
event.preventDefault();//запрет на дальнейшее действие
|
||||
}
|
||||
|
|
@ -229,7 +227,7 @@ var CloudCommander;
|
|||
/* set current file and
|
||||
* move scrollbar to bottom
|
||||
*/
|
||||
Util.setCurrentFile(lCurrentFile);
|
||||
DOM.setCurrentFile(lCurrentFile);
|
||||
event.preventDefault();//запрет на дальнейшее действие
|
||||
}
|
||||
|
||||
|
|
@ -237,14 +235,14 @@ var CloudCommander;
|
|||
* проматываем экран
|
||||
*/
|
||||
else if(lKeyCode === KEY.PAGE_DOWN){
|
||||
Util.getPanel().scrollByPages(1);
|
||||
DOM.getPanel().scrollByPages(1);
|
||||
|
||||
for(i=0; i<30; i++){
|
||||
if(!lCurrentFile.nextSibling) break;
|
||||
|
||||
lCurrentFile = lCurrentFile.nextSibling;
|
||||
}
|
||||
Util.setCurrentFile(lCurrentFile);
|
||||
DOM.setCurrentFile(lCurrentFile);
|
||||
|
||||
event.preventDefault();//запрет на дальнейшее действие
|
||||
}
|
||||
|
|
@ -253,7 +251,7 @@ var CloudCommander;
|
|||
* проматываем экран
|
||||
*/
|
||||
else if(lKeyCode === KEY.PAGE_UP){
|
||||
Util.getPanel().scrollByPages(-1);
|
||||
DOM.getPanel().scrollByPages(-1);
|
||||
|
||||
for(i=0; i<30; i++){
|
||||
if(!lCurrentFile.previousSibling) break;
|
||||
|
|
@ -269,7 +267,7 @@ var CloudCommander;
|
|||
}
|
||||
lCurrentFile = lCurrentFile.previousSibling;
|
||||
}
|
||||
Util.setCurrentFile(lCurrentFile);
|
||||
DOM.setCurrentFile(lCurrentFile);
|
||||
|
||||
event.preventDefault();//запрет на дальнейшее действие
|
||||
}
|
||||
|
|
@ -280,13 +278,13 @@ var CloudCommander;
|
|||
if(!lCurrentFile)return;
|
||||
|
||||
/* из него достаём спан с именем файла*/
|
||||
lName = Util.getByClass('name', lCurrentFile);
|
||||
lName = DOM.getByClass('name', lCurrentFile);
|
||||
|
||||
/* если нету (что вряд ли) - выходим*/
|
||||
if(!lName)return false;
|
||||
|
||||
/* достаём все ссылки*/
|
||||
var lATag = Util.getByTag('a', lName[0]);
|
||||
var lATag = DOM.getByTag('a', lName[0]);
|
||||
|
||||
/* если нету - выходим */
|
||||
if(!lATag)return false;
|
||||
|
|
@ -323,10 +321,10 @@ var CloudCommander;
|
|||
/* Программно нажимаем на кнопку перезагрузки
|
||||
* содержимого каталога
|
||||
*/
|
||||
var lRefreshIcon = Util.getRefreshButton();
|
||||
var lRefreshIcon = DOM.getRefreshButton();
|
||||
if(lRefreshIcon){
|
||||
/* получаем название файла*/
|
||||
var lSelectedName = Util.getCurrentName();
|
||||
var lSelectedName = DOM.getCurrentName();
|
||||
|
||||
/* если нашли элемент нажимаем него
|
||||
* а если не можем - нажимаем на
|
||||
|
|
@ -348,7 +346,7 @@ var CloudCommander;
|
|||
console.log('clearing cache...');
|
||||
console.log('press <alt>+q to remove all key-handlers');
|
||||
|
||||
var lClearCache = Util.getById('clear-cache');
|
||||
var lClearCache = DOM.getById('clear-cache');
|
||||
if(lClearCache && lClearCache.onclick)
|
||||
lClearCache.onclick();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
/* Module contain additional system functional */
|
||||
var Util, exports;
|
||||
|
||||
(function(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue