From b6a7c2c7d1ebbf57a0d24b1dd1e4c18203aeaf7a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 23 Apr 2013 10:27:20 +0300 Subject: [PATCH 001/239] added more demos --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9131212b..c59a8f6a 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,11 @@ Cloud Commander v0.2.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] DEMO: [cloudfoundry] (https://cloudcmd.cloudfoundry.com "cloudfoundry"), [appfog] (https://cloudcmd.aws.af.cm "appfog"), -[jitsu] (https://cloudcmd.jit.su "jitsu"). +[jitsu] (https://cloudcmd.jit.su "jitsu"), +[nitrous](http://cloudcmd-5950.euw1.actionbox.io:3000/) +([1](http://cloudcmd-5950.euw1.actionbox.io:8888/), +[2](http://cloudcmd-5950.euw1.actionbox.io:8080/), +[3](http://cloudcmd-5950.euw1.actionbox.io:4000/)). Google PageSpeed Score : [100](//developers.google.com/speed/pagespeed/insights#url=http_3A_2F_2Fcloudcmd.aws.af.cm_2F&mobile=false "score") (out of 100) (or 96 if js or css minification disabled in config.json). From d1e13d7917228f06e37bbcb7c7e2e1beb794a74a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 23 Apr 2013 03:33:33 -0400 Subject: [PATCH 002/239] changed jquery cdn to one with https suport jquery.com -> google cdn --- ChangeLog | 5 +++++ cloudcmd.js | 2 +- lib/client/dom.js | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 65146bfd..29624af4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012.*.*, v0.2.1 + +* Changed jquery cdn to one with https suport jquery.com -> google cdn. + + 2012.04.22, v0.2.0 * Added alerting about errors. diff --git a/cloudcmd.js b/cloudcmd.js index 64716bbf..10eae0d5 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -83,7 +83,7 @@ function appCacheProcessing(){ var lFONT_REMOTE = '//themes.googleusercontent.com/static/fonts/droidsansmono/v4/ns-m2xQYezAtqh7ai59hJUYuTAAIFFn5GTWtryCmBQ4.woff', lFONT_LOCAL = './font/DroidSansMono.woff', - lJQUERY_REMOTE = 'http://code.jquery.com/jquery-2.0.0.min.js', + lJQUERY_REMOTE = '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js', lJQUERY_LOCAL = './lib/client/jquery.js', lFiles = [{}, {}]; diff --git a/lib/client/dom.js b/lib/client/dom.js index 2584addd..45134981 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -834,7 +834,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; */ DOM.jqueryLoad = function(pCallBack){ /* загружаем jquery: */ - DOM.jsload('http://code.jquery.com/jquery-2.0.0.min.js',{ + DOM.jsload('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js',{ onload: Util.retExec(pCallBack), onerror: function(){ From e81bb22565cf4cb117bcddf3bc290421e3cccbce Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 25 Apr 2013 04:47:42 -0400 Subject: [PATCH 003/239] added Access-Control-Allow-Origin header --- ChangeLog | 2 ++ lib/server/main.js | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 29624af4..f682129f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * Changed jquery cdn to one with https suport jquery.com -> google cdn. +* Added Access-Control-Allow-Origin header. + 2012.04.22, v0.2.0 diff --git a/lib/server/main.js b/lib/server/main.js index 79c0cceb..dd900007 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -193,11 +193,11 @@ if( Util.isContainStr(p.query, 'download') ) lType = 'application/octet-stream'; - lRet = { - 'Content-Type': lType + lContentEncoding, - 'last-modified': new Date().toString(), - 'Vary': 'Accept-Encoding' + 'Access-Control-Allow-Origin' : '*', + 'Content-Type' : lType + lContentEncoding, + 'last-modified' : new Date().toString(), + 'Vary' : 'Accept-Encoding' }; if( !Util.strCmp(lExt, '.appcache') && p.cache) From dc6295af2a4c45758ce1788a966f70690feabeea Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sun, 5 May 2013 04:06:57 -0400 Subject: [PATCH 004/239] added functions in DOM module createEvent and dispatch --- ChangeLog | 5 +++ lib/client/dom.js | 95 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/ChangeLog b/ChangeLog index f682129f..ad470a90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,11 @@ * Added Access-Control-Allow-Origin header. +* Added functions in DOM module: createEvent +(createKeyEvent, createClickEvent, createDblClickEvent), +dispatch +(dispatchKeyEvent, dispatchClickEvent, dispatchDblClickEvent) + 2012.04.22, v0.2.0 diff --git a/lib/client/dom.js b/lib/client/dom.js index 45134981..d8ebddc0 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -270,6 +270,101 @@ var CloudCommander, Util, DOM = {}, CloudFunc; return DOM.addListener('error', pListener, pElement, pUseCapture); }; + /** + * crossbrowser create event + * + * @param pEventName + * @param pKeyCode - not necessarily + */ + DOM.createEvent = function(pEventName, pKeyCode){ + var lEvent = document.createEvent('Event'); + + lEvent.initEvent(pEventName, true, true); + + if(pKeyCode) + lEvent.keyCode = pKeyCode; + + lEvent.isDefaultPrevented = function(){ + return this.defaultPrevented; + }; + + return lEvent; + }; + + + /** + * create keydown event + * + * @param pKeyCode + */ + DOM.createKeyEvent = function(pKeyCode){ + return DOM.createEvent('keydown', pKeyCode); + }; + + /** + * create click event + * + * @param pKeyCode + */ + DOM.createClickEvent = function(){ + return DOM.createEvent('click'); + }; + + /** + * create click event + * + * @param pKeyCode + */ + DOM.createDblClickEvent = function(){ + return DOM.createEvent('dblclick'); + }; + + /** + * dispatch event + * + * @param pEvent + */ + DOM.dispatch = function(pEvent, pElement){ + return (pElement || window).dispatchEvent(pEvent); + }; + + /** + * dispatch keydown event + * + * @param pKeyCode + * @param pElement + */ + DOM.dispatchKeyEvent = function(pKeyCode, pElement){ + var lEvent = DOM.createKeyEvent(pKeyCode), + lRet = DOM.dispatch(lEvent, pElement); + + return lRet; + }; + + /** + * dispatch click event + * + * @param pElement + */ + DOM.dispatchClickEvent = function(pElement){ + var lEvent = DOM.createClickEvent(), + lRet = DOM.dispatch(lEvent, pElement); + + return lRet; + }; + + /** + * dispatch dblclick event + * + * @param pElement + */ + DOM.dispatchDblClickEvent = function(pElement){ + var lEvent = DOM.createDblClickEvent(), + lRet = DOM.dispatch(lEvent, pElement); + + return lRet; + }; + /** * load file countent thrue ajax From af00d74e075c5e3d344aa0ca33c43b419366776d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 6 May 2013 06:25:41 -0400 Subject: [PATCH 005/239] Moved all methods of DOM module to prototype --- json/config.json | 2 +- lib/client/dom.js | 810 +++++++++++++++++++++++----------------------- 2 files changed, 413 insertions(+), 399 deletions(-) diff --git a/json/config.json b/json/config.json index 5f9fc6cf..3a8b6f66 100644 --- a/json/config.json +++ b/json/config.json @@ -2,7 +2,7 @@ "api_url" : "/api/v1", "appcache" : false, "minification" : { - "js" : true, + "js" : false, "css" : true, "html" : true, "img" : true diff --git a/lib/client/dom.js b/lib/client/dom.js index d8ebddc0..73b37bed 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1,41 +1,116 @@ -var CloudCommander, Util, DOM = {}, CloudFunc; +var CloudCommander, Util, DOM, CloudFunc; -(function(Util, DOM){ +(function(Util){ 'use strict'; - var CURRENT_FILE = 'current-file', - SELECTED_FILE = 'selected-file', + var DOMConstructor = function(){}, + CURRENT_FILE = 'current-file', + SELECTED_FILE = 'selected-file', XMLHTTP, Title, /* Обьект содержит функции для отображения картинок */ - Images = function (){ - function getImage(pName){ - var lId = pName + '-image', - lE = DOM.getById(lId); - if (!lE) - lE = DOM.anyload({ - name : 'span', - className : 'icon ' + pName, - id : lId, - not_append : true - }); + ImagesProto = function(){ + var LImagesProto = function (){ + function getImage(pName){ + var lId = pName + '-image', + lE = DOMProto.getById(lId); + + if (!lE) + lE = DOMProto.anyload({ + name : 'span', + className : 'icon ' + pName, + id : lId, + not_append : true + }); + + return lE; + } + + /* Функция создаёт картинку загрузки */ + this.loading = function(){ + return getImage('loading'); + }; - return lE; - } - - /* Функция создаёт картинку загрузки*/ - this.loading = function(){ - return getImage('loading'); + /* Функция создаёт картинку ошибки загрузки */ + this.error = function(){ + return getImage('error'); + }; + }, + lImages = new LImagesProto(); + /** + * Function shows loading spinner + * pPosition = {top: true}; + */ + this.showLoad = function(pPosition){ + var lRet_b, + lLoadingImage = lImages.loading(), + lErrorImage = lImages.error(); + + DOMProto.hide(lErrorImage); + + var lCurrent; + if(pPosition && pPosition.top) + lCurrent = DOMProto.getRefreshButton().parentElement; + else{ + var lFile = DOMProto.getCurrentFile(); + lCurrent = DOMProto.getByClass('name', lFile)[0]; + } + + /* show loading icon if it not showed */ + + var lParent = lLoadingImage.parentElement; + if(!lParent || (lParent && lParent !== lCurrent)) + lCurrent.appendChild(lLoadingImage); + + lRet_b = DOMProto.show(lLoadingImage); /* показываем загрузку*/ + + return lRet_b; }; - /* Функция создаёт картинку ошибки загрузки*/ - this.error = function(){ - return getImage('error'); + /** + * hide load image + */ + this.hideLoad = function(){ + + DOMProto.hide( lImages.loading() ); + }; + + /** + * show error image (usualy after error on ajax request) + */ + this.showError = function(jqXHR, textStatus, errorThrown){ + var lLoadingImage = lImages.loading(), + lErrorImage = lImages.error(), + lResponce = jqXHR.responseText, + lStatusText = jqXHR.statusText, + lStatus = jqXHR.status, + lText = (lStatus === 404 ? lResponce : lStatusText); + + /* если файла не существует*/ + if( Util.isContainStr(lText, 'Error: ENOENT, ') ) + lText = lText.replace('Error: ENOENT, n','N'); + + /* если не хватает прав для чтения файла*/ + else if( Util.isContainStr(lText, 'Error: EACCES,') ) + lText = lText.replace('Error: EACCES, p','P'); + + + DOMProto.show(lErrorImage); + lErrorImage.title = lText; + + var lParent = lLoadingImage.parentElement; + if(lParent) + lParent.appendChild(lErrorImage); + + DOMProto.hide(lLoadingImage); + + Util.log(lText); + + setTimeout( Util.retExec(alert, lText), 100); }; }, - /* Обьект содержит функции для работы с CloudCmd API */ - RESTfull = function(){ + RESTfullProto = function(){ this.delete = function(pUrl, pData, pCallBack, pQuery){ sendRequest({ method : 'DELETE', @@ -87,7 +162,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; if(lRet){ var p = pParams; - DOM.Images.showLoad( p.imgPosition ); + DOMProto.Images.showLoad( p.imgPosition ); CloudCommander.getConfig(function(pConfig){ var lData; @@ -100,13 +175,13 @@ var CloudCommander, Util, DOM = {}, CloudFunc; lData = p.data; p.url = pConfig && pConfig.api_url + p.url, - DOM.ajax({ + DOMProto.ajax({ method : p.method, url : p.url, data : lData, - error : DOM.Images.showError, + error : DOMProto.Images.showError, success : function(pData){ - DOM.Images.hideLoad(); + DOMProto.Images.hideLoad(); Util.log(pData); Util.exec(p.callback, pData); } @@ -116,12 +191,89 @@ var CloudCommander, Util, DOM = {}, CloudFunc; return lRet; } - }; + }, + DOMTreeProto = function(){ + /** + * add class to element + * + * @param pElement + * @param pClass + */ + this.addClass = function(pElement, pClass){ + var lRet; + + if(pElement){ + var lClassList = pElement.classList; + lRet = !this.isContainClass(pElement, pClass); + + if( lRet ) + lClassList.add(pClass); + } + + return lRet; + }; + + /** + * check class of element + * + * @param pElement + * @param pClass + */ + this.isContainClass = function(pElement, pClass){ + var lRet, + lClassList = pElement && pElement.classList; + + if( lClassList ) + lRet = lClassList.contains(pClass); + + return lRet; + }; + + /** + * Function search element by tag + * @param pTag - className + * @param pElement - element + */ + this.getByTag = function(pTag, pElement){ + return (pElement || document).getElementsByTagName(pTag); + }; + + /** + * Function search element by id + * @param Id - className + * @param pElement - element + */ + this.getById = function(pId, pElement){ + return (pElement || document).getElementById(pId); + }; + + /** + * Function search element by class name + * @param pClass - className + * @param pElement - element + */ + this.getByClass = function(pClass, pElement){ + return (pElement || document).getElementsByClassName(pClass); + }; + }, + RESTfull = function(){}, + Images = function(){}, + DOMTreeConstructor = function(){}, + DOMTree, + DOMProto; - Images = new Images(); + DOMTreeConstructor.prototype= new DOMTreeProto(); + DOMTree = new DOMTreeConstructor(); - DOM.RESTfull = new RESTfull(); + DOMProto = new DOMTreeConstructor(); + DOMConstructor.prototype = DOMProto; + DOM = new DOMConstructor(); + RESTfull.prototype = new RESTfullProto(); + DOMProto.RESTfull = new RESTfull(); + + Images.prototype = new ImagesProto(); + DOMProto.Images = new Images(); /** * private function thet unset currentfile @@ -129,49 +281,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @pCurrentFile */ function unsetCurrentFile(pCurrentFile){ - var lRet = DOM.isCurrentFile(pCurrentFile); + var lRet = DOMProto.isCurrentFile(pCurrentFile); if(lRet) - DOM.removeClass(pCurrentFile, CURRENT_FILE); + DOMProto.removeClass(pCurrentFile, CURRENT_FILE); return lRet; } - /** - * add class to element - * - * @param pElement - * @param pClass - */ - DOM.addClass = function(pElement, pClass){ - var lRet; - - if(pElement){ - var lClassList = pElement.classList; - lRet = !DOM.isContainClass(pElement, pClass); - - if( lRet ) - lClassList.add(pClass); - } - - return lRet; - }; - - /** - * check class of element - * - * @param pElement - * @param pClass - */ - DOM.isContainClass = function(pElement, pClass){ - var lRet, - lClassList = pElement && pElement.classList; - - if( lClassList ) - lRet = lClassList.contains(pClass); - - return lRet; - }; /** * safe add event listener @@ -181,7 +298,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pUseCapture * @param pElement {document by default} */ - DOM.addListener = function(pType, pListener, pElement, pUseCapture){ + DOMProto.addListener = function(pType, pListener, pElement, pUseCapture){ var lRet = this, lElement = (pElement || window); @@ -203,14 +320,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pUseCapture * @param pElement {document by default} */ - DOM.addOneTimeListener = function(pType, pListener, pElement, pUseCapture){ + DOMProto.addOneTimeListener = function(pType, pListener, pElement, pUseCapture){ var lRet = this, lOneTime = function (pEvent){ - DOM.removeListener(pType, lOneTime, pElement, pUseCapture); + DOMProto.removeListener(pType, lOneTime, pElement, pUseCapture); pListener(pEvent); }; - DOM.addListener(pType, lOneTime, pElement, pUseCapture); + DOMProto.addListener(pType, lOneTime, pElement, pUseCapture); return lRet; }; @@ -223,7 +340,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pUseCapture * @param pElement {document by default} */ - DOM.removeListener = function(pType, pListener, pElement, pUseCapture){ + DOMProto.removeListener = function(pType, pListener, pElement, pUseCapture){ var lRet = this; (pElement || window).removeEventListener( @@ -242,8 +359,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pListener * @param pUseCapture */ - DOM.addKeyListener = function(pListener, pElement, pUseCapture){ - return DOM.addListener('keydown', pListener, pElement, pUseCapture); + DOMProto.addKeyListener = function(pListener, pElement, pUseCapture){ + return DOMProto.addListener('keydown', pListener, pElement, pUseCapture); }; /** @@ -252,12 +369,12 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pListener * @param pUseCapture */ - DOM.addClickListener = function(pListener, pElement, pUseCapture){ - return DOM.addListener('click', pListener, pElement, pUseCapture); + DOMProto.addClickListener = function(pListener, pElement, pUseCapture){ + return DOMProto.addListener('click', pListener, pElement, pUseCapture); }; - DOM.addContextMenuListener = function(pListener, pElement, pUseCapture){ - return DOM.addListener('contextmenu', pListener, pElement, pUseCapture); + DOMProto.addContextMenuListener = function(pListener, pElement, pUseCapture){ + return DOMProto.addListener('contextmenu', pListener, pElement, pUseCapture); }; /** @@ -266,8 +383,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pListener * @param pUseCapture */ - DOM.addErrorListener = function(pListener, pElement, pUseCapture){ - return DOM.addListener('error', pListener, pElement, pUseCapture); + DOMProto.addErrorListener = function(pListener, pElement, pUseCapture){ + return DOMProto.addListener('error', pListener, pElement, pUseCapture); }; /** @@ -276,7 +393,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pEventName * @param pKeyCode - not necessarily */ - DOM.createEvent = function(pEventName, pKeyCode){ + DOMProto.createEvent = function(pEventName, pKeyCode){ var lEvent = document.createEvent('Event'); lEvent.initEvent(pEventName, true, true); @@ -297,8 +414,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pKeyCode */ - DOM.createKeyEvent = function(pKeyCode){ - return DOM.createEvent('keydown', pKeyCode); + DOMProto.createKeyEvent = function(pKeyCode){ + return DOMProto.createEvent('keydown', pKeyCode); }; /** @@ -306,8 +423,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pKeyCode */ - DOM.createClickEvent = function(){ - return DOM.createEvent('click'); + DOMProto.createClickEvent = function(){ + return DOMProto.createEvent('click'); }; /** @@ -315,8 +432,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pKeyCode */ - DOM.createDblClickEvent = function(){ - return DOM.createEvent('dblclick'); + DOMProto.createDblClickEvent = function(){ + return DOMProto.createEvent('dblclick'); }; /** @@ -324,7 +441,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pEvent */ - DOM.dispatch = function(pEvent, pElement){ + DOMProto.dispatch = function(pEvent, pElement){ return (pElement || window).dispatchEvent(pEvent); }; @@ -334,9 +451,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pKeyCode * @param pElement */ - DOM.dispatchKeyEvent = function(pKeyCode, pElement){ - var lEvent = DOM.createKeyEvent(pKeyCode), - lRet = DOM.dispatch(lEvent, pElement); + DOMProto.dispatchKeyEvent = function(pKeyCode, pElement){ + var lEvent = DOMProto.createKeyEvent(pKeyCode), + lRet = DOMProto.dispatch(lEvent, pElement); return lRet; }; @@ -346,9 +463,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pElement */ - DOM.dispatchClickEvent = function(pElement){ - var lEvent = DOM.createClickEvent(), - lRet = DOM.dispatch(lEvent, pElement); + DOMProto.dispatchClickEvent = function(pElement){ + var lEvent = DOMProto.createClickEvent(), + lRet = DOMProto.dispatch(lEvent, pElement); return lRet; }; @@ -358,9 +475,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pElement */ - DOM.dispatchDblClickEvent = function(pElement){ - var lEvent = DOM.createDblClickEvent(), - lRet = DOM.dispatch(lEvent, pElement); + DOMProto.dispatchDblClickEvent = function(pElement){ + var lEvent = DOMProto.createDblClickEvent(), + lRet = DOMProto.dispatch(lEvent, pElement); return lRet; }; @@ -371,7 +488,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pParams */ - DOM.ajax = function(pParams){ + DOMProto.ajax = function(pParams){ var lRet = Util.checkObjTrue(pParams, ['url', 'success']); if(lRet){ var p = pParams, @@ -420,7 +537,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * работы с LocalStorage, webdb, * indexed db etc. */ - DOM.Cache = function(){ + DOMProto.Cache = function(){ /* приватный переключатель возможности работы с кэшем */ var CacheAllowed; @@ -493,15 +610,15 @@ var CloudCommander, Util, DOM = {}, CloudFunc; }; }; - DOM.Cache = new DOM.Cache(); + DOMProto.Cache = new DOMProto.Cache(); /** * create new folder * * @pCurrentFile */ - DOM.promptNewDir = function(){ - DOM.promptNewFile('directory', '?dir'); + DOMProto.promptNewDir = function(){ + DOMProto.promptNewFile('directory', '?dir'); }; /** @@ -509,9 +626,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrentFile */ - DOM.promptNewFile = function(pTypeName, pType){ - var lName = DOM.getCurrentName(), - lDir = DOM.getCurrentDirPath(), + DOMProto.promptNewFile = function(pTypeName, pType){ + var lName = DOMProto.getCurrentName(), + lDir = DOMProto.getCurrentDirPath(), lMsg = 'New ' + pTypeName || 'File', lType = Util.isString(pType) ? pType : ''; @@ -521,7 +638,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; lName = prompt(lMsg, lName); if(lName) - DOM.RESTfull.save(lDir + lName + lType, null, CloudCommander.refresh); + DOMProto.RESTfull.save(lDir + lName + lType, null, CloudCommander.refresh); }; @@ -531,14 +648,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrentFile */ - DOM.promptDeleteSelected = function(pCurrentFile){ + DOMProto.promptDeleteSelected = function(pCurrentFile){ var lRet, lCurrent, lQuery, lMsg, lName = '', lMsgAsk = 'Do you really want to delete the ', lMsgSel = 'selected ', - lFiles = DOM.getSelectedFiles(), - lSelected = DOM.getSelectedNames(lFiles), + lFiles = DOMProto.getSelectedFiles(), + lSelected = DOMProto.getSelectedNames(lFiles), i, n = lSelected && lSelected.length; if(n > 1){ @@ -557,9 +674,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; if( pCurrentFile && !pCurrentFile.pType) lCurrent = pCurrentFile; else - lCurrent = DOM.getCurrentFile(); + lCurrent = DOMProto.getCurrentFile(); - lIsDir = DOM.isCurrentIsDir(lCurrent); + lIsDir = DOMProto.isCurrentIsDir(lCurrent); if(lIsDir){ lQuery = '?dir'; @@ -570,7 +687,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; lType += ' '; - lName = DOM.getCurrentName(lCurrent); + lName = DOMProto.getCurrentName(lCurrent); lMsg = lMsgAsk + lMsgSel + lType + lName + '?'; } @@ -582,24 +699,24 @@ var CloudCommander, Util, DOM = {}, CloudFunc; var lUrl; if(lCurrent) - lUrl = DOM.getCurrentPath(lCurrent); + lUrl = DOMProto.getCurrentPath(lCurrent); else{ - lUrl = DOM.getCurrentDirPath(); + lUrl = DOMProto.getCurrentDirPath(); lCurrent = lFiles[0]; } if(lCurrent || lSelected) - DOM.RESTfull.delete(lUrl, lSelected, function(){ + DOMProto.RESTfull.delete(lUrl, lSelected, function(){ if(n > 1) - DOM.deleteSelected(lFiles); + DOMProto.deleteSelected(lFiles); else - DOM.deleteCurrent(lCurrent); + DOMProto.deleteCurrent(lCurrent); var lDir = CloudFunc.removeLastSlash( - DOM.getCurrentDirPath() + DOMProto.getCurrentDirPath() ); - DOM.Cache.remove(lDir); + DOMProto.Cache.remove(lDir); }, lQuery); return lCurrent; @@ -614,7 +731,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * Example: http://domain.com/1.js -> 1_js */ - DOM.getIdBySrc = function(pSrc){ + DOMProto.getIdBySrc = function(pSrc){ var lRet = Util.isString(pSrc); if(lRet){ @@ -639,26 +756,26 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pParams_a * @param pFunc - onload function */ - DOM.anyLoadOnLoad = function(pParams_a, pFunc){ + DOMProto.anyLoadOnLoad = function(pParams_a, pFunc){ var lRet = this; if( Util.isArray(pParams_a) ) { var lParam = pParams_a.pop(), lFunc = function(){ - DOM.anyLoadOnLoad(pParams_a, pFunc); + DOMProto.anyLoadOnLoad(pParams_a, pFunc); }; if( Util.isString(lParam) ) lParam = { src : lParam }; else if( Util.isArray(lParam) ){ - DOM.anyLoadInParallel(lParam, lFunc); + DOMProto.anyLoadInParallel(lParam, lFunc); } if(lParam && !lParam.func){ lParam.func = lFunc; - DOM.anyload(lParam); + DOMProto.anyload(lParam); }else Util.exec(pFunc); @@ -675,7 +792,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pParams_a * @param pFunc - onload function */ - DOM.anyLoadInParallel = function(pParams_a, pFunc){ + DOMProto.anyLoadInParallel = function(pParams_a, pFunc){ var lRet = this, lDone = [], @@ -702,7 +819,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; var lFunc = lParam.func; lParam.func = Util.retExec(lDoneFunc, lFunc); - DOM.anyload(lParam); + DOMProto.anyload(lParam); } } @@ -727,7 +844,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * not_append - false by default * } */ - DOM.anyload = function(pParams_o){ + DOMProto.anyload = function(pParams_o){ if( !pParams_o ) return; @@ -738,7 +855,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; 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]); + lElements_a[i] = DOMProto.anyload(pParams_o[i]); return lElements_a; } @@ -761,9 +878,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; } /* убираем путь к файлу, оставляя только название файла */ if(!lID && lSrc) - lID = DOM.getIdBySrc(lSrc); + lID = DOMProto.getIdBySrc(lSrc); - var lElement = DOM.getById(lID); + var lElement = DOMProto.getById(lID); /* если скрипт еще не загружен */ if(!lElement){ @@ -809,8 +926,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; */ var lLoad = function(pEvent){ - DOM.removeListener('load', lLoad, lElement); - DOM.removeListener('error', lError, lElement); + DOMProto.removeListener('load', lLoad, lElement); + DOMProto.removeListener('error', lError, lElement); Util.exec(lFunc, pEvent); }, @@ -818,7 +935,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; lError = function(){ lParent.removeChild(lElement); - DOM.Images.showError({ + DOMProto.Images.showError({ responseText: 'file ' + lSrc + ' could not be loaded', @@ -828,8 +945,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; Util.exec(lOnError); }; - DOM.addListener('load', lLoad, lElement); - DOM.addErrorListener(lError, lElement); + DOMProto.addListener('load', lLoad, lElement); + DOMProto.addErrorListener(lError, lElement); if(lStyle) lElement.style.cssText = lStyle; @@ -858,15 +975,15 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pSrc * @param pFunc */ - DOM.jsload = function(pSrc, pFunc){ + DOMProto.jsload = function(pSrc, pFunc){ if( Util.isArray(pSrc) ){ for(var i=0; i < pSrc.length; i++) pSrc[i].name = 'script'; - return DOM.anyload(pSrc); + return DOMProto.anyload(pSrc); } - return DOM.anyload({ + return DOMProto.anyload({ name : 'script', src : pSrc, func : pFunc @@ -876,9 +993,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * returns jsload functions */ - DOM.retJSLoad = function(pSrc, pFunc){ + DOMProto.retJSLoad = function(pSrc, pFunc){ var lRet = function(){ - return DOM.jsload(pSrc, pFunc); + return DOMProto.jsload(pSrc, pFunc); }; return lRet; @@ -891,11 +1008,11 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * образом: {src: ' ',func: '', id: '', element: '', inner: ''} * все параметры опциональны */ - DOM.cssSet = function(pParams_o){ + DOMProto.cssSet = function(pParams_o){ pParams_o.name = 'style'; pParams_o.parent = pParams_o.parent || document.head; - return DOM.anyload(pParams_o); + return DOMProto.anyload(pParams_o); }, /** @@ -904,14 +1021,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * образом: {src: ' ',func: '', id: '', element: '', inner: ''} * все параметры опциональны */ - DOM.cssLoad = function(pParams_o){ + DOMProto.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); + return DOMProto.anyload(pParams_o); } else if( Util.isString(pParams_o) ) @@ -920,25 +1037,25 @@ var CloudCommander, Util, DOM = {}, CloudFunc; pParams_o.name = 'link'; pParams_o.parent = pParams_o.parent || document.head; - return DOM.anyload(pParams_o); + return DOMProto.anyload(pParams_o); }; /** * load jquery from google cdn or local copy * @param pCallBack */ - DOM.jqueryLoad = function(pCallBack){ + DOMProto.jqueryLoad = function(pCallBack){ /* загружаем jquery: */ - DOM.jsload('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js',{ + DOMProto.jsload('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js',{ onload: Util.retExec(pCallBack), onerror: function(){ - DOM.jsload('/lib/client/jquery.js'); + DOMProto.jsload('/lib/client/jquery.js'); /* if could not load jquery from google server * maybe we offline, load font from local * directory */ - DOM.cssSet({ + DOMProto.cssSet({ id :'local-droids-font', element : document.head, inner : '@font-face {font-family: "Droid Sans Mono";' + @@ -954,123 +1071,20 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * load socket.io * @param pCallBack */ - DOM.socketLoad = function(pCallBack){ - DOM.jsload('/lib/client/socket.js', Util.retExec(pCallBack) ); + DOMProto.socketLoad = function(pCallBack){ + DOMProto.jsload('/lib/client/socket.js', Util.retExec(pCallBack) ); }; - /* DOM */ - - /** - * Function search element by tag - * @param pTag - className - * @param pElement - element - */ - DOM.getByTag = function(pTag, pElement){ - return (pElement || document).getElementsByTagName(pTag); - }; - - /** - * Function search element by id - * @param Id - className - * @param pElement - element - */ - DOM.getById = function(pId, pElement){ - return (pElement || document).getElementById(pId); - }; - - /** - * Function search element by class name - * @param pClass - className - * @param pElement - element - */ - DOM.getByClass = function(pClass, pElement){ - return (pElement || document).getElementsByClassName(pClass); - }; - - - DOM.Images = { - /** - * Function shows loading spinner - * pPosition = {top: true}; - */ - showLoad : function(pPosition){ - var lRet_b, - lLoadingImage = Images.loading(), - lErrorImage = Images.error(); - - DOM.hide(lErrorImage); - - var lCurrent; - if(pPosition && pPosition.top) - lCurrent = DOM.getRefreshButton().parentElement; - else{ - var lFile = DOM.getCurrentFile(); - lCurrent = DOM.getByClass('name', lFile)[0]; - } - - /* show loading icon if it not showed */ - - var lParent = lLoadingImage.parentElement; - if(!lParent || (lParent && lParent !== lCurrent)) - lCurrent.appendChild(lLoadingImage); - - lRet_b = DOM.show(lLoadingImage); /* показываем загрузку*/ - - return lRet_b; - }, - - /** - * hide load image - */ - hideLoad : function(){ - - DOM.hide( Images.loading() ); - }, - - /** - * show error image (usualy after error on ajax request) - */ - showError : function(jqXHR, textStatus, errorThrown){ - var lLoadingImage = Images.loading(), - lErrorImage = Images.error(), - lResponce = jqXHR.responseText, - lStatusText = jqXHR.statusText, - lStatus = jqXHR.status, - lText = (lStatus === 404 ? lResponce : lStatusText); - - /* если файла не существует*/ - if( Util.isContainStr(lText, 'Error: ENOENT, ') ) - lText = lText.replace('Error: ENOENT, n','N'); - - /* если не хватает прав для чтения файла*/ - else if( Util.isContainStr(lText, 'Error: EACCES,') ) - lText = lText.replace('Error: EACCES, p','P'); - - - DOM.show(lErrorImage); - lErrorImage.title = lText; - - var lParent = lLoadingImage.parentElement; - if(lParent) - lParent.appendChild(lErrorImage); - - DOM.hide(lLoadingImage); - - Util.log(lText); - - setTimeout( Util.retExec(alert, lText), 100); - } - }; /** * get current direcotory name */ - DOM.getCurrentDirName = function(){ + DOMProto.getCurrentDirName = function(){ var lRet, lSubstr, - lPanel = DOM.getPanel(), + lPanel = DOMProto.getPanel(), /* получаем имя каталога в котором находимся */ - lHref = DOM.getByClass('path', lPanel); + lHref = DOMProto.getByClass('path', lPanel); lHref = lHref[0].textContent; @@ -1084,9 +1098,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * get current direcotory path */ - DOM.getCurrentDirPath = function(pPanel){ - var lPanel = pPanel || DOM.getPanel(), - lPath = DOM.getByClass('path', lPanel)[0], + DOMProto.getCurrentDirPath = function(pPanel){ + var lPanel = pPanel || DOMProto.getPanel(), + lPath = DOMProto.getByClass('path', lPanel)[0], lRet; if(lPath) @@ -1098,9 +1112,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * get current direcotory path */ - DOM.getNotCurrentDirPath = function(){ - var lPanel = DOM.getPanel(true), - lPath = DOM.getByClass('path', lPanel)[0], + DOMProto.getNotCurrentDirPath = function(){ + var lPanel = DOMProto.getPanel(true), + lPath = DOMProto.getByClass('path', lPanel)[0], lRet; if(lPath) @@ -1114,8 +1128,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrentFile */ - DOM.getCurrentFile = function(){ - var lRet = DOM.getByClass( CURRENT_FILE )[0]; + DOMProto.getCurrentFile = function(){ + var lRet = DOMProto.getByClass( CURRENT_FILE )[0]; return lRet; }; @@ -1125,8 +1139,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrentFile */ - DOM.getSelectedFiles = function(){ - var lRet = DOM.getByClass(SELECTED_FILE); + DOMProto.getSelectedFiles = function(){ + var lRet = DOMProto.getByClass(SELECTED_FILE); return lRet.length ? lRet : null; }; @@ -1135,10 +1149,10 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * get size * @pCurrentFile */ - DOM.getCurrentSize = function(pCurrentFile){ + DOMProto.getCurrentSize = function(pCurrentFile){ var lRet, - lCurrent = pCurrentFile || DOM.getCurrentFile(), - lSize = DOM.getByClass('size', lCurrent); + lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lSize = DOMProto.getByClass('size', lCurrent); lSize = lSize[0].textContent; /* если это папка - возвращаем слово dir вместо размера*/ lRet = Util.removeStrOneTime(lSize, ['<', '>']); @@ -1150,16 +1164,16 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * get size * @pCurrentFile */ - DOM.loadCurrentSize = function(pCallBack, pCurrent){ + DOMProto.loadCurrentSize = function(pCallBack, pCurrent){ var lRet, - lCurrent = pCurrent || DOM.getCurrentFile(), - lLink = DOM.getCurrentPath(lCurrent), - lName = DOM.getCurrentName(lCurrent); + lCurrent = pCurrent || DOMProto.getCurrentFile(), + lLink = DOMProto.getCurrentPath(lCurrent), + lName = DOMProto.getCurrentName(lCurrent); /* если это папка - возвращаем слово dir вместо размера*/ if(lName !== '..') - DOM.RESTfull.read(lLink, function(pSize){ - DOM.setCurrentSize(pSize, lCurrent); + DOMProto.RESTfull.read(lLink, function(pSize){ + DOMProto.setCurrentSize(pSize, lCurrent); Util.exec(pCallBack, lCurrent); }, '?size'); @@ -1170,9 +1184,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * set size * @pCurrentFile */ - DOM.setCurrentSize = function(pSize, pCurrentFile){ - var lCurrent = pCurrentFile || DOM.getCurrentFile(), - lSizeElement = DOM.getByClass('size', lCurrent), + DOMProto.setCurrentSize = function(pSize, pCurrentFile){ + var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lSizeElement = DOMProto.getByClass('size', lCurrent), lSize = CloudFunc.getShortSize(pSize); lSizeElement[0].textContent = lSize; @@ -1182,10 +1196,10 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * @pCurrentFile */ - DOM.getCurrentMode = function(pCurrentFile){ + DOMProto.getCurrentMode = function(pCurrentFile){ var lRet, - lCurrent = pCurrentFile || DOM.getCurrentFile(), - lMode = DOM.getByClass('mode', lCurrent); + lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lMode = DOMProto.getByClass('mode', lCurrent); lRet = lMode[0].textContent; return lRet; @@ -1197,15 +1211,15 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @pCallBack - callback function or data struct {sucess, error} * @pCurrentFile */ - DOM.getCurrentFileContent = function(pParams, pCurrentFile){ + DOMProto.getCurrentFileContent = function(pParams, pCurrentFile){ var lRet, - lCurrentFile = pCurrentFile ? pCurrentFile : DOM.getCurrentFile(), + lCurrentFile = pCurrentFile ? pCurrentFile : DOMProto.getCurrentFile(), lParams = pParams ? pParams : {}, - lPath = DOM.getCurrentPath(lCurrentFile), + lPath = DOMProto.getCurrentPath(lCurrentFile), lErrorWas = pParams.error, lError = function(jqXHR){ Util.exec(lErrorWas); - DOM.Images.showError(jqXHR); + DOMProto.Images.showError(jqXHR); }; if( Util.isFunction(lParams) ) @@ -1214,13 +1228,13 @@ var CloudCommander, Util, DOM = {}, CloudFunc; lParams.error = lError; - if( DOM.isCurrentIsDir(lCurrentFile) ) + if( DOMProto.isCurrentIsDir(lCurrentFile) ) lPath += '?json'; if(!lParams.url) lParams.url = CloudFunc.FS + lPath; - lRet = DOM.ajax(lParams); + lRet = DOMProto.ajax(lParams); return lRet; }; @@ -1231,12 +1245,12 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @pCallBack - function({data, name}){} * @pCurrentFile */ - DOM.getCurrentData = function(pCallBack, pCurrentFile){ + DOMProto.getCurrentData = function(pCallBack, pCurrentFile){ var lParams, - lCurrentFile = pCurrentFile ? pCurrentFile : DOM.getCurrentFile(), + lCurrentFile = pCurrentFile ? pCurrentFile : DOMProto.getCurrentFile(), lFunc = function(pData){ - var lName = DOM.getCurrentName(lCurrentFile); + var lName = DOMProto.getCurrentName(lCurrentFile); if( Util.isObject(pData) ){ pData = Util.stringifyJSON(pData); @@ -1260,15 +1274,15 @@ var CloudCommander, Util, DOM = {}, CloudFunc; }; - return DOM.getCurrentFileContent(lParams, lCurrentFile); + return DOMProto.getCurrentFileContent(lParams, lCurrentFile); }; /** * unified way to get RefreshButton */ - DOM.getRefreshButton = function(){ - var lPanel = DOM.getPanel(), - lRefresh = DOM.getByClass(CloudFunc.REFRESHICON, lPanel), + DOMProto.getRefreshButton = function(){ + var lPanel = DOMProto.getPanel(), + lRefresh = DOMProto.getByClass(CloudFunc.REFRESHICON, lPanel), lRet = lRefresh[0]; return lRet; @@ -1278,9 +1292,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * unified way to set current file */ - DOM.setCurrentFile = function(pCurrentFile){ + DOMProto.setCurrentFile = function(pCurrentFile){ var lRet, - lCurrentFileWas = DOM.getCurrentFile(); + lCurrentFileWas = DOMProto.getCurrentFile(); if(pCurrentFile){ if (pCurrentFile.className === 'path') @@ -1292,10 +1306,10 @@ var CloudCommander, Util, DOM = {}, CloudFunc; if(lCurrentFileWas) unsetCurrentFile(lCurrentFileWas); - DOM.addClass(pCurrentFile, CURRENT_FILE); + DOMProto.addClass(pCurrentFile, CURRENT_FILE); /* scrolling to current file */ - DOM.scrollIntoViewIfNeeded(pCurrentFile); + DOMProto.scrollIntoViewIfNeeded(pCurrentFile); lRet = true; } @@ -1307,12 +1321,12 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * select current file * @param pCurrent */ - DOM.setSelectedFile = function(pCurrent){ - var lCurrent = pCurrent || DOM.getCurrentFile(), - lRet = DOM.addClass(pCurrent, SELECTED_FILE); + DOMProto.setSelectedFile = function(pCurrent){ + var lCurrent = pCurrent || DOMProto.getCurrentFile(), + lRet = DOMProto.addClass(pCurrent, SELECTED_FILE); if(!lRet) - DOM.unsetSelectedFile(lCurrent); + DOMProto.unsetSelectedFile(lCurrent); return lRet; }; @@ -1321,9 +1335,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * unselect current file * @param pCurrent */ - DOM.unsetSelectedFile = function(pCurrent){ - var lCurrent = pCurrent || DOM.getCurrentFile(), - lRet = DOM.removeClass(lCurrent, SELECTED_FILE); + DOMProto.unsetSelectedFile = function(pCurrent){ + var lCurrent = pCurrent || DOMProto.getCurrentFile(), + lRet = DOMProto.removeClass(lCurrent, SELECTED_FILE); return lRet; }; @@ -1331,7 +1345,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * setting history wrapper */ - DOM.setHistory = function(pData, pTitle, pUrl){ + DOMProto.setHistory = function(pData, pTitle, pUrl){ var lRet = window.history; if(lRet) @@ -1344,7 +1358,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * set onclick handler on buttons f1-f10 * @param pKey - 'f1'-'f10' */ - DOM.setButtonKey = function(pKey, pFunc){ + DOMProto.setButtonKey = function(pKey, pFunc){ Util.tryCatchLog(function(){ CloudCommander.KeysPanel[pKey].onclick = pFunc; }); @@ -1357,10 +1371,10 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pName */ - DOM.setTitle = function(pName){ + DOMProto.setTitle = function(pName){ if(!Title) - Title = DOM.getByTag('title')[0] || - DOM.anyload({ + Title = DOMProto.getByTag('title')[0] || + DOMProto.anyload({ name:'title', parentElement: document.head, innerHTML: pName @@ -1376,11 +1390,11 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile */ - DOM.isCurrentFile = function(pCurrent){ + DOMProto.isCurrentFile = function(pCurrent){ var lRet; if( pCurrent ) - lRet = DOM.isContainClass(pCurrent, CURRENT_FILE); + lRet = DOMProto.isContainClass(pCurrent, CURRENT_FILE); return lRet; }; @@ -1390,11 +1404,11 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile */ - DOM.isSelected = function(pSelected){ + DOMProto.isSelected = function(pSelected){ var lRet; if( pSelected ) - lRet = DOM.isContainClass(pSelected, SELECTED_FILE); + lRet = DOMProto.isContainClass(pSelected, SELECTED_FILE); return lRet; }; @@ -1404,10 +1418,10 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile */ - DOM.isCurrentIsDir = function(pCurrent){ - var lCurrent = pCurrent || DOM.getCurrentFile(), - lFileType = DOM.getByClass('mini-icon', lCurrent)[0], - lRet = DOM.isContainClass(lFileType, 'directory'); + DOMProto.isCurrentIsDir = function(pCurrent){ + var lCurrent = pCurrent || DOMProto.getCurrentFile(), + lFileType = DOMProto.getByClass('mini-icon', lCurrent)[0], + lRet = DOMProto.isContainClass(lFileType, 'directory'); return lRet; }; @@ -1418,8 +1432,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile - current file by default */ - DOM.getCurrentLink = function(pCurrentFile){ - var lLink = DOM.getByTag( 'a', pCurrentFile || DOM.getCurrentFile() ), + DOMProto.getCurrentLink = function(pCurrentFile){ + var lLink = DOMProto.getByTag( 'a', pCurrentFile || DOMProto.getCurrentFile() ), lRet = lLink.length > 0 ? lLink[0] : -1; @@ -1431,9 +1445,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile - current file by default */ - DOM.getCurrentPath = function(pCurrentFile){ - var lCurrent = pCurrentFile || DOM.getCurrentFile(), - lPath = DOM.getCurrentLink( lCurrent ).href; + DOMProto.getCurrentPath = function(pCurrentFile){ + var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lPath = DOMProto.getCurrentLink( lCurrent ).href; lPath = decodeURI(lPath); /* убираем адрес хоста*/ @@ -1447,9 +1461,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile */ - DOM.getCurrentName = function(pCurrentFile){ - var lCurrent = pCurrentFile || DOM.getCurrentFile(), - lLink = DOM.getCurrentLink( lCurrent ); + DOMProto.getCurrentName = function(pCurrentFile){ + var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lLink = DOMProto.getCurrentLink( lCurrent ); if( Util.isObject(lLink) ) lLink = lLink.title || lLink.textContent; @@ -1457,19 +1471,19 @@ var CloudCommander, Util, DOM = {}, CloudFunc; return lLink; }; - DOM.getSelectedNames = function(pSelected){ - var lSelected = pSelected || DOM.getSelectedFiles(), + DOMProto.getSelectedNames = function(pSelected){ + var lSelected = pSelected || DOMProto.getSelectedFiles(), lRet = lSelected ? [] : null; if(lRet){ var lFirst = lSelected[0], - lName = DOM.getCurrentName( lFirst ); + lName = DOMProto.getCurrentName( lFirst ); if(lName === '..') - DOM.unsetSelectedFile( lFirst ); + DOMProto.unsetSelectedFile( lFirst ); for(var i = 0, n = lSelected.length; i < n;i++) - lRet[i] = DOM.getCurrentName( lSelected[i] ); + lRet[i] = DOMProto.getCurrentName( lSelected[i] ); } return lRet; }; @@ -1479,9 +1493,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pCurrentFile */ - DOM.setCurrentName = function(pName, pCurrentFile){ - var lLink = DOM.getCurrentLink( pCurrentFile ), - lDir = DOM.getCurrentDirName() + '/'; + DOMProto.setCurrentName = function(pName, pCurrentFile){ + var lLink = DOMProto.getCurrentLink( pCurrentFile ), + lDir = DOMProto.getCurrentDirName() + '/'; lLink.title = lLink.textContent = pName; lLink.href = lDir + pName; @@ -1492,20 +1506,20 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** function getting FM * @param pPanel_o = {active: true} */ - DOM.getFM = function(){ - return DOM.getPanel().parentElement; + DOMProto.getFM = function(){ + return DOMProto.getPanel().parentElement; }; /** function getting panel active, or passive * @param pPanel_o = {active: true} */ - DOM.getPanel = function(pActive){ - var lPanel = DOM.getCurrentFile().parentElement; + DOMProto.getPanel = function(pActive){ + var lPanel = DOMProto.getCurrentFile().parentElement; /* if {active : false} getting passive panel */ if(pActive && !pActive.active){ var lId = lPanel.id === 'left' ? 'right' : 'left'; - lPanel = DOM.getById(lId); + lPanel = DOMProto.getById(lId); } /* if two panels showed @@ -1513,7 +1527,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * panel */ if(window.innerWidth < CloudCommander.MIN_ONE_PANEL_WIDTH) - lPanel = DOM.getById('left'); + lPanel = DOMProto.getById('left'); if(!lPanel) @@ -1523,7 +1537,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; }; /** prevent default event */ - DOM.preventDefault = function(pEvent){ + DOMProto.preventDefault = function(pEvent){ var lRet, lPreventDefault = pEvent && pEvent.preventDefault, lFunc = Util.bind(lPreventDefault, pEvent); @@ -1533,19 +1547,19 @@ var CloudCommander, Util, DOM = {}, CloudFunc; return lRet; }; - DOM.show = function(pElement){ - DOM.removeClass(pElement, 'hidden'); + DOMProto.show = function(pElement){ + DOMProto.removeClass(pElement, 'hidden'); }; /** * shows panel right or left (or active) */ - DOM.showPanel = function(pActive){ + DOMProto.showPanel = function(pActive){ var lRet = true, - lPanel = DOM.getPanel(pActive); + lPanel = DOMProto.getPanel(pActive); if(lPanel) - DOM.show(lPanel); + DOMProto.show(lPanel); else lRet = false; @@ -1555,12 +1569,12 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * hides panel right or left (or active) */ - DOM.hidePanel = function(pActive){ + DOMProto.hidePanel = function(pActive){ var lRet = false, - lPanel = DOM.getPanel(pActive); + lPanel = DOMProto.getPanel(pActive); if(lPanel) - lRet = DOM.hide(lPanel); + lRet = DOMProto.hide(lPanel); return lRet; }; @@ -1570,15 +1584,15 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @param pElement */ - DOM.hide = function(pElement){ - return DOM.addClass(pElement, 'hidden'); + DOMProto.hide = function(pElement){ + return DOMProto.addClass(pElement, 'hidden'); }; /** * open window with URL * @param pUrl */ - DOM.openWindow = function(pUrl){ + DOMProto.openWindow = function(pUrl){ var left = 140, top = 187, width = 1000, @@ -1601,7 +1615,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pChild * @param pElement */ - DOM.remove = function(pChild, pElement){ + DOMProto.remove = function(pChild, pElement){ return (pElement || document.body).removeChild(pChild); }; @@ -1610,7 +1624,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * @param pElement * @param pClass */ - DOM.removeClass = function(pElement, pClass){ + DOMProto.removeClass = function(pElement, pClass){ var lRet_b = true, lClassList = pElement.classList; @@ -1627,10 +1641,10 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * remove current file from file table * @pCurrent */ - DOM.deleteCurrent = function(pCurrent, pNextFile, pPreviousFile, pNotSet){ - var lCurrent = pCurrent || DOM.getCurrentFile(), + DOMProto.deleteCurrent = function(pCurrent, pNextFile, pPreviousFile, pNotSet){ + var lCurrent = pCurrent || DOMProto.getCurrentFile(), lParent = lCurrent && lCurrent.parentElement, - lName = DOM.getCurrentName(lCurrent); + lName = DOMProto.getCurrentName(lCurrent); if(lCurrent && lParent && lName !== '..'){ var lNext = pNextFile || lCurrent.nextSibling, @@ -1638,9 +1652,9 @@ var CloudCommander, Util, DOM = {}, CloudFunc; if(!pNotSet) if(lNext) - DOM.setCurrentFile(lNext); + DOMProto.setCurrentFile(lNext); else if(lPrevious) - DOM.setCurrentFile(lPrevious); + DOMProto.setCurrentFile(lPrevious); lParent.removeChild(lCurrent); } @@ -1652,8 +1666,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * remove selected files from file table * @Selected */ - DOM.deleteSelected = function(pSelected){ - var lSelected = pSelected || DOM.getSelectedFiles(); + DOMProto.deleteSelected = function(pSelected){ + var lSelected = pSelected || DOMProto.getSelectedFiles(); if(lSelected){ var n = lSelected.length, @@ -1665,7 +1679,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * when we remove 0 element, it's removed from lSelected to */ for(var i = 0; i < n; i++) - DOM.deleteCurrent( lSelected[0], lNext, lPrev, i !== lLast); + DOMProto.deleteCurrent( lSelected[0], lNext, lPrev, i !== lLast); } return lSelected; @@ -1676,14 +1690,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrent */ - DOM.renameCurrent = function(pCurrentFile){ - if( !DOM.isCurrentFile(pCurrentFile) ) + DOMProto.renameCurrent = function(pCurrentFile){ + if( !DOMProto.isCurrentFile(pCurrentFile) ) pCurrentFile = null; - var lCurrent = pCurrentFile || DOM.getCurrentFile(), - lFrom = DOM.getCurrentName(lCurrent), + var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lFrom = DOMProto.getCurrentName(lCurrent), lTo = prompt('Rename', lFrom) || lFrom, - lDirPath = DOM.getCurrentDirPath(); + lDirPath = DOMProto.getCurrentDirPath(); if( !Util.strCmp(lFrom, lTo) ){ var lFiles = { @@ -1691,8 +1705,8 @@ var CloudCommander, Util, DOM = {}, CloudFunc; to : lDirPath + lTo }; - DOM.RESTfull.mv(lFiles, function(){ - DOM.setCurrentName(lTo, lCurrent); + DOMProto.RESTfull.mv(lFiles, function(){ + DOMProto.setCurrentName(lTo, lCurrent); }); } }; @@ -1702,14 +1716,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrent */ - DOM.moveCurrent = function(pCurrentFile){ - if( !DOM.isCurrentFile(pCurrentFile) ) + DOMProto.moveCurrent = function(pCurrentFile){ + if( !DOMProto.isCurrentFile(pCurrentFile) ) pCurrentFile = null; - var lCurrent = pCurrentFile || DOM.getCurrentFile(), - lName = DOM.getCurrentName(lCurrent), - lFromPath = DOM.getCurrentPath(), - lToPath = DOM.getNotCurrentDirPath() + lName; + var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lName = DOMProto.getCurrentName(lCurrent), + lFromPath = DOMProto.getCurrentPath(), + lToPath = DOMProto.getNotCurrentDirPath() + lName; lToPath = prompt( 'Rename/Move file "' + lName + '"', lToPath ); @@ -1719,13 +1733,13 @@ var CloudCommander, Util, DOM = {}, CloudFunc; to : lToPath }; - DOM.RESTfull.mv(lFiles, function(){ - DOM.deleteCurrent(lCurrent); + DOMProto.RESTfull.mv(lFiles, function(){ + DOMProto.deleteCurrent(lCurrent); - var lPanel = DOM.getPanel(true), - lDotDot = DOM.getById( '..(' + lPanel.id + ')'); + var lPanel = DOMProto.getPanel(true), + lDotDot = DOMProto.getById( '..(' + lPanel.id + ')'); - DOM.setCurrentFile ( lDotDot ); + DOMProto.setCurrentFile ( lDotDot ); CloudCommander.refresh(); }); } @@ -1736,14 +1750,14 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * * @pCurrent */ - DOM.copyCurrent = function(pCurrentFile){ - if( !DOM.isCurrentFile(pCurrentFile) ) + DOMProto.copyCurrent = function(pCurrentFile){ + if( !DOMProto.isCurrentFile(pCurrentFile) ) pCurrentFile = null; - var lCurrent = pCurrentFile || DOM.getCurrentFile(), - lName = DOM.getCurrentName(lCurrent), - lFromPath = DOM.getCurrentPath(), - lToPath = DOM.getNotCurrentDirPath() + lName; + var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), + lName = DOMProto.getCurrentName(lCurrent), + lFromPath = DOMProto.getCurrentPath(), + lToPath = DOMProto.getNotCurrentDirPath() + lName; lToPath = prompt( 'Copy file "' + lName + '" to', lToPath ); if( lToPath && !Util.strCmp(lFromPath, lToPath) ){ @@ -1752,11 +1766,11 @@ var CloudCommander, Util, DOM = {}, CloudFunc; to : lToPath }; - DOM.RESTfull.cp(lFiles, function(){ - var lPanel = DOM.getPanel(true), - lDotDot = DOM.getById( '..(' + lPanel.id + ')'); + DOMProto.RESTfull.cp(lFiles, function(){ + var lPanel = DOMProto.getPanel(true), + lDotDot = DOMProto.getById( '..(' + lPanel.id + ')'); - DOM.setCurrentFile ( lDotDot ); + DOMProto.setCurrentFile ( lDotDot ); CloudCommander.refresh(); }); } @@ -1767,7 +1781,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; * (native suporte by webkit only) * @param pElement */ - DOM.scrollIntoViewIfNeeded = function(pElement){ + DOMProto.scrollIntoViewIfNeeded = function(pElement){ var lRet = pElement && pElement.scrollIntoViewIfNeeded; if(lRet) @@ -1777,7 +1791,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; }; /* scroll on one page*/ - DOM.scrollByPages = function(pElement, pPages){ + DOMProto.scrollByPages = function(pElement, pPages){ var lRet = pElement && pElement.scrollByPages && pPages; if(lRet) @@ -1789,7 +1803,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc; /** * function gets time */ - DOM.getTime = function(){ + DOMProto.getTime = function(){ var lRet, lDate = new Date(), lHours = lDate.getHours(), @@ -1804,4 +1818,4 @@ var CloudCommander, Util, DOM = {}, CloudFunc; return lRet; }; -})(Util, DOM); \ No newline at end of file +})(Util); \ No newline at end of file From 7c2590122228d7cb43e32b3a6791e34f82a7a9e5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 6 May 2013 07:27:50 -0400 Subject: [PATCH 006/239] added function extend to Util module --- lib/client/dom.js | 401 +++++++++++++++++++++++----------------------- lib/util.js | 17 ++ 2 files changed, 216 insertions(+), 202 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 73b37bed..15a4d2db 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -3,7 +3,8 @@ var CloudCommander, Util, DOM, CloudFunc; (function(Util){ 'use strict'; - var DOMConstructor = function(){}, + var DOMProto = {}, + DOMConstructor = function(){}, CURRENT_FILE = 'current-file', SELECTED_FILE = 'selected-file', XMLHTTP, Title, @@ -256,16 +257,205 @@ var CloudCommander, Util, DOM, CloudFunc; return (pElement || document).getElementsByClassName(pClass); }; }, + EventsProto = function(){ + /** + * safe add event listener + * + * @param pType + * @param pListener + * @param pUseCapture + * @param pElement {document by default} + */ + this.addListener = function(pType, pListener, pElement, pUseCapture){ + var lRet = this, + lElement = (pElement || window); + + if( lElement.addEventListener) + lElement.addEventListener( + pType, + pListener, + pUseCapture + ); + + return lRet; + }; + + /** + * safe add event listener + * + * @param pType + * @param pListener + * @param pUseCapture + * @param pElement {document by default} + */ + this.addOneTimeListener = function(pType, pListener, pElement, pUseCapture){ + var lRet = this, + lOneTime = function (pEvent){ + lRet.removeListener(pType, lOneTime, pElement, pUseCapture); + pListener(pEvent); + }; + + this.addListener(pType, lOneTime, pElement, pUseCapture); + + return lRet; + }; + + /** + * safe remove event listener + * + * @param pType + * @param pListener + * @param pUseCapture + * @param pElement {document by default} + */ + this.removeListener = function(pType, pListener, pElement, pUseCapture){ + var lRet = this; + + (pElement || window).removeEventListener( + pType, + pListener, + pUseCapture + ); + + return lRet; + }; + + + /** + * safe add event keydown listener + * + * @param pListener + * @param pUseCapture + */ + this.addKeyListener = function(pListener, pElement, pUseCapture){ + return this.addListener('keydown', pListener, pElement, pUseCapture); + }; + + /** + * safe add event click listener + * + * @param pListener + * @param pUseCapture + */ + this.addClickListener = function(pListener, pElement, pUseCapture){ + return this.addListener('click', pListener, pElement, pUseCapture); + }; + + this.addContextMenuListener = function(pListener, pElement, pUseCapture){ + return this.addListener('contextmenu', pListener, pElement, pUseCapture); + }; + + /** + * safe add event click listener + * + * @param pListener + * @param pUseCapture + */ + this.addErrorListener = function(pListener, pElement, pUseCapture){ + return this.addListener('error', pListener, pElement, pUseCapture); + }; + + /** + * crossbrowser create event + * + * @param pEventName + * @param pKeyCode - not necessarily + */ + this.createEvent = function(pEventName, pKeyCode){ + var lEvent = document.createEvent('Event'); + + lEvent.initEvent(pEventName, true, true); + + if(pKeyCode) + lEvent.keyCode = pKeyCode; + + lEvent.isDefaultPrevented = function(){ + return this.defaultPrevented; + }; + + return lEvent; + }; + + + /** + * create keydown event + * + * @param pKeyCode + */ + this.createKeyEvent = function(pKeyCode){ + return this.createEvent('keydown', pKeyCode); + }; + + /** + * create click event + * + * @param pKeyCode + */ + this.createClickEvent = function(){ + return this.createEvent('click'); + }; + + /** + * create click event + * + * @param pKeyCode + */ + this.createDblClickEvent = function(){ + return this.createEvent('dblclick'); + }; + + /** + * dispatch event + * + * @param pEvent + */ + this.dispatch = function(pEvent, pElement){ + return (pElement || window).dispatchEvent(pEvent); + }; + + /** + * dispatch keydown event + * + * @param pKeyCode + * @param pElement + */ + this.dispatchKeyEvent = function(pKeyCode, pElement){ + var lEvent = this.createKeyEvent(pKeyCode), + lRet = this.dispatch(lEvent, pElement); + + return lRet; + }; + + /** + * dispatch click event + * + * @param pElement + */ + this.dispatchClickEvent = function(pElement){ + var lEvent = this.createClickEvent(), + lRet = this.dispatch(lEvent, pElement); + + return lRet; + }; + + /** + * dispatch dblclick event + * + * @param pElement + */ + this.dispatchDblClickEvent = function(pElement){ + var lEvent = this.createDblClickEvent(), + lRet = this.dispatch(lEvent, pElement); + + return lRet; + }; + }, + RESTfull = function(){}, Images = function(){}, - DOMTreeConstructor = function(){}, - DOMTree, - DOMProto; - - DOMTreeConstructor.prototype= new DOMTreeProto(); - DOMTree = new DOMTreeConstructor(); - - DOMProto = new DOMTreeConstructor(); + DOMTreeConstructor = function(){}; + + Util.extend(DOMProto, [DOMTreeProto, EventsProto]); DOMConstructor.prototype = DOMProto; DOM = new DOMConstructor(); @@ -290,199 +480,6 @@ var CloudCommander, Util, DOM, CloudFunc; } - /** - * safe add event listener - * - * @param pType - * @param pListener - * @param pUseCapture - * @param pElement {document by default} - */ - DOMProto.addListener = function(pType, pListener, pElement, pUseCapture){ - var lRet = this, - lElement = (pElement || window); - - if( lElement.addEventListener) - lElement.addEventListener( - pType, - pListener, - pUseCapture - ); - - return lRet; - }; - - /** - * safe add event listener - * - * @param pType - * @param pListener - * @param pUseCapture - * @param pElement {document by default} - */ - DOMProto.addOneTimeListener = function(pType, pListener, pElement, pUseCapture){ - var lRet = this, - lOneTime = function (pEvent){ - DOMProto.removeListener(pType, lOneTime, pElement, pUseCapture); - pListener(pEvent); - }; - - DOMProto.addListener(pType, lOneTime, pElement, pUseCapture); - - return lRet; - }; - - /** - * safe remove event listener - * - * @param pType - * @param pListener - * @param pUseCapture - * @param pElement {document by default} - */ - DOMProto.removeListener = function(pType, pListener, pElement, pUseCapture){ - var lRet = this; - - (pElement || window).removeEventListener( - pType, - pListener, - pUseCapture - ); - - return lRet; - }; - - - /** - * safe add event keydown listener - * - * @param pListener - * @param pUseCapture - */ - DOMProto.addKeyListener = function(pListener, pElement, pUseCapture){ - return DOMProto.addListener('keydown', pListener, pElement, pUseCapture); - }; - - /** - * safe add event click listener - * - * @param pListener - * @param pUseCapture - */ - DOMProto.addClickListener = function(pListener, pElement, pUseCapture){ - return DOMProto.addListener('click', pListener, pElement, pUseCapture); - }; - - DOMProto.addContextMenuListener = function(pListener, pElement, pUseCapture){ - return DOMProto.addListener('contextmenu', pListener, pElement, pUseCapture); - }; - - /** - * safe add event click listener - * - * @param pListener - * @param pUseCapture - */ - DOMProto.addErrorListener = function(pListener, pElement, pUseCapture){ - return DOMProto.addListener('error', pListener, pElement, pUseCapture); - }; - - /** - * crossbrowser create event - * - * @param pEventName - * @param pKeyCode - not necessarily - */ - DOMProto.createEvent = function(pEventName, pKeyCode){ - var lEvent = document.createEvent('Event'); - - lEvent.initEvent(pEventName, true, true); - - if(pKeyCode) - lEvent.keyCode = pKeyCode; - - lEvent.isDefaultPrevented = function(){ - return this.defaultPrevented; - }; - - return lEvent; - }; - - - /** - * create keydown event - * - * @param pKeyCode - */ - DOMProto.createKeyEvent = function(pKeyCode){ - return DOMProto.createEvent('keydown', pKeyCode); - }; - - /** - * create click event - * - * @param pKeyCode - */ - DOMProto.createClickEvent = function(){ - return DOMProto.createEvent('click'); - }; - - /** - * create click event - * - * @param pKeyCode - */ - DOMProto.createDblClickEvent = function(){ - return DOMProto.createEvent('dblclick'); - }; - - /** - * dispatch event - * - * @param pEvent - */ - DOMProto.dispatch = function(pEvent, pElement){ - return (pElement || window).dispatchEvent(pEvent); - }; - - /** - * dispatch keydown event - * - * @param pKeyCode - * @param pElement - */ - DOMProto.dispatchKeyEvent = function(pKeyCode, pElement){ - var lEvent = DOMProto.createKeyEvent(pKeyCode), - lRet = DOMProto.dispatch(lEvent, pElement); - - return lRet; - }; - - /** - * dispatch click event - * - * @param pElement - */ - DOMProto.dispatchClickEvent = function(pElement){ - var lEvent = DOMProto.createClickEvent(), - lRet = DOMProto.dispatch(lEvent, pElement); - - return lRet; - }; - - /** - * dispatch dblclick event - * - * @param pElement - */ - DOMProto.dispatchDblClickEvent = function(pElement){ - var lEvent = DOMProto.createDblClickEvent(), - lRet = DOMProto.dispatch(lEvent, pElement); - - return lRet; - }; - - /** * load file countent thrue ajax * diff --git a/lib/util.js b/lib/util.js index 66e7a8b5..b0d82633 100644 --- a/lib/util.js +++ b/lib/util.js @@ -168,6 +168,23 @@ Util = exports || {}; return lRet; }; + Util.extend = function(pTarget, PObj){ + var i, n, lObj, lRet = Util.isObject(pTarget) ? pTarget : {}; + + if( Util.isArray(PObj) ) + for(i = 0, n = PObj.length; i < n; i++) + Util.extend(pTarget, PObj[i]); + + else if(PObj){ + lObj = Util.isFunction(PObj) ? new PObj() : PObj; + + for(i in lObj) + lRet[i] = lObj[i]; + } + + return lRet; + }; + /** for function * @param pI * @param pN From 6da9a928b2a90c42291704742339f19a7a9f6c3f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 6 May 2013 07:39:54 -0400 Subject: [PATCH 007/239] refactored --- lib/client/dom.js | 173 +++++++++++++++++++++++----------------------- 1 file changed, 88 insertions(+), 85 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 15a4d2db..c21e692f 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -450,21 +450,105 @@ var CloudCommander, Util, DOM, CloudFunc; return lRet; }; }, - + /** + * Обьект для работы с кэшем + * в него будут включены функции для + * работы с LocalStorage, webdb, + * indexed db etc. + */ + CacheProto = function(){ + /* приватный переключатель возможности работы с кэшем */ + var CacheAllowed; + + /* функция проверяет возможно ли работать с кэшем каким-либо образом */ + this.isAllowed = function(){ + var lRet = CacheAllowed && window.localStorage; + return lRet; + }; + + /** + * allow cache usage + */ + this.setAllowed = function(pAllowd){ + CacheAllowed = pAllowd; + + return pAllowd; + }; + + /** remove element */ + this.remove = function(pItem){ + var lRet = this; + + if(CacheAllowed) + localStorage.removeItem(pItem); + + return lRet; + }; + + /** если доступен localStorage и + * в нём есть нужная нам директория - + * записываем данные в него + */ + this.set = function(pName, pData){ + var lRet = this; + + if(CacheAllowed && pName && pData) + localStorage.setItem(pName,pData); + + return lRet; + }, + + /** Если доступен Cache принимаем из него данные*/ + this.get = function(pName){ + var lRet; + + if(CacheAllowed) + lRet = localStorage.getItem(pName); + + return lRet; + }, + + /* get all cache from local storage */ + this.getAll = function(){ + var lRet = null; + + if(CacheAllowed) + lRet = localStorage; + + return lRet; + }; + + /** функция чистит весь кэш для всех каталогов*/ + this.clear = function(){ + var lRet = this; + + if(CacheAllowed) + localStorage.clear(); + + return lRet; + }; + }, RESTfull = function(){}, Images = function(){}, - DOMTreeConstructor = function(){}; + Cache = function(){}; - Util.extend(DOMProto, [DOMTreeProto, EventsProto]); DOMConstructor.prototype = DOMProto; DOM = new DOMConstructor(); - + RESTfull.prototype = new RESTfullProto(); DOMProto.RESTfull = new RESTfull(); Images.prototype = new ImagesProto(); DOMProto.Images = new Images(); + Cache.prototype = new CacheProto(); + DOMProto.Cache = new Cache(); + + Util.extend(DOMProto, [ + DOMTreeProto, + EventsProto + ]); + /** * private function thet unset currentfile * @@ -528,87 +612,6 @@ var CloudCommander, Util, DOM, CloudFunc; return lRet; }; - /** - * Обьект для работы с кэшем - * в него будут включены функции для - * работы с LocalStorage, webdb, - * indexed db etc. - */ - DOMProto.Cache = function(){ - /* приватный переключатель возможности работы с кэшем */ - var CacheAllowed; - - /* функция проверяет возможно ли работать с кэшем каким-либо образом */ - this.isAllowed = function(){ - var lRet = CacheAllowed && window.localStorage; - return lRet; - }; - - /** - * allow cache usage - */ - this.setAllowed = function(pAllowd){ - CacheAllowed = pAllowd; - - return pAllowd; - }; - - /** remove element */ - this.remove = function(pItem){ - var lRet = this; - - if(CacheAllowed) - localStorage.removeItem(pItem); - - return lRet; - }; - - /** если доступен localStorage и - * в нём есть нужная нам директория - - * записываем данные в него - */ - this.set = function(pName, pData){ - var lRet = this; - - if(CacheAllowed && pName && pData) - localStorage.setItem(pName,pData); - - return lRet; - }, - - /** Если доступен Cache принимаем из него данные*/ - this.get = function(pName){ - var lRet; - - if(CacheAllowed) - lRet = localStorage.getItem(pName); - - return lRet; - }, - - /* get all cache from local storage */ - this.getAll = function(){ - var lRet = null; - - if(CacheAllowed) - lRet = localStorage; - - return lRet; - }; - - /** функция чистит весь кэш для всех каталогов*/ - this.clear = function(){ - var lRet = this; - - if(CacheAllowed) - localStorage.clear(); - - return lRet; - }; - }; - - DOMProto.Cache = new DOMProto.Cache(); - /** * create new folder * From 1d4619f286d3a2671cbf0c48cb9b32315c9a0ca2 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 6 May 2013 12:27:10 -0400 Subject: [PATCH 008/239] moved Cmd functions to Cmd object inside DOM --- json/config.json | 2 +- lib/client/dom.js | 2583 ++++++++++++++++++++++----------------------- lib/util.js | 35 +- 3 files changed, 1323 insertions(+), 1297 deletions(-) diff --git a/json/config.json b/json/config.json index 3a8b6f66..5f9fc6cf 100644 --- a/json/config.json +++ b/json/config.json @@ -2,7 +2,7 @@ "api_url" : "/api/v1", "appcache" : false, "minification" : { - "js" : false, + "js" : true, "css" : true, "html" : true, "img" : true diff --git a/lib/client/dom.js b/lib/client/dom.js index c21e692f..6e449d9f 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -3,21 +3,17 @@ var CloudCommander, Util, DOM, CloudFunc; (function(Util){ 'use strict'; - var DOMProto = {}, - DOMConstructor = function(){}, - CURRENT_FILE = 'current-file', - SELECTED_FILE = 'selected-file', - XMLHTTP, Title, + var DOMFunc = function(){}, + DOMProto, - /* Обьект содержит функции для отображения картинок */ - ImagesProto = function(){ + ImagesProto = function(){ var LImagesProto = function (){ function getImage(pName){ var lId = pName + '-image', - lE = DOMProto.getById(lId); + lE = DOM.getById(lId); if (!lE) - lE = DOMProto.anyload({ + lE = DOM.anyload({ name : 'span', className : 'icon ' + pName, id : lId, @@ -47,14 +43,14 @@ var CloudCommander, Util, DOM, CloudFunc; lLoadingImage = lImages.loading(), lErrorImage = lImages.error(); - DOMProto.hide(lErrorImage); + DOM.hide(lErrorImage); var lCurrent; if(pPosition && pPosition.top) - lCurrent = DOMProto.getRefreshButton().parentElement; + lCurrent = DOM.getRefreshButton().parentElement; else{ - var lFile = DOMProto.getCurrentFile(); - lCurrent = DOMProto.getByClass('name', lFile)[0]; + var lFile = DOM.getCurrentFile(); + lCurrent = DOM.getByClass('name', lFile)[0]; } /* show loading icon if it not showed */ @@ -63,7 +59,7 @@ var CloudCommander, Util, DOM, CloudFunc; if(!lParent || (lParent && lParent !== lCurrent)) lCurrent.appendChild(lLoadingImage); - lRet_b = DOMProto.show(lLoadingImage); /* показываем загрузку*/ + lRet_b = DOM.show(lLoadingImage); /* показываем загрузку*/ return lRet_b; }; @@ -73,7 +69,7 @@ var CloudCommander, Util, DOM, CloudFunc; */ this.hideLoad = function(){ - DOMProto.hide( lImages.loading() ); + DOM.hide( lImages.loading() ); }; /** @@ -96,22 +92,21 @@ var CloudCommander, Util, DOM, CloudFunc; lText = lText.replace('Error: EACCES, p','P'); - DOMProto.show(lErrorImage); + DOM.show(lErrorImage); lErrorImage.title = lText; var lParent = lLoadingImage.parentElement; if(lParent) lParent.appendChild(lErrorImage); - DOMProto.hide(lLoadingImage); + DOM.hide(lLoadingImage); Util.log(lText); setTimeout( Util.retExec(alert, lText), 100); }; }, - /* Обьект содержит функции для работы с CloudCmd API */ - RESTfullProto = function(){ + RESTfullProto = function(){ this.delete = function(pUrl, pData, pCallBack, pQuery){ sendRequest({ method : 'DELETE', @@ -163,7 +158,7 @@ var CloudCommander, Util, DOM, CloudFunc; if(lRet){ var p = pParams; - DOMProto.Images.showLoad( p.imgPosition ); + Images.showLoad( p.imgPosition ); CloudCommander.getConfig(function(pConfig){ var lData; @@ -176,13 +171,13 @@ var CloudCommander, Util, DOM, CloudFunc; lData = p.data; p.url = pConfig && pConfig.api_url + p.url, - DOMProto.ajax({ + DOM.ajax({ method : p.method, url : p.url, data : lData, - error : DOMProto.Images.showError, + error : Images.showError, success : function(pData){ - DOMProto.Images.hideLoad(); + Images.hideLoad(); Util.log(pData); Util.exec(p.callback, pData); } @@ -193,7 +188,7 @@ var CloudCommander, Util, DOM, CloudFunc; return lRet; } }, - DOMTreeProto = function(){ + DOMTreeProto = function(){ /** * add class to element * @@ -256,8 +251,21 @@ var CloudCommander, Util, DOM, CloudFunc; this.getByClass = function(pClass, pElement){ return (pElement || document).getElementsByClassName(pClass); }; + + /** + * add class=hidden to element + * + * @param pElement + */ + this.hide = function(pElement){ + return this.addClass(pElement, 'hidden'); + }; + + this.show = function(pElement){ + this.removeClass(pElement, 'hidden'); + }; }, - EventsProto = function(){ + EventsProto = function(){ /** * safe add event listener * @@ -450,13 +458,7 @@ var CloudCommander, Util, DOM, CloudFunc; return lRet; }; }, - /** - * Обьект для работы с кэшем - * в него будут включены функции для - * работы с LocalStorage, webdb, - * indexed db etc. - */ - CacheProto = function(){ + CacheProto = function(){ /* приватный переключатель возможности работы с кэшем */ var CacheAllowed; @@ -528,1294 +530,1285 @@ var CloudCommander, Util, DOM, CloudFunc; return lRet; }; }, - RESTfull = function(){}, - Images = function(){}, - Cache = function(){}; - - DOMConstructor.prototype = DOMProto; - DOM = new DOMConstructor(); - - RESTfull.prototype = new RESTfullProto(); - DOMProto.RESTfull = new RESTfull(); - - Images.prototype = new ImagesProto(); - DOMProto.Images = new Images(); - - Cache.prototype = new CacheProto(); - DOMProto.Cache = new Cache(); - - Util.extend(DOMProto, [ - DOMTreeProto, - EventsProto - ]); - - /** - * private function thet unset currentfile - * - * @pCurrentFile - */ - function unsetCurrentFile(pCurrentFile){ - var lRet = DOMProto.isCurrentFile(pCurrentFile); - - if(lRet) - DOMProto.removeClass(pCurrentFile, CURRENT_FILE); - - return lRet; - } - - - /** - * load file countent thrue ajax - * - * @param pParams - */ - DOMProto.ajax = function(pParams){ - var lRet = Util.checkObjTrue(pParams, ['url', 'success']); - if(lRet){ - var p = pParams, - lType = p.type || p.method || 'GET'; + CmdProto = function(){ + var CURRENT_FILE = 'current-file', + SELECTED_FILE = 'selected-file', + XMLHTTP, Title; - if(!XMLHTTP) - XMLHTTP = new XMLHttpRequest(); - - XMLHTTP.open(lType, pParams.url, true); - XMLHTTP.send(p.data); - - XMLHTTP.onreadystatechange = function(pEvent){ - if (XMLHTTP.readyState === 4 /* Complete */){ - var lJqXHR = pEvent.target, - lType = XMLHTTP.getResponseHeader('content-type'); - - if (XMLHTTP.status === 200 /* OK */){ - var lData = lJqXHR.response; - - /* If it's json - parse it as json */ - if(lType && Util.isContainStr(lType, 'application/json') ) - lData = Util.parseJSON(lJqXHR.response) || lJqXHR.response; - - if( Util.isFunction(p.success) ) - p.success(lData, lJqXHR.statusText, lJqXHR); - } - /* file not found or connection lost */ - else{ - /* if html given or something like thet - * getBack just status of result - */ - if(lType && lType.indexOf('text/plain') !== 0) - lJqXHR.responseText = lJqXHR.statusText; - - Util.exec(p.error, lJqXHR); - } - } - }; - } - return lRet; - }; - - /** - * create new folder - * - * @pCurrentFile - */ - DOMProto.promptNewDir = function(){ - DOMProto.promptNewFile('directory', '?dir'); - }; - - /** - * create new file - * - * @pCurrentFile - */ - DOMProto.promptNewFile = function(pTypeName, pType){ - var lName = DOMProto.getCurrentName(), - lDir = DOMProto.getCurrentDirPath(), - lMsg = 'New ' + pTypeName || 'File', - lType = Util.isString(pType) ? pType : ''; - - if(lName === '..') - lName = ''; - - lName = prompt(lMsg, lName); - - if(lName) - DOMProto.RESTfull.save(lDir + lName + lType, null, CloudCommander.refresh); - }; - - - - /** - * delete currentfile, prompt before it - * - * @pCurrentFile - */ - DOMProto.promptDeleteSelected = function(pCurrentFile){ - var lRet, - lCurrent, lQuery, lMsg, - lName = '', - lMsgAsk = 'Do you really want to delete the ', - lMsgSel = 'selected ', - lFiles = DOMProto.getSelectedFiles(), - lSelected = DOMProto.getSelectedNames(lFiles), - i, n = lSelected && lSelected.length; - - if(n > 1){ - for(i = 0; i < 5 && i < n; i++) - lName += '\n' + lSelected[i]; - - if(n >= 5) - lName += '\n...'; - - lMsg = lMsgAsk + lMsgSel + n + ' files/directoris?\n' + lName ; - lQuery = '?files'; - }else{ - var lType, lIsDir; - - /* dom element passed and it is not event */ - if( pCurrentFile && !pCurrentFile.pType) - lCurrent = pCurrentFile; - else - lCurrent = DOMProto.getCurrentFile(); - - lIsDir = DOMProto.isCurrentIsDir(lCurrent); - - if(lIsDir){ - lQuery = '?dir'; - lType ='directory'; - } - else - lType = 'file'; - - lType += ' '; - - lName = DOMProto.getCurrentName(lCurrent); - lMsg = lMsgAsk + lMsgSel + lType + lName + '?'; - } - - if(lName !== '..') - lRet = confirm(lMsg); - else - alert('No files selected!'); - if(lRet){ - var lUrl; - - if(lCurrent) - lUrl = DOMProto.getCurrentPath(lCurrent); - else{ - lUrl = DOMProto.getCurrentDirPath(); - lCurrent = lFiles[0]; - } - - if(lCurrent || lSelected) - DOMProto.RESTfull.delete(lUrl, lSelected, function(){ - if(n > 1) - DOMProto.deleteSelected(lFiles); - else - DOMProto.deleteCurrent(lCurrent); - - var lDir = CloudFunc.removeLastSlash( - DOMProto.getCurrentDirPath() - ); - - DOMProto.Cache.remove(lDir); - }, lQuery); - - return lCurrent; - } - - return lRet; - }; - - /** - * Function gets id by src - * @param pSrc - * - * Example: http://domain.com/1.js -> 1_js - */ - DOMProto.getIdBySrc = function(pSrc){ - var lRet = Util.isString(pSrc); - - if(lRet){ - var lNum = pSrc.lastIndexOf('/') + 1, - lSub = pSrc.substr(pSrc, lNum), - lID = Util.removeStrOneTime(pSrc, lSub ); - - /* убираем точки */ - while(lID.indexOf('.') > 0) - lID = lID.replace('.', '_'); - - lRet = lID; - } - - return lRet; - }, - - /** - * create elements and load them to DOM-tree - * one-by-one - * - * @param pParams_a - * @param pFunc - onload function - */ - DOMProto.anyLoadOnLoad = function(pParams_a, pFunc){ - var lRet = this; - - if( Util.isArray(pParams_a) ) { - var lParam = pParams_a.pop(), - lFunc = function(){ - DOMProto.anyLoadOnLoad(pParams_a, pFunc); - }; - - if( Util.isString(lParam) ) - lParam = { src : lParam }; - else if( Util.isArray(lParam) ){ - - DOMProto.anyLoadInParallel(lParam, lFunc); - } - - if(lParam && !lParam.func){ - lParam.func = lFunc; - - DOMProto.anyload(lParam); - - }else - Util.exec(pFunc); - } - - return lRet; - }; - - /** - * improve callback of funcs so - * we pop number of function and - * if it's last we call pCallBack - * - * @param pParams_a - * @param pFunc - onload function - */ - DOMProto.anyLoadInParallel = function(pParams_a, pFunc){ - var lRet = this, - lDone = [], - - lDoneFunc = function (pCallBack){ - Util.exec(pCallBack); - - if( !lDone.pop() ) - Util.exec(pFunc); - }; - - if( !Util.isArray(pParams_a) ){ - pParams_a = [pParams_a]; - } - - for(var i = 0, n = pParams_a.length; i < n; i++){ - var lParam = pParams_a.pop(); - - if(lParam){ - lDone.push(i); - - if(Util.isString(lParam) ) - lParam = { src : lParam }; - - var lFunc = lParam.func; - lParam.func = Util.retExec(lDoneFunc, lFunc); - - DOMProto.anyload(lParam); - } - } - - return lRet; - }; - - /** - * Функция создаёт элемент и загружает файл с src. - * - * @param pParams_o = { - * name, - название тэга - * src', - путь к файлу - * func, - обьект, содержаий одну из функций - * или сразу две onload и onerror - * {onload: function(){}, onerror: function();} - * style, - * id, - * element, - * async, - true by default - * inner: 'id{color:red, }, - * class, - * not_append - false by default - * } - */ - DOMProto.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] = DOMProto.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 || document.body, - lInner = pParams_o.inner, - lStyle = pParams_o.style, - lNotAppend = pParams_o.not_append; - - if ( Util.isObject(lFunc) ){ - lOnError = lFunc.onerror; - lFunc = lFunc.onload; - } - /* убираем путь к файлу, оставляя только название файла */ - if(!lID && lSrc) - lID = DOMProto.getIdBySrc(lSrc); - - var lElement = DOMProto.getById(lID); - - /* если скрипт еще не загружен */ - if(!lElement){ - 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'}; - } - } - lElement = document.createElement(lName); - - if(lID) - lElement.id = lID; - - if(lClass) - lElement.className = lClass; - - /* if working with external css - * using href in any other case - * using src + /** + * private function thet unset currentfile + * + * @pCurrentFile */ - if(lName === 'link'){ - lElement.href = lSrc; - lElement.rel = 'stylesheet'; - }else - lElement.src = lSrc; + function unsetCurrentFile(pCurrentFile){ + var lRet = DOM.isCurrentFile(pCurrentFile); + + if(lRet) + DOM.removeClass(pCurrentFile, CURRENT_FILE); + + return lRet; + } - /* - * if passed arguments function - * then it's onload by default + + /** + * load file countent thrue ajax + * + * @param pParams + */ + this.ajax = function(pParams){ + var lRet = Util.checkObjTrue(pParams, ['url', 'success']); + if(lRet){ + var p = pParams, + lType = p.type || p.method || 'GET'; + + if(!XMLHTTP) + XMLHTTP = new XMLHttpRequest(); + + XMLHTTP.open(lType, pParams.url, true); + XMLHTTP.send(p.data); + + XMLHTTP.onreadystatechange = function(pEvent){ + if (XMLHTTP.readyState === 4 /* Complete */){ + var lJqXHR = pEvent.target, + lType = XMLHTTP.getResponseHeader('content-type'); + + if (XMLHTTP.status === 200 /* OK */){ + var lData = lJqXHR.response; + + /* If it's json - parse it as json */ + if(lType && Util.isContainStr(lType, 'application/json') ) + lData = Util.parseJSON(lJqXHR.response) || lJqXHR.response; + + if( Util.isFunction(p.success) ) + p.success(lData, lJqXHR.statusText, lJqXHR); + } + /* file not found or connection lost */ + else{ + /* if html given or something like thet + * getBack just status of result + */ + if(lType && lType.indexOf('text/plain') !== 0) + lJqXHR.responseText = lJqXHR.statusText; + + Util.exec(p.error, lJqXHR); + } + } + }; + } + return lRet; + }; + + /** + * create new folder * - * if object - then onload and onerror + * @pCurrentFile */ - - var lLoad = function(pEvent){ - DOMProto.removeListener('load', lLoad, lElement); - DOMProto.removeListener('error', lError, lElement); - - Util.exec(lFunc, pEvent); - }, - - lError = function(){ - lParent.removeChild(lElement); - - DOMProto.Images.showError({ - responseText: 'file ' + - lSrc + - ' could not be loaded', - status : 404 - }); - - Util.exec(lOnError); - }; - - DOMProto.addListener('load', lLoad, lElement); - DOMProto.addErrorListener(lError, lElement); - - if(lStyle) - lElement.style.cssText = lStyle; - - if(lAsync || lAsync === undefined) - lElement.async = true; - - if(!lNotAppend) - lParent.appendChild(lElement); - - if(lInner) - lElement.innerHTML = lInner; - } - /* если js-файл уже загружен - * запускаем функцию onload - */ - else - Util.exec(lFunc); - - return lElement; - }, - - /** - * Функция загружает js-файл - * - * @param pSrc - * @param pFunc - */ - DOMProto.jsload = function(pSrc, pFunc){ - if( Util.isArray(pSrc) ){ - for(var i=0; i < pSrc.length; i++) - pSrc[i].name = 'script'; - - return DOMProto.anyload(pSrc); - } - - return DOMProto.anyload({ - name : 'script', - src : pSrc, - func : pFunc - }); - }, - - /** - * returns jsload functions - */ - DOMProto.retJSLoad = function(pSrc, pFunc){ - var lRet = function(){ - return DOMProto.jsload(pSrc, pFunc); - }; - - return lRet; - }, - - - /** - * Функция создаёт елемент style и записывает туда стили - * @param pParams_o - структура параметров, заполняеться таким - * образом: {src: ' ',func: '', id: '', element: '', inner: ''} - * все параметры опциональны - */ - DOMProto.cssSet = function(pParams_o){ - pParams_o.name = 'style'; - pParams_o.parent = pParams_o.parent || document.head; - - return DOMProto.anyload(pParams_o); - }, - - /** - * Function loads external css files - * @pParams_o - структура параметров, заполняеться таким - * образом: {src: ' ',func: '', id: '', element: '', inner: ''} - * все параметры опциональны - */ - DOMProto.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 DOMProto.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 DOMProto.anyload(pParams_o); - }; - - /** - * load jquery from google cdn or local copy - * @param pCallBack - */ - DOMProto.jqueryLoad = function(pCallBack){ - /* загружаем jquery: */ - DOMProto.jsload('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js',{ - onload: Util.retExec(pCallBack), - - onerror: function(){ - DOMProto.jsload('/lib/client/jquery.js'); - - /* if could not load jquery from google server - * maybe we offline, load font from local - * directory */ - DOMProto.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");}' - }); - } - }); - }; - - /** - * load socket.io - * @param pCallBack - */ - DOMProto.socketLoad = function(pCallBack){ - DOMProto.jsload('/lib/client/socket.js', Util.retExec(pCallBack) ); - }; - - - /** - * get current direcotory name - */ - DOMProto.getCurrentDirName = function(){ - var lRet, - lSubstr, - lPanel = DOMProto.getPanel(), - /* получаем имя каталога в котором находимся */ - lHref = DOMProto.getByClass('path', lPanel); - - lHref = lHref[0].textContent; - - lHref = CloudFunc.removeLastSlash(lHref); - lSubstr = lHref.substr(lHref , lHref.lastIndexOf('/')); - lRet = Util.removeStrOneTime(lHref, lSubstr + '/') || '/'; - - return lRet; - }; - - /** - * get current direcotory path - */ - DOMProto.getCurrentDirPath = function(pPanel){ - var lPanel = pPanel || DOMProto.getPanel(), - lPath = DOMProto.getByClass('path', lPanel)[0], - lRet; - - if(lPath) - lRet = lPath.textContent; - - return lRet; - }; - - /** - * get current direcotory path - */ - DOMProto.getNotCurrentDirPath = function(){ - var lPanel = DOMProto.getPanel(true), - lPath = DOMProto.getByClass('path', lPanel)[0], - lRet; - - if(lPath) - lRet = lPath.textContent; - - return lRet; - }; - - /** - * unified way to get current file - * - * @pCurrentFile - */ - DOMProto.getCurrentFile = function(){ - var lRet = DOMProto.getByClass( CURRENT_FILE )[0]; - - return lRet; - }; - - /** - * unified way to get current file - * - * @pCurrentFile - */ - DOMProto.getSelectedFiles = function(){ - var lRet = DOMProto.getByClass(SELECTED_FILE); - - return lRet.length ? lRet : null; - }; - - /** - * get size - * @pCurrentFile - */ - DOMProto.getCurrentSize = function(pCurrentFile){ - var lRet, - lCurrent = pCurrentFile || DOMProto.getCurrentFile(), - lSize = DOMProto.getByClass('size', lCurrent); - lSize = lSize[0].textContent; - /* если это папка - возвращаем слово dir вместо размера*/ - lRet = Util.removeStrOneTime(lSize, ['<', '>']); - - return lRet; - }; - - /** - * get size - * @pCurrentFile - */ - DOMProto.loadCurrentSize = function(pCallBack, pCurrent){ - var lRet, - lCurrent = pCurrent || DOMProto.getCurrentFile(), - lLink = DOMProto.getCurrentPath(lCurrent), - lName = DOMProto.getCurrentName(lCurrent); - /* если это папка - возвращаем слово dir вместо размера*/ - - if(lName !== '..') - DOMProto.RESTfull.read(lLink, function(pSize){ - DOMProto.setCurrentSize(pSize, lCurrent); - Util.exec(pCallBack, lCurrent); - }, '?size'); - - return lRet; - }; - - /** - * set size - * @pCurrentFile - */ - DOMProto.setCurrentSize = function(pSize, pCurrentFile){ - var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), - lSizeElement = DOMProto.getByClass('size', lCurrent), - lSize = CloudFunc.getShortSize(pSize); - - lSizeElement[0].textContent = lSize; - - }; - - /** - * @pCurrentFile - */ - DOMProto.getCurrentMode = function(pCurrentFile){ - var lRet, - lCurrent = pCurrentFile || DOMProto.getCurrentFile(), - lMode = DOMProto.getByClass('mode', lCurrent); - lRet = lMode[0].textContent; - - return lRet; - }; - - /** - * unified way to get current file content - * - * @pCallBack - callback function or data struct {sucess, error} - * @pCurrentFile - */ - DOMProto.getCurrentFileContent = function(pParams, pCurrentFile){ - var lRet, - lCurrentFile = pCurrentFile ? pCurrentFile : DOMProto.getCurrentFile(), - lParams = pParams ? pParams : {}, - lPath = DOMProto.getCurrentPath(lCurrentFile), - lErrorWas = pParams.error, - lError = function(jqXHR){ - Util.exec(lErrorWas); - DOMProto.Images.showError(jqXHR); + this.promptNewDir = function(){ + this.promptNewFile('directory', '?dir'); }; - - if( Util.isFunction(lParams) ) - lParams.success = Util.retExec(pParams); - - lParams.error = lError; - - - if( DOMProto.isCurrentIsDir(lCurrentFile) ) - lPath += '?json'; - - if(!lParams.url) - lParams.url = CloudFunc.FS + lPath; - - lRet = DOMProto.ajax(lParams); - - return lRet; - }; - - /** - * unified way to get current file content - * - * @pCallBack - function({data, name}){} - * @pCurrentFile - */ - DOMProto.getCurrentData = function(pCallBack, pCurrentFile){ - - var lParams, - lCurrentFile = pCurrentFile ? pCurrentFile : DOMProto.getCurrentFile(), - lFunc = function(pData){ - var lName = DOMProto.getCurrentName(lCurrentFile); - if( Util.isObject(pData) ){ - pData = Util.stringifyJSON(pData); + + /** + * create new file + * + * @pCurrentFile + */ + this.promptNewFile = function(pTypeName, pType){ + var lName = this.getCurrentName(), + lDir = this.getCurrentDirPath(), + lMsg = 'New ' + pTypeName || 'File', + lType = Util.isString(pType) ? pType : ''; + + if(lName === '..') + lName = ''; + + lName = prompt(lMsg, lName); + + if(lName) + RESTfull.save(lDir + lName + lType, null, CloudCommander.refresh); + }; + + + + /** + * delete currentfile, prompt before it + * + * @pCurrentFile + */ + this.promptDeleteSelected = function(pCurrentFile){ + var lRet, + lCurrent, lQuery, lMsg, + lName = '', + lMsgAsk = 'Do you really want to delete the ', + lMsgSel = 'selected ', + lFiles = this.getSelectedFiles(), + lSelected = this.getSelectedNames(lFiles), + i, n = lSelected && lSelected.length; - var lExt = '.json'; - if( !Util.checkExtension(lName, lExt) ) - lName += lExt; + if(n > 1){ + for(i = 0; i < 5 && i < n; i++) + lName += '\n' + lSelected[i]; + + if(n >= 5) + lName += '\n...'; + + lMsg = lMsgAsk + lMsgSel + n + ' files/directoris?\n' + lName ; + lQuery = '?files'; + }else{ + var lType, lIsDir; + + /* dom element passed and it is not event */ + if( pCurrentFile && !pCurrentFile.pType) + lCurrent = pCurrentFile; + else + lCurrent = this.getCurrentFile(); + + lIsDir = this.isCurrentIsDir(lCurrent); + + if(lIsDir){ + lQuery = '?dir'; + lType ='directory'; + } + else + lType = 'file'; + + lType += ' '; + + lName = this.getCurrentName(lCurrent); + lMsg = lMsgAsk + lMsgSel + lType + lName + '?'; } - Util.exec(pCallBack, { - data: pData, - name: lName + if(lName !== '..') + lRet = confirm(lMsg); + else + alert('No files selected!'); + if(lRet){ + var lUrl; + + if(lCurrent) + lUrl = this.getCurrentPath(lCurrent); + else{ + lUrl = this.getCurrentDirPath(); + lCurrent = lFiles[0]; + } + + if(lCurrent || lSelected) + RESTfull.delete(lUrl, lSelected, function(){ + if(n > 1) + DOM.deleteSelected(lFiles); + else + DOM.deleteCurrent(lCurrent); + + var lDir = CloudFunc.removeLastSlash( + DOM.getCurrentDirPath() + ); + + Cache.remove(lDir); + }, lQuery); + + return lCurrent; + } + + return lRet; + }; + + /** + * Function gets id by src + * @param pSrc + * + * Example: http://domain.com/1.js -> 1_js + */ + this.getIdBySrc = function(pSrc){ + var lRet = Util.isString(pSrc); + + if(lRet){ + var lNum = pSrc.lastIndexOf('/') + 1, + lSub = pSrc.substr(pSrc, lNum), + lID = Util.removeStrOneTime(pSrc, lSub ); + + /* убираем точки */ + while(lID.indexOf('.') > 0) + lID = lID.replace('.', '_'); + + lRet = lID; + } + + return lRet; + }, + + /** + * create elements and load them to DOM-tree + * one-by-one + * + * @param pParams_a + * @param pFunc - onload function + */ + this.anyLoadOnLoad = function(pParams_a, pFunc){ + var lRet = this; + + if( Util.isArray(pParams_a) ) { + var lParam = pParams_a.pop(), + lFunc = function(){ + this.anyLoadOnLoad(pParams_a, pFunc); + }; + + if( Util.isString(lParam) ) + lParam = { src : lParam }; + else if( Util.isArray(lParam) ){ + + this.anyLoadInParallel(lParam, lFunc); + } + + if(lParam && !lParam.func){ + lParam.func = lFunc; + + this.anyload(lParam); + + }else + Util.exec(pFunc); + } + + return lRet; + }; + + /** + * improve callback of funcs so + * we pop number of function and + * if it's last we call pCallBack + * + * @param pParams_a + * @param pFunc - onload function + */ + this.anyLoadInParallel = function(pParams_a, pFunc){ + var lRet = this, + lDone = [], + + lDoneFunc = function (pCallBack){ + Util.exec(pCallBack); + + if( !lDone.pop() ) + Util.exec(pFunc); + }; + + if( !Util.isArray(pParams_a) ){ + pParams_a = [pParams_a]; + } + + for(var i = 0, n = pParams_a.length; i < n; i++){ + var lParam = pParams_a.pop(); + + if(lParam){ + lDone.push(i); + + if(Util.isString(lParam) ) + lParam = { src : lParam }; + + var lFunc = lParam.func; + lParam.func = Util.retExec(lDoneFunc, lFunc); + + this.anyload(lParam); + } + } + + return lRet; + }; + + /** + * Функция создаёт элемент и загружает файл с src. + * + * @param pParams_o = { + * name, - название тэга + * src', - путь к файлу + * func, - обьект, содержаий одну из функций + * или сразу две onload и onerror + * {onload: function(){}, onerror: function();} + * style, + * id, + * element, + * async, - true by default + * inner: 'id{color:red, }, + * class, + * not_append - false by default + * } + */ + this.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] = this.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 || document.body, + lInner = pParams_o.inner, + lStyle = pParams_o.style, + lNotAppend = pParams_o.not_append; + + if ( Util.isObject(lFunc) ){ + lOnError = lFunc.onerror; + lFunc = lFunc.onload; + } + /* убираем путь к файлу, оставляя только название файла */ + if(!lID && lSrc) + lID = this.getIdBySrc(lSrc); + + var lElement = this.getById(lID); + + /* если скрипт еще не загружен */ + if(!lElement){ + 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'}; + } + } + lElement = document.createElement(lName); + + if(lID) + lElement.id = lID; + + if(lClass) + lElement.className = lClass; + + /* if working with external css + * using href in any other case + * using src + */ + if(lName === 'link'){ + lElement.href = lSrc; + lElement.rel = 'stylesheet'; + }else + lElement.src = lSrc; + + /* + * if passed arguments function + * then it's onload by default + * + * if object - then onload and onerror + */ + + var lLoad = function(pEvent){ + Events.removeListener('load', lLoad, lElement); + Events.removeListener('error', lError, lElement); + + Util.exec(lFunc, pEvent); + }, + + lError = function(){ + lParent.removeChild(lElement); + + Images.showError({ + responseText: 'file ' + + lSrc + + ' could not be loaded', + status : 404 + }); + + Util.exec(lOnError); + }; + + Events.addListener('load', lLoad, lElement); + Events.addErrorListener(lError, lElement); + + if(lStyle) + lElement.style.cssText = lStyle; + + if(lAsync || lAsync === undefined) + lElement.async = true; + + if(!lNotAppend) + lParent.appendChild(lElement); + + if(lInner) + lElement.innerHTML = lInner; + } + /* если js-файл уже загружен + * запускаем функцию onload + */ + else + Util.exec(lFunc); + + return lElement; + }, + + /** + * Функция загружает js-файл + * + * @param pSrc + * @param pFunc + */ + this.jsload = function(pSrc, pFunc){ + if( Util.isArray(pSrc) ){ + for(var i=0; i < pSrc.length; i++) + pSrc[i].name = 'script'; + + return this.anyload(pSrc); + } + + return this.anyload({ + name : 'script', + src : pSrc, + func : pFunc + }); + }, + + /** + * returns jsload functions + */ + this.retJSLoad = function(pSrc, pFunc){ + var lRet = function(){ + return this.jsload(pSrc, pFunc); + }; + + return lRet; + }, + + + /** + * Функция создаёт елемент style и записывает туда стили + * @param pParams_o - структура параметров, заполняеться таким + * образом: {src: ' ',func: '', id: '', element: '', inner: ''} + * все параметры опциональны + */ + this.cssSet = function(pParams_o){ + pParams_o.name = 'style'; + pParams_o.parent = pParams_o.parent || document.head; + + return this.anyload(pParams_o); + }, + + /** + * Function loads external css files + * @pParams_o - структура параметров, заполняеться таким + * образом: {src: ' ',func: '', id: '', element: '', inner: ''} + * все параметры опциональны + */ + this.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 this.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 this.anyload(pParams_o); + }; + + /** + * load jquery from google cdn or local copy + * @param pCallBack + */ + this.jqueryLoad = function(pCallBack){ + /* загружаем jquery: */ + this.jsload('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js',{ + onload: Util.retExec(pCallBack), + + onerror: function(){ + this.jsload('/lib/client/jquery.js'); + + /* if could not load jquery from google server + * maybe we offline, load font from local + * directory */ + this.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");}' + }); + } }); }; - - if( !Util.isObject(pCallBack) ) - lParams = lFunc; - else - lParams = { - success : lFunc, - error : pCallBack.error + + /** + * load socket.io + * @param pCallBack + */ + this.socketLoad = function(pCallBack){ + this.jsload('/lib/client/socket.js', Util.retExec(pCallBack) ); }; - - return DOMProto.getCurrentFileContent(lParams, lCurrentFile); - }; - - /** - * unified way to get RefreshButton - */ - DOMProto.getRefreshButton = function(){ - var lPanel = DOMProto.getPanel(), - lRefresh = DOMProto.getByClass(CloudFunc.REFRESHICON, lPanel), - lRet = lRefresh[0]; - - return lRet; - }; - - - /** - * unified way to set current file - */ - DOMProto.setCurrentFile = function(pCurrentFile){ - var lRet, - lCurrentFileWas = DOMProto.getCurrentFile(); - - if(pCurrentFile){ - if (pCurrentFile.className === 'path') - pCurrentFile = pCurrentFile.nextSibling; - if (pCurrentFile.className === 'fm-header') - pCurrentFile = pCurrentFile.nextSibling; - - if(lCurrentFileWas) - unsetCurrentFile(lCurrentFileWas); - - DOMProto.addClass(pCurrentFile, CURRENT_FILE); - - /* scrolling to current file */ - DOMProto.scrollIntoViewIfNeeded(pCurrentFile); - - lRet = true; - } - - return lRet; - }; - - /** - * select current file - * @param pCurrent - */ - DOMProto.setSelectedFile = function(pCurrent){ - var lCurrent = pCurrent || DOMProto.getCurrentFile(), - lRet = DOMProto.addClass(pCurrent, SELECTED_FILE); - - if(!lRet) - DOMProto.unsetSelectedFile(lCurrent); - - return lRet; - }; - - /** - * unselect current file - * @param pCurrent - */ - DOMProto.unsetSelectedFile = function(pCurrent){ - var lCurrent = pCurrent || DOMProto.getCurrentFile(), - lRet = DOMProto.removeClass(lCurrent, SELECTED_FILE); - - return lRet; - }; - - /** - * setting history wrapper - */ - DOMProto.setHistory = function(pData, pTitle, pUrl){ - var lRet = window.history; - - if(lRet) - history.pushState(pData, pTitle, pUrl); - - return lRet; - }; - - /** - * set onclick handler on buttons f1-f10 - * @param pKey - 'f1'-'f10' - */ - DOMProto.setButtonKey = function(pKey, pFunc){ - Util.tryCatchLog(function(){ - CloudCommander.KeysPanel[pKey].onclick = pFunc; - }); - }; - - /** - * set title with pName - * create title element - * if it absent - * @param pName - */ - - DOMProto.setTitle = function(pName){ - if(!Title) - Title = DOMProto.getByTag('title')[0] || - DOMProto.anyload({ - name:'title', - parentElement: document.head, - innerHTML: pName - }); - if(Title) - Title.textContent = pName; - - return Title; - }; - - /** - * current file check - * - * @param pCurrentFile - */ - DOMProto.isCurrentFile = function(pCurrent){ - var lRet; - - if( pCurrent ) - lRet = DOMProto.isContainClass(pCurrent, CURRENT_FILE); - - return lRet; - }; - - /** - * selected file check - * - * @param pCurrentFile - */ - DOMProto.isSelected = function(pSelected){ - var lRet; - - if( pSelected ) - lRet = DOMProto.isContainClass(pSelected, SELECTED_FILE); - - return lRet; - }; - - /** - * check is current file is a directory - * - * @param pCurrentFile - */ - DOMProto.isCurrentIsDir = function(pCurrent){ - var lCurrent = pCurrent || DOMProto.getCurrentFile(), - lFileType = DOMProto.getByClass('mini-icon', lCurrent)[0], - lRet = DOMProto.isContainClass(lFileType, 'directory'); - - return lRet; - }; - - - /** - * get link from current (or param) file - * - * @param pCurrentFile - current file by default - */ - DOMProto.getCurrentLink = function(pCurrentFile){ - var lLink = DOMProto.getByTag( 'a', pCurrentFile || DOMProto.getCurrentFile() ), - - lRet = lLink.length > 0 ? lLink[0] : -1; - - return lRet; - }; - - /** - * get link from current (or param) file - * - * @param pCurrentFile - current file by default - */ - DOMProto.getCurrentPath = function(pCurrentFile){ - var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), - lPath = DOMProto.getCurrentLink( lCurrent ).href; - - lPath = decodeURI(lPath); - /* убираем адрес хоста*/ - lPath = Util.removeStrOneTime( lPath, [CloudCommander.HOST, CloudFunc.FS] ); - - return lPath; - }; - - /** - * get name from current (or param) file - * - * @param pCurrentFile - */ - DOMProto.getCurrentName = function(pCurrentFile){ - var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), - lLink = DOMProto.getCurrentLink( lCurrent ); - - if( Util.isObject(lLink) ) - lLink = lLink.title || lLink.textContent; - - return lLink; - }; - - DOMProto.getSelectedNames = function(pSelected){ - var lSelected = pSelected || DOMProto.getSelectedFiles(), - lRet = lSelected ? [] : null; - - if(lRet){ - var lFirst = lSelected[0], - lName = DOMProto.getCurrentName( lFirst ); - - if(lName === '..') - DOMProto.unsetSelectedFile( lFirst ); - - for(var i = 0, n = lSelected.length; i < n;i++) - lRet[i] = DOMProto.getCurrentName( lSelected[i] ); - } - return lRet; - }; - - /** - * set name from current (or param) file - * - * @param pCurrentFile - */ - DOMProto.setCurrentName = function(pName, pCurrentFile){ - var lLink = DOMProto.getCurrentLink( pCurrentFile ), - lDir = DOMProto.getCurrentDirName() + '/'; - - lLink.title = lLink.textContent = pName; - lLink.href = lDir + pName; - - return lLink; - }; - - /** function getting FM - * @param pPanel_o = {active: true} - */ - DOMProto.getFM = function(){ - return DOMProto.getPanel().parentElement; - }; - - /** function getting panel active, or passive - * @param pPanel_o = {active: true} - */ - DOMProto.getPanel = function(pActive){ - var lPanel = DOMProto.getCurrentFile().parentElement; - - /* if {active : false} getting passive panel */ - if(pActive && !pActive.active){ - var lId = lPanel.id === 'left' ? 'right' : 'left'; - lPanel = DOMProto.getById(lId); - } - - /* if two panels showed - * then always work with passive - * panel - */ - if(window.innerWidth < CloudCommander.MIN_ONE_PANEL_WIDTH) - lPanel = DOMProto.getById('left'); - - - if(!lPanel) - Util.log('Error can not find Active Panel'); - - return lPanel; - }; - - /** prevent default event */ - DOMProto.preventDefault = function(pEvent){ - var lRet, - lPreventDefault = pEvent && pEvent.preventDefault, - lFunc = Util.bind(lPreventDefault, pEvent); - - lRet = Util.exec(lFunc); - - return lRet; - }; - - DOMProto.show = function(pElement){ - DOMProto.removeClass(pElement, 'hidden'); - }; - - /** - * shows panel right or left (or active) - */ - DOMProto.showPanel = function(pActive){ - var lRet = true, - lPanel = DOMProto.getPanel(pActive); - - if(lPanel) - DOMProto.show(lPanel); - else - lRet = false; - - return lRet; - }; - - /** - * hides panel right or left (or active) - */ - DOMProto.hidePanel = function(pActive){ - var lRet = false, - lPanel = DOMProto.getPanel(pActive); - - if(lPanel) - lRet = DOMProto.hide(lPanel); - - return lRet; - }; - - /** - * add class=hidden to element - * - * @param pElement - */ - DOMProto.hide = function(pElement){ - return DOMProto.addClass(pElement, 'hidden'); - }; - - /** - * open window with URL - * @param pUrl - */ - DOMProto.openWindow = function(pUrl){ - var left = 140, - top = 187, - width = 1000, - height = 650, - - lOptions = 'left=' + left + - ',top=' + top + - ',width=' + width + - ',height=' + height + - ',personalbar=0,toolbar=0' + - ',scrollbars=1,resizable=1'; - - var lWind = window.open(pUrl, 'Cloud Commander Auth', lOptions); - if(!lWind) - Util.log('Pupup blocked!'); - }; - - /** - * remove child of element - * @param pChild - * @param pElement - */ - DOMProto.remove = function(pChild, pElement){ - return (pElement || document.body).removeChild(pChild); - }; - - /** - * remove class pClass from element pElement - * @param pElement - * @param pClass - */ - DOMProto.removeClass = function(pElement, pClass){ - var lRet_b = true, - lClassList = pElement.classList; - - if(pElement && lClassList) - lClassList.remove(pClass); - - else - lRet_b = false; - - return lRet_b; - }; - - /** - * remove current file from file table - * @pCurrent - */ - DOMProto.deleteCurrent = function(pCurrent, pNextFile, pPreviousFile, pNotSet){ - var lCurrent = pCurrent || DOMProto.getCurrentFile(), - lParent = lCurrent && lCurrent.parentElement, - lName = DOMProto.getCurrentName(lCurrent); - - if(lCurrent && lParent && lName !== '..'){ - var lNext = pNextFile || lCurrent.nextSibling, - lPrevious = pPreviousFile || lCurrent.previousSibling; - - if(!pNotSet) - if(lNext) - DOMProto.setCurrentFile(lNext); - else if(lPrevious) - DOMProto.setCurrentFile(lPrevious); - - lParent.removeChild(lCurrent); - } - - return lCurrent; - }; - - /** - * remove selected files from file table - * @Selected - */ - DOMProto.deleteSelected = function(pSelected){ - var lSelected = pSelected || DOMProto.getSelectedFiles(); - - if(lSelected){ - var n = lSelected.length, - lLast = n-1, - lNext = lSelected[lLast].nextSibling, - lPrev = lSelected[0].previousSibling; - - /* lSelected[0] - becouse lSelected is a link to DOM so - * when we remove 0 element, it's removed from lSelected to + /** + * get current direcotory name */ - for(var i = 0; i < n; i++) - DOMProto.deleteCurrent( lSelected[0], lNext, lPrev, i !== lLast); - } - - return lSelected; - }; - - /** - * rename current file - * - * @pCurrent - */ - DOMProto.renameCurrent = function(pCurrentFile){ - if( !DOMProto.isCurrentFile(pCurrentFile) ) - pCurrentFile = null; - - var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), - lFrom = DOMProto.getCurrentName(lCurrent), - lTo = prompt('Rename', lFrom) || lFrom, - lDirPath = DOMProto.getCurrentDirPath(); - - if( !Util.strCmp(lFrom, lTo) ){ - var lFiles = { - from : lDirPath + lFrom, - to : lDirPath + lTo + this.getCurrentDirName = function(){ + var lRet, + lSubstr, + lPanel = this.getPanel(), + /* получаем имя каталога в котором находимся */ + lHref = this.getByClass('path', lPanel); + + lHref = lHref[0].textContent; + + lHref = CloudFunc.removeLastSlash(lHref); + lSubstr = lHref.substr(lHref , lHref.lastIndexOf('/')); + lRet = Util.removeStrOneTime(lHref, lSubstr + '/') || '/'; + + return lRet; }; - DOMProto.RESTfull.mv(lFiles, function(){ - DOMProto.setCurrentName(lTo, lCurrent); - }); - } - }; - - /** - * move current file - * - * @pCurrent - */ - DOMProto.moveCurrent = function(pCurrentFile){ - if( !DOMProto.isCurrentFile(pCurrentFile) ) - pCurrentFile = null; - - var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), - lName = DOMProto.getCurrentName(lCurrent), - lFromPath = DOMProto.getCurrentPath(), - lToPath = DOMProto.getNotCurrentDirPath() + lName; - - lToPath = prompt( 'Rename/Move file "' + lName + '"', lToPath ); - - if( lToPath && !Util.strCmp(lFromPath, lToPath) ){ - var lFiles = { - from : lFromPath, - to : lToPath + /** + * get current direcotory path + */ + this.getCurrentDirPath = function(pPanel){ + var lPanel = pPanel || this.getPanel(), + lPath = this.getByClass('path', lPanel)[0], + lRet; + + if(lPath) + lRet = lPath.textContent; + + return lRet; }; - DOMProto.RESTfull.mv(lFiles, function(){ - DOMProto.deleteCurrent(lCurrent); + /** + * get current direcotory path + */ + this.getNotCurrentDirPath = function(){ + var lPanel = this.getPanel(true), + lPath = this.getByClass('path', lPanel)[0], + lRet; - var lPanel = DOMProto.getPanel(true), - lDotDot = DOMProto.getById( '..(' + lPanel.id + ')'); + if(lPath) + lRet = lPath.textContent; - DOMProto.setCurrentFile ( lDotDot ); - CloudCommander.refresh(); - }); - } - }; - - /** - * copy current file - * - * @pCurrent - */ - DOMProto.copyCurrent = function(pCurrentFile){ - if( !DOMProto.isCurrentFile(pCurrentFile) ) - pCurrentFile = null; - - var lCurrent = pCurrentFile || DOMProto.getCurrentFile(), - lName = DOMProto.getCurrentName(lCurrent), - lFromPath = DOMProto.getCurrentPath(), - lToPath = DOMProto.getNotCurrentDirPath() + lName; - lToPath = prompt( 'Copy file "' + lName + '" to', lToPath ); - - if( lToPath && !Util.strCmp(lFromPath, lToPath) ){ - var lFiles = { - from : lFromPath, - to : lToPath + return lRet; }; - DOMProto.RESTfull.cp(lFiles, function(){ - var lPanel = DOMProto.getPanel(true), - lDotDot = DOMProto.getById( '..(' + lPanel.id + ')'); + /** + * unified way to get current file + * + * @pCurrentFile + */ + this.getCurrentFile = function(){ + var lRet = this.getByClass( CURRENT_FILE )[0]; - DOMProto.setCurrentFile ( lDotDot ); - CloudCommander.refresh(); - }); - } - }; - - /** - * unified way to scrollIntoViewIfNeeded - * (native suporte by webkit only) - * @param pElement - */ - DOMProto.scrollIntoViewIfNeeded = function(pElement){ - var lRet = pElement && pElement.scrollIntoViewIfNeeded; - - if(lRet) - pElement.scrollIntoViewIfNeeded(); - - return lRet; - }; - - /* scroll on one page*/ - DOMProto.scrollByPages = function(pElement, pPages){ - var lRet = pElement && pElement.scrollByPages && pPages; - - if(lRet) - pElement.scrollByPages(pPages); - - return lRet; - }; - - /** - * function gets time - */ - DOMProto.getTime = function(){ - var lRet, - lDate = new Date(), - lHours = lDate.getHours(), - lMinutes = lDate.getMinutes(), - lSeconds = lDate.getSeconds(); + return lRet; + }; - lMinutes = lMinutes < 10 ? '0' + lMinutes : lMinutes; - lSeconds = lSeconds < 10 ? '0' + lSeconds : lSeconds; + /** + * unified way to get current file + * + * @pCurrentFile + */ + this.getSelectedFiles = function(){ + var lRet = this.getByClass(SELECTED_FILE); + + return lRet.length ? lRet : null; + }; + + /** + * get size + * @pCurrentFile + */ + this.getCurrentSize = function(pCurrentFile){ + var lRet, + lCurrent = pCurrentFile || this.getCurrentFile(), + lSize = this.getByClass('size', lCurrent); + lSize = lSize[0].textContent; + /* если это папка - возвращаем слово dir вместо размера*/ + lRet = Util.removeStrOneTime(lSize, ['<', '>']); + + return lRet; + }; + + /** + * get size + * @pCurrentFile + */ + this.loadCurrentSize = function(pCallBack, pCurrent){ + var lRet, + lCurrent = pCurrent || this.getCurrentFile(), + lLink = this.getCurrentPath(lCurrent), + lName = this.getCurrentName(lCurrent); + /* если это папка - возвращаем слово dir вместо размера*/ + + if(lName !== '..') + RESTfull.read(lLink, function(pSize){ + DOM.setCurrentSize(pSize, lCurrent); + Util.exec(pCallBack, lCurrent); + }, '?size'); + + return lRet; + }; + + /** + * set size + * @pCurrentFile + */ + this.setCurrentSize = function(pSize, pCurrentFile){ + var lCurrent = pCurrentFile || this.getCurrentFile(), + lSizeElement = this.getByClass('size', lCurrent), + lSize = CloudFunc.getShortSize(pSize); + + lSizeElement[0].textContent = lSize; + + }; + + /** + * @pCurrentFile + */ + this.getCurrentMode = function(pCurrentFile){ + var lRet, + lCurrent = pCurrentFile || this.getCurrentFile(), + lMode = this.getByClass('mode', lCurrent); + lRet = lMode[0].textContent; + + return lRet; + }; + + /** + * unified way to get current file content + * + * @pCallBack - callback function or data struct {sucess, error} + * @pCurrentFile + */ + this.getCurrentFileContent = function(pParams, pCurrentFile){ + var lRet, + lCurrentFile = pCurrentFile ? pCurrentFile : this.getCurrentFile(), + lParams = pParams ? pParams : {}, + lPath = this.getCurrentPath(lCurrentFile), + lErrorWas = pParams.error, + lError = function(jqXHR){ + Util.exec(lErrorWas); + Images.showError(jqXHR); + }; + + if( Util.isFunction(lParams) ) + lParams.success = Util.retExec(pParams); + + lParams.error = lError; + + + if( this.isCurrentIsDir(lCurrentFile) ) + lPath += '?json'; + + if(!lParams.url) + lParams.url = CloudFunc.FS + lPath; + + lRet = this.ajax(lParams); + + return lRet; + }; + + /** + * unified way to get current file content + * + * @pCallBack - function({data, name}){} + * @pCurrentFile + */ + this.getCurrentData = function(pCallBack, pCurrentFile){ + + var lParams, + lCurrentFile = pCurrentFile ? pCurrentFile : this.getCurrentFile(), + lFunc = function(pData){ + var lName = this.getCurrentName(lCurrentFile); + if( Util.isObject(pData) ){ + pData = Util.stringifyJSON(pData); + + var lExt = '.json'; + if( !Util.checkExtension(lName, lExt) ) + lName += lExt; + } + + Util.exec(pCallBack, { + data: pData, + name: lName + }); + }; + + if( !Util.isObject(pCallBack) ) + lParams = lFunc; + else + lParams = { + success : lFunc, + error : pCallBack.error + }; + + + return this.getCurrentFileContent(lParams, lCurrentFile); + }; + + /** + * unified way to get RefreshButton + */ + this.getRefreshButton = function(){ + var lPanel = this.getPanel(), + lRefresh = this.getByClass(CloudFunc.REFRESHICON, lPanel), + lRet = lRefresh[0]; + + return lRet; + }; + + + /** + * unified way to set current file + */ + this.setCurrentFile = function(pCurrentFile){ + var lRet, + lCurrentFileWas = this.getCurrentFile(); + + if(pCurrentFile){ + if (pCurrentFile.className === 'path') + pCurrentFile = pCurrentFile.nextSibling; + + if (pCurrentFile.className === 'fm-header') + pCurrentFile = pCurrentFile.nextSibling; + + if(lCurrentFileWas) + unsetCurrentFile(lCurrentFileWas); + + this.addClass(pCurrentFile, CURRENT_FILE); + + /* scrolling to current file */ + this.scrollIntoViewIfNeeded(pCurrentFile); + + lRet = true; + } + + return lRet; + }; + + /** + * select current file + * @param pCurrent + */ + this.setSelectedFile = function(pCurrent){ + var lCurrent = pCurrent || this.getCurrentFile(), + lRet = this.addClass(pCurrent, SELECTED_FILE); + + if(!lRet) + this.unsetSelectedFile(lCurrent); + + return lRet; + }; + + /** + * unselect current file + * @param pCurrent + */ + this.unsetSelectedFile = function(pCurrent){ + var lCurrent = pCurrent || this.getCurrentFile(), + lRet = this.removeClass(lCurrent, SELECTED_FILE); + + return lRet; + }; + + /** + * setting history wrapper + */ + this.setHistory = function(pData, pTitle, pUrl){ + var lRet = window.history; + + if(lRet) + history.pushState(pData, pTitle, pUrl); + + return lRet; + }; + + /** + * set onclick handler on buttons f1-f10 + * @param pKey - 'f1'-'f10' + */ + this.setButtonKey = function(pKey, pFunc){ + Util.tryCatchLog(function(){ + CloudCommander.KeysPanel[pKey].onclick = pFunc; + }); + }; + + /** + * set title with pName + * create title element + * if it absent + * @param pName + */ + + this.setTitle = function(pName){ + if(!Title) + Title = this.getByTag('title')[0] || + this.anyload({ + name:'title', + parentElement: document.head, + innerHTML: pName + }); + if(Title) + Title.textContent = pName; + + return Title; + }; + + /** + * current file check + * + * @param pCurrentFile + */ + this.isCurrentFile = function(pCurrent){ + var lRet; + + if( pCurrent ) + lRet = this.isContainClass(pCurrent, CURRENT_FILE); + + return lRet; + }; + + /** + * selected file check + * + * @param pCurrentFile + */ + this.isSelected = function(pSelected){ + var lRet; + + if( pSelected ) + lRet = this.isContainClass(pSelected, SELECTED_FILE); + + return lRet; + }; + + /** + * check is current file is a directory + * + * @param pCurrentFile + */ + this.isCurrentIsDir = function(pCurrent){ + var lCurrent = pCurrent || this.getCurrentFile(), + lFileType = this.getByClass('mini-icon', lCurrent)[0], + lRet = this.isContainClass(lFileType, 'directory'); + + return lRet; + }; + + + /** + * get link from current (or param) file + * + * @param pCurrentFile - current file by default + */ + this.getCurrentLink = function(pCurrentFile){ + var lLink = this.getByTag( 'a', pCurrentFile || this.getCurrentFile() ), + + lRet = lLink.length > 0 ? lLink[0] : -1; + + return lRet; + }; + + /** + * get link from current (or param) file + * + * @param pCurrentFile - current file by default + */ + this.getCurrentPath = function(pCurrentFile){ + var lCurrent = pCurrentFile || this.getCurrentFile(), + lPath = this.getCurrentLink( lCurrent ).href; + + lPath = decodeURI(lPath); + /* убираем адрес хоста*/ + lPath = Util.removeStrOneTime( lPath, [CloudCommander.HOST, CloudFunc.FS] ); + + return lPath; + }; + + /** + * get name from current (or param) file + * + * @param pCurrentFile + */ + this.getCurrentName = function(pCurrentFile){ + var lCurrent = pCurrentFile || this.getCurrentFile(), + lLink = this.getCurrentLink( lCurrent ); + + if( Util.isObject(lLink) ) + lLink = lLink.title || lLink.textContent; + + return lLink; + }; + + this.getSelectedNames = function(pSelected){ + var lSelected = pSelected || this.getSelectedFiles(), + lRet = lSelected ? [] : null; + + if(lRet){ + var lFirst = lSelected[0], + lName = this.getCurrentName( lFirst ); + + if(lName === '..') + this.unsetSelectedFile( lFirst ); + + for(var i = 0, n = lSelected.length; i < n;i++) + lRet[i] = this.getCurrentName( lSelected[i] ); + } + return lRet; + }; + + /** + * set name from current (or param) file + * + * @param pCurrentFile + */ + this.setCurrentName = function(pName, pCurrentFile){ + var lLink = this.getCurrentLink( pCurrentFile ), + lDir = this.getCurrentDirName() + '/'; + + lLink.title = lLink.textContent = pName; + lLink.href = lDir + pName; + + return lLink; + }; + + /** function getting FM + * @param pPanel_o = {active: true} + */ + this.getFM = function(){ + return this.getPanel().parentElement; + }; + + /** function getting panel active, or passive + * @param pPanel_o = {active: true} + */ + this.getPanel = function(pActive){ + var lPanel = this.getCurrentFile().parentElement; + + /* if {active : false} getting passive panel */ + if(pActive && !pActive.active){ + var lId = lPanel.id === 'left' ? 'right' : 'left'; + lPanel = this.getById(lId); + } + + /* if two panels showed + * then always work with passive + * panel + */ + if(window.innerWidth < CloudCommander.MIN_ONE_PANEL_WIDTH) + lPanel = this.getById('left'); + + + if(!lPanel) + Util.log('Error can not find Active Panel'); + + return lPanel; + }; + + /** prevent default event */ + this.preventDefault = function(pEvent){ + var lRet, + lPreventDefault = pEvent && pEvent.preventDefault, + lFunc = Util.bind(lPreventDefault, pEvent); + + lRet = Util.exec(lFunc); + + return lRet; + }; + + /** + * shows panel right or left (or active) + */ + this.showPanel = function(pActive){ + var lRet = true, + lPanel = this.getPanel(pActive); + + if(lPanel) + this.show(lPanel); + else + lRet = false; + + return lRet; + }; + + /** + * hides panel right or left (or active) + */ + this.hidePanel = function(pActive){ + var lRet = false, + lPanel = this.getPanel(pActive); + + if(lPanel) + lRet = this.hide(lPanel); + + return lRet; + }; + + /** + * open window with URL + * @param pUrl + */ + this.openWindow = function(pUrl){ + var left = 140, + top = 187, + width = 1000, + height = 650, + + lOptions = 'left=' + left + + ',top=' + top + + ',width=' + width + + ',height=' + height + + ',personalbar=0,toolbar=0' + + ',scrollbars=1,resizable=1'; + + var lWind = window.open(pUrl, 'Cloud Commander Auth', lOptions); + if(!lWind) + Util.log('Pupup blocked!'); + }; + + /** + * remove child of element + * @param pChild + * @param pElement + */ + this.remove = function(pChild, pElement){ + return (pElement || document.body).removeChild(pChild); + }; + + /** + * remove class pClass from element pElement + * @param pElement + * @param pClass + */ + this.removeClass = function(pElement, pClass){ + var lRet_b = true, + lClassList = pElement.classList; + + if(pElement && lClassList) + lClassList.remove(pClass); + + else + lRet_b = false; + + return lRet_b; + }; + + /** + * remove current file from file table + * @pCurrent + */ + this.deleteCurrent = function(pCurrent, pNextFile, pPreviousFile, pNotSet){ + var lCurrent = pCurrent || this.getCurrentFile(), + lParent = lCurrent && lCurrent.parentElement, + lName = this.getCurrentName(lCurrent); + + if(lCurrent && lParent && lName !== '..'){ + var lNext = pNextFile || lCurrent.nextSibling, + lPrevious = pPreviousFile || lCurrent.previousSibling; + + if(!pNotSet) + if(lNext) + this.setCurrentFile(lNext); + else if(lPrevious) + this.setCurrentFile(lPrevious); + + lParent.removeChild(lCurrent); + } + + return lCurrent; + }; + + /** + * remove selected files from file table + * @Selected + */ + this.deleteSelected = function(pSelected){ + var lSelected = pSelected || this.getSelectedFiles(); + + if(lSelected){ + var n = lSelected.length, + lLast = n-1, + lNext = lSelected[lLast].nextSibling, + lPrev = lSelected[0].previousSibling; + + /* lSelected[0] - becouse lSelected is a link to DOM so + * when we remove 0 element, it's removed from lSelected to + */ + for(var i = 0; i < n; i++) + this.deleteCurrent( lSelected[0], lNext, lPrev, i !== lLast); + } + + return lSelected; + }; + + /** + * rename current file + * + * @pCurrent + */ + this.renameCurrent = function(pCurrentFile){ + if( !this.isCurrentFile(pCurrentFile) ) + pCurrentFile = null; + + var lCurrent = pCurrentFile || this.getCurrentFile(), + lFrom = this.getCurrentName(lCurrent), + lTo = prompt('Rename', lFrom) || lFrom, + lDirPath = this.getCurrentDirPath(); + + if( !Util.strCmp(lFrom, lTo) ){ + var lFiles = { + from : lDirPath + lFrom, + to : lDirPath + lTo + }; + + RESTfull.mv(lFiles, function(){ + DOM.setCurrentName(lTo, lCurrent); + }); + } + }; + + /** + * move current file + * + * @pCurrent + */ + this.moveCurrent = function(pCurrentFile){ + if( !this.isCurrentFile(pCurrentFile) ) + pCurrentFile = null; + + var lCurrent = pCurrentFile || this.getCurrentFile(), + lName = this.getCurrentName(lCurrent), + lFromPath = this.getCurrentPath(), + lToPath = this.getNotCurrentDirPath() + lName; + + lToPath = prompt( 'Rename/Move file "' + lName + '"', lToPath ); + + if( lToPath && !Util.strCmp(lFromPath, lToPath) ){ + var lFiles = { + from : lFromPath, + to : lToPath + }; + + RESTfull.mv(lFiles, function(){ + DOM.deleteCurrent(lCurrent); + + var lPanel = DOM.getPanel(true), + lDotDot = DOM.getById( '..(' + lPanel.id + ')'); + + DOM.setCurrentFile ( lDotDot ); + CloudCommander.refresh(); + }); + } + }; + + /** + * copy current file + * + * @pCurrent + */ + this.copyCurrent = function(pCurrentFile){ + if( !this.isCurrentFile(pCurrentFile) ) + pCurrentFile = null; + + var lCurrent = pCurrentFile || this.getCurrentFile(), + lName = this.getCurrentName(lCurrent), + lFromPath = this.getCurrentPath(), + lToPath = this.getNotCurrentDirPath() + lName; + lToPath = prompt( 'Copy file "' + lName + '" to', lToPath ); + + if( lToPath && !Util.strCmp(lFromPath, lToPath) ){ + var lFiles = { + from : lFromPath, + to : lToPath + }; + + RESTfull.cp(lFiles, function(){ + var lPanel = DOM.getPanel(true), + lDotDot = DOM.getById( '..(' + lPanel.id + ')'); + + DOM.setCurrentFile ( lDotDot ); + CloudCommander.refresh(); + }); + } + }; + + /** + * unified way to scrollIntoViewIfNeeded + * (native suporte by webkit only) + * @param pElement + */ + this.scrollIntoViewIfNeeded = function(pElement){ + var lRet = pElement && pElement.scrollIntoViewIfNeeded; + + if(lRet) + pElement.scrollIntoViewIfNeeded(); + + return lRet; + }; + + /* scroll on one page*/ + this.scrollByPages = function(pElement, pPages){ + var lRet = pElement && pElement.scrollByPages && pPages; + + if(lRet) + pElement.scrollByPages(pPages); + + return lRet; + }; + + /** + * function gets time + */ + this.getTime = function(){ + var lRet, + lDate = new Date(), + lHours = lDate.getHours(), + lMinutes = lDate.getMinutes(), + lSeconds = lDate.getSeconds(); + + lMinutes = lMinutes < 10 ? '0' + lMinutes : lMinutes; + lSeconds = lSeconds < 10 ? '0' + lSeconds : lSeconds; + + lRet = lHours + ":" + lMinutes + ":" + lSeconds; + + return lRet; + }; + }, - lRet = lHours + ":" + lMinutes + ":" + lSeconds; - - return lRet; - }; + Images = Util.extendProto(ImagesProto), + RESTfull = Util.extendProto(RESTfullProto), + DOMTree = Util.extendProto(DOMTreeProto), + Events = Util.extendProto(EventsProto), + Cache = Util.extendProto(CacheProto); + + DOMProto = DOMFunc.prototype = new CmdProto(); + + Util.extend(DOMProto, [ + DOMTree, + Events, { + RESTfull: RESTfull, + Images : Images, + Cache : Cache + } + ]); + + DOM = new DOMFunc(); })(Util); \ No newline at end of file diff --git a/lib/util.js b/lib/util.js index b0d82633..b8103455 100644 --- a/lib/util.js +++ b/lib/util.js @@ -168,12 +168,31 @@ Util = exports || {}; return lRet; }; + Util.convertArrToObj = function(pArrKeys, pArrVal){ + var i, n, lName, lRet; + + if(pArrKeys && pArrVal){ + for(i = 0, n = pArrKeys; i < n; i++){ + lName = pArrKeys[i]; + lRet[lName] = pArrVal[i]; + } + } + + return lRet; + }; + + /** + * copy pObj properties to pTargetObject + * + * @pTarget + * @pObj + */ Util.extend = function(pTarget, PObj){ var i, n, lObj, lRet = Util.isObject(pTarget) ? pTarget : {}; if( Util.isArray(PObj) ) for(i = 0, n = PObj.length; i < n; i++) - Util.extend(pTarget, PObj[i]); + lRet = Util.extend(pTarget, PObj[i]); else if(PObj){ lObj = Util.isFunction(PObj) ? new PObj() : PObj; @@ -185,6 +204,20 @@ Util = exports || {}; return lRet; }; + /** + * copy pObj properties to pTargetObject + * + * @pTarget + * @pObj + */ + Util.extendProto = function(pObj){ + var lRet, F = function(){}; + F.prototype = Util.extend({}, pObj); + lRet = new F(); + + return lRet; + }; + /** for function * @param pI * @param pN From df460bbc89803a69fced20af13eba8da05948db8 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 8 May 2013 11:12:37 -0400 Subject: [PATCH 009/239] moved loading functions to Loader object in DOM module --- ChangeLog | 4 + lib/client.js | 8 +- lib/client/config.js | 12 +- lib/client/dom.js | 331 ++++++++++---------- lib/client/editor/_ace.js | 412 ++++++++++++------------- lib/client/editor/_codemirror.js | 6 +- lib/client/keyBinding.js | 20 +- lib/client/menu.js | 9 +- lib/client/socket.js | 206 ++++++------- lib/client/storage/_dropbox.js | 4 +- lib/client/storage/_dropbox_chooser.js | 109 ++++--- lib/client/storage/_filepicker.js | 4 +- lib/client/storage/_gdrive.js | 4 +- lib/client/storage/_github.js | 4 +- lib/client/storage/_skydrive.js | 4 +- lib/client/storage/_vk.js | 194 ++++++------ lib/client/terminal.js | 4 +- lib/client/viewer.js | 4 +- 18 files changed, 670 insertions(+), 669 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad470a90..142e433c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,10 @@ dispatch (dispatchKeyEvent, dispatchClickEvent, dispatchDblClickEvent) +* Changed object name CloudCommander -> CloudCmd + +* Moved loading functions to Loader object in DOM module. + 2012.04.22, v0.2.0 diff --git a/lib/client.js b/lib/client.js index 02d244c3..80658705 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1,8 +1,8 @@ -/* Функция которая возвратит обьект CloudCommander +/* Функция которая возвратит обьект CloudCmd * @CloudFunc - обьект содержащий общий функционал * клиентский и серверный */ -var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; +var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; (function(Util, DOM){ 'use strict'; @@ -10,7 +10,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; var Config, Modules, FileTemplate, PathTemplate; /* Клиентский обьект, содержащий функциональную часть*/ - var CloudCmd = { + CloudCmd = { /* Конструктор CloudClient, который выполняет * весь функционал по инициализации */ @@ -706,8 +706,6 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCommander; return Util.stringifyJSON(lFileTable); }; - CloudCommander = CloudCmd; - DOM.addOneTimeListener('load', function(){ /* базовая инициализация*/ CloudCmd.init(); diff --git a/lib/client/config.js b/lib/client/config.js index e86b5596..1806e1a2 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -1,28 +1,26 @@ /* gui module for config.json editing */ -var CloudCommander; +var CloudCmd; (function(){ - "use strict"; - - var cloudcmd = CloudCommander; + 'use strict'; var Config = {}; Config.Show = (function(){ console.log('config showed'); - var lFancyBox = cloudcmd.Viewer.FancyBox; + var lFancyBox = CloudCmd.Viewer.FancyBox; lFancyBox.loadData({hreef: 'htlm/config.html'}, lFancyBox.onDataLoaded); }); Config.Keys = function(){ console.log('config.js loaded'); - cloudcmd.Viewer(function(){ + CloudCmd.Viewer(function(){ Config.Show(); }); }; - cloudcmd.Config = Config; + CloudCmd.Config = Config; })(); \ No newline at end of file diff --git a/lib/client/dom.js b/lib/client/dom.js index 6e449d9f..f0555cb0 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1,4 +1,4 @@ -var CloudCommander, Util, DOM, CloudFunc; +var CloudCmd, Util, DOM, CloudFunc; (function(Util){ 'use strict'; @@ -68,7 +68,6 @@ var CloudCommander, Util, DOM, CloudFunc; * hide load image */ this.hideLoad = function(){ - DOM.hide( lImages.loading() ); }; @@ -159,7 +158,7 @@ var CloudCommander, Util, DOM, CloudFunc; var p = pParams; Images.showLoad( p.imgPosition ); - CloudCommander.getConfig(function(pConfig){ + CloudCmd.getConfig(function(pConfig){ var lData; if( Util.isString(p.url) ) @@ -171,7 +170,7 @@ var CloudCommander, Util, DOM, CloudFunc; lData = p.data; p.url = pConfig && pConfig.api_url + p.url, - DOM.ajax({ + Loader.ajax({ method : p.method, url : p.url, data : lData, @@ -530,27 +529,34 @@ var CloudCommander, Util, DOM, CloudFunc; return lRet; }; }, - CmdProto = function(){ - var CURRENT_FILE = 'current-file', - SELECTED_FILE = 'selected-file', - XMLHTTP, Title; + LoaderProto = function(){ + var XMLHTTP; /** - * private function thet unset currentfile + * Function gets id by src + * @param pSrc * - * @pCurrentFile + * Example: http://domain.com/1.js -> 1_js */ - function unsetCurrentFile(pCurrentFile){ - var lRet = DOM.isCurrentFile(pCurrentFile); + this.getIdBySrc = function(pSrc){ + var lRet = Util.isString(pSrc); - if(lRet) - DOM.removeClass(pCurrentFile, CURRENT_FILE); + if(lRet){ + var lNum = pSrc.lastIndexOf('/') + 1, + lSub = pSrc.substr(pSrc, lNum), + lID = Util.removeStrOneTime(pSrc, lSub ); + + /* убираем точки */ + while(lID.indexOf('.') > 0) + lID = lID.replace('.', '_'); + + lRet = lID; + } return lRet; - } + }; - - /** + /** * load file countent thrue ajax * * @param pParams @@ -598,143 +604,6 @@ var CloudCommander, Util, DOM, CloudFunc; return lRet; }; - /** - * create new folder - * - * @pCurrentFile - */ - this.promptNewDir = function(){ - this.promptNewFile('directory', '?dir'); - }; - - /** - * create new file - * - * @pCurrentFile - */ - this.promptNewFile = function(pTypeName, pType){ - var lName = this.getCurrentName(), - lDir = this.getCurrentDirPath(), - lMsg = 'New ' + pTypeName || 'File', - lType = Util.isString(pType) ? pType : ''; - - if(lName === '..') - lName = ''; - - lName = prompt(lMsg, lName); - - if(lName) - RESTfull.save(lDir + lName + lType, null, CloudCommander.refresh); - }; - - - - /** - * delete currentfile, prompt before it - * - * @pCurrentFile - */ - this.promptDeleteSelected = function(pCurrentFile){ - var lRet, - lCurrent, lQuery, lMsg, - lName = '', - lMsgAsk = 'Do you really want to delete the ', - lMsgSel = 'selected ', - lFiles = this.getSelectedFiles(), - lSelected = this.getSelectedNames(lFiles), - i, n = lSelected && lSelected.length; - - if(n > 1){ - for(i = 0; i < 5 && i < n; i++) - lName += '\n' + lSelected[i]; - - if(n >= 5) - lName += '\n...'; - - lMsg = lMsgAsk + lMsgSel + n + ' files/directoris?\n' + lName ; - lQuery = '?files'; - }else{ - var lType, lIsDir; - - /* dom element passed and it is not event */ - if( pCurrentFile && !pCurrentFile.pType) - lCurrent = pCurrentFile; - else - lCurrent = this.getCurrentFile(); - - lIsDir = this.isCurrentIsDir(lCurrent); - - if(lIsDir){ - lQuery = '?dir'; - lType ='directory'; - } - else - lType = 'file'; - - lType += ' '; - - lName = this.getCurrentName(lCurrent); - lMsg = lMsgAsk + lMsgSel + lType + lName + '?'; - } - - if(lName !== '..') - lRet = confirm(lMsg); - else - alert('No files selected!'); - if(lRet){ - var lUrl; - - if(lCurrent) - lUrl = this.getCurrentPath(lCurrent); - else{ - lUrl = this.getCurrentDirPath(); - lCurrent = lFiles[0]; - } - - if(lCurrent || lSelected) - RESTfull.delete(lUrl, lSelected, function(){ - if(n > 1) - DOM.deleteSelected(lFiles); - else - DOM.deleteCurrent(lCurrent); - - var lDir = CloudFunc.removeLastSlash( - DOM.getCurrentDirPath() - ); - - Cache.remove(lDir); - }, lQuery); - - return lCurrent; - } - - return lRet; - }; - - /** - * Function gets id by src - * @param pSrc - * - * Example: http://domain.com/1.js -> 1_js - */ - this.getIdBySrc = function(pSrc){ - var lRet = Util.isString(pSrc); - - if(lRet){ - var lNum = pSrc.lastIndexOf('/') + 1, - lSub = pSrc.substr(pSrc, lNum), - lID = Util.removeStrOneTime(pSrc, lSub ); - - /* убираем точки */ - while(lID.indexOf('.') > 0) - lID = lID.replace('.', '_'); - - lRet = lID; - } - - return lRet; - }, - /** * create elements and load them to DOM-tree * one-by-one @@ -1060,6 +929,138 @@ var CloudCommander, Util, DOM, CloudFunc; this.socketLoad = function(pCallBack){ this.jsload('/lib/client/socket.js', Util.retExec(pCallBack) ); }; + }, + CmdProto = function(){ + var CURRENT_FILE = 'current-file', + SELECTED_FILE = 'selected-file', + Title; + + /** + * private function thet unset currentfile + * + * @pCurrentFile + */ + function unsetCurrentFile(pCurrentFile){ + var lRet = DOM.isCurrentFile(pCurrentFile); + + if(lRet) + DOM.removeClass(pCurrentFile, CURRENT_FILE); + + return lRet; + } + + + /** + * create new folder + * + * @pCurrentFile + */ + this.promptNewDir = function(){ + this.promptNewFile('directory', '?dir'); + }; + + /** + * create new file + * + * @pCurrentFile + */ + this.promptNewFile = function(pTypeName, pType){ + var lName = this.getCurrentName(), + lDir = this.getCurrentDirPath(), + lMsg = 'New ' + pTypeName || 'File', + lType = Util.isString(pType) ? pType : ''; + + if(lName === '..') + lName = ''; + + lName = prompt(lMsg, lName); + + if(lName) + RESTfull.save(lDir + lName + lType, null, CloudCmd.refresh); + }; + + + /** + * delete currentfile, prompt before it + * + * @pCurrentFile + */ + this.promptDeleteSelected = function(pCurrentFile){ + var lRet, + lCurrent, lQuery, lMsg, + lName = '', + lMsgAsk = 'Do you really want to delete the ', + lMsgSel = 'selected ', + lFiles = this.getSelectedFiles(), + lSelected = this.getSelectedNames(lFiles), + i, n = lSelected && lSelected.length; + + if(n > 1){ + for(i = 0; i < 5 && i < n; i++) + lName += '\n' + lSelected[i]; + + if(n >= 5) + lName += '\n...'; + + lMsg = lMsgAsk + lMsgSel + n + ' files/directoris?\n' + lName ; + lQuery = '?files'; + }else{ + var lType, lIsDir; + + /* dom element passed and it is not event */ + if( pCurrentFile && !pCurrentFile.pType) + lCurrent = pCurrentFile; + else + lCurrent = this.getCurrentFile(); + + lIsDir = this.isCurrentIsDir(lCurrent); + + if(lIsDir){ + lQuery = '?dir'; + lType ='directory'; + } + else + lType = 'file'; + + lType += ' '; + + lName = this.getCurrentName(lCurrent); + lMsg = lMsgAsk + lMsgSel + lType + lName + '?'; + } + + if(lName !== '..') + lRet = confirm(lMsg); + else + alert('No files selected!'); + if(lRet){ + var lUrl; + + if(lCurrent) + lUrl = this.getCurrentPath(lCurrent); + else{ + lUrl = this.getCurrentDirPath(); + lCurrent = lFiles[0]; + } + + if(lCurrent || lSelected) + RESTfull.delete(lUrl, lSelected, function(){ + if(n > 1) + DOM.deleteSelected(lFiles); + else + DOM.deleteCurrent(lCurrent); + + var lDir = CloudFunc.removeLastSlash( + DOM.getCurrentDirPath() + ); + + Cache.remove(lDir); + }, lQuery); + + return lCurrent; + } + + return lRet; + }; /** @@ -1346,7 +1347,7 @@ var CloudCommander, Util, DOM, CloudFunc; */ this.setButtonKey = function(pKey, pFunc){ Util.tryCatchLog(function(){ - CloudCommander.KeysPanel[pKey].onclick = pFunc; + CloudCmd.KeysPanel[pKey].onclick = pFunc; }); }; @@ -1359,8 +1360,8 @@ var CloudCommander, Util, DOM, CloudFunc; this.setTitle = function(pName){ if(!Title) - Title = this.getByTag('title')[0] || - this.anyload({ + Title = DOMTree.getByTag('title')[0] || + Loader.anyload({ name:'title', parentElement: document.head, innerHTML: pName @@ -1437,7 +1438,7 @@ var CloudCommander, Util, DOM, CloudFunc; lPath = decodeURI(lPath); /* убираем адрес хоста*/ - lPath = Util.removeStrOneTime( lPath, [CloudCommander.HOST, CloudFunc.FS] ); + lPath = Util.removeStrOneTime( lPath, [CloudCmd.HOST, CloudFunc.FS] ); return lPath; }; @@ -1512,7 +1513,7 @@ var CloudCommander, Util, DOM, CloudFunc; * then always work with passive * panel */ - if(window.innerWidth < CloudCommander.MIN_ONE_PANEL_WIDTH) + if(window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH) lPanel = this.getById('left'); @@ -1713,7 +1714,7 @@ var CloudCommander, Util, DOM, CloudFunc; lDotDot = DOM.getById( '..(' + lPanel.id + ')'); DOM.setCurrentFile ( lDotDot ); - CloudCommander.refresh(); + CloudCmd.refresh(); }); } }; @@ -1744,7 +1745,7 @@ var CloudCommander, Util, DOM, CloudFunc; lDotDot = DOM.getById( '..(' + lPanel.id + ')'); DOM.setCurrentFile ( lDotDot ); - CloudCommander.refresh(); + CloudCmd.refresh(); }); } }; @@ -1792,17 +1793,19 @@ var CloudCommander, Util, DOM, CloudFunc; }; }, - Images = Util.extendProto(ImagesProto), - RESTfull = Util.extendProto(RESTfullProto), DOMTree = Util.extendProto(DOMTreeProto), Events = Util.extendProto(EventsProto), + Loader = Util.extendProto(LoaderProto), + Images = Util.extendProto(ImagesProto), + RESTfull = Util.extendProto(RESTfullProto), Cache = Util.extendProto(CacheProto); DOMProto = DOMFunc.prototype = new CmdProto(); Util.extend(DOMProto, [ DOMTree, - Events, { + Events, + Loader, { RESTfull: RESTfull, Images : Images, Cache : Cache diff --git a/lib/client/editor/_ace.js b/lib/client/editor/_ace.js index 75097f2f..d93dc1c4 100644 --- a/lib/client/editor/_ace.js +++ b/lib/client/editor/_ace.js @@ -1,207 +1,207 @@ -var CloudCommander, CloudFunc, ace; -/* object contains editors Ace - * and later will be Ace - */ - (function(){ - "use strict"; - var cloudcmd = CloudCommander, - Util = CloudCommander.Util, - KeyBinding = CloudCommander.KeyBinding, - AceEditor = {}, - AceLoaded = false, - ReadOnly = false, - AceElement, - FM; - - CloudCommander.Editor = { - get : (function(){ - return this.Ace; - }) - }; - - cloudcmd.Editor.dir = 'lib/client/editor/'; - AceEditor.dir = cloudcmd.Editor.dir + 'ace/'; - - - /* private functions */ - function initCodeMirror(pValue){ - if(!FM) - FM = Util.getById('fm'); - - AceElement = Util.anyload({ - name : 'div', - id : 'CodeMirrorEditor', - className : 'panel', - parent : FM - }); - - var editor = ace.edit("AceEditor"); - - editor.setTheme("ace/theme/tomorrow_night_blue"); - editor.getSession().setMode("ace/mode/javascript"); - - /* - editor.commands.addCommand({ - name : 'new_command', - //bindKey : {win: 'Esc', mac: 'Esc'}, - bindKey: {win: 'Ctrl-M', mac: 'Command-M'}, - exec : function(pEditor){ - lThis.hide(); - } - }); - */ - - editor.setReadOnly(ReadOnly); - - editor.setValue(pValue); - } - - /* indicator says Ace still loads */ - AceEditor.loading = false; - - /* function loads Ace js and css files */ - AceEditor.load = (function(){ - Util.cssSet({id:'editor', - inner : '#AceEditor{' + - 'font-size : 15px;' + - 'padding : 0 0 0 0;' + - '}' - }); - - /* load Ace main module */ - Util.jsload(AceEditor.dir + 'ace.js', function() { - Util.jsload(AceEditor.dir + 'mode-javascript.js', - function(){ - AceLoaded = true; - AceEditor.show(); - }); - }); - }); - - /* function shows Ace editor */ - AceEditor.show = (function(){ - /* if Ace function show already - * called do not call it again - * if f4 key pressed couple times - */ - if(this.loading) - return; - - if(!AceLoaded){ - return AceEditor.load(); - } - - /* getting link */ - var lCurrentFile = Util.getCurrentFile(), - lA = Util.getCurrentLink(lCurrentFile); - lA = lA.href; - - /* убираем адрес хоста*/ - lA = '/' + lA.replace(document.location.href,''); - - /* checking is this link is to directory */ - var lSize = Util.getByClass('size', lCurrentFile); - if(lSize){ - lSize = lSize[0].textContent; - - /* if directory - load json - * not html data - */ - if (lSize === '') - /* when folder view - * is no need to edit - * data - */ - ReadOnly = true; - } - - this.loading = true; - setTimeout(function(){ - lThis.loading = false;}, - 400); - - /* reading data from current file */ - Util.ajax({ - url:lA, - error: (function(jqXHR, textStatus, errorThrown){ - lThis.loading = false; - - return Util.Images.showError(jqXHR); - }), - - success:function(data, textStatus, jqXHR){ - /* if we got json - show it */ - if(typeof data === 'object') - data = JSON.stringify(data, null, 4); - - initAce_f(data); - - /* removing keyBinding if set */ - KeyBinding.unSet(); - - Util.hidePanel(); - Util.Images.hideLoad(); - - lThis.loading = false; - } - }); - }); - - /* function hides Ace editor */ - AceEditor.hide = (function() { - var lElem = AceElement; - KeyBinding.set(); - - if(lElem && FM) - FM.removeChild(lElem); - - Util.showPanel(); - }); - - cloudcmd.Editor.Keys = (function(pCurrentFile, pIsReadOnly){ - "use strict"; - - var lThis = this.Ace; - /* loading js and css of Ace */ - this.Ace.show(pCurrentFile, pIsReadOnly); - - var key_event = function(pEvent){ - - /* если клавиши можно обрабатывать */ - if( KeyBinding.get() ){ - /* if f4 or f3 pressed */ - var lF3 = cloudcmd.KEY.F3; - var lF4 = cloudcmd.KEY.F4; - var lShow = Util.bind(lThis.show, lThis); - - if(!pEvent.shiftKey){ - if(pEvent.keyCode === lF4) - lShow(); - else if(pEvent.keyCode === lF3){ - lShow(true); - } - } - }else if (pEvent.keyCode === cloudcmd.KEY.ESC) - AceEditor.hide(); - }; - - /* добавляем обработчик клавишь */ - if (document.addEventListener) - document.addEventListener('keydown', key_event,false); - - else{ - var lFunc; - if(typeof document.onkeydown === 'function') - lFunc = document.onkeydown; - - document.onkeydown = function(){ - if(lFunc) - lFunc(); - - key_event(); - }; - } - }); - - cloudcmd.Editor.Ace = AceEditor; +var CloudCmd, CloudFunc, ace; +/* object contains editors Ace + * and later will be Ace + */ + (function(){ + "use strict"; + var cloudcmd = CloudCmd, + Util = CloudCmd.Util, + KeyBinding = CloudCmd.KeyBinding, + AceEditor = {}, + AceLoaded = false, + ReadOnly = false, + AceElement, + FM; + + CloudCmd.Editor = { + get : (function(){ + return this.Ace; + }) + }; + + cloudcmd.Editor.dir = 'lib/client/editor/'; + AceEditor.dir = cloudcmd.Editor.dir + 'ace/'; + + + /* private functions */ + function initCodeMirror(pValue){ + if(!FM) + FM = Util.getById('fm'); + + AceElement = Util.anyload({ + name : 'div', + id : 'CodeMirrorEditor', + className : 'panel', + parent : FM + }); + + var editor = ace.edit("AceEditor"); + + editor.setTheme("ace/theme/tomorrow_night_blue"); + editor.getSession().setMode("ace/mode/javascript"); + + /* + editor.commands.addCommand({ + name : 'new_command', + //bindKey : {win: 'Esc', mac: 'Esc'}, + bindKey: {win: 'Ctrl-M', mac: 'Command-M'}, + exec : function(pEditor){ + lThis.hide(); + } + }); + */ + + editor.setReadOnly(ReadOnly); + + editor.setValue(pValue); + } + + /* indicator says Ace still loads */ + AceEditor.loading = false; + + /* function loads Ace js and css files */ + AceEditor.load = (function(){ + Util.cssSet({id:'editor', + inner : '#AceEditor{' + + 'font-size : 15px;' + + 'padding : 0 0 0 0;' + + '}' + }); + + /* load Ace main module */ + Util.jsload(AceEditor.dir + 'ace.js', function() { + Util.jsload(AceEditor.dir + 'mode-javascript.js', + function(){ + AceLoaded = true; + AceEditor.show(); + }); + }); + }); + + /* function shows Ace editor */ + AceEditor.show = (function(){ + /* if Ace function show already + * called do not call it again + * if f4 key pressed couple times + */ + if(this.loading) + return; + + if(!AceLoaded){ + return AceEditor.load(); + } + + /* getting link */ + var lCurrentFile = Util.getCurrentFile(), + lA = Util.getCurrentLink(lCurrentFile); + lA = lA.href; + + /* убираем адрес хоста*/ + lA = '/' + lA.replace(document.location.href,''); + + /* checking is this link is to directory */ + var lSize = Util.getByClass('size', lCurrentFile); + if(lSize){ + lSize = lSize[0].textContent; + + /* if directory - load json + * not html data + */ + if (lSize === '') + /* when folder view + * is no need to edit + * data + */ + ReadOnly = true; + } + + this.loading = true; + setTimeout(function(){ + lThis.loading = false;}, + 400); + + /* reading data from current file */ + Util.ajax({ + url:lA, + error: (function(jqXHR, textStatus, errorThrown){ + lThis.loading = false; + + return Util.Images.showError(jqXHR); + }), + + success:function(data, textStatus, jqXHR){ + /* if we got json - show it */ + if(typeof data === 'object') + data = JSON.stringify(data, null, 4); + + initAce_f(data); + + /* removing keyBinding if set */ + KeyBinding.unSet(); + + Util.hidePanel(); + Util.Images.hideLoad(); + + lThis.loading = false; + } + }); + }); + + /* function hides Ace editor */ + AceEditor.hide = (function() { + var lElem = AceElement; + KeyBinding.set(); + + if(lElem && FM) + FM.removeChild(lElem); + + Util.showPanel(); + }); + + cloudcmd.Editor.Keys = (function(pCurrentFile, pIsReadOnly){ + "use strict"; + + var lThis = this.Ace; + /* loading js and css of Ace */ + this.Ace.show(pCurrentFile, pIsReadOnly); + + var key_event = function(pEvent){ + + /* если клавиши можно обрабатывать */ + if( KeyBinding.get() ){ + /* if f4 or f3 pressed */ + var lF3 = cloudcmd.KEY.F3; + var lF4 = cloudcmd.KEY.F4; + var lShow = Util.bind(lThis.show, lThis); + + if(!pEvent.shiftKey){ + if(pEvent.keyCode === lF4) + lShow(); + else if(pEvent.keyCode === lF3){ + lShow(true); + } + } + }else if (pEvent.keyCode === cloudcmd.KEY.ESC) + AceEditor.hide(); + }; + + /* добавляем обработчик клавишь */ + if (document.addEventListener) + document.addEventListener('keydown', key_event,false); + + else{ + var lFunc; + if(typeof document.onkeydown === 'function') + lFunc = document.onkeydown; + + document.onkeydown = function(){ + if(lFunc) + lFunc(); + + key_event(); + }; + } + }); + + cloudcmd.Editor.Ace = AceEditor; })(); \ No newline at end of file diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index cd721292..253471e8 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -1,9 +1,9 @@ -var CloudCommander, Util, DOM, CodeMirror; +var CloudCmd, Util, DOM, CodeMirror; /* object contains editors CodeMirror */ (function(CloudCmd, Util, DOM){ 'use strict'; - var KeyBinding = CloudCommander.KeyBinding, + var KeyBinding = CloudCmd.KeyBinding, CodeMirrorEditor = {}, FM, CodeMirrorElement, @@ -215,4 +215,4 @@ var CloudCommander, Util, DOM, CodeMirror; CloudCmd.Editor.CodeMirror = CodeMirrorEditor; -})(CloudCommander, Util, DOM); \ No newline at end of file +})(CloudCmd, Util, DOM); \ No newline at end of file diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index 56111a50..91a3953d 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -1,9 +1,9 @@ -var CloudCommander, Util, DOM; +var CloudCmd, Util, DOM; (function(CloudCmd, Util, DOM){ 'use strict'; /* private property set or set key binding */ - var keyBinded; + var Binded; /* Key constants*/ CloudCmd.KEY = { @@ -53,11 +53,11 @@ var CloudCommander, Util, DOM; var KeyBinding = CloudCmd.KeyBinding; - KeyBinding.get = function(){return keyBinded;}; + KeyBinding.get = function(){return Binded;}; - KeyBinding.set = function(){keyBinded = true;}; + KeyBinding.set = function(){Binded = true;}; - KeyBinding.unSet = function(){keyBinded = false;}; + KeyBinding.unSet = function(){Binded = false;}; KeyBinding.init = function(){ /* saving state of tabs varibles */ @@ -75,7 +75,7 @@ var CloudCommander, Util, DOM; lAlt = pEvent.altKey, lCtrl = pEvent.ctrlKey; /* если клавиши можно обрабатывать*/ - if(keyBinded){ + if(Binded){ switch(lKeyCode){ case KEY.TAB: /* changing parent panel of curent-file */ @@ -323,7 +323,7 @@ var CloudCommander, Util, DOM; 'press +s to to set them'); /* обработчик нажатий клавиш снят*/ - keyBinded = false; + Binded = false; DOM.preventDefault(pEvent); } break; @@ -335,7 +335,7 @@ var CloudCommander, Util, DOM; */ else if(lKeyCode === KEY.S && lAlt){ /* обрабатываем нажатия на клавиши*/ - keyBinded = true; + Binded = true; Util.log('+s pressed\n' + '+r reload key-handerl - set\n' + '+s clear cache key-handler - set\n' + @@ -348,7 +348,7 @@ var CloudCommander, Util, DOM; DOM.addKeyListener(key_event); /* клавиши назначены*/ - keyBinded = true; + Binded = true; }; -})(CloudCommander, Util, DOM); \ No newline at end of file +})(CloudCmd, Util, DOM); \ No newline at end of file diff --git a/lib/client/menu.js b/lib/client/menu.js index 3f5c5e14..b4a34506 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -1,7 +1,7 @@ /* object contains jQuery-contextMenu * https://github.com/medialize/jQuery-contextMenu */ -var CloudCommander, Util, DOM, CloudFunc, $; +var CloudCmd, Util, DOM, CloudFunc, $; (function(CloudCmd, Util, DOM, CloudFunc){ 'use strict'; @@ -119,12 +119,11 @@ var CloudCommander, Util, DOM, CloudFunc, $; DOM.Images.showLoad(); var lPath = DOM.getCurrentPath(), - lId = DOM.getIdBySrc(lPath); + lId = DOM.getIdBySrc(lPath), + lDir = DOM.isCurrentIsDir() ? '&&json' : ''; Util.log('downloading file ' + lPath +'...'); - var lDir = DOM.isCurrentIsDir() ? '&&json' : ''; - lPath = CloudFunc.FS + lPath + '?download' + lDir; if(!DOM.getById(lId)){ @@ -313,4 +312,4 @@ var CloudCommander, Util, DOM, CloudFunc, $; }; CloudCmd.Menu = Menu; -})(CloudCommander, Util, DOM, CloudFunc); \ No newline at end of file +})(CloudCmd, Util, DOM, CloudFunc); \ No newline at end of file diff --git a/lib/client/socket.js b/lib/client/socket.js index bb6dcf96..32041b78 100644 --- a/lib/client/socket.js +++ b/lib/client/socket.js @@ -1,103 +1,103 @@ -/* module make possible connectoin thrue socket.io on a client */ -var CloudCommander, Util, DOM, io; -(function(CloudCmd, Util, DOM){ - 'use strict'; - - var Messages = [], - socket, - Terminal, - - ERROR_MSG = 'could not connect to socket.io\n'+ - 'npm i socket.io'; - - function getTerminal(){ - return CloudCmd.Terminal.JqueryTerminal; - } - - DOM.jsload('/socket.io/lib/socket.io.js', { - onerror : Util.retExec(Util.log, ERROR_MSG), - - onload : function(){ - socket = io.connect(CloudCmd.HOST); - - CloudCmd.Socket = socket; - - socket.on('connect', function () { - Terminal = getTerminal(); - - if(Terminal){ - outToTerminal({stdout: 'socket connected'}); - - Terminal.Term.resume(); - } - }); - - socket.on('message', function (msg) { - var lMsg = Util.parseJSON(msg); - - outToTerminal(lMsg); - - }); - - socket.on('disconnect', function () { - Terminal = getTerminal(); - - if(Terminal){ - outToTerminal({stderr: 'socket disconected'}); - - Terminal.Term.pause(); - } - }); - } - }); - - function outToTerminal(pMsg){ - var lResult, lTerm; - - Terminal = getTerminal(); - if(Terminal) - lTerm = Terminal.Term; - - if(lTerm){ - var lStdout, - lStderr; - - if(Messages.length){ - /* show oll msg from buffer */ - for(var i = 0, n = Messages.length; i < n; i++){ - lStdout = Messages[i].stdout; - lStderr = Messages[i].stderr; - - if(lStdout) - lTerm.echo(lStdout); - - if(lStderr){ - /* if it's object - convert is to string' */ - if( Util.isObject(lStderr) ) - lStderr = Util.stringifyJSON(lStderr); - - lTerm.error(lStderr); - } - } - Messages = []; - } - - lStdout = pMsg.stdout; - lStderr = pMsg.stderr; - - if(lStdout) - lResult = lTerm.echo(lStdout); - - if(lStderr && lStderr.code !== 1) - lResult = lTerm.error(lStderr.toString()); - } - else - /* if term not accesable save msg to buffer */ - Messages.push(pMsg); - - Util.log(pMsg); - - return lResult; - } - -})(CloudCommander, Util, DOM); \ No newline at end of file +/* module make possible connectoin thrue socket.io on a client */ +var CloudCmd, Util, DOM, io; +(function(CloudCmd, Util, DOM){ + 'use strict'; + + var Messages = [], + socket, + Terminal, + + ERROR_MSG = 'could not connect to socket.io\n'+ + 'npm i socket.io'; + + function getTerminal(){ + return CloudCmd.Terminal.JqueryTerminal; + } + + DOM.jsload('/socket.io/lib/socket.io.js', { + onerror : Util.retExec(Util.log, ERROR_MSG), + + onload : function(){ + socket = io.connect(CloudCmd.HOST); + + CloudCmd.Socket = socket; + + socket.on('connect', function () { + Terminal = getTerminal(); + + if(Terminal){ + outToTerminal({stdout: 'socket connected'}); + + Terminal.Term.resume(); + } + }); + + socket.on('message', function (msg) { + var lMsg = Util.parseJSON(msg); + + outToTerminal(lMsg); + + }); + + socket.on('disconnect', function () { + Terminal = getTerminal(); + + if(Terminal){ + outToTerminal({stderr: 'socket disconected'}); + + Terminal.Term.pause(); + } + }); + } + }); + + function outToTerminal(pMsg){ + var lResult, lTerm; + + Terminal = getTerminal(); + if(Terminal) + lTerm = Terminal.Term; + + if(lTerm){ + var lStdout, + lStderr; + + if(Messages.length){ + /* show oll msg from buffer */ + for(var i = 0, n = Messages.length; i < n; i++){ + lStdout = Messages[i].stdout; + lStderr = Messages[i].stderr; + + if(lStdout) + lTerm.echo(lStdout); + + if(lStderr){ + /* if it's object - convert is to string' */ + if( Util.isObject(lStderr) ) + lStderr = Util.stringifyJSON(lStderr); + + lTerm.error(lStderr); + } + } + Messages = []; + } + + lStdout = pMsg.stdout; + lStderr = pMsg.stderr; + + if(lStdout) + lResult = lTerm.echo(lStdout); + + if(lStderr && lStderr.code !== 1) + lResult = lTerm.error(lStderr.toString()); + } + else + /* if term not accesable save msg to buffer */ + Messages.push(pMsg); + + Util.log(pMsg); + + return lResult; + } + +})(CloudCmd, Util, DOM); \ No newline at end of file diff --git a/lib/client/storage/_dropbox.js b/lib/client/storage/_dropbox.js index 2fa9feb4..d64edeef 100644 --- a/lib/client/storage/_dropbox.js +++ b/lib/client/storage/_dropbox.js @@ -1,4 +1,4 @@ -var CloudCommander, Util, DOM, Dropbox, cb, Client; +var CloudCmd, Util, DOM, Dropbox, cb, Client; /* module for work with github */ (function(CloudCmd, Util, DOM){ @@ -108,4 +108,4 @@ var CloudCommander, Util, DOM, Dropbox, cb, Client; }; CloudCmd.DropBox = DropBoxStore; -})(CloudCommander, Util, DOM); +})(CloudCmd, Util, DOM); diff --git a/lib/client/storage/_dropbox_chooser.js b/lib/client/storage/_dropbox_chooser.js index 5532e1a9..e3a59f5e 100644 --- a/lib/client/storage/_dropbox_chooser.js +++ b/lib/client/storage/_dropbox_chooser.js @@ -1,55 +1,54 @@ -var CloudCommander, DOM, Dropbox; -/* module for work with github */ - -(function(){ - "use strict"; - - var cloudcmd = CloudCommander, - CHOOSER_API = 'https://www.dropbox.com/static/api/1/dropbox.js', - CLIENT_ID, - DropBoxStore = {}, - options = { - linkType: "direct", - success: function(files) { - console.log("Here's the file link:" + files[0].link); - }, - cancel: function() { - console.log('Chose something'); - } - }; - - /* PRIVATE FUNCTIONS */ - - /** - * function loads dropbox.js - */ - function load(){ - console.time('dropbox load'); - - cloudcmd.getConfig(function(pConfig){ - var lElement = DOM.anyload({ - src : CHOOSER_API, - not_append : true, - id : 'dropboxjs', - func : DropBoxStore.choose - - }); - - var lDropBoxId = pConfig.dropbox_chooser_key; - lElement.setAttribute('data-app-key', lDropBoxId); - document.body.appendChild(lElement); - - console.timeEnd('dropbox load'); - }); - } - - DropBoxStore.choose = function(){ - Dropbox.choose(options); - }; - - DropBoxStore.init = function(){ - load(); - }; - - cloudcmd.DropBox = DropBoxStore; -})(); +var CloudCmd, DOM, Dropbox; +/* module for work with github */ + +(function(CloudCmd, DOM){ + 'use strict'; + + var CHOOSER_API = 'https://www.dropbox.com/static/api/1/dropbox.js', + CLIENT_ID, + DropBoxStore = {}, + options = { + linkType: "direct", + success: function(files) { + console.log("Here's the file link:" + files[0].link); + }, + cancel: function() { + console.log('Chose something'); + } + }; + + /* PRIVATE FUNCTIONS */ + + /** + * function loads dropbox.js + */ + function load(){ + console.time('dropbox load'); + + CloudCmd.getConfig(function(pConfig){ + var lElement = DOM.anyload({ + src : CHOOSER_API, + not_append : true, + id : 'dropboxjs', + func : DropBoxStore.choose + + }); + + var lDropBoxId = pConfig.dropbox_chooser_key; + lElement.setAttribute('data-app-key', lDropBoxId); + document.body.appendChild(lElement); + + console.timeEnd('dropbox load'); + }); + } + + DropBoxStore.choose = function(){ + Dropbox.choose(options); + }; + + DropBoxStore.init = function(){ + load(); + }; + + CloudCmd.DropBox = DropBoxStore; +})(CloudCmd, DOM); diff --git a/lib/client/storage/_filepicker.js b/lib/client/storage/_filepicker.js index 9dcd50ef..d029fc59 100644 --- a/lib/client/storage/_filepicker.js +++ b/lib/client/storage/_filepicker.js @@ -1,4 +1,4 @@ -var CloudCommander, Util, DOM, $, filepicker; +var CloudCmd, Util, DOM, $, filepicker; /* module for work with filepicker */ (function(CloudCmd, Util, DOM){ @@ -55,4 +55,4 @@ var CloudCommander, Util, DOM, $, filepicker; }; CloudCmd.FilePicker = new FilePicker(); -})(CloudCommander, Util, DOM); +})(CloudCmd, Util, DOM); diff --git a/lib/client/storage/_gdrive.js b/lib/client/storage/_gdrive.js index b8a83c39..21aad69f 100644 --- a/lib/client/storage/_gdrive.js +++ b/lib/client/storage/_gdrive.js @@ -1,4 +1,4 @@ -var CloudCommander, Util, DOM, gapi; +var CloudCmd, Util, DOM, gapi; (function(CloudCmd, Util, DOM){ 'use strict'; @@ -106,4 +106,4 @@ var CloudCommander, Util, DOM, gapi; }; CloudCmd.GDrive = GDrive; -})(CloudCommander, Util, DOM); \ No newline at end of file +})(CloudCmd, Util, DOM); \ No newline at end of file diff --git a/lib/client/storage/_github.js b/lib/client/storage/_github.js index e1593d2b..773bbffd 100644 --- a/lib/client/storage/_github.js +++ b/lib/client/storage/_github.js @@ -1,4 +1,4 @@ -var CloudCommander, Util, DOM, $, Github, cb; +var CloudCmd, Util, DOM, $, Github, cb; /* module for work with github */ (function(CloudCmd, Util, DOM){ @@ -156,4 +156,4 @@ var CloudCommander, Util, DOM, $, Github, cb; }; CloudCmd.GitHub = GitHubStore; -})(CloudCommander, Util, DOM); +})(CloudCmd, Util, DOM); diff --git a/lib/client/storage/_skydrive.js b/lib/client/storage/_skydrive.js index 5d8f1871..874f16e8 100644 --- a/lib/client/storage/_skydrive.js +++ b/lib/client/storage/_skydrive.js @@ -1,5 +1,5 @@ //http://isdk.dev.live.com/ISDK.aspx?category=scenarioGroup_skyDrive&index=0 -var CloudCommander, Util, DOM, WL; +var CloudCmd, Util, DOM, WL; (function(CloudCmd, Util, DOM){ 'use strict'; @@ -75,4 +75,4 @@ var CloudCommander, Util, DOM, WL; CloudCmd.SkyDrive = SkyDrive; -})(CloudCommander, Util, DOM); +})(CloudCmd, Util, DOM); diff --git a/lib/client/storage/_vk.js b/lib/client/storage/_vk.js index 66972fa0..27d9d5cf 100644 --- a/lib/client/storage/_vk.js +++ b/lib/client/storage/_vk.js @@ -1,97 +1,97 @@ -var CloudCommander, Util, DOM, VK; - -(function(CloudCmd, Util, DOM){ - 'use strict'; - - var VKStorage = {}; - - - /* PRIVATE FUNCTIONS */ - - /** - * load google api library - */ - function load(pCallBack){ - console.time('vk'); - - var lUrl = 'http://vkontakte.ru/js/api/openapi.js', - lLocal = CloudCmd.LIBDIRCLIENT + 'storage/vk/open.js', - - lOnload = function(){ - console.timeEnd('vk load'); - DOM.Images.hideLoad(); - - Util.exec(pCallBack); - }; - - DOM.jsload(lUrl, { - onload : lOnload, - error : DOM.retJSLoad(lLocal, lOnload) - }); - - } - - function auth(pCallBack){ - CloudCmd.getConfig(function(pConfig){ - var lDOCUMENTS_ACCESS = 131072; - - VK.init({ apiId: pConfig.vk_id}); - - VK.Auth.login(function(){ - var lNAME = 1281; - VK.Api.call('getVariable', {key: lNAME}, function(r) { - var lName = r.response; - - if(lName) - Util.log ('Hello, ' + lName + ':)'); - }); - - Util.exec(pCallBack); - - }, lDOCUMENTS_ACCESS); /* Доступ к документам пользователя */ - }); - } - - - /** - * Insert new file. - * - * @param {File} fileData {name, data} File object to read data from. - * @param {Function} callback Function to call when the request is complete. - */ - VKStorage.uploadFile = function(pParams, pCallBack) { - /* http://vk.com/developers.php?oid=-1&p=docs.getUploadServer */ - VK.Api.call('docs.getUploadServer', {}, function(pResult){ - var lURL = pResult.response.upload_url, - lData = pParams.data, - lName = pParams.name; - - DOM.ajax({ - type : "POST", - url : lURL, - data : { - file: lData, - name: lName - }, - dataType: 'application/x-www-form-urlencoded', - success : function(pData){ - Util.log(pData); - VK.Api.call('docs.save', {}, Util.log); - }, - - error : Util.log - }); - }); - }; - - - VKStorage.init = function(pCallBack){ - Util.loadOnLoad([ - Util.retExec(pCallBack), - auth, - load - ]); - }; - - CloudCmd.VK = VKStorage; -})(CloudCommander, Util, DOM); \ No newline at end of file +var CloudCmd, Util, DOM, VK; + +(function(CloudCmd, Util, DOM){ + 'use strict'; + + var VKStorage = {}; + + + /* PRIVATE FUNCTIONS */ + + /** + * load google api library + */ + function load(pCallBack){ + console.time('vk'); + + var lUrl = 'http://vkontakte.ru/js/api/openapi.js', + lLocal = CloudCmd.LIBDIRCLIENT + 'storage/vk/open.js', + + lOnload = function(){ + console.timeEnd('vk load'); + DOM.Images.hideLoad(); + + Util.exec(pCallBack); + }; + + DOM.jsload(lUrl, { + onload : lOnload, + error : DOM.retJSLoad(lLocal, lOnload) + }); + + } + + function auth(pCallBack){ + CloudCmd.getConfig(function(pConfig){ + var lDOCUMENTS_ACCESS = 131072; + + VK.init({ apiId: pConfig.vk_id}); + + VK.Auth.login(function(){ + var lNAME = 1281; + VK.Api.call('getVariable', {key: lNAME}, function(r) { + var lName = r.response; + + if(lName) + Util.log ('Hello, ' + lName + ':)'); + }); + + Util.exec(pCallBack); + + }, lDOCUMENTS_ACCESS); /* Доступ к документам пользователя */ + }); + } + + + /** + * Insert new file. + * + * @param {File} fileData {name, data} File object to read data from. + * @param {Function} callback Function to call when the request is complete. + */ + VKStorage.uploadFile = function(pParams, pCallBack) { + /* http://vk.com/developers.php?oid=-1&p=docs.getUploadServer */ + VK.Api.call('docs.getUploadServer', {}, function(pResult){ + var lURL = pResult.response.upload_url, + lData = pParams.data, + lName = pParams.name; + + DOM.ajax({ + type : "POST", + url : lURL, + data : { + file: lData, + name: lName + }, + dataType: 'application/x-www-form-urlencoded', + success : function(pData){ + Util.log(pData); + VK.Api.call('docs.save', {}, Util.log); + }, + + error : Util.log + }); + }); + }; + + + VKStorage.init = function(pCallBack){ + Util.loadOnLoad([ + Util.retExec(pCallBack), + auth, + load + ]); + }; + + CloudCmd.VK = VKStorage; +})(CloudCmd, Util, DOM); \ No newline at end of file diff --git a/lib/client/terminal.js b/lib/client/terminal.js index 341a6448..4dc7f503 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -1,4 +1,4 @@ -var CloudCommander, Util, DOM, $; +var CloudCmd, Util, DOM, $; /* object contains terminal jqconsole */ (function(CloudCmd, Util, DOM){ @@ -133,4 +133,4 @@ var CloudCommander, Util, DOM, $; CloudCmd.Terminal.JqueryTerminal = JqueryTerminal; -})(CloudCommander, Util, DOM); +})(CloudCmd, Util, DOM); diff --git a/lib/client/viewer.js b/lib/client/viewer.js index 071859f2..cdc0e30d 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -1,4 +1,4 @@ -var CloudCommander, Util, DOM, CloudFunc, $; +var CloudCmd, Util, DOM, CloudFunc, $; /* object contains viewer FancyBox * https://github.com/fancyapps/fancyBox */ @@ -159,4 +159,4 @@ var CloudCommander, Util, DOM, CloudFunc, $; CloudCmd.Viewer.FancyBox = FancyBox; -})(CloudCommander, Util, DOM, CloudFunc); \ No newline at end of file +})(CloudCmd, Util, DOM, CloudFunc); \ No newline at end of file From 22a8346c33f8647a8de42addbb453ca25dde936e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 8 May 2013 12:10:25 -0400 Subject: [PATCH 010/239] added addtables script --- ChangeLog | 2 ++ shell/addtables.sh | 8 ++++++++ shell/c9kill.sh | 23 ++++++++++++----------- shell/ssl.sh | 5 +++-- 4 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 shell/addtables.sh diff --git a/ChangeLog b/ChangeLog index 142e433c..0228abfc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,8 @@ dispatch * Moved loading functions to Loader object in DOM module. +* Added addtables script' + 2012.04.22, v0.2.0 diff --git a/shell/addtables.sh b/shell/addtables.sh new file mode 100644 index 00000000..f38def48 --- /dev/null +++ b/shell/addtables.sh @@ -0,0 +1,8 @@ +#!/bin/sh +su iptables -t nat -L # look rules before +su iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000 +su iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 4430 +su iptables -t nat -L # look reles after + +#su iptables -t nat -D PREROUTING 1 +#su iptables -t nat -D PREROUTING 2 \ No newline at end of file diff --git a/shell/c9kill.sh b/shell/c9kill.sh index 40e87d7e..44ced9bf 100755 --- a/shell/c9kill.sh +++ b/shell/c9kill.sh @@ -1,12 +1,13 @@ -kill -9 `ps ax|grep node-openshift|grep -v grep|awk '{print $1}'` -# print finded process -ProcessList=`ps ax|grep node-openshift` -echo $ProcessList -# getting pid of process -PID=`echo "${ProcessList}"|grep -v grep|awk '{print $1}'` -echo $PID -#kill it -if test ! $PID -then echo 'process not found' -else kill -9 $PID && echo 'killed process' +#!/bin/sh +kill -9 `ps ax|grep node-openshift|grep -v grep|awk '{print $1}'` +# print finded process +ProcessList=`ps ax|grep node-openshift` +echo $ProcessList +# getting pid of process +PID=`echo "${ProcessList}"|grep -v grep|awk '{print $1}'` +echo $PID +#kill it +if test ! $PID +then echo 'process not found' +else kill -9 $PID && echo 'killed process' fi \ No newline at end of file diff --git a/shell/ssl.sh b/shell/ssl.sh index e703ad7d..3f02e9e8 100644 --- a/shell/ssl.sh +++ b/shell/ssl.sh @@ -1,3 +1,4 @@ -openssl genrsa -out privatekey.pem 1024 -openssl req -new -key privatekey.pem -out certrequest.csr +#!/bin/sh +openssl genrsa -out privatekey.pem 1024 +openssl req -new -key privatekey.pem -out certrequest.csr openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem \ No newline at end of file From e1e04282f30d859812b725fa9ec400ac9291c4d6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 8 May 2013 12:11:16 -0400 Subject: [PATCH 011/239] added addtables script --- shell/addtables.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 shell/addtables.sh diff --git a/shell/addtables.sh b/shell/addtables.sh old mode 100644 new mode 100755 From 769fb0761d556f63d2f22c71526560814b388f33 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 8 May 2013 12:14:37 -0400 Subject: [PATCH 012/239] fixed typo in README --- ChangeLog | 2 ++ README.md | 12 ++++++------ shell/addtables.sh | 12 ++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0228abfc..784432ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,8 @@ dispatch * Added addtables script' +* Fixed typo in README. + 2012.04.22, v0.2.0 diff --git a/README.md b/README.md index c59a8f6a..f590d9d0 100644 --- a/README.md +++ b/README.md @@ -137,10 +137,10 @@ to start Cloud Commander as non-root. How it could be solved? There is a couple easy and fast ways. One of them is port forwarding by iptables. ```sh -@:/tmp/cloudcmd (dev) $ su iptables -t nat -L # look rules before -@:/tmp/cloudcmd (dev) $ su iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000 -@:/tmp/cloudcmd (dev) $ su iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 4430 -@:/tmp/cloudcmd (dev) $ su iptables -t nat -L # look reles after +@:/tmp/cloudcmd (dev) $ sudo iptables -t nat -L # look rules before +@:/tmp/cloudcmd (dev) $ sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000 +@:/tmp/cloudcmd (dev) $ sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 4430 +@:/tmp/cloudcmd (dev) $ sudo iptables -t nat -L # look reles after ``` You should see somethins like this ( **8000** and **4430** should be in config as **port** and **sslPort** ) @@ -152,8 +152,8 @@ If you would want to get things back just clear rules ( **1** and **2** it's rul in your list they could differ). ```sh -@:/tmp/cloudcmd (dev) $ su iptables -t nat -D PREROUTING 1 -@:/tmp/cloudcmd (dev) $ su iptables -t nat -D PREROUTING 2 +@:/tmp/cloudcmd (dev) $ sudo iptables -t nat -D PREROUTING 1 +@:/tmp/cloudcmd (dev) $ sudo iptables -t nat -D PREROUTING 2 ``` To run Cloud Commander as daemon in linux you could set **log** to true in config and diff --git a/shell/addtables.sh b/shell/addtables.sh index f38def48..1d3d78c2 100755 --- a/shell/addtables.sh +++ b/shell/addtables.sh @@ -1,8 +1,8 @@ #!/bin/sh -su iptables -t nat -L # look rules before -su iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000 -su iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 4430 -su iptables -t nat -L # look reles after +sudo iptables -t nat -L # look rules before +sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000 +sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 4430 +sudo iptables -t nat -L # look reles after -#su iptables -t nat -D PREROUTING 1 -#su iptables -t nat -D PREROUTING 2 \ No newline at end of file +#sudo iptables -t nat -D PREROUTING 1 +#sudo iptables -t nat -D PREROUTING 2 \ No newline at end of file From 0c504a6d53440a12d2126f036622cd63a91cf8da Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 8 May 2013 12:17:39 -0400 Subject: [PATCH 013/239] fixed bug --- lib/client/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index f0555cb0..fad2cfc6 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -617,7 +617,7 @@ var CloudCmd, Util, DOM, CloudFunc; if( Util.isArray(pParams_a) ) { var lParam = pParams_a.pop(), lFunc = function(){ - this.anyLoadOnLoad(pParams_a, pFunc); + Loader.anyLoadOnLoad(pParams_a, pFunc); }; if( Util.isString(lParam) ) From 7ae6ab4ef7e13e20e05d860abf26cb68be9fca31 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 8 May 2013 12:18:46 -0400 Subject: [PATCH 014/239] fixed bug --- lib/client/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index fad2cfc6..8ba0e981 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -735,7 +735,7 @@ var CloudCmd, Util, DOM, CloudFunc; if(!lID && lSrc) lID = this.getIdBySrc(lSrc); - var lElement = this.getById(lID); + var lElement = DOMTree.getById(lID); /* если скрипт еще не загружен */ if(!lElement){ From 14a84c6f1294a7adfcca55990003b112a2ad1e37 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 8 May 2013 12:20:05 -0400 Subject: [PATCH 015/239] fixed bug --- lib/client/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 8ba0e981..85bdedcc 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1237,7 +1237,7 @@ var CloudCmd, Util, DOM, CloudFunc; var lParams, lCurrentFile = pCurrentFile ? pCurrentFile : this.getCurrentFile(), lFunc = function(pData){ - var lName = this.getCurrentName(lCurrentFile); + var lName = DOM.getCurrentName(lCurrentFile); if( Util.isObject(pData) ){ pData = Util.stringifyJSON(pData); From 0ddc432f073bdfd17268f689653ec7c40879f663 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 8 May 2013 16:38:50 +0000 Subject: [PATCH 016/239] fixed bug with jqueryLoad and socketLoad --- json/config.json | 6 +++--- lib/client/dom.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/json/config.json b/json/config.json index 5f9fc6cf..b012c13a 100644 --- a/json/config.json +++ b/json/config.json @@ -12,9 +12,9 @@ "show_keys_panel" : true, "server" : true, "socket" : true, - "port" : 80, - "sslPort" : 443, + "port" : 8000, + "sslPort" : 4430, "ip" : null, "ssl" : false, "rest" : true -} \ No newline at end of file +} diff --git a/lib/client/dom.js b/lib/client/dom.js index 85bdedcc..71fe8775 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -901,16 +901,16 @@ var CloudCmd, Util, DOM, CloudFunc; */ this.jqueryLoad = function(pCallBack){ /* загружаем jquery: */ - this.jsload('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js',{ + Loader.jsload('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js',{ onload: Util.retExec(pCallBack), onerror: function(){ - this.jsload('/lib/client/jquery.js'); + Loader.jsload('/lib/client/jquery.js'); /* if could not load jquery from google server * maybe we offline, load font from local * directory */ - this.cssSet({ + Loader.cssSet({ id :'local-droids-font', element : document.head, inner : '@font-face {font-family: "Droid Sans Mono";' + @@ -927,7 +927,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pCallBack */ this.socketLoad = function(pCallBack){ - this.jsload('/lib/client/socket.js', Util.retExec(pCallBack) ); + Loader.jsload('/lib/client/socket.js', Util.retExec(pCallBack) ); }; }, CmdProto = function(){ From c4a42f86124045d2edb45b7a7d93f4c75d7a1ab8 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sat, 11 May 2013 22:54:45 +0300 Subject: [PATCH 017/239] added null param --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f590d9d0..fde2c331 100644 --- a/README.md +++ b/README.md @@ -121,9 +121,9 @@ All main configuration could be done thrue config.json. "server" : true, /* server mode or testing mode */ "logs" : false, /* logs or console ouput */ "socket" : true /* enable web sockets */ - "port" : 80, /* http port */ - "sslPort" : 443, /* https port */ - "ip" : "127.0.0.1", /* Cloud Commander IP */ + "port" : 80, /* http port or null(default) */ + "sslPort" : 443, /* https port or null(default) */ + "ip" : "127.0.0.1", /* ip or null for null(default) */ "ssl" : true /* should use https? */ "rest" : true /* enable rest interface */ } From 9bdc05a3a8d5b28f8db9e9767380046a79c55f65 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sun, 12 May 2013 10:47:48 -0400 Subject: [PATCH 018/239] fixed same background declaration a couple times --- ChangeLog | 2 ++ css/style.css | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 784432ad..c3302572 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,8 @@ dispatch * Fixed typo in README. +* Fixed same background declartion a couple times. + 2012.04.22, v0.2.0 diff --git a/css/style.css b/css/style.css index b68f19c2..c46c3b52 100644 --- a/css/style.css +++ b/css/style.css @@ -80,8 +80,7 @@ body{ background:url(/img/panel_refresh.png) no-repeat; } .refresh-icon:active{ - /*background-position-y: -15px;*/ - background:url(/img/panel_refresh.png) 0 -15px no-repeat; + background-position: 0 -15px; } .cmd-button{ From 1a92e30bd7cc504b32294fd9e5435b7d7e02aec2 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sun, 12 May 2013 17:48:51 +0300 Subject: [PATCH 019/239] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fde2c331..9ba194df 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ All main configuration could be done thrue config.json. "socket" : true /* enable web sockets */ "port" : 80, /* http port or null(default) */ "sslPort" : 443, /* https port or null(default) */ - "ip" : "127.0.0.1", /* ip or null for null(default) */ + "ip" : "127.0.0.1", /* ip or null(default) */ "ssl" : true /* should use https? */ "rest" : true /* enable rest interface */ } From 64fe5361f41e5d9f88671f2aac9305fb84136eeb Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sun, 12 May 2013 17:50:05 +0300 Subject: [PATCH 020/239] removed demos on nitrous --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 9ba194df..82f6aa2a 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,7 @@ Cloud Commander v0.2.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] DEMO: [cloudfoundry] (https://cloudcmd.cloudfoundry.com "cloudfoundry"), [appfog] (https://cloudcmd.aws.af.cm "appfog"), -[jitsu] (https://cloudcmd.jit.su "jitsu"), -[nitrous](http://cloudcmd-5950.euw1.actionbox.io:3000/) -([1](http://cloudcmd-5950.euw1.actionbox.io:8888/), -[2](http://cloudcmd-5950.euw1.actionbox.io:8080/), -[3](http://cloudcmd-5950.euw1.actionbox.io:4000/)). +[jitsu] (https://cloudcmd.jit.su "jitsu") Google PageSpeed Score : [100](//developers.google.com/speed/pagespeed/insights#url=http_3A_2F_2Fcloudcmd.aws.af.cm_2F&mobile=false "score") (out of 100) (or 96 if js or css minification disabled in config.json). From ad05877173fb8fdac49d2d49789fa1fb2cf2eb0f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Sun, 12 May 2013 17:50:17 +0300 Subject: [PATCH 021/239] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 82f6aa2a..a14e6ca0 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Cloud Commander v0.2.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] DEMO: [cloudfoundry] (https://cloudcmd.cloudfoundry.com "cloudfoundry"), [appfog] (https://cloudcmd.aws.af.cm "appfog"), -[jitsu] (https://cloudcmd.jit.su "jitsu") +[jitsu] (https://cloudcmd.jit.su "jitsu"). Google PageSpeed Score : [100](//developers.google.com/speed/pagespeed/insights#url=http_3A_2F_2Fcloudcmd.aws.af.cm_2F&mobile=false "score") (out of 100) (or 96 if js or css minification disabled in config.json). From c7e13af2db6438b3345c2585d9af2f8a1739898e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 21 May 2013 08:40:22 -0400 Subject: [PATCH 022/239] * Changed the way of work with listeners (DOM.addListener to DOM.Events.add) --- ChangeLog | 2 ++ json/config.json | 2 +- lib/client.js | 34 +++++++++++----------- lib/client/dom.js | 52 +++++++++++++++++----------------- lib/client/google_analytics.js | 2 +- lib/client/keyBinding.js | 2 +- lib/client/menu.js | 2 +- lib/client/terminal.js | 2 +- lib/client/viewer.js | 2 +- 9 files changed, 51 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3302572..33351802 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,8 @@ dispatch * Fixed same background declartion a couple times. +* Changed the way of work with listeners (DOM.addListener to DOM.Events.add). + 2012.04.22, v0.2.0 diff --git a/json/config.json b/json/config.json index b012c13a..ddc547fd 100644 --- a/json/config.json +++ b/json/config.json @@ -2,7 +2,7 @@ "api_url" : "/api/v1", "appcache" : false, "minification" : { - "js" : true, + "js" : false, "css" : true, "html" : true, "img" : true diff --git a/lib/client.js b/lib/client.js index 80658705..63ea87e3 100644 --- a/lib/client.js +++ b/lib/client.js @@ -7,7 +7,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; (function(Util, DOM){ 'use strict'; - var Config, Modules, FileTemplate, PathTemplate; + var Config, Modules, FileTemplate, PathTemplate, Events = DOM.Events; /* Клиентский обьект, содержащий функциональную часть*/ CloudCmd = { @@ -59,7 +59,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; }; CloudCmd.GoogleAnalytics = function(){ - DOM.addOneTimeListener('mousemove', function(){ + Events.addOneTime('mousemove', function(){ var lUrl = CloudCmd.LIBDIRCLIENT + 'google_analytics.js'; setTimeout(function(){ @@ -117,7 +117,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; * if user clicks somewhere keyBinded * backs */ - DOM.addOneTimeListener('click', function(){ + DOM.Events.addOneTime('click', function(){ //lA.contentEditable = false; //KeyBinding && KeyBinding.set(); }); @@ -225,7 +225,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; CloudCmd.getModules(function(pModules){ pModules = pModules || []; - DOM.addContextMenuListener(function(pEvent){ + Events.addContextMenu(function(pEvent){ CloudCmd.Menu.ENABLED || DOM.preventDefault(pEvent); }, document); @@ -287,9 +287,9 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; var lButton = 'f' + i, lEl = DOM.getById('f' + i); if( i === 3 || i === 4) - DOM.addOneTimeListener('click', lFuncs[i], lEl); + Events.addOneTime('click', lFuncs[i], lEl); else - DOM.addClickListener(lFuncs[i], lEl); + Events.addClick(lFuncs[i], lEl); lKeysPanel[lButton] = lEl; } @@ -311,7 +311,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; /* загружаем общие функции для клиента и сервера */ DOM.jsload(CloudCmd.LIBDIR + 'cloudfunc.js', function(){ - DOM.addListener("popstate", function(pEvent) { + Events.add("popstate", function(pEvent) { var lPath = pEvent.state + '?json'; if(lPath) @@ -414,7 +414,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; CloudCmd._changeLinks = function(pPanelID){ /* назначаем кнопку очистить кэш и показываем её */ var lClearcache = DOM.getById('clear-cache'); - DOM.addClickListener(DOM.Cache.clear, lClearcache); + Events.addClick(DOM.Cache.clear, lClearcache); /* меняем ссылки на ajax-запросы */ var lPanel = DOM.getById(pPanelID), @@ -495,7 +495,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; }; /* ставим загрузку гифа на клик*/ - DOM.addClickListener( CloudCmd.refresh, a[0].parentElement ); + Events.addClick( CloudCmd.refresh, a[0].parentElement ); /* start from 1 cous 0 is a path and it's setted up */ for(var i = 1, n = a.length; i < n ; i++){ @@ -509,20 +509,20 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; /* if we in path - set click event */ if (lLi.className === 'path') - DOM.addClickListener( lLoadDir, ai ); + Events.addClick( lLoadDir, ai ); else { - DOM.addClickListener( DOM.preventDefault, lLi); - DOM.addListener('mousedown', lSetCurrentFile_f, lLi); - DOM.addListener('dragstart', lOnDragStart_f, ai); + Events.addClick( DOM.preventDefault, lLi); + Events.add('mousedown', lSetCurrentFile_f, lLi); + Events.add('dragstart', lOnDragStart_f, ai); /* if right button clicked menu will * loads and shows */ - DOM.addListener('contextmenu', lOnContextMenu_f, lLi); + Events.add('contextmenu', lOnContextMenu_f, lLi); /* если ссылка на папку, а не файл */ if(ai.target !== '_blank'){ - DOM.addListener('dblclick', lLoadDirOnce, lLi); - DOM.addListener('touchend', lLoadDirOnce, lLi); + Events.add('dblclick', lLoadDirOnce, lLi); + Events.add('touchend', lLoadDirOnce, lLi); } lLi.id = (ai.title ? ai.title : ai.textContent) + @@ -706,7 +706,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; return Util.stringifyJSON(lFileTable); }; - DOM.addOneTimeListener('load', function(){ + Events.addOneTime('load', function(){ /* базовая инициализация*/ CloudCmd.init(); diff --git a/lib/client/dom.js b/lib/client/dom.js index 71fe8775..79ce9243 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -273,7 +273,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pUseCapture * @param pElement {document by default} */ - this.addListener = function(pType, pListener, pElement, pUseCapture){ + this.add = function(pType, pListener, pElement, pUseCapture){ var lRet = this, lElement = (pElement || window); @@ -295,14 +295,14 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pUseCapture * @param pElement {document by default} */ - this.addOneTimeListener = function(pType, pListener, pElement, pUseCapture){ + this.addOneTime = function(pType, pListener, pElement, pUseCapture){ var lRet = this, lOneTime = function (pEvent){ - lRet.removeListener(pType, lOneTime, pElement, pUseCapture); + lRet.remove(pType, lOneTime, pElement, pUseCapture); pListener(pEvent); }; - this.addListener(pType, lOneTime, pElement, pUseCapture); + this.add(pType, lOneTime, pElement, pUseCapture); return lRet; }; @@ -315,7 +315,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pUseCapture * @param pElement {document by default} */ - this.removeListener = function(pType, pListener, pElement, pUseCapture){ + this.remove = function(pType, pListener, pElement, pUseCapture){ var lRet = this; (pElement || window).removeEventListener( @@ -334,8 +334,8 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pListener * @param pUseCapture */ - this.addKeyListener = function(pListener, pElement, pUseCapture){ - return this.addListener('keydown', pListener, pElement, pUseCapture); + this.addKey = function(pListener, pElement, pUseCapture){ + return this.add('keydown', pListener, pElement, pUseCapture); }; /** @@ -344,12 +344,12 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pListener * @param pUseCapture */ - this.addClickListener = function(pListener, pElement, pUseCapture){ - return this.addListener('click', pListener, pElement, pUseCapture); + this.addClick = function(pListener, pElement, pUseCapture){ + return this.add('click', pListener, pElement, pUseCapture); }; - this.addContextMenuListener = function(pListener, pElement, pUseCapture){ - return this.addListener('contextmenu', pListener, pElement, pUseCapture); + this.addContextMenu = function(pListener, pElement, pUseCapture){ + return this.add('contextmenu', pListener, pElement, pUseCapture); }; /** @@ -358,8 +358,8 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pListener * @param pUseCapture */ - this.addErrorListener = function(pListener, pElement, pUseCapture){ - return this.addListener('error', pListener, pElement, pUseCapture); + this.addError = function(pListener, pElement, pUseCapture){ + return this.add('error', pListener, pElement, pUseCapture); }; /** @@ -368,7 +368,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pEventName * @param pKeyCode - not necessarily */ - this.createEvent = function(pEventName, pKeyCode){ + this.create = function(pEventName, pKeyCode){ var lEvent = document.createEvent('Event'); lEvent.initEvent(pEventName, true, true); @@ -389,7 +389,7 @@ var CloudCmd, Util, DOM, CloudFunc; * * @param pKeyCode */ - this.createKeyEvent = function(pKeyCode){ + this.createKey = function(pKeyCode){ return this.createEvent('keydown', pKeyCode); }; @@ -398,7 +398,7 @@ var CloudCmd, Util, DOM, CloudFunc; * * @param pKeyCode */ - this.createClickEvent = function(){ + this.createClick = function(){ return this.createEvent('click'); }; @@ -407,7 +407,7 @@ var CloudCmd, Util, DOM, CloudFunc; * * @param pKeyCode */ - this.createDblClickEvent = function(){ + this.createDblClick = function(){ return this.createEvent('dblclick'); }; @@ -416,7 +416,7 @@ var CloudCmd, Util, DOM, CloudFunc; * * @param pEvent */ - this.dispatch = function(pEvent, pElement){ + this.dispatch = function(pEvent, pElement){ return (pElement || window).dispatchEvent(pEvent); }; @@ -426,7 +426,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pKeyCode * @param pElement */ - this.dispatchKeyEvent = function(pKeyCode, pElement){ + this.dispatchKey = function(pKeyCode, pElement){ var lEvent = this.createKeyEvent(pKeyCode), lRet = this.dispatch(lEvent, pElement); @@ -438,7 +438,7 @@ var CloudCmd, Util, DOM, CloudFunc; * * @param pElement */ - this.dispatchClickEvent = function(pElement){ + this.dispatchClick = function(pElement){ var lEvent = this.createClickEvent(), lRet = this.dispatch(lEvent, pElement); @@ -450,7 +450,7 @@ var CloudCmd, Util, DOM, CloudFunc; * * @param pElement */ - this.dispatchDblClickEvent = function(pElement){ + this.dispatchDblClick = function(pElement){ var lEvent = this.createDblClickEvent(), lRet = this.dispatch(lEvent, pElement); @@ -781,8 +781,8 @@ var CloudCmd, Util, DOM, CloudFunc; */ var lLoad = function(pEvent){ - Events.removeListener('load', lLoad, lElement); - Events.removeListener('error', lError, lElement); + Events.remove('load', lLoad, lElement); + Events.remove('error', lError, lElement); Util.exec(lFunc, pEvent); }, @@ -800,8 +800,8 @@ var CloudCmd, Util, DOM, CloudFunc; Util.exec(lOnError); }; - Events.addListener('load', lLoad, lElement); - Events.addErrorListener(lError, lElement); + Events.add('load', lLoad, lElement); + Events.addError(lError, lElement); if(lStyle) lElement.style.cssText = lStyle; @@ -1804,8 +1804,8 @@ var CloudCmd, Util, DOM, CloudFunc; Util.extend(DOMProto, [ DOMTree, - Events, Loader, { + Events : Events, RESTfull: RESTfull, Images : Images, Cache : Cache diff --git a/lib/client/google_analytics.js b/lib/client/google_analytics.js index ed65f695..32238497 100644 --- a/lib/client/google_analytics.js +++ b/lib/client/google_analytics.js @@ -5,7 +5,7 @@ var DOM, _gaq; /* setting google analitics tracking code */ _gaq = [['_setAccount', 'UA-33536569-2'], ['_trackPageview']]; - DOM.addErrorListener(function(msg, url, line) { + DOM.Events.addError(function(msg, url, line) { _gaq.push(['_trackEvent', 'JS Error', msg, navigator.userAgent + ' -> ' + url + " : " + line]); }); diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index 91a3953d..eab0ccd5 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -345,7 +345,7 @@ var CloudCmd, Util, DOM; }; /* добавляем обработчик клавишь */ - DOM.addKeyListener(key_event); + DOM.Events.addKey(key_event); /* клавиши назначены*/ Binded = true; diff --git a/lib/client/menu.js b/lib/client/menu.js index b4a34506..d12c5b1a 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -308,7 +308,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; }; /* добавляем обработчик клавишь */ - DOM.addKeyListener( key_event ); + DOM.Events.addKey( key_event ); }; CloudCmd.Menu = Menu; diff --git a/lib/client/terminal.js b/lib/client/terminal.js index 4dc7f503..6f81fadd 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -128,7 +128,7 @@ var CloudCmd, Util, DOM, $; return lRet; }; - DOM.addKeyListener(lKeyHandler); + DOM.Events.addKey(lKeyHandler); }; CloudCmd.Terminal.JqueryTerminal = JqueryTerminal; diff --git a/lib/client/viewer.js b/lib/client/viewer.js index cdc0e30d..226472f6 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -153,7 +153,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; }; /* добавляем обработчик клавишь */ - DOM .addKeyListener(lKeyListener) + DOM .Events.addKey(lKeyListener) .setButtonKey('f3', lView); }; From c043a5d04849f8b1c3196864cc7d5d827f8470d8 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 21 May 2013 08:50:47 -0400 Subject: [PATCH 023/239] minor changes --- lib/client/dom.js | 4 +--- lib/client/editor/_codemirror.js | 4 ++-- lib/client/menu.js | 3 +-- lib/client/viewer.js | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 79ce9243..615f9200 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1346,9 +1346,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pKey - 'f1'-'f10' */ this.setButtonKey = function(pKey, pFunc){ - Util.tryCatchLog(function(){ - CloudCmd.KeysPanel[pKey].onclick = pFunc; - }); + Events.addClick(CloudCmd.KeysPanel[pKey], pFunc); }; /** diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index 253471e8..51ffbc27 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -209,8 +209,8 @@ var CloudCmd, Util, DOM, CodeMirror; }; /* добавляем обработчик клавишь */ - DOM .addKeyListener( lKeyListener ) - .setButtonKey('f4', CodeMirrorEditor.show); + DOM.Events.add( lKeyListener ); + DOM.setButtonKey('f4', CodeMirrorEditor.show); }; CloudCmd.Editor.CodeMirror = CodeMirrorEditor; diff --git a/lib/client/menu.js b/lib/client/menu.js index d12c5b1a..485f8878 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -257,8 +257,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; if(!MenuSeted){ $.contextMenu(getConfig()); MenuSeted = true; - //DOM.addListener('mousedown', clickProcessing); - DOM.addListener('mousemove', function(pEvent){ + DOM.Events.add('mousemove', function(pEvent){ Position = { x : pEvent.clientX, y : pEvent.clientY diff --git a/lib/client/viewer.js b/lib/client/viewer.js index 226472f6..b695c9ad 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -153,8 +153,8 @@ var CloudCmd, Util, DOM, CloudFunc, $; }; /* добавляем обработчик клавишь */ - DOM .Events.addKey(lKeyListener) - .setButtonKey('f3', lView); + DOM.Events.addKey(lKeyListener) + DOM.setButtonKey('f3', lView); }; CloudCmd.Viewer.FancyBox = FancyBox; From 293cb32e6ec5911472a066e80c0a16dd0279e94c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 21 May 2013 09:01:47 -0400 Subject: [PATCH 024/239] minor changes --- lib/client/editor/_codemirror.js | 1 - lib/client/viewer.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index 51ffbc27..ca095a03 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -189,7 +189,6 @@ var CloudCmd, Util, DOM, CodeMirror; var lKeyListener = function(pEvent){ /* если клавиши можно обрабатывать */ if( KeyBinding.get() ){ - /* if f4 or f3 pressed */ var lF3 = CloudCmd.KEY.F3, lF4 = CloudCmd.KEY.F4; diff --git a/lib/client/viewer.js b/lib/client/viewer.js index b695c9ad..c1f2fa37 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -153,7 +153,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; }; /* добавляем обработчик клавишь */ - DOM.Events.addKey(lKeyListener) + DOM.Events.addKey(lKeyListener); DOM.setButtonKey('f3', lView); }; From 5765025f8ff3ddee4967452b404471b81ccf2497 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 21 May 2013 09:22:39 -0400 Subject: [PATCH 025/239] minor changes --- lib/client/dom.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 615f9200..cb45369d 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -931,7 +931,8 @@ var CloudCmd, Util, DOM, CloudFunc; }; }, CmdProto = function(){ - var CURRENT_FILE = 'current-file', + var Cmd = this, + CURRENT_FILE = 'current-file', SELECTED_FILE = 'selected-file', Title; @@ -1663,13 +1664,13 @@ var CloudCmd, Util, DOM, CloudFunc; * @pCurrent */ this.renameCurrent = function(pCurrentFile){ - if( !this.isCurrentFile(pCurrentFile) ) + if( !Cmd.isCurrentFile(pCurrentFile) ) pCurrentFile = null; - var lCurrent = pCurrentFile || this.getCurrentFile(), - lFrom = this.getCurrentName(lCurrent), + var lCurrent = pCurrentFile || Cmd.getCurrentFile(), + lFrom = Cmd.getCurrentName(lCurrent), lTo = prompt('Rename', lFrom) || lFrom, - lDirPath = this.getCurrentDirPath(); + lDirPath = Cmd.getCurrentDirPath(); if( !Util.strCmp(lFrom, lTo) ){ var lFiles = { From 200cd3ec090d5d5eb540c3cf6ecb7208525999dd Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 21 May 2013 09:53:16 -0400 Subject: [PATCH 026/239] minor changes --- lib/client/editor/_codemirror.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index ca095a03..bd152e5e 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -208,7 +208,7 @@ var CloudCmd, Util, DOM, CodeMirror; }; /* добавляем обработчик клавишь */ - DOM.Events.add( lKeyListener ); + DOM.Events.addKey( lKeyListener ); DOM.setButtonKey('f4', CodeMirrorEditor.show); }; From 68ae90a9e0929230818a319c40d90e0ff6326626 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 21 May 2013 11:01:00 -0400 Subject: [PATCH 027/239] dded ability to add a couple events in Events.add --- ChangeLog | 2 ++ lib/client.js | 20 +++++++------- lib/client/dom.js | 69 +++++++++++++++++++++++++++++++++++------------ 3 files changed, 65 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33351802..67ed547a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,8 @@ dispatch * Changed the way of work with listeners (DOM.addListener to DOM.Events.add). +* Added ability to add a couple events in Events.add. + 2012.04.22, v0.2.0 diff --git a/lib/client.js b/lib/client.js index 63ea87e3..56f49cea 100644 --- a/lib/client.js +++ b/lib/client.js @@ -117,7 +117,7 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; * if user clicks somewhere keyBinded * backs */ - DOM.Events.addOneTime('click', function(){ + Events.addOneTime('click', function(){ //lA.contentEditable = false; //KeyBinding && KeyBinding.set(); }); @@ -511,18 +511,20 @@ var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; if (lLi.className === 'path') Events.addClick( lLoadDir, ai ); else { - Events.addClick( DOM.preventDefault, lLi); - Events.add('mousedown', lSetCurrentFile_f, lLi); + Events.add({ + 'click' : DOM.preventDefault, + 'mousedown' : lSetCurrentFile_f, + 'contextmenu' : lOnContextMenu_f + }, lLi); + Events.add('dragstart', lOnDragStart_f, ai); - /* if right button clicked menu will - * loads and shows - */ - Events.add('contextmenu', lOnContextMenu_f, lLi); /* если ссылка на папку, а не файл */ if(ai.target !== '_blank'){ - Events.add('dblclick', lLoadDirOnce, lLi); - Events.add('touchend', lLoadDirOnce, lLi); + Events.add({ + 'dblclick' : lLoadDirOnce, + 'touchend' : lLoadDirOnce + }, lLi); } lLi.id = (ai.title ? ai.title : ai.textContent) + diff --git a/lib/client/dom.js b/lib/client/dom.js index cb45369d..19b98e53 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -265,6 +265,10 @@ var CloudCmd, Util, DOM, CloudFunc; }; }, EventsProto = function(){ + var Events = this, + ADD = true, + REMOVE = false; + /** * safe add event listener * @@ -274,17 +278,13 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pElement {document by default} */ this.add = function(pType, pListener, pElement, pUseCapture){ - var lRet = this, - lElement = (pElement || window); - - if( lElement.addEventListener) - lElement.addEventListener( - pType, - pListener, - pUseCapture - ); - - return lRet; + return process( + ADD, + pType, + pListener, + pElement, + pUseCapture + ); }; /** @@ -316,15 +316,13 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pElement {document by default} */ this.remove = function(pType, pListener, pElement, pUseCapture){ - var lRet = this; - - (pElement || window).removeEventListener( + return process( + REMOVE, pType, pListener, + pElement, pUseCapture ); - - return lRet; }; @@ -456,6 +454,43 @@ var CloudCmd, Util, DOM, CloudFunc; return lRet; }; + + function process(pAdd, pType, pListener, pElement, pUseCapture){ + var lElement = (pElement || window), + + lEventProcess = pAdd ? + lElement.addEventListener : + lElement.removeEventListener, + + lProcessName = pAdd ? 'add' : 'remove', + lProcess = Events[lProcessName], + + lRet = pType && lEventProcess, + lEvent = ''; + + lEventProcess = lEventProcess.bind(lElement); + + if(lRet){ + if(Util.isString(pType) ) + lEventProcess( + pType, + pListener, + pUseCapture + ); + else if(Util.isObject(pType)){ + if(pListener) + pElement = pListener; + + for(lEvent in pType) + lProcess( + lEvent, + pType[lEvent], + pElement, + pUseCapture + ); + } + } + } }, CacheProto = function(){ /* приватный переключатель возможности работы с кэшем */ @@ -1347,7 +1382,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pKey - 'f1'-'f10' */ this.setButtonKey = function(pKey, pFunc){ - Events.addClick(CloudCmd.KeysPanel[pKey], pFunc); + Events.addClick(pFunc, CloudCmd.KeysPanel[pKey]); }; /** From 8f2f3a418253029052197e5789faa40534cf6ec8 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 21 May 2013 11:06:00 -0400 Subject: [PATCH 028/239] minor changes --- lib/client/dom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 19b98e53..fcf5b327 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1001,8 +1001,8 @@ var CloudCmd, Util, DOM, CloudFunc; * @pCurrentFile */ this.promptNewFile = function(pTypeName, pType){ - var lName = this.getCurrentName(), - lDir = this.getCurrentDirPath(), + var lName = Cmd.getCurrentName(), + lDir = Cmd.getCurrentDirPath(), lMsg = 'New ' + pTypeName || 'File', lType = Util.isString(pType) ? pType : ''; From 6bf2d02e6173f40c4d20081cce5a5d79dec1b514 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 24 May 2013 09:08:07 -0400 Subject: [PATCH 029/239] fixed bug in Events object --- lib/client/dom.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index fcf5b327..21119f4c 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -388,7 +388,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pKeyCode */ this.createKey = function(pKeyCode){ - return this.createEvent('keydown', pKeyCode); + return this.create('keydown', pKeyCode); }; /** @@ -397,7 +397,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pKeyCode */ this.createClick = function(){ - return this.createEvent('click'); + return this.create('click'); }; /** @@ -406,7 +406,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pKeyCode */ this.createDblClick = function(){ - return this.createEvent('dblclick'); + return this.create('dblclick'); }; /** @@ -425,7 +425,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pElement */ this.dispatchKey = function(pKeyCode, pElement){ - var lEvent = this.createKeyEvent(pKeyCode), + var lEvent = this.createKey(pKeyCode), lRet = this.dispatch(lEvent, pElement); return lRet; @@ -437,7 +437,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pElement */ this.dispatchClick = function(pElement){ - var lEvent = this.createClickEvent(), + var lEvent = this.createClick(), lRet = this.dispatch(lEvent, pElement); return lRet; @@ -449,7 +449,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pElement */ this.dispatchDblClick = function(pElement){ - var lEvent = this.createDblClickEvent(), + var lEvent = this.createDblClick(), lRet = this.dispatch(lEvent, pElement); return lRet; From c7dd643e18593c5a07627fbafb0519b197561398 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 24 May 2013 10:21:38 -0400 Subject: [PATCH 030/239] changed if( -> if ( --- cloudcmd.js | 48 ++++---- lib/client/dom.js | 264 ++++++++++++++++++++++------------------- lib/client/menu.js | 4 +- lib/client/terminal.js | 4 +- lib/util.js | 118 +++++++++--------- 5 files changed, 226 insertions(+), 212 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 10eae0d5..17111deb 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -53,7 +53,7 @@ * меняем в index.html обычные css на * минифицированый */ - if(Minify.allowed.css){ + if (Minify.allowed.css){ var lPath = '/' + Util.removeStr(Minify.MinFolder, DIR), lReplace = ''; lData = Util.removeStr(lData, lReplace) @@ -65,10 +65,10 @@ fm : lAdditional }); - if(!Config.appcache) + if (!Config.appcache) lData = Util.removeStr(lData, ' manifest="/cloudcmd.appcache"'); - if(!Config.show_keys_panel){ + if (!Config.show_keys_panel){ var lKeysPanel = '
' + p.name); pParams.name = main.HTMLDIR + p.name + '.html'; lRet = main.sendFile( pParams ); } - else if( Util.isContainStrAtBegin(p.name, FS) || Util.strCmp( p.name, '/') ){ + else if ( Util.isContainStrAtBegin(p.name, FS) || Util.strCmp( p.name, '/') ){ - if( Util.isContainStrAtBegin(p.name, FS + 'no-js/') ){ + if ( Util.isContainStrAtBegin(p.name, FS + 'no-js/') ){ var lURL = Util.removeStr(pParams.name, 'no-js/'); return main.redirect(pParams, lURL); } @@ -279,13 +279,13 @@ function sendCommanderContent(pParams){ var lRet = main.checkParams(pParams); - if(lRet){ + if (lRet){ var p = pParams; p.name = Util.removeStrOneTime(p.name, CloudFunc.FS) || main.SLASH; fs.stat(p.name, function(pError, pStat){ - if(!pError) - if( pStat.isDirectory() ) + if (!pError) + if ( pStat.isDirectory() ) processCommanderContent(pParams); else main.sendFile(p); @@ -301,12 +301,12 @@ function processCommanderContent(pParams){ var lRet = main.checkParams(pParams); - if(lRet){ + if (lRet){ var p = pParams; main.commander.getDirContent(p.name, function(pError, pJSON){ - if(!pError){ + if (!pError){ var lQuery = main.getQuery(p.request); - if( Util.isContainStr(lQuery, 'json') ){ + if ( Util.isContainStr(lQuery, 'json') ){ p.data = Util.stringifyJSON(pJSON); p.name +='.json'; main.sendResponse(p); @@ -314,7 +314,7 @@ else{ /* get back html*/ p.name = Minify.allowed.html ? Minify.getName(INDEX) : INDEX; fs.readFile(p.name, function(pError, pData){ - if(!pError){ + if (!pError){ var lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate), lList = '
    ' + lPanel + '
' + ''; diff --git a/lib/client/dom.js b/lib/client/dom.js index 21119f4c..7bd39036 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -46,7 +46,7 @@ var CloudCmd, Util, DOM, CloudFunc; DOM.hide(lErrorImage); var lCurrent; - if(pPosition && pPosition.top) + if (pPosition && pPosition.top) lCurrent = DOM.getRefreshButton().parentElement; else{ var lFile = DOM.getCurrentFile(); @@ -56,7 +56,7 @@ var CloudCmd, Util, DOM, CloudFunc; /* show loading icon if it not showed */ var lParent = lLoadingImage.parentElement; - if(!lParent || (lParent && lParent !== lCurrent)) + if (!lParent || (lParent && lParent !== lCurrent)) lCurrent.appendChild(lLoadingImage); lRet_b = DOM.show(lLoadingImage); /* показываем загрузку*/ @@ -83,11 +83,11 @@ var CloudCmd, Util, DOM, CloudFunc; lText = (lStatus === 404 ? lResponce : lStatusText); /* если файла не существует*/ - if( Util.isContainStr(lText, 'Error: ENOENT, ') ) + if ( Util.isContainStr(lText, 'Error: ENOENT, ') ) lText = lText.replace('Error: ENOENT, n','N'); /* если не хватает прав для чтения файла*/ - else if( Util.isContainStr(lText, 'Error: EACCES,') ) + else if ( Util.isContainStr(lText, 'Error: EACCES,') ) lText = lText.replace('Error: EACCES, p','P'); @@ -95,7 +95,7 @@ var CloudCmd, Util, DOM, CloudFunc; lErrorImage.title = lText; var lParent = lLoadingImage.parentElement; - if(lParent) + if (lParent) lParent.appendChild(lErrorImage); DOM.hide(lLoadingImage); @@ -154,17 +154,17 @@ var CloudCmd, Util, DOM, CloudFunc; function sendRequest(pParams){ var lRet = Util.checkObjTrue(pParams, ['method']); - if(lRet){ + if (lRet){ var p = pParams; Images.showLoad( p.imgPosition ); CloudCmd.getConfig(function(pConfig){ var lData; - if( Util.isString(p.url) ) + if ( Util.isString(p.url) ) p.url = decodeURI(p.url); - if( p.data && !Util.isString(p.data)) + if ( p.data && !Util.isString(p.data)) lData = Util.stringifyJSON(p.data); else lData = p.data; @@ -197,11 +197,11 @@ var CloudCmd, Util, DOM, CloudFunc; this.addClass = function(pElement, pClass){ var lRet; - if(pElement){ + if (pElement){ var lClassList = pElement.classList; lRet = !this.isContainClass(pElement, pClass); - if( lRet ) + if ( lRet ) lClassList.add(pClass); } @@ -218,7 +218,7 @@ var CloudCmd, Util, DOM, CloudFunc; var lRet, lClassList = pElement && pElement.classList; - if( lClassList ) + if ( lClassList ) lRet = lClassList.contains(pClass); return lRet; @@ -371,7 +371,7 @@ var CloudCmd, Util, DOM, CloudFunc; lEvent.initEvent(pEventName, true, true); - if(pKeyCode) + if (pKeyCode) lEvent.keyCode = pKeyCode; lEvent.isDefaultPrevented = function(){ @@ -470,15 +470,15 @@ var CloudCmd, Util, DOM, CloudFunc; lEventProcess = lEventProcess.bind(lElement); - if(lRet){ - if(Util.isString(pType) ) + if (lRet){ + if (Util.isString(pType) ) lEventProcess( pType, pListener, pUseCapture ); - else if(Util.isObject(pType)){ - if(pListener) + else if (Util.isObject(pType)){ + if (pListener) pElement = pListener; for(lEvent in pType) @@ -515,7 +515,7 @@ var CloudCmd, Util, DOM, CloudFunc; this.remove = function(pItem){ var lRet = this; - if(CacheAllowed) + if (CacheAllowed) localStorage.removeItem(pItem); return lRet; @@ -528,7 +528,7 @@ var CloudCmd, Util, DOM, CloudFunc; this.set = function(pName, pData){ var lRet = this; - if(CacheAllowed && pName && pData) + if (CacheAllowed && pName && pData) localStorage.setItem(pName,pData); return lRet; @@ -538,7 +538,7 @@ var CloudCmd, Util, DOM, CloudFunc; this.get = function(pName){ var lRet; - if(CacheAllowed) + if (CacheAllowed) lRet = localStorage.getItem(pName); return lRet; @@ -548,7 +548,7 @@ var CloudCmd, Util, DOM, CloudFunc; this.getAll = function(){ var lRet = null; - if(CacheAllowed) + if (CacheAllowed) lRet = localStorage; return lRet; @@ -558,7 +558,7 @@ var CloudCmd, Util, DOM, CloudFunc; this.clear = function(){ var lRet = this; - if(CacheAllowed) + if (CacheAllowed) localStorage.clear(); return lRet; @@ -576,7 +576,7 @@ var CloudCmd, Util, DOM, CloudFunc; this.getIdBySrc = function(pSrc){ var lRet = Util.isString(pSrc); - if(lRet){ + if (lRet){ var lNum = pSrc.lastIndexOf('/') + 1, lSub = pSrc.substr(pSrc, lNum), lID = Util.removeStrOneTime(pSrc, lSub ); @@ -598,11 +598,11 @@ var CloudCmd, Util, DOM, CloudFunc; */ this.ajax = function(pParams){ var lRet = Util.checkObjTrue(pParams, ['url', 'success']); - if(lRet){ + if (lRet){ var p = pParams, lType = p.type || p.method || 'GET'; - if(!XMLHTTP) + if (!XMLHTTP) XMLHTTP = new XMLHttpRequest(); XMLHTTP.open(lType, pParams.url, true); @@ -617,10 +617,10 @@ var CloudCmd, Util, DOM, CloudFunc; var lData = lJqXHR.response; /* If it's json - parse it as json */ - if(lType && Util.isContainStr(lType, 'application/json') ) + if (lType && Util.isContainStr(lType, 'application/json') ) lData = Util.parseJSON(lJqXHR.response) || lJqXHR.response; - if( Util.isFunction(p.success) ) + if ( Util.isFunction(p.success) ) p.success(lData, lJqXHR.statusText, lJqXHR); } /* file not found or connection lost */ @@ -628,7 +628,7 @@ var CloudCmd, Util, DOM, CloudFunc; /* if html given or something like thet * getBack just status of result */ - if(lType && lType.indexOf('text/plain') !== 0) + if (lType && lType.indexOf('text/plain') !== 0) lJqXHR.responseText = lJqXHR.statusText; Util.exec(p.error, lJqXHR); @@ -649,20 +649,20 @@ var CloudCmd, Util, DOM, CloudFunc; this.anyLoadOnLoad = function(pParams_a, pFunc){ var lRet = this; - if( Util.isArray(pParams_a) ) { + if ( Util.isArray(pParams_a) ) { var lParam = pParams_a.pop(), lFunc = function(){ Loader.anyLoadOnLoad(pParams_a, pFunc); }; - if( Util.isString(lParam) ) + if ( Util.isString(lParam) ) lParam = { src : lParam }; - else if( Util.isArray(lParam) ){ + else if ( Util.isArray(lParam) ){ this.anyLoadInParallel(lParam, lFunc); } - if(lParam && !lParam.func){ + if (lParam && !lParam.func){ lParam.func = lFunc; this.anyload(lParam); @@ -689,21 +689,21 @@ var CloudCmd, Util, DOM, CloudFunc; lDoneFunc = function (pCallBack){ Util.exec(pCallBack); - if( !lDone.pop() ) + if ( !lDone.pop() ) Util.exec(pFunc); }; - if( !Util.isArray(pParams_a) ){ + if ( !Util.isArray(pParams_a) ){ pParams_a = [pParams_a]; } for(var i = 0, n = pParams_a.length; i < n; i++){ var lParam = pParams_a.pop(); - if(lParam){ + if (lParam){ lDone.push(i); - if(Util.isString(lParam) ) + if (Util.isString(lParam) ) lParam = { src : lParam }; var lFunc = lParam.func; @@ -736,13 +736,13 @@ var CloudCmd, Util, DOM, CloudFunc; */ this.anyload = function(pParams_o){ - if( !pParams_o ) return; + if ( !pParams_o ) return; /* if a couple of params was * processing every of params * and quit */ - if( Util.isArray(pParams_o) ){ + if ( Util.isArray(pParams_o) ){ var lElements_a = []; for(var i = 0, n = pParams_o.length; i < n ; i++) lElements_a[i] = this.anyload(pParams_o[i]); @@ -767,14 +767,14 @@ var CloudCmd, Util, DOM, CloudFunc; lFunc = lFunc.onload; } /* убираем путь к файлу, оставляя только название файла */ - if(!lID && lSrc) + if (!lID && lSrc) lID = this.getIdBySrc(lSrc); var lElement = DOMTree.getById(lID); /* если скрипт еще не загружен */ - if(!lElement){ - if(!lName && lSrc){ + if (!lElement){ + if (!lName && lSrc){ var lDot = lSrc.lastIndexOf('.'), lExt = lSrc.substr(lDot); @@ -792,17 +792,17 @@ var CloudCmd, Util, DOM, CloudFunc; } lElement = document.createElement(lName); - if(lID) + if (lID) lElement.id = lID; - if(lClass) + if (lClass) lElement.className = lClass; /* if working with external css * using href in any other case * using src */ - if(lName === 'link'){ + if (lName === 'link'){ lElement.href = lSrc; lElement.rel = 'stylesheet'; }else @@ -838,16 +838,16 @@ var CloudCmd, Util, DOM, CloudFunc; Events.add('load', lLoad, lElement); Events.addError(lError, lElement); - if(lStyle) + if (lStyle) lElement.style.cssText = lStyle; - if(lAsync || lAsync === undefined) + if (lAsync || lAsync === undefined) lElement.async = true; - if(!lNotAppend) + if (!lNotAppend) lParent.appendChild(lElement); - if(lInner) + if (lInner) lElement.innerHTML = lInner; } /* если js-файл уже загружен @@ -866,7 +866,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pFunc */ this.jsload = function(pSrc, pFunc){ - if( Util.isArray(pSrc) ){ + if ( Util.isArray(pSrc) ){ for(var i=0; i < pSrc.length; i++) pSrc[i].name = 'script'; @@ -912,7 +912,7 @@ var CloudCmd, Util, DOM, CloudFunc; * все параметры опциональны */ this.cssLoad = function(pParams_o){ - if( Util.isArray(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; @@ -921,7 +921,7 @@ var CloudCmd, Util, DOM, CloudFunc; return this.anyload(pParams_o); } - else if( Util.isString(pParams_o) ) + else if ( Util.isString(pParams_o) ) pParams_o = { src: pParams_o }; pParams_o.name = 'link'; @@ -932,12 +932,47 @@ var CloudCmd, Util, DOM, CloudFunc; /** * load jquery from google cdn or local copy + * @param pParams + */ + this.jquery = function(pParams){ + if (!pParams) + pParams = {}; + /* загружаем jquery: */ + Loader.jsload('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js',{ + onload : Util.retExec(pParams.onload), + onerror : Util.retExec(pParams.onerror) + }); + }; + + }, + CmdProto = function(){ + var Cmd = this, + CURRENT_FILE = 'current-file', + SELECTED_FILE = 'selected-file', + Title; + + /** + * private function thet unset currentfile + * + * @pCurrentFile + */ + function unsetCurrentFile(pCurrentFile){ + var lRet = DOM.isCurrentFile(pCurrentFile); + + if (lRet) + DOM.removeClass(pCurrentFile, CURRENT_FILE); + + return lRet; + } + + + /** + * load jquery from google cdn or local copy * @param pCallBack */ this.jqueryLoad = function(pCallBack){ - /* загружаем jquery: */ - Loader.jsload('//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js',{ - onload: Util.retExec(pCallBack), + Loader.jsqueryLoad({ + onload: pCallBack, onerror: function(){ Loader.jsload('/lib/client/jquery.js'); @@ -964,27 +999,6 @@ var CloudCmd, Util, DOM, CloudFunc; this.socketLoad = function(pCallBack){ Loader.jsload('/lib/client/socket.js', Util.retExec(pCallBack) ); }; - }, - CmdProto = function(){ - var Cmd = this, - CURRENT_FILE = 'current-file', - SELECTED_FILE = 'selected-file', - Title; - - /** - * private function thet unset currentfile - * - * @pCurrentFile - */ - function unsetCurrentFile(pCurrentFile){ - var lRet = DOM.isCurrentFile(pCurrentFile); - - if(lRet) - DOM.removeClass(pCurrentFile, CURRENT_FILE); - - return lRet; - } - /** * create new folder @@ -1006,12 +1020,12 @@ var CloudCmd, Util, DOM, CloudFunc; lMsg = 'New ' + pTypeName || 'File', lType = Util.isString(pType) ? pType : ''; - if(lName === '..') + if (lName === '..') lName = ''; lName = prompt(lMsg, lName); - if(lName) + if (lName) RESTfull.save(lDir + lName + lType, null, CloudCmd.refresh); }; @@ -1031,11 +1045,11 @@ var CloudCmd, Util, DOM, CloudFunc; lSelected = this.getSelectedNames(lFiles), i, n = lSelected && lSelected.length; - if(n > 1){ + if (n > 1){ for(i = 0; i < 5 && i < n; i++) lName += '\n' + lSelected[i]; - if(n >= 5) + if (n >= 5) lName += '\n...'; lMsg = lMsgAsk + lMsgSel + n + ' files/directoris?\n' + lName ; @@ -1044,14 +1058,14 @@ var CloudCmd, Util, DOM, CloudFunc; var lType, lIsDir; /* dom element passed and it is not event */ - if( pCurrentFile && !pCurrentFile.pType) + if ( pCurrentFile && !pCurrentFile.pType) lCurrent = pCurrentFile; else lCurrent = this.getCurrentFile(); lIsDir = this.isCurrentIsDir(lCurrent); - if(lIsDir){ + if (lIsDir){ lQuery = '?dir'; lType ='directory'; } @@ -1064,23 +1078,23 @@ var CloudCmd, Util, DOM, CloudFunc; lMsg = lMsgAsk + lMsgSel + lType + lName + '?'; } - if(lName !== '..') + if (lName !== '..') lRet = confirm(lMsg); else alert('No files selected!'); - if(lRet){ + if (lRet){ var lUrl; - if(lCurrent) + if (lCurrent) lUrl = this.getCurrentPath(lCurrent); else{ lUrl = this.getCurrentDirPath(); lCurrent = lFiles[0]; } - if(lCurrent || lSelected) + if (lCurrent || lSelected) RESTfull.delete(lUrl, lSelected, function(){ - if(n > 1) + if (n > 1) DOM.deleteSelected(lFiles); else DOM.deleteCurrent(lCurrent); @@ -1126,7 +1140,7 @@ var CloudCmd, Util, DOM, CloudFunc; lPath = this.getByClass('path', lPanel)[0], lRet; - if(lPath) + if (lPath) lRet = lPath.textContent; return lRet; @@ -1140,7 +1154,7 @@ var CloudCmd, Util, DOM, CloudFunc; lPath = this.getByClass('path', lPanel)[0], lRet; - if(lPath) + if (lPath) lRet = lPath.textContent; return lRet; @@ -1194,7 +1208,7 @@ var CloudCmd, Util, DOM, CloudFunc; lName = this.getCurrentName(lCurrent); /* если это папка - возвращаем слово dir вместо размера*/ - if(lName !== '..') + if (lName !== '..') RESTfull.read(lLink, function(pSize){ DOM.setCurrentSize(pSize, lCurrent); Util.exec(pCallBack, lCurrent); @@ -1245,16 +1259,16 @@ var CloudCmd, Util, DOM, CloudFunc; Images.showError(jqXHR); }; - if( Util.isFunction(lParams) ) + if ( Util.isFunction(lParams) ) lParams.success = Util.retExec(pParams); lParams.error = lError; - if( this.isCurrentIsDir(lCurrentFile) ) + if ( this.isCurrentIsDir(lCurrentFile) ) lPath += '?json'; - if(!lParams.url) + if (!lParams.url) lParams.url = CloudFunc.FS + lPath; lRet = this.ajax(lParams); @@ -1274,11 +1288,11 @@ var CloudCmd, Util, DOM, CloudFunc; lCurrentFile = pCurrentFile ? pCurrentFile : this.getCurrentFile(), lFunc = function(pData){ var lName = DOM.getCurrentName(lCurrentFile); - if( Util.isObject(pData) ){ + if ( Util.isObject(pData) ){ pData = Util.stringifyJSON(pData); var lExt = '.json'; - if( !Util.checkExtension(lName, lExt) ) + if ( !Util.checkExtension(lName, lExt) ) lName += lExt; } @@ -1288,7 +1302,7 @@ var CloudCmd, Util, DOM, CloudFunc; }); }; - if( !Util.isObject(pCallBack) ) + if ( !Util.isObject(pCallBack) ) lParams = lFunc; else lParams = { @@ -1319,14 +1333,14 @@ var CloudCmd, Util, DOM, CloudFunc; var lRet, lCurrentFileWas = this.getCurrentFile(); - if(pCurrentFile){ + if (pCurrentFile){ if (pCurrentFile.className === 'path') pCurrentFile = pCurrentFile.nextSibling; if (pCurrentFile.className === 'fm-header') pCurrentFile = pCurrentFile.nextSibling; - if(lCurrentFileWas) + if (lCurrentFileWas) unsetCurrentFile(lCurrentFileWas); this.addClass(pCurrentFile, CURRENT_FILE); @@ -1348,7 +1362,7 @@ var CloudCmd, Util, DOM, CloudFunc; var lCurrent = pCurrent || this.getCurrentFile(), lRet = this.addClass(pCurrent, SELECTED_FILE); - if(!lRet) + if (!lRet) this.unsetSelectedFile(lCurrent); return lRet; @@ -1371,7 +1385,7 @@ var CloudCmd, Util, DOM, CloudFunc; this.setHistory = function(pData, pTitle, pUrl){ var lRet = window.history; - if(lRet) + if (lRet) history.pushState(pData, pTitle, pUrl); return lRet; @@ -1393,14 +1407,14 @@ var CloudCmd, Util, DOM, CloudFunc; */ this.setTitle = function(pName){ - if(!Title) + if (!Title) Title = DOMTree.getByTag('title')[0] || Loader.anyload({ name:'title', parentElement: document.head, innerHTML: pName }); - if(Title) + if (Title) Title.textContent = pName; return Title; @@ -1414,7 +1428,7 @@ var CloudCmd, Util, DOM, CloudFunc; this.isCurrentFile = function(pCurrent){ var lRet; - if( pCurrent ) + if ( pCurrent ) lRet = this.isContainClass(pCurrent, CURRENT_FILE); return lRet; @@ -1428,7 +1442,7 @@ var CloudCmd, Util, DOM, CloudFunc; this.isSelected = function(pSelected){ var lRet; - if( pSelected ) + if ( pSelected ) lRet = this.isContainClass(pSelected, SELECTED_FILE); return lRet; @@ -1486,7 +1500,7 @@ var CloudCmd, Util, DOM, CloudFunc; var lCurrent = pCurrentFile || this.getCurrentFile(), lLink = this.getCurrentLink( lCurrent ); - if( Util.isObject(lLink) ) + if ( Util.isObject(lLink) ) lLink = lLink.title || lLink.textContent; return lLink; @@ -1496,11 +1510,11 @@ var CloudCmd, Util, DOM, CloudFunc; var lSelected = pSelected || this.getSelectedFiles(), lRet = lSelected ? [] : null; - if(lRet){ + if (lRet){ var lFirst = lSelected[0], lName = this.getCurrentName( lFirst ); - if(lName === '..') + if (lName === '..') this.unsetSelectedFile( lFirst ); for(var i = 0, n = lSelected.length; i < n;i++) @@ -1538,7 +1552,7 @@ var CloudCmd, Util, DOM, CloudFunc; var lPanel = this.getCurrentFile().parentElement; /* if {active : false} getting passive panel */ - if(pActive && !pActive.active){ + if (pActive && !pActive.active){ var lId = lPanel.id === 'left' ? 'right' : 'left'; lPanel = this.getById(lId); } @@ -1547,11 +1561,11 @@ var CloudCmd, Util, DOM, CloudFunc; * then always work with passive * panel */ - if(window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH) + if (window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH) lPanel = this.getById('left'); - if(!lPanel) + if (!lPanel) Util.log('Error can not find Active Panel'); return lPanel; @@ -1575,7 +1589,7 @@ var CloudCmd, Util, DOM, CloudFunc; var lRet = true, lPanel = this.getPanel(pActive); - if(lPanel) + if (lPanel) this.show(lPanel); else lRet = false; @@ -1590,7 +1604,7 @@ var CloudCmd, Util, DOM, CloudFunc; var lRet = false, lPanel = this.getPanel(pActive); - if(lPanel) + if (lPanel) lRet = this.hide(lPanel); return lRet; @@ -1614,7 +1628,7 @@ var CloudCmd, Util, DOM, CloudFunc; ',scrollbars=1,resizable=1'; var lWind = window.open(pUrl, 'Cloud Commander Auth', lOptions); - if(!lWind) + if (!lWind) Util.log('Pupup blocked!'); }; @@ -1636,7 +1650,7 @@ var CloudCmd, Util, DOM, CloudFunc; var lRet_b = true, lClassList = pElement.classList; - if(pElement && lClassList) + if (pElement && lClassList) lClassList.remove(pClass); else @@ -1654,14 +1668,14 @@ var CloudCmd, Util, DOM, CloudFunc; lParent = lCurrent && lCurrent.parentElement, lName = this.getCurrentName(lCurrent); - if(lCurrent && lParent && lName !== '..'){ + if (lCurrent && lParent && lName !== '..'){ var lNext = pNextFile || lCurrent.nextSibling, lPrevious = pPreviousFile || lCurrent.previousSibling; - if(!pNotSet) - if(lNext) + if (!pNotSet) + if (lNext) this.setCurrentFile(lNext); - else if(lPrevious) + else if (lPrevious) this.setCurrentFile(lPrevious); lParent.removeChild(lCurrent); @@ -1677,7 +1691,7 @@ var CloudCmd, Util, DOM, CloudFunc; this.deleteSelected = function(pSelected){ var lSelected = pSelected || this.getSelectedFiles(); - if(lSelected){ + if (lSelected){ var n = lSelected.length, lLast = n-1, lNext = lSelected[lLast].nextSibling, @@ -1699,7 +1713,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @pCurrent */ this.renameCurrent = function(pCurrentFile){ - if( !Cmd.isCurrentFile(pCurrentFile) ) + if ( !Cmd.isCurrentFile(pCurrentFile) ) pCurrentFile = null; var lCurrent = pCurrentFile || Cmd.getCurrentFile(), @@ -1707,7 +1721,7 @@ var CloudCmd, Util, DOM, CloudFunc; lTo = prompt('Rename', lFrom) || lFrom, lDirPath = Cmd.getCurrentDirPath(); - if( !Util.strCmp(lFrom, lTo) ){ + if ( !Util.strCmp(lFrom, lTo) ){ var lFiles = { from : lDirPath + lFrom, to : lDirPath + lTo @@ -1725,7 +1739,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @pCurrent */ this.moveCurrent = function(pCurrentFile){ - if( !this.isCurrentFile(pCurrentFile) ) + if ( !this.isCurrentFile(pCurrentFile) ) pCurrentFile = null; var lCurrent = pCurrentFile || this.getCurrentFile(), @@ -1735,7 +1749,7 @@ var CloudCmd, Util, DOM, CloudFunc; lToPath = prompt( 'Rename/Move file "' + lName + '"', lToPath ); - if( lToPath && !Util.strCmp(lFromPath, lToPath) ){ + if ( lToPath && !Util.strCmp(lFromPath, lToPath) ){ var lFiles = { from : lFromPath, to : lToPath @@ -1759,7 +1773,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @pCurrent */ this.copyCurrent = function(pCurrentFile){ - if( !this.isCurrentFile(pCurrentFile) ) + if ( !this.isCurrentFile(pCurrentFile) ) pCurrentFile = null; var lCurrent = pCurrentFile || this.getCurrentFile(), @@ -1768,7 +1782,7 @@ var CloudCmd, Util, DOM, CloudFunc; lToPath = this.getNotCurrentDirPath() + lName; lToPath = prompt( 'Copy file "' + lName + '" to', lToPath ); - if( lToPath && !Util.strCmp(lFromPath, lToPath) ){ + if ( lToPath && !Util.strCmp(lFromPath, lToPath) ){ var lFiles = { from : lFromPath, to : lToPath @@ -1792,7 +1806,7 @@ var CloudCmd, Util, DOM, CloudFunc; this.scrollIntoViewIfNeeded = function(pElement){ var lRet = pElement && pElement.scrollIntoViewIfNeeded; - if(lRet) + if (lRet) pElement.scrollIntoViewIfNeeded(); return lRet; @@ -1802,7 +1816,7 @@ var CloudCmd, Util, DOM, CloudFunc; this.scrollByPages = function(pElement, pPages){ var lRet = pElement && pElement.scrollByPages && pPages; - if(lRet) + if (lRet) pElement.scrollByPages(pPages); return lRet; diff --git a/lib/client/menu.js b/lib/client/menu.js index 485f8878..90d42ad6 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -291,7 +291,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.jqueryLoad ]); - var key_event = function(pEvent){ + var lKeyListener = function(pEvent){ var lKEY = CloudCmd.KEY, lKeyCode = pEvent.keyCode; /* если клавиши можно обрабатывать */ @@ -307,7 +307,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; }; /* добавляем обработчик клавишь */ - DOM.Events.addKey( key_event ); + DOM.Events.addKey( lKeyListener ); }; CloudCmd.Menu = Menu; diff --git a/lib/client/terminal.js b/lib/client/terminal.js index 6f81fadd..783fbe96 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -110,7 +110,7 @@ var CloudCmd, Util, DOM, $; ]); /* добавляем обработчик клавишь */ - var lKeyHandler = function(pEvent){ + var lKeyListener = function(pEvent){ var lRet = true, lKEY = CloudCmd.KEY, lKeyCode = pEvent.keyCode, @@ -128,7 +128,7 @@ var CloudCmd, Util, DOM, $; return lRet; }; - DOM.Events.addKey(lKeyHandler); + DOM.Events.addKey( lKeyListener ); }; CloudCmd.Terminal.JqueryTerminal = JqueryTerminal; diff --git a/lib/util.js b/lib/util.js index b8103455..1c1ede9c 100644 --- a/lib/util.js +++ b/lib/util.js @@ -17,7 +17,7 @@ Util = exports || {}; Util.bind = function(pFunction, pContext){ var lRet; - if( Util.isFunction(pFunction) ) + if ( Util.isFunction(pFunction) ) lRet = pFunction.bind(pContext); return lRet; @@ -61,11 +61,11 @@ Util = exports || {}; /* если pExt - расширение pName */ lRet = lExtSub === pExt.length; - }else if(Util.isObject(pExt) && pExt.length){ + }else if (Util.isObject(pExt) && pExt.length){ for(var i=0; i < pName.length; i++){ lRet = Util.checkExtension(pName, pExt[i]); - if(lRet) + if (lRet) break; } } @@ -84,14 +84,14 @@ Util = exports || {}; Util.checkObj = function(pObj, pPropArr, pTrueArr){ var lRet, i, n; - if( pObj ){ + if ( pObj ){ lRet = Util.isArray(pPropArr); - if(lRet){ + if (lRet){ n = pPropArr.length; - for(i = 0; i < n; i++){ + for (i = 0; i < n; i++){ var lProp = pPropArr[i]; lRet = pObj.hasOwnProperty( lProp ); - if(!lRet){ + if (!lRet){ Util.logError(lProp + ' not in Obj!'); Util.log(pObj); break; @@ -99,7 +99,7 @@ Util = exports || {}; } } - if( lRet && Util.isArray(pTrueArr) ) + if ( lRet && Util.isArray(pTrueArr) ) lRet = Util.checkObjTrue( pObj, pTrueArr ); } @@ -116,7 +116,7 @@ Util = exports || {}; Util.checkObjTrue = function(pObj, pTrueArr){ var lRet, lTrueArr, i, n; - if( pObj ){ + if ( pObj ){ lTrueArr = Util.isArray(pTrueArr) ? pTrueArr : [pTrueArr]; n = lTrueArr.length; @@ -124,7 +124,7 @@ Util = exports || {}; var lProp = lTrueArr[i]; lRet = pObj[lProp]; - if( !lRet){ + if ( !lRet){ Util.logError(lProp + ' not true!'); Util.log(pObj); break; @@ -145,19 +145,19 @@ Util = exports || {}; Util.copyObj = function(pFromObj, pToObj, pProps){ var lRet; - if( !pToObj ) + if ( !pToObj ) lRet = pToObj = {}; function copy(pI){ var lName = pProps ? pProps[pI] : pI, lValue = pFromObj[lName]; - if(lValue) + if (lValue) pToObj[lName] = pFromObj[lName]; } - if( Util.isObject(pFromObj) ){ - if(!pProps) + if ( Util.isObject(pFromObj) ){ + if (!pProps) Util.forIn(pFromObj, copy); else Util.fori(pProps.length, copy); @@ -171,7 +171,7 @@ Util = exports || {}; Util.convertArrToObj = function(pArrKeys, pArrVal){ var i, n, lName, lRet; - if(pArrKeys && pArrVal){ + if (pArrKeys && pArrVal){ for(i = 0, n = pArrKeys; i < n; i++){ lName = pArrKeys[i]; lRet[lName] = pArrVal[i]; @@ -190,11 +190,11 @@ Util = exports || {}; Util.extend = function(pTarget, PObj){ var i, n, lObj, lRet = Util.isObject(pTarget) ? pTarget : {}; - if( Util.isArray(PObj) ) + if ( Util.isArray(PObj) ) for(i = 0, n = PObj.length; i < n; i++) lRet = Util.extend(pTarget, PObj[i]); - else if(PObj){ + else if (PObj){ lObj = Util.isFunction(PObj) ? new PObj() : PObj; for(i in lObj) @@ -224,9 +224,9 @@ Util = exports || {}; * @param pFunc */ Util.for = function(pI, pN, pFunc){ - if(Util.isFunction(pFunc)) + if (Util.isFunction(pFunc)) for(var i = pI, n = pN; i < n; i++){ - if(pFunc(i)) + if (pFunc(i)) break; } }; @@ -236,9 +236,9 @@ Util = exports || {}; * @param pFunc */ Util.forIn = function(pObj, pFunc){ - if(Util.isFunction(pFunc)) + if (Util.isFunction(pFunc)) for(var lName in pObj) - if(pFunc(lName)) + if (pFunc(lName)) break; }; @@ -287,15 +287,15 @@ Util = exports || {}; Util.strCmp = function (pStr1, pStr2){ var lRet = Util.isString(pStr1); - if(lRet){ - if( Util.isArray(pStr2) ) + if (lRet){ + if ( Util.isArray(pStr2) ) for(var i = 0, n = pStr2.length; i < n; i++){ lRet = Util.strCmp( pStr1, pStr2[i] ); - if(lRet) + if (lRet) break; } - else if( Util.isString(pStr2) ) + else if ( Util.isString(pStr2) ) lRet = Util.isContainStr(pStr1, pStr2) && pStr1.length === pStr2.length; } @@ -314,15 +314,15 @@ Util = exports || {}; var lRet = Util.isString(pStr1); - if( lRet ){ - if( Util.isArray(pStr2) ) + if ( lRet ){ + if ( Util.isArray(pStr2) ) for(var i = 0, n = pStr2.length; i < n; i++){ lRet = Util.isContainStr( pStr1, pStr2[i] ); - if(lRet) + if (lRet) break; } - else if( Util.isString(pStr2) ) + else if ( Util.isString(pStr2) ) lRet = pStr1.indexOf(pStr2) >= 0; } @@ -337,7 +337,7 @@ Util = exports || {}; Util.isContainStrAtBegin = function(pStr1, pStr2){ var lRet; - if( Util.isString(pStr1) && Util.isString(pStr2) ){ + if ( Util.isString(pStr1) && Util.isString(pStr2) ){ var lLength = pStr2.length, lSubStr = pStr1.substring(0, lLength); @@ -355,7 +355,7 @@ Util = exports || {}; var lConsole = Scope.console, lDate = '[' + Util.getDate() + '] '; - if(lConsole && pArg) + if (lConsole && pArg) lConsole.log(lDate, pArg); return pArg; @@ -369,9 +369,9 @@ Util = exports || {}; var lConsole = Scope.console, lDate = '[' + Util.getDate() + '] '; - if(lConsole && pArg){ + if (lConsole && pArg){ var lMsg = pArg.message; - if( lMsg ) + if ( lMsg ) lDate += pArg.message + ' '; lConsole.error(lDate, pArg); @@ -386,14 +386,14 @@ Util = exports || {}; * @param pData - not necessarily */ Util.loadOnLoad = function(pFunc_a, pData){ - if( Util.isArray(pFunc_a) && pFunc_a.length) { + if ( Util.isArray(pFunc_a) && pFunc_a.length) { var lFunc_a = pFunc_a.slice(), lFunc = lFunc_a.pop(), lCallBack = function(pData){ return Util.loadOnLoad(lFunc_a, pData); }; - if( !Util.isUndefined(pData) ) + if ( !Util.isUndefined(pData) ) pData = { data : pData, callback : lCallBack @@ -411,10 +411,10 @@ Util = exports || {}; Util.removeStr = function(pStr, pSubStr){ var lRet = Util.isString(pStr) && pSubStr; - if( lRet ){ + if ( lRet ){ var n = pSubStr.length; - if( Util.isArray(pSubStr) ) + if ( Util.isArray(pSubStr) ) Util.fori(n, function(i){ lRet = pStr = Util.replaceStr(pStr, pSubStr[i], ''); }); @@ -435,10 +435,10 @@ Util = exports || {}; Util.removeStrOneTime = function(pStr, pSubStr){ var lRet = Util.isString(pStr) && pSubStr; - if( lRet ){ + if ( lRet ){ var n = pSubStr.length; - if( Util.isArray(pSubStr) ) + if ( Util.isArray(pSubStr) ) Util.fori(n, function(i){ lRet = pStr = pStr.replace(pSubStr[i], ''); }); @@ -461,7 +461,7 @@ Util = exports || {}; Util.replaceStr = function(pStr, pFrom, pTo){ var lRet = pStr; - if(pStr && pFrom){ + if (pStr && pFrom){ pFrom = Util.escapeRegExp(pFrom); lRet = pStr.replace(new RegExp(pFrom, 'g'), pTo); } @@ -473,7 +473,7 @@ Util = exports || {}; Util.escapeRegExp = function(pStr) { var lRet = pStr; - if( Util.isString(pStr) ) + if ( Util.isString(pStr) ) lRet = pStr.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); return lRet; @@ -497,7 +497,7 @@ Util = exports || {}; * @pSymbols */ Util.ownRender = function(pTempl, pView, pSymbols){ - if(!pSymbols) + if (!pSymbols) pSymbols = ['{', '}']; var lRet = pTempl, @@ -544,7 +544,7 @@ Util = exports || {}; Util.exec(pParams.callback); var lNum = done.pop (pParams.number); - if(!lNum){ + if (!lNum){ Util.exec(pCallback); } } @@ -634,7 +634,7 @@ Util = exports || {}; */ Util.retExec = function(pCallBack, pArg){ return function(pArgument){ - if( !Util.isUndefined(pArg) ) + if ( !Util.isUndefined(pArg) ) pArgument = pArg; Util.exec(pCallBack, pArgument); }; @@ -685,12 +685,12 @@ Util = exports || {}; Util.setValue = function(pArgs){ var lRet = false; - if( Util.isObject(pArgs) ){ + if ( Util.isObject(pArgs) ){ var lObj = pArgs.object, lProp = pArgs.property, lVal = pArgs.lVal; - if(lObj){ + if (lObj){ lObj[lProp] = lVal; lRet = true; } @@ -708,7 +708,7 @@ Util = exports || {}; lFunc = pArgs.func, lTime = pArgs.time || 1000, lCallBack = function(pArgument){ - if(!lDone){ + if (!lDone){ lDone = Util.exec(pArgs.callback, pArgument); } }; @@ -716,7 +716,7 @@ Util = exports || {}; var lTimeoutFunc = function(){ setTimeout(function(){ Util.exec(lFunc, lCallBack); - if(!lDone) + if (!lDone) lTimeoutFunc(); }, lTime); }; @@ -752,7 +752,7 @@ Util = exports || {}; Util.tryCatchDebug = function(pTryFunc){ var lRet = Util.tryCatch(pTryFunc); - if(lRet) + if (lRet) Util.debug(); return lRet; @@ -783,7 +783,7 @@ Util = exports || {}; lRet = Util.tryCatch(pTryFunc); - if(lRet) + if (lRet) Util.exec(pCallBack, lRet); return lRet; @@ -797,8 +797,8 @@ Util = exports || {}; Util.exec = function(pCallBack, pArg, pArg1){ var lRet; - if(pCallBack){ - if( Util.isFunction(pCallBack) ) + if (pCallBack){ + if ( Util.isFunction(pCallBack) ) lRet = pCallBack(pArg, pArg1); else { var lCallBack = pCallBack.callback || pCallBack.success; @@ -816,7 +816,7 @@ Util = exports || {}; Util.execIfExist = function(pObj, pName, pArg){ var lRet; - if(pObj){ + if (pObj){ var lFunc = Util.bind(pObj[pName], pObj); lRet = Util.exec(lFunc, pArg); } @@ -833,7 +833,7 @@ Util = exports || {}; Util.ifExec = function(pCondition, pCallBack, pFunc){ var lRet; - if(pCondition) + if (pCondition) Util.exec(pCallBack, pCondition); else Util.exec(pFunc, pCallBack); @@ -849,7 +849,7 @@ Util = exports || {}; Util.getExtension = function(pFileName){ var lRet, lDot; - if( Util.isString(pFileName) ){ + if ( Util.isString(pFileName) ){ lDot = pFileName.lastIndexOf('.'); lRet = pFileName.substr(lDot); } @@ -865,10 +865,10 @@ Util = exports || {}; Util.getNamesFromObjArray = function(pArr){ var lRet = []; - if(pArr && !Util.isArray(pArr)) + if (pArr && !Util.isArray(pArr)) pArr = pArr.data; - if(pArr) + if (pArr) Util.fori(pArr.length, function(i){ lRet[i] = pArr[i].name || pArr[i]; }); @@ -884,9 +884,9 @@ Util = exports || {}; Util.findObjByNameInArr = function(pArr, pObjName){ var lRet; - if(pArr){ + if (pArr){ for(var i = 0, n = pArr.length; i < n; i++ ) - if(pArr[i].name === pObjName) break; + if (pArr[i].name === pObjName) break; lRet = pArr[i].data; } From 80e09260e74af32f72fa17c1afa57fbc3b595e5f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 24 May 2013 11:54:21 -0400 Subject: [PATCH 031/239] minor changes --- lib/client/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 7bd39036..86ae760d 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -971,7 +971,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pCallBack */ this.jqueryLoad = function(pCallBack){ - Loader.jsqueryLoad({ + Loader.jquery({ onload: pCallBack, onerror: function(){ From 9b9e6ab66658889f94ab6c7578cd89b993e3154b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 27 May 2013 07:18:44 -0400 Subject: [PATCH 032/239] moved jqeuryLoader and socketLoader to CMD object in DOM --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 67ed547a..44383515 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,8 @@ dispatch * Added ability to add a couple events in Events.add. +* Moved jqeuryLoader and socketLoader to CMD object in DOM. + 2012.04.22, v0.2.0 From b5624f0973949273cc05a599ff6cf49906b03477 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 27 May 2013 11:02:22 -0400 Subject: [PATCH 033/239] fixed bug with deletting in menu js --- ChangeLog | 2 ++ lib/client/menu.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 44383515..07a3fe1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,8 @@ dispatch * Moved jqeuryLoader and socketLoader to CMD object in DOM. +* Fixed bug with deletting in menu js. + 2012.04.22, v0.2.0 diff --git a/lib/client/menu.js b/lib/client/menu.js index 90d42ad6..9fe8c9d6 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -157,7 +157,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; 'Rename' : function(){ setTimeout( Util.retExec(DOM.renameCurrent), 100); }, - 'Delete' : Util.retExec(DOM.promptDeleteCurrent) + 'Delete' : Util.retExec(DOM.promptDeleteSelected) }; if(UploadToItemNames.length) From 795d4c7768a4aaa55843957b1c00b2b4e17827b4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 29 May 2013 07:48:02 -0400 Subject: [PATCH 034/239] refactored --- css/reset.css | 3 - html/index.html | 3 +- json/config.json | 2 +- lib/client.js | 2 +- lib/client/keyBinding.js | 556 +++++++++++++++++++-------------------- 5 files changed, 278 insertions(+), 288 deletions(-) diff --git a/css/reset.css b/css/reset.css index 17497957..dbf21d3d 100644 --- a/css/reset.css +++ b/css/reset.css @@ -8,8 +8,6 @@ */ html{ - font-family: sans-serif; - font-size: 100%; color: #222; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; @@ -22,7 +20,6 @@ body { margin: 0; font-size: 1em; line-height: 1.4; } * Also: hot pink! (or customize the background color to match your design) */ /* -::-moz-selection { background: #fe57a1; color: #fff; text-shadow: none; } ::selection { background: #fe57a1; color: #fff; text-shadow: none; } */ ::-moz-selection{ text-shadow: none; opacity: 0;} diff --git a/html/index.html b/html/index.html index b8da6c04..bd0cfbac 100644 --- a/html/index.html +++ b/html/index.html @@ -28,9 +28,8 @@ diff --git a/json/config.json b/json/config.json index ddc547fd..ca98c321 100644 --- a/json/config.json +++ b/json/config.json @@ -3,7 +3,7 @@ "appcache" : false, "minification" : { "js" : false, - "css" : true, + "css" : false, "html" : true, "img" : true }, diff --git a/lib/client.js b/lib/client.js index 56f49cea..89f08fc7 100644 --- a/lib/client.js +++ b/lib/client.js @@ -2,7 +2,7 @@ * @CloudFunc - обьект содержащий общий функционал * клиентский и серверный */ -var Util, DOM, CloudFunc, $, KeyBinding, CloudCmd; +var Util, DOM, CloudFunc, KeyBinding, CloudCmd; (function(Util, DOM){ 'use strict'; diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index eab0ccd5..3b441de6 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -2,10 +2,6 @@ var CloudCmd, Util, DOM; (function(CloudCmd, Util, DOM){ 'use strict'; - /* private property set or set key binding */ - var Binded; - - /* Key constants*/ CloudCmd.KEY = { TAB : 9, ENTER : 13, @@ -47,308 +43,306 @@ var CloudCmd, Util, DOM; TRA : 192 /* Typewritten Reverse Apostrophe (`) */ }; - var KEY = CloudCmd.KEY; + CloudCmd.KeyBinding = new KeyBindingProto(); - CloudCmd.KeyBinding = {}; - - var KeyBinding = CloudCmd.KeyBinding; - - KeyBinding.get = function(){return Binded;}; - - KeyBinding.set = function(){Binded = true;}; - - KeyBinding.unSet = function(){Binded = false;}; - - KeyBinding.init = function(){ - /* saving state of tabs varibles */ - var lTabPanel = { - left : 0, - right : 0 + function KeyBindingProto(){ + var Binded, + KEY = CloudCmd.KEY, + lTabPanel = { + left : 0, + right : 0 + + }; + + this.get = function(){return Binded;}; + + this.set = function(){Binded = true;}; + + this.unSet = function(){Binded = false;}; + + this.init = function(){ + DOM.Events.addKey(listener); + /* клавиши назначены*/ + Binded = true; }; - var key_event = function(pEvent){ - /* получаем выдленный файл*/ - var i, n, lCurrent = DOM.getCurrentFile(), - lKeyCode = pEvent.keyCode, - lShift = pEvent.shiftKey, - lAlt = pEvent.altKey, - lCtrl = pEvent.ctrlKey; - /* если клавиши можно обрабатывать*/ - if(Binded){ - switch(lKeyCode){ - case KEY.TAB: - /* changing parent panel of curent-file */ - var lPanel = DOM.getPanel(), - lId = lPanel.id; - - lTabPanel[lId] = lCurrent; - - lPanel = DOM.getPanel({active:false}); + function listener(pEvent){ + /* получаем выдленный файл*/ + var i, n, lCurrent = DOM.getCurrentFile(), + lKeyCode = pEvent.keyCode, + lShift = pEvent.shiftKey, + lAlt = pEvent.altKey, + lCtrl = pEvent.ctrlKey; + /* если клавиши можно обрабатывать*/ + if(Binded){ + switch(lKeyCode){ + case KEY.TAB: + /* changing parent panel of curent-file */ + var lPanel = DOM.getPanel(), lId = lPanel.id; - - if(lTabPanel[lId]) - DOM.setCurrentFile(lTabPanel[lId]); - else{ - var lFirstFileOnList = DOM.getByTag('li', lPanel)[2]; - - DOM.setCurrentFile(lFirstFileOnList); - } - - DOM.preventDefault(pEvent);//запрет на дальнейшее действие - break; - case KEY.INSERT: - DOM.setSelectedFile( lCurrent ); - DOM.setCurrentFile( lCurrent.nextSibling ); - break; + lTabPanel[lId] = lCurrent; - case KEY.DELETE: - if(lShift){ - var lUrl = DOM.getCurrentPath(lCurrent); + lPanel = DOM.getPanel({active:false}); + lId = lPanel.id; + + if(lTabPanel[lId]) + DOM.setCurrentFile(lTabPanel[lId]); + else{ + var lFirstFileOnList = DOM.getByTag('li', lPanel)[2]; - if( DOM.isCurrentIsDir(lCurrent) ) - lUrl += '?dir'; - - DOM.RESTfull.delete(lUrl, function(){ - DOM.deleteCurrent(lCurrent); - }); - } - else - DOM.promptDeleteSelected(lCurrent); - break; + DOM.setCurrentFile(lFirstFileOnList); + } - case KEY.F1: - DOM.preventDefault(pEvent); - break; - - case KEY.F2: - DOM.renameCurrent(lCurrent); - break; + DOM.preventDefault(pEvent);//запрет на дальнейшее действие + break; + + case KEY.INSERT: + DOM.setSelectedFile( lCurrent ); + DOM.setCurrentFile( lCurrent.nextSibling ); + break; + + case KEY.DELETE: + if(lShift){ + var lUrl = DOM.getCurrentPath(lCurrent); - case KEY.F3: - var lEditor = CloudCmd[lShift ? 'Viewer' : 'Editor']; + if( DOM.isCurrentIsDir(lCurrent) ) + lUrl += '?dir'; - Util.exec(lEditor, true); - DOM.preventDefault(pEvent); - break; - - case KEY.F4: - DOM.Images.showLoad(); - Util.exec(CloudCmd.Editor); - DOM.preventDefault(pEvent); - break; - - case KEY.F5: - DOM.copyCurrent(lCurrent); - DOM.preventDefault(pEvent); - break; - - case KEY.F6: - DOM.moveCurrent(lCurrent); - DOM.preventDefault(pEvent); - break; - - case KEY.F7: - DOM.promptNewDir(); - break; - - case KEY.F8: - DOM.promptDeleteSelected(lCurrent); - break; - - case KEY.F: - DOM.promptDeleteCurrent(lCurrent); - break; - - case KEY.F10: - if(lShift){ - Util.exec(CloudCmd.Menu); - DOM.preventDefault(pEvent); - } - break; - - case KEY.TRA: - DOM.Images.showLoad({top: true}); - Util.exec(CloudCmd.Terminal); - break; - - case KEY.SPACE: - var lSelected = DOM.isSelected(lCurrent), - lDir = DOM.isCurrentIsDir(lCurrent), - lName = DOM.getCurrentName(lCurrent); - - if(!lDir || lName === '..') - lSelected = true; - - Util.ifExec(lSelected, function(){ - DOM.setSelectedFile(lCurrent); - }, function(pCallBack){ - DOM.loadCurrentSize(pCallBack, lCurrent); + DOM.RESTfull.delete(lUrl, function(){ + DOM.deleteCurrent(lCurrent); }); + } + else + DOM.promptDeleteSelected(lCurrent); + break; + + case KEY.F1: + DOM.preventDefault(pEvent); + break; + + case KEY.F2: + DOM.renameCurrent(lCurrent); + break; + + case KEY.F3: + var lEditor = CloudCmd[lShift ? 'Viewer' : 'Editor']; + + Util.exec(lEditor, true); + DOM.preventDefault(pEvent); + break; + + case KEY.F4: + DOM.Images.showLoad(); + Util.exec(CloudCmd.Editor); + DOM.preventDefault(pEvent); + break; + + case KEY.F5: + DOM.copyCurrent(lCurrent); + DOM.preventDefault(pEvent); + break; + + case KEY.F6: + DOM.moveCurrent(lCurrent); + DOM.preventDefault(pEvent); + break; + + case KEY.F7: + DOM.promptNewDir(); + break; + + case KEY.F8: + DOM.promptDeleteSelected(lCurrent); + break; + + case KEY.F: + DOM.promptDeleteCurrent(lCurrent); + break; + + case KEY.F10: + if(lShift){ + Util.exec(CloudCmd.Menu); + DOM.preventDefault(pEvent); + } + break; + + case KEY.TRA: + DOM.Images.showLoad({top: true}); + Util.exec(CloudCmd.Terminal); + break; + + case KEY.SPACE: + var lSelected = DOM.isSelected(lCurrent), + lDir = DOM.isCurrentIsDir(lCurrent), + lName = DOM.getCurrentName(lCurrent); + + if(!lDir || lName === '..') + lSelected = true; + + Util.ifExec(lSelected, function(){ + DOM.setSelectedFile(lCurrent); + }, function(pCallBack){ + DOM.loadCurrentSize(pCallBack, lCurrent); + }); + + DOM.preventDefault(pEvent); + break; + + /* навигация по таблице файлов * + * если нажали клавишу вверх * + * выделяем предыдущую строку */ + case KEY.UP: + if(lShift) + DOM.setSelectedFile(lCurrent); + + DOM.setCurrentFile( lCurrent.previousSibling ); + DOM.preventDefault( pEvent ); + break; + + /* если нажали клавишу в низ * + * выделяем следующую строку */ + case KEY.DOWN: + if(lShift) + DOM.setSelectedFile(lCurrent); + + DOM.setCurrentFile( lCurrent.nextSibling ); + DOM.preventDefault( pEvent ); + break; + + /* если нажали клавишу Home * + * переходим к самому верхнему * + * элементу */ + case KEY.HOME: + DOM.setCurrentFile( lCurrent.parentElement.firstChild ); + DOM.preventDefault(pEvent); + break; + + /* если нажали клавишу End + * выделяем последний элемент */ + case KEY.END: + DOM.setCurrentFile( lCurrent.parentElement.lastElementChild ); + DOM.preventDefault( pEvent ); + break; + + /* если нажали клавишу page down + * проматываем экран */ + case KEY.PAGE_DOWN: + DOM.scrollByPages( DOM.getPanel(), 1 ); + + for(i=0; i<30; i++){ + if(!lCurrent.nextSibling) break; - DOM.preventDefault(pEvent); - break; + lCurrent = lCurrent.nextSibling; + } + DOM.setCurrentFile(lCurrent); + DOM.preventDefault(pEvent); + break; + + /* если нажали клавишу page up проматываем экран */ + case KEY.PAGE_UP: + DOM.scrollByPages( DOM.getPanel(), -1 ); - /* навигация по таблице файлов * - * если нажали клавишу вверх * - * выделяем предыдущую строку */ - case KEY.UP: - if(lShift) - DOM.setSelectedFile(lCurrent); - - DOM.setCurrentFile( lCurrent.previousSibling ); - DOM.preventDefault( pEvent ); - break; - - /* если нажали клавишу в низ * - * выделяем следующую строку */ - case KEY.DOWN: - if(lShift) - DOM.setSelectedFile(lCurrent); - - DOM.setCurrentFile( lCurrent.nextSibling ); - DOM.preventDefault( pEvent ); - break; - - /* если нажали клавишу Home * - * переходим к самому верхнему * - * элементу */ - case KEY.HOME: - DOM.setCurrentFile( lCurrent.parentElement.firstChild ); - DOM.preventDefault(pEvent); - break; - - /* если нажали клавишу End - * выделяем последний элемент */ - case KEY.END: - DOM.setCurrentFile( lCurrent.parentElement.lastElementChild ); - DOM.preventDefault( pEvent ); - break; - - /* если нажали клавишу page down - * проматываем экран */ - case KEY.PAGE_DOWN: - DOM.scrollByPages( DOM.getPanel(), 1 ); - - for(i=0; i<30; i++){ - if(!lCurrent.nextSibling) break; - - lCurrent = lCurrent.nextSibling; - } - DOM.setCurrentFile(lCurrent); - DOM.preventDefault(pEvent); - break; - - /* если нажали клавишу page up проматываем экран */ - case KEY.PAGE_UP: - DOM.scrollByPages( DOM.getPanel(), -1 ); - - var lC = lCurrent, - tryCatch = function(pCurrentFile){ - Util.tryCatch(function(){ - return pCurrentFile + var lC = lCurrent, + tryCatch = function(pCurrentFile){ + Util.tryCatch(function(){ + return pCurrentFile + .previousSibling .previousSibling .previousSibling - .previousSibling - .previousSibling; - }); - }; - - for(i = 0; i < 30; i++){ - if(!lC.previousSibling || tryCatch(lC) ) break; - - lC = lC.previousSibling; - } - DOM.setCurrentFile(lC); - DOM.preventDefault(pEvent); - break; - - /* открываем папку*/ - case KEY.ENTER: - if( DOM.isCurrentIsDir() ) - Util.exec( CloudCmd.loadDir() ); - break; + .previousSibling; + }); + }; - case KEY.A: - if(pEvent.ctrlKey){ - var lParent = lCurrent.parentElement, - lNodes = lParent.childNodes; - - /* not path and fm_header */ - for(i = 2, n = lNodes.length; i < n; i++) - DOM.setSelectedFile( lNodes[i] ); - - DOM.preventDefault(pEvent); - } + for(i = 0; i < 30; i++){ + if(!lC.previousSibling || tryCatch(lC) ) break; - break; - - /* обновляем страницу, - * загружаем содержимое каталога - * при этом данные берём всегда с - * сервера, а не из кэша - * (обновляем кэш)*/ - case KEY.R: - if(lCtrl){ - Util.log('+r pressed\n' + - 'reloading page...\n' + - 'press +q to remove all key-handlers'); - - CloudCmd.refresh(); - DOM.preventDefault(pEvent); - } + lC = lC.previousSibling; + } + DOM.setCurrentFile(lC); + DOM.preventDefault(pEvent); break; - /* чистим кэш */ - case KEY.D: - if(lCtrl){ - Util.log('+d pressed\n' + - 'clearing cache...\n' + - 'press +q to remove all key-handlers'); - - DOM.Cache.clear(); - DOM.preventDefault(); - } - break; + /* открываем папку*/ + case KEY.ENTER: + if( DOM.isCurrentIsDir() ) + Util.exec( CloudCmd.loadDir() ); + break; - /* убираем все обработчики - * нажатий клавиш */ - case KEY.Q: - if(lAlt){ - Util.log('+q pressed\n' + - '+r reload key-handerl - removed' + - '+s clear cache key-handler - removed'+ - 'press +s to to set them'); - - /* обработчик нажатий клавиш снят*/ - Binded = false; - DOM.preventDefault(pEvent); - } + case KEY.A: + if(pEvent.ctrlKey){ + var lParent = lCurrent.parentElement, + lNodes = lParent.childNodes; + + /* not path and fm_header */ + for(i = 2, n = lNodes.length; i < n; i++) + DOM.setSelectedFile( lNodes[i] ); + + DOM.preventDefault(pEvent); + } + + break; + + /* обновляем страницу, + * загружаем содержимое каталога + * при этом данные берём всегда с + * сервера, а не из кэша + * (обновляем кэш)*/ + case KEY.R: + if(lCtrl){ + Util.log('+r pressed\n' + + 'reloading page...\n' + + 'press +q to remove all key-handlers'); + + CloudCmd.refresh(); + DOM.preventDefault(pEvent); + } + break; + + /* чистим кэш */ + case KEY.D: + if(lCtrl){ + Util.log('+d pressed\n' + + 'clearing cache...\n' + + 'press +q to remove all key-handlers'); + + DOM.Cache.clear(); + DOM.preventDefault(); + } break; - } - } - /* устанавливаем все обработчики - * нажатий клавиш - */ - else if(lKeyCode === KEY.S && lAlt){ - /* обрабатываем нажатия на клавиши*/ - Binded = true; - Util.log('+s pressed\n' + - '+r reload key-handerl - set\n' + - '+s clear cache key-handler - set\n' + - 'press +q to remove them'); - DOM.preventDefault(pEvent); + /* убираем все обработчики + * нажатий клавиш */ + case KEY.Q: + if(lAlt){ + Util.log('+q pressed\n' + + '+r reload key-handerl - removed' + + '+s clear cache key-handler - removed'+ + 'press +s to to set them'); + + /* обработчик нажатий клавиш снят*/ + Binded = false; + DOM.preventDefault(pEvent); + } + break; } + } + + /* устанавливаем все обработчики + * нажатий клавиш + */ + else if(lKeyCode === KEY.S && lAlt){ + /* обрабатываем нажатия на клавиши*/ + Binded = true; + Util.log('+s pressed\n' + + '+r reload key-handerl - set\n' + + '+s clear cache key-handler - set\n' + + 'press +q to remove them'); + DOM.preventDefault(pEvent); + } }; - - /* добавляем обработчик клавишь */ - DOM.Events.addKey(key_event); - - /* клавиши назначены*/ - Binded = true; - }; + } })(CloudCmd, Util, DOM); \ No newline at end of file From da61667eadecf3c4bdcb7a978cd3518e8b594b05 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 30 May 2013 04:37:54 -0400 Subject: [PATCH 035/239] removed -webkit-text-size-adjust property --- css/reset.css | 2 -- 1 file changed, 2 deletions(-) diff --git a/css/reset.css b/css/reset.css index dbf21d3d..3008d4e2 100644 --- a/css/reset.css +++ b/css/reset.css @@ -9,8 +9,6 @@ html{ color: #222; - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; } body { margin: 0; font-size: 1em; line-height: 1.4; } From 19567c834039b708b7bb23d1d6487b3419d94cdd Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 30 May 2013 04:38:49 -0400 Subject: [PATCH 036/239] removed dublicates --- lib/client.js | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/lib/client.js b/lib/client.js index 89f08fc7..43bdd39d 100644 --- a/lib/client.js +++ b/lib/client.js @@ -11,35 +11,6 @@ var Util, DOM, CloudFunc, KeyBinding, CloudCmd; /* Клиентский обьект, содержащий функциональную часть*/ CloudCmd = { - /* Конструктор CloudClient, который выполняет - * весь функционал по инициализации - */ - init : null, /* start initialization */ - - KeyBinding : null, /* обьект обработки нажатий клавишь */ - KeysPanel : null, /* panel with key buttons f1-f8 */ - Editor : null, /* function loads and shows editor */ - Storage : null, /* function loads storage */ - Viewer : null, /* function loads and shows viewer */ - Terminal : null, /* function loads and shows terminal*/ - Menu : null, /* function loads and shows menu */ - GoogleAnalytics : null, - - loadDir : null, /* Функция привязываеться ко всем ссылкам и - * загружает содержимое каталогов */ - - /* ОБЬЕКТЫ */ - - /* ПРИВАТНЫЕ ФУНКЦИИ */ - /* функция загружает json-данные о файловой системе */ - _ajaxLoad : null, - - /* Функция генерирует JSON из html-таблицы файлов */ - _getJSONfromFileTable : null, - - /* функция меняет ссыки на ajax-овые */ - _changeLinks : null, - /* КОНСТАНТЫ*/ LIBDIR : '/lib/', LIBDIRCLIENT : '/lib/client/', From 04e493561341524caec7e07520a995860753564b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 30 May 2013 04:43:05 -0400 Subject: [PATCH 037/239] removed function _editFileName --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 07a3fe1d..3bab68d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,8 @@ dispatch * Fixed bug with deletting in menu js. +* Removed function _editFileName from client.js. + 2012.04.22, v0.2.0 From 8e9dfd8e844a043240e716108fb03b0836f66bb4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 30 May 2013 04:44:12 -0400 Subject: [PATCH 038/239] removed function _editFileName --- lib/client.js | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/lib/client.js b/lib/client.js index 43bdd39d..ef3b2841 100644 --- a/lib/client.js +++ b/lib/client.js @@ -69,33 +69,6 @@ var Util, DOM, CloudFunc, KeyBinding, CloudCmd; }; - /** - * Function edits file name - * - * @param pParent - parent element - * @param pEvent - */ - CloudCmd._editFileName = function(pParent){ - var lA = DOM.getCurrentLink(pParent), - lName = DOM.getCurrentName(); - - if ( lName !== '..' ){ - - lA.contentEditable = true; - KeyBinding && KeyBinding.unSet(); - - /* setting event handler onclick - * if user clicks somewhere keyBinded - * backs - */ - Events.addOneTime('click', function(){ - //lA.contentEditable = false; - //KeyBinding && KeyBinding.set(); - }); - } - }; - - /** функция устанавливает курсор на каталог * с которого мы пришли, если мы поднялись * в верх по файловой структуре From dd413c87e576e36bbce4bc71de98c77317180c04 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 30 May 2013 06:38:42 -0400 Subject: [PATCH 039/239] removed linuxWatch function from main.js --- ChangeLog | 2 ++ lib/server/main.js | 8 -------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3bab68d5..5b4b5b3c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,6 +29,8 @@ dispatch * Removed function _editFileName from client.js. +* Removed linuxWatch function from main.js. + 2012.04.22, v0.2.0 diff --git a/lib/server/main.js b/lib/server/main.js index dd900007..afe4e7a0 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -437,12 +437,4 @@ return lGZIP; } - - function linuxWatch(pFile, pCallBack){ - fs.watchFile(pFile, function(pCurr, pPrev){ - if(pCurr.mtime !== pPrev.mtime) - Util.exec(pCallBack); - }); - } - })(); From 7f217de93150844cfebc1a86dc75d832a7623045 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 30 May 2013 06:39:38 -0400 Subject: [PATCH 040/239] added tryCatch to fs.watch in cloudcmd.js --- ChangeLog | 2 ++ cloudcmd.js | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b4b5b3c..79e28542 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,6 +31,8 @@ dispatch * Removed linuxWatch function from main.js. +* Added tryCatch to fs.watch in cloudcmd.js. + 2012.04.22, v0.2.0 diff --git a/cloudcmd.js b/cloudcmd.js index 17111deb..4803059b 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -179,11 +179,13 @@ } if (Config.server) - fs.watch(CONFIG_PATH, function(){ - /* every catch up - calling twice */ - setTimeout(function() { - readConfig(); - }, 1000); + Util.tryCatchLog(function(){ + fs.watch(CONFIG_PATH, function(){ + /* every catch up - calling twice */ + setTimeout(function() { + readConfig(); + }, 1000); + }); }); var lParams = { From deb0ec43561ac0d7be44b48880b5ded79cb88954 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 30 May 2013 10:56:43 -0400 Subject: [PATCH 041/239] set f3 to view --- ChangeLog | 2 ++ README.md | 3 +- lib/client/editor/_codemirror.js | 49 ++++++++++++-------------------- lib/client/keyBinding.js | 4 +-- lib/client/viewer.js | 25 +++++++--------- 5 files changed, 33 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79e28542..9b4b9041 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,8 @@ dispatch * Added tryCatch to fs.watch in cloudcmd.js. +* Set F3 to veiw. + 2012.04.22, v0.2.0 diff --git a/README.md b/README.md index a14e6ca0..528ef9e8 100644 --- a/README.md +++ b/README.md @@ -66,12 +66,11 @@ There is a short list: Viewer's hot keys --------------- -- **Shift + F3** - open viewer window +- **F3** - open viewer window - **Esc** - close viewer window Editor's hot keys --------------- -- **F3** - open CodeMirror editor in read only mode - **F4** - open CodeMirror editor - **Ctrl + s** - save file - **Esc** - close CodeMirror editor diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index bd152e5e..149b7bd2 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -1,6 +1,6 @@ var CloudCmd, Util, DOM, CodeMirror; -/* object contains editors CodeMirror */ - (function(CloudCmd, Util, DOM){ + +(function(CloudCmd, Util, DOM){ 'use strict'; var KeyBinding = CloudCmd.KeyBinding, @@ -132,8 +132,6 @@ var CloudCmd, Util, DOM, CodeMirror; Loading = true; - var lFalseLoading = function(){ Loading = false; }; - setTimeout(lFalseLoading, 400); DOM.getCurrentData({ @@ -149,17 +147,18 @@ var CloudCmd, Util, DOM, CodeMirror; } }); } + + function lFalseLoading(){ Loading = false; } } /** * function hides CodeMirror editor */ function hide() { - var lElem = CodeMirrorElement; KeyBinding.set(); - if(lElem && FM) - FM.removeChild(lElem); + if(CodeMirrorElement && FM) + FM.removeChild(CodeMirrorElement); DOM.showPanel(); } @@ -180,36 +179,24 @@ var CloudCmd, Util, DOM, CodeMirror; /** * function bind keys */ - CloudCmd.Editor.init = function(pReadOnly){ - ReadOnly = pReadOnly; - + CloudCmd.Editor.init = function(){ CodeMirrorEditor.show(); CallBacks.pop(); - var lKeyListener = function(pEvent){ - /* если клавиши можно обрабатывать */ - if( KeyBinding.get() ){ - var lF3 = CloudCmd.KEY.F3, - lF4 = CloudCmd.KEY.F4; - - if(!pEvent.shiftKey) - switch(pEvent.keyCode) - { - case lF4: - ReadOnly = false; - CodeMirrorEditor.show(); - break; - case lF3: - ReadOnly = true; - CodeMirrorEditor.show(); - break; - } - } - }; - /* добавляем обработчик клавишь */ DOM.Events.addKey( lKeyListener ); DOM.setButtonKey('f4', CodeMirrorEditor.show); + + function lKeyListener(pEvent){ + /* если клавиши можно обрабатывать */ + if( KeyBinding.get() ){ + var lF4 = CloudCmd.KEY.F4, + lKey = pEvent.keyCode; + + if(lKey === lF4) + CodeMirrorEditor.show(); + } + } }; CloudCmd.Editor.CodeMirror = CodeMirrorEditor; diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index 3b441de6..70471c09 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -127,9 +127,7 @@ var CloudCmd, Util, DOM; break; case KEY.F3: - var lEditor = CloudCmd[lShift ? 'Viewer' : 'Editor']; - - Util.exec(lEditor, true); + Util.exec(CloudCmd.Viewer); DOM.preventDefault(pEvent); break; diff --git a/lib/client/viewer.js b/lib/client/viewer.js index c1f2fa37..b7c8d7a3 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -123,26 +123,27 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.jqueryLoad ]); - var lView = function(){ + DOM.Events.addKey(lKeyListener); + DOM.setButtonKey('f3', lView); + + function lView(){ DOM.Images.showLoad(); FancyBox.show( DOM.getCurrentFile() ); - }; + } - var lKeyListener = function(pEvent){ + function lKeyListener(pEvent){ var lKEY = CloudCmd.KEY, lF3 = lKEY.F3, + F1 = lKEY.F1, lKeyBinded = KeyBinding.get(), - lKeyCode = pEvent.keyCode, - lShift = pEvent.shiftKey; + lKeyCode = pEvent.keyCode; /* если клавиши можно обрабатывать */ if( lKeyBinded){ switch(lKeyCode){ case lF3: - if(lShift){ - lView(); - DOM.preventDefault(pEvent); - } + lView(); + DOM.preventDefault(pEvent); break; case lKEY.F1: @@ -150,11 +151,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; break; } } - }; - - /* добавляем обработчик клавишь */ - DOM.Events.addKey(lKeyListener); - DOM.setButtonKey('f3', lView); + } }; CloudCmd.Viewer.FancyBox = FancyBox; From 6d2f918f79cc74c541e0240707a082e371220b89 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 31 May 2013 05:52:21 -0400 Subject: [PATCH 042/239] added f1-f7 keys description --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 528ef9e8..fd6a288d 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,14 @@ Hot keys --------------- In all modern web browsers (but not in IE, becouse he special) hot keys works. There is a short list: +- **F1** - help +- **F2** - rename current file +- **F3** - view +- **F4** - edit +- **F5** - copy +- **F6** - rename/move +- **F7** - new dir +- **F8, Delete** - remove current file - **Ctrl + r** - reload dir content - **Ctrl + d** - clear local cache (wich contains dir contents) - **Alt + q** - disable key bindings @@ -58,10 +66,8 @@ There is a short list: - **Page Down** - down on one page - **Home** - to begin of list - **End** - to end of list -- **F8, Delete** - remove current file - **Shift + Delete** - remove without prompt - **Insert** - select current file -- **F2** - rename current file - **Shift + F10** - show context menu Viewer's hot keys From e1edc480c7eea7073b99d8566f900fd883bad969 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 31 May 2013 06:56:59 -0400 Subject: [PATCH 043/239] KeyBinding -> Key --- ChangeLog | 2 ++ lib/client.js | 14 ++++++------- lib/client/editor/_ace.js | 8 +++---- lib/client/editor/_codemirror.js | 14 ++++++------- lib/client/{keyBinding.js => key.js} | 4 ++-- lib/client/menu.js | 31 ++++++++++++++-------------- lib/client/terminal.js | 26 +++++++++++------------ lib/client/viewer.js | 28 ++++++++++++------------- 8 files changed, 65 insertions(+), 62 deletions(-) rename lib/client/{keyBinding.js => key.js} (99%) diff --git a/ChangeLog b/ChangeLog index 9b4b9041..1cbab1f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,8 @@ dispatch * Set F3 to veiw. +* Renamed KeyBinding -> Key. + 2012.04.22, v0.2.0 diff --git a/lib/client.js b/lib/client.js index ef3b2841..483eaac8 100644 --- a/lib/client.js +++ b/lib/client.js @@ -2,12 +2,12 @@ * @CloudFunc - обьект содержащий общий функционал * клиентский и серверный */ -var Util, DOM, CloudFunc, KeyBinding, CloudCmd; +var Util, DOM, CloudFunc, CloudCmd; (function(Util, DOM){ 'use strict'; - var Config, Modules, FileTemplate, PathTemplate, Events = DOM.Events; + var Key, Config, Modules, FileTemplate, PathTemplate, Events = DOM.Events; /* Клиентский обьект, содержащий функциональную часть*/ CloudCmd = { @@ -159,10 +159,10 @@ var Util, DOM, CloudFunc, KeyBinding, CloudCmd; function initModules(pCallBack){ loadModule({ /* привязываем клавиши к функциям */ - path : 'keyBinding.js', + path : 'key.js', func : function(){ - KeyBinding = CloudCmd.KeyBinding; - KeyBinding.init(); + Key = CloudCmd.Key; + Key.init(); } }); @@ -311,7 +311,7 @@ var Util, DOM, CloudFunc, KeyBinding, CloudCmd; }); Util.exec(pCallBack); - CloudCmd.KeyBinding(); + CloudCmd.Key(); } @@ -368,7 +368,7 @@ var Util, DOM, CloudFunc, KeyBinding, CloudCmd; lOnContextMenu_f = function(pEvent){ var lReturn_b = true; - KeyBinding && KeyBinding.unSet(); + Key && Key.unSet(); /* getting html element * currentTarget - DOM event diff --git a/lib/client/editor/_ace.js b/lib/client/editor/_ace.js index d93dc1c4..974d1080 100644 --- a/lib/client/editor/_ace.js +++ b/lib/client/editor/_ace.js @@ -6,7 +6,7 @@ var CloudCmd, CloudFunc, ace; "use strict"; var cloudcmd = CloudCmd, Util = CloudCmd.Util, - KeyBinding = CloudCmd.KeyBinding, + Key = CloudCmd.Key, AceEditor = {}, AceLoaded = false, ReadOnly = false, @@ -137,7 +137,7 @@ var CloudCmd, CloudFunc, ace; initAce_f(data); /* removing keyBinding if set */ - KeyBinding.unSet(); + Key.unSet(); Util.hidePanel(); Util.Images.hideLoad(); @@ -150,7 +150,7 @@ var CloudCmd, CloudFunc, ace; /* function hides Ace editor */ AceEditor.hide = (function() { var lElem = AceElement; - KeyBinding.set(); + Key.set(); if(lElem && FM) FM.removeChild(lElem); @@ -168,7 +168,7 @@ var CloudCmd, CloudFunc, ace; var key_event = function(pEvent){ /* если клавиши можно обрабатывать */ - if( KeyBinding.get() ){ + if( Key.get() ){ /* if f4 or f3 pressed */ var lF3 = cloudcmd.KEY.F3; var lF4 = cloudcmd.KEY.F4; diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index 149b7bd2..155c0546 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -3,7 +3,7 @@ var CloudCmd, Util, DOM, CodeMirror; (function(CloudCmd, Util, DOM){ 'use strict'; - var KeyBinding = CloudCmd.KeyBinding, + var Key = CloudCmd.Key, CodeMirrorEditor = {}, FM, CodeMirrorElement, @@ -139,7 +139,7 @@ var CloudCmd, Util, DOM, CodeMirror; success : function(data){ if( DOM.hidePanel() ){ Util.exec(pCallBack, data); - KeyBinding.unSet(); + Key.unSet(); } DOM.Images.hideLoad(); @@ -155,7 +155,7 @@ var CloudCmd, Util, DOM, CodeMirror; * function hides CodeMirror editor */ function hide() { - KeyBinding.set(); + Key.set(); if(CodeMirrorElement && FM) FM.removeChild(CodeMirrorElement); @@ -184,12 +184,12 @@ var CloudCmd, Util, DOM, CodeMirror; CallBacks.pop(); /* добавляем обработчик клавишь */ - DOM.Events.addKey( lKeyListener ); + DOM.Events.addKey( lListener ); DOM.setButtonKey('f4', CodeMirrorEditor.show); - function lKeyListener(pEvent){ + function lListener(pEvent){ /* если клавиши можно обрабатывать */ - if( KeyBinding.get() ){ + if( Key.get() ){ var lF4 = CloudCmd.KEY.F4, lKey = pEvent.keyCode; @@ -201,4 +201,4 @@ var CloudCmd, Util, DOM, CodeMirror; CloudCmd.Editor.CodeMirror = CodeMirrorEditor; -})(CloudCmd, Util, DOM); \ No newline at end of file +})(CloudCmd, Util, DOM); diff --git a/lib/client/keyBinding.js b/lib/client/key.js similarity index 99% rename from lib/client/keyBinding.js rename to lib/client/key.js index 70471c09..236b0d57 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/key.js @@ -43,9 +43,9 @@ var CloudCmd, Util, DOM; TRA : 192 /* Typewritten Reverse Apostrophe (`) */ }; - CloudCmd.KeyBinding = new KeyBindingProto(); + CloudCmd.Key = new KeyProto(); - function KeyBindingProto(){ + function KeyProto(){ var Binded, KEY = CloudCmd.KEY, lTabPanel = { diff --git a/lib/client/menu.js b/lib/client/menu.js index 9fe8c9d6..02d00d1c 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -5,7 +5,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; (function(CloudCmd, Util, DOM, CloudFunc){ 'use strict'; - var KeyBinding = CloudCmd.KeyBinding, + var Key = CloudCmd.Key, MenuSeted = false, Menu = {}, Position, @@ -186,7 +186,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; var m = "clicked: " + key; Util.log(m, options); - KeyBinding.set(); + Key.set(); }, // define the elements of the menu @@ -248,7 +248,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.setCurrentFile(lElement); } - KeyBinding.set(); + Key.set(); } } @@ -291,24 +291,25 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.jqueryLoad ]); - var lKeyListener = function(pEvent){ + DOM.Events.addKey( lListener ); + + function lListener(pEvent){ var lKEY = CloudCmd.KEY, - lKeyCode = pEvent.keyCode; + lF10 = lKEY.F10, + lESC = lKEY.ESC, + lKey = pEvent.keyCode, + lShift = pEvent.shiftKey; /* если клавиши можно обрабатывать */ - if( KeyBinding.get() ){ - /* if shift + F10 pressed */ - if(lKeyCode === lKEY.F10 && pEvent.shiftKey){ + if( Key.get() ){ + if(lKey === lF10 && lShift){ $( DOM.getCurrentFile() ).contextMenu(); DOM.preventDefault(pEvent); } } - else if (lKeyCode === lKEY.ESC) - KeyBinding.set(); - }; - - /* добавляем обработчик клавишь */ - DOM.Events.addKey( lKeyListener ); + else if (lKey === lESC) + Key.set(); + } }; CloudCmd.Menu = Menu; -})(CloudCmd, Util, DOM, CloudFunc); \ No newline at end of file +})(CloudCmd, Util, DOM, CloudFunc); diff --git a/lib/client/terminal.js b/lib/client/terminal.js index 783fbe96..d6390a8b 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -4,7 +4,7 @@ var CloudCmd, Util, DOM, $; (function(CloudCmd, Util, DOM){ 'use strict'; - var KeyBinding = CloudCmd.KeyBinding, + var Key = CloudCmd.Key, TerminalId, Term, Hidden = false, @@ -79,7 +79,7 @@ var CloudCmd, Util, DOM, $; if( DOM.hidePanel() ){ Hidden = false; DOM.show(TerminalId); - KeyBinding.unSet(); + Key.unSet(); Term.resume(); } }; @@ -92,7 +92,7 @@ var CloudCmd, Util, DOM, $; DOM.hide(TerminalId); DOM.showPanel(); - KeyBinding.set(); + Key.set(); Term.pause(); }; @@ -101,7 +101,6 @@ var CloudCmd, Util, DOM, $; * function bind keys */ CloudCmd.Terminal.init = function(){ - /* loading js and css*/ Util.loadOnLoad([ JqueryTerminal.show, load, @@ -109,26 +108,27 @@ var CloudCmd, Util, DOM, $; DOM.jqueryLoad, ]); - /* добавляем обработчик клавишь */ - var lKeyListener = function(pEvent){ + DOM.Events.addKey( lListener ); + + function lListener(pEvent){ var lRet = true, lKEY = CloudCmd.KEY, - lKeyCode = pEvent.keyCode, - lKeyBinded = KeyBinding.get(); + lESC = lKEY.ESC, + lTRA = lKEY.TRA, + lKey = pEvent.keyCode, + lBinded = Key.get(); /* если клавиши можно обрабатывать */ - if(Hidden && lKeyBinded && lKeyCode === lKEY.TRA){ + if(Hidden && lBinded && lKey === lTRA){ JqueryTerminal.show(); DOM.preventDefault(pEvent); lRet = false; } - else if(!Hidden && lKeyCode === lKEY.ESC) + else if(!Hidden && lKey === lESC) JqueryTerminal.hide(); return lRet; - }; - - DOM.Events.addKey( lKeyListener ); + } }; CloudCmd.Terminal.JqueryTerminal = JqueryTerminal; diff --git a/lib/client/viewer.js b/lib/client/viewer.js index b7c8d7a3..9baa81a4 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -5,13 +5,13 @@ var CloudCmd, Util, DOM, CloudFunc, $; (function(CloudCmd, Util, DOM, CloudFunc){ 'use strict'; - var KeyBinding = CloudCmd.KeyBinding, + var Key = CloudCmd.Key, FancyBox = {}, Config = { beforeShow : function(){ DOM.Images.hideLoad(); - KeyBinding.unSet(); + Key.unSet(); }, afterShow : function(){ @@ -20,7 +20,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; lEditor.focus(); }, - beforeClose : Util.retFunc( KeyBinding.set ), + beforeClose : Util.retFunc( Key.set ), openEffect : 'none', closeEffect : 'none', @@ -123,7 +123,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.jqueryLoad ]); - DOM.Events.addKey(lKeyListener); + DOM.Events.addKey(lListener); DOM.setButtonKey('f3', lView); function lView(){ @@ -131,22 +131,22 @@ var CloudCmd, Util, DOM, CloudFunc, $; FancyBox.show( DOM.getCurrentFile() ); } - function lKeyListener(pEvent){ + function lListener(pEvent){ var lKEY = CloudCmd.KEY, lF3 = lKEY.F3, - F1 = lKEY.F1, - lKeyBinded = KeyBinding.get(), - lKeyCode = pEvent.keyCode; + lF1 = lKEY.F1, + lBinded = Key.get(), + lKey = pEvent.keyCode; /* если клавиши можно обрабатывать */ - if( lKeyBinded){ - switch(lKeyCode){ + if( lBinded){ + switch(lKey){ case lF3: lView(); DOM.preventDefault(pEvent); - break; - - case lKEY.F1: + break; + + case lF1: FancyBox.showHelp(); break; } @@ -156,4 +156,4 @@ var CloudCmd, Util, DOM, CloudFunc, $; CloudCmd.Viewer.FancyBox = FancyBox; -})(CloudCmd, Util, DOM, CloudFunc); \ No newline at end of file +})(CloudCmd, Util, DOM, CloudFunc); From 4448ad73551903a598e93d32f64384a9da915d3b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 31 May 2013 09:21:26 -0400 Subject: [PATCH 044/239] renamed: set -> setBinded, unSet -> unsetBinded, get -> isBinded --- ChangeLog | 2 + lib/client.js | 4 +- lib/client/editor/_ace.js | 8 +- lib/client/editor/_codemirror.js | 9 +- lib/client/key.js | 10 +- lib/client/menu.js | 7 +- lib/client/terminal.js | 28 +- lib/client/viewer.js | 8 +- .../fancyBox/source/jquery.fancybox.css | 496 +++++++++--------- 9 files changed, 291 insertions(+), 281 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1cbab1f9..02c45e08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,6 +37,8 @@ dispatch * Renamed KeyBinding -> Key. +* Renamed: set -> setBinded, unSet -> unsetBinded, get -> isBinded. + 2012.04.22, v0.2.0 diff --git a/lib/client.js b/lib/client.js index 483eaac8..90945975 100644 --- a/lib/client.js +++ b/lib/client.js @@ -162,7 +162,7 @@ var Util, DOM, CloudFunc, CloudCmd; path : 'key.js', func : function(){ Key = CloudCmd.Key; - Key.init(); + Key.bind(); } }); @@ -368,7 +368,7 @@ var Util, DOM, CloudFunc, CloudCmd; lOnContextMenu_f = function(pEvent){ var lReturn_b = true; - Key && Key.unSet(); + Key && Key.unsetBind(); /* getting html element * currentTarget - DOM event diff --git a/lib/client/editor/_ace.js b/lib/client/editor/_ace.js index 974d1080..989f68be 100644 --- a/lib/client/editor/_ace.js +++ b/lib/client/editor/_ace.js @@ -137,7 +137,7 @@ var CloudCmd, CloudFunc, ace; initAce_f(data); /* removing keyBinding if set */ - Key.unSet(); + Key.unsetBind(); Util.hidePanel(); Util.Images.hideLoad(); @@ -150,7 +150,7 @@ var CloudCmd, CloudFunc, ace; /* function hides Ace editor */ AceEditor.hide = (function() { var lElem = AceElement; - Key.set(); + Key.setBind(); if(lElem && FM) FM.removeChild(lElem); @@ -166,9 +166,9 @@ var CloudCmd, CloudFunc, ace; this.Ace.show(pCurrentFile, pIsReadOnly); var key_event = function(pEvent){ - + var lBinded = Key.get(); /* если клавиши можно обрабатывать */ - if( Key.get() ){ + if( lBinded ){ /* if f4 or f3 pressed */ var lF3 = cloudcmd.KEY.F3; var lF4 = cloudcmd.KEY.F4; diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index 155c0546..361897bd 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -139,7 +139,7 @@ var CloudCmd, Util, DOM, CodeMirror; success : function(data){ if( DOM.hidePanel() ){ Util.exec(pCallBack, data); - Key.unSet(); + Key.unsetBind(); } DOM.Images.hideLoad(); @@ -155,7 +155,7 @@ var CloudCmd, Util, DOM, CodeMirror; * function hides CodeMirror editor */ function hide() { - Key.set(); + Key.setBind(); if(CodeMirrorElement && FM) FM.removeChild(CodeMirrorElement); @@ -188,8 +188,9 @@ var CloudCmd, Util, DOM, CodeMirror; DOM.setButtonKey('f4', CodeMirrorEditor.show); function lListener(pEvent){ - /* если клавиши можно обрабатывать */ - if( Key.get() ){ + var lIsBind = Key.isBind(); + + if (lIsBind) { var lF4 = CloudCmd.KEY.F4, lKey = pEvent.keyCode; diff --git a/lib/client/key.js b/lib/client/key.js index 236b0d57..4f02f60b 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -47,20 +47,19 @@ var CloudCmd, Util, DOM; function KeyProto(){ var Binded, - KEY = CloudCmd.KEY, lTabPanel = { left : 0, right : 0 }; - this.get = function(){return Binded;}; + this.isBind = function(){return Binded;}; - this.set = function(){Binded = true;}; + this.setBind = function(){Binded = true;}; - this.unSet = function(){Binded = false;}; + this.unsetBind = function(){Binded = false;}; - this.init = function(){ + this.bind = function(){ DOM.Events.addKey(listener); /* клавиши назначены*/ @@ -70,6 +69,7 @@ var CloudCmd, Util, DOM; function listener(pEvent){ /* получаем выдленный файл*/ var i, n, lCurrent = DOM.getCurrentFile(), + KEY = CloudCmd.KEY, lKeyCode = pEvent.keyCode, lShift = pEvent.shiftKey, lAlt = pEvent.altKey, diff --git a/lib/client/menu.js b/lib/client/menu.js index 02d00d1c..80d18f29 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -298,9 +298,10 @@ var CloudCmd, Util, DOM, CloudFunc, $; lF10 = lKEY.F10, lESC = lKEY.ESC, lKey = pEvent.keyCode, - lShift = pEvent.shiftKey; - /* если клавиши можно обрабатывать */ - if( Key.get() ){ + lShift = pEvent.shiftKey, + lIsBind = Key.isBind(); + + if( lIsBind ){ if(lKey === lF10 && lShift){ $( DOM.getCurrentFile() ).contextMenu(); DOM.preventDefault(pEvent); diff --git a/lib/client/terminal.js b/lib/client/terminal.js index d6390a8b..df039658 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -79,7 +79,7 @@ var CloudCmd, Util, DOM, $; if( DOM.hidePanel() ){ Hidden = false; DOM.show(TerminalId); - Key.unSet(); + Key.unsetBind(); Term.resume(); } }; @@ -92,7 +92,7 @@ var CloudCmd, Util, DOM, $; DOM.hide(TerminalId); DOM.showPanel(); - Key.set(); + Key.setBind(); Term.pause(); }; @@ -116,16 +116,22 @@ var CloudCmd, Util, DOM, $; lESC = lKEY.ESC, lTRA = lKEY.TRA, lKey = pEvent.keyCode, - lBinded = Key.get(); - /* если клавиши можно обрабатывать */ - if(Hidden && lBinded && lKey === lTRA){ - JqueryTerminal.show(); - DOM.preventDefault(pEvent); - lRet = false; - } + lIsBind = Key.isBind(); - else if(!Hidden && lKey === lESC) - JqueryTerminal.hide(); + switch(lKey){ + case lTRA: + if(Hidden && lIsBind){ + JqueryTerminal.show(); + DOM.preventDefault(pEvent); + lRet = false; + } + break; + + case lESC: + if(!Hidden) + JqueryTerminal.hide(); + break; + } return lRet; } diff --git a/lib/client/viewer.js b/lib/client/viewer.js index 9baa81a4..54c6021f 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -11,7 +11,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; Config = { beforeShow : function(){ DOM.Images.hideLoad(); - Key.unSet(); + Key.unsetBind(); }, afterShow : function(){ @@ -20,7 +20,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; lEditor.focus(); }, - beforeClose : Util.retFunc( Key.set ), + beforeClose : Util.retFunc( Key.setBind ), openEffect : 'none', closeEffect : 'none', @@ -135,11 +135,11 @@ var CloudCmd, Util, DOM, CloudFunc, $; var lKEY = CloudCmd.KEY, lF3 = lKEY.F3, lF1 = lKEY.F1, - lBinded = Key.get(), + lIsBind = Key.isBind(), lKey = pEvent.keyCode; /* если клавиши можно обрабатывать */ - if( lBinded){ + if (lIsBind) { switch(lKey){ case lF3: lView(); diff --git a/lib/client/viewer/fancyBox/source/jquery.fancybox.css b/lib/client/viewer/fancyBox/source/jquery.fancybox.css index bd3289b2..6f307ec6 100644 --- a/lib/client/viewer/fancyBox/source/jquery.fancybox.css +++ b/lib/client/viewer/fancyBox/source/jquery.fancybox.css @@ -1,249 +1,249 @@ -/*! fancyBox v2.1.4 fancyapps.com | fancyapps.com/fancybox/#license */ -.fancybox-wrap, -.fancybox-skin, -.fancybox-outer, -.fancybox-inner, -.fancybox-image, -.fancybox-wrap iframe, -.fancybox-wrap object, -.fancybox-nav, -.fancybox-nav span, -.fancybox-tmp -{ - padding: 0; - margin: 0; - border: 0; - outline: none; - vertical-align: top; -} - -.fancybox-wrap { - position: absolute; - top: 0; - left: 0; - z-index: 8020; -} - -.fancybox-skin { - position: relative; - background: #f9f9f9; - color: #444; - text-shadow: none; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} - -.fancybox-opened { - z-index: 8030; -} - -.fancybox-opened .fancybox-skin { - -webkit-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); - -moz-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); - box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); -} - -.fancybox-outer, .fancybox-inner { - position: relative; -} - -.fancybox-inner { - overflow: hidden; -} - -.fancybox-type-iframe .fancybox-inner { - -webkit-overflow-scrolling: touch; -} - -.fancybox-error { - color: #444; - font: 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif; - margin: 0; - padding: 15px; - white-space: nowrap; -} - -.fancybox-image, .fancybox-iframe { - display: block; - width: 100%; - height: 100%; -} - -.fancybox-image { - max-width: 100%; - max-height: 100%; -} - -#fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span { - background-image: url('fancybox_sprite.png'); -} - -#fancybox-loading { - position: fixed; - top: 50%; - left: 50%; - margin-top: -22px; - margin-left: -22px; - background-position: 0 -108px; - opacity: 0.8; - cursor: pointer; - z-index: 8060; -} - -#fancybox-loading div { - width: 44px; - height: 44px; - background: url('fancybox_loading.gif') center center no-repeat; -} - -.fancybox-close { - position: absolute; - top: -18px; - right: -18px; - width: 36px; - height: 36px; - cursor: pointer; - z-index: 8040; -} - -.fancybox-nav { - position: absolute; - top: 0; - width: 40%; - height: 100%; - cursor: pointer; - text-decoration: none; - background: transparent url('blank.gif'); /* helps IE */ - -webkit-tap-highlight-color: rgba(0,0,0,0); - z-index: 8040; -} - -.fancybox-prev { - left: 0; -} - -.fancybox-next { - right: 0; -} - -.fancybox-nav span { - position: absolute; - top: 50%; - width: 36px; - height: 34px; - margin-top: -18px; - cursor: pointer; - z-index: 8040; - visibility: hidden; -} - -.fancybox-prev span { - left: 10px; - background-position: 0 -36px; -} - -.fancybox-next span { - right: 10px; - background-position: 0 -72px; -} - -.fancybox-nav:hover span { - visibility: visible; -} - -.fancybox-tmp { - position: absolute; - top: -99999px; - left: -99999px; - visibility: hidden; - max-width: 99999px; - max-height: 99999px; - overflow: visible !important; -} - -/* Overlay helper */ - -.fancybox-lock { - overflow: hidden; -} - -.fancybox-overlay { - position: absolute; - top: 0; - left: 0; - overflow: hidden; - display: none; - z-index: 8010; - background: url('fancybox_overlay.png'); -} - -.fancybox-overlay-fixed { - position: fixed; - bottom: 0; - right: 0; -} - -.fancybox-lock .fancybox-overlay { - overflow: auto; - overflow-y: scroll; -} - -/* Title helper */ - -.fancybox-title { - visibility: hidden; - font: normal 13px/20px "Helvetica Neue",Helvetica,Arial,sans-serif; - position: relative; - text-shadow: none; - z-index: 8050; -} - -.fancybox-opened .fancybox-title { - visibility: visible; -} - -.fancybox-title-float-wrap { - position: absolute; - bottom: 0; - right: 50%; - margin-bottom: -35px; - z-index: 8050; - text-align: center; -} - -.fancybox-title-float-wrap .child { - display: inline-block; - margin-right: -100%; - padding: 2px 20px; - background: transparent; /* Fallback for web browsers that doesn't support RGBa */ - background: rgba(0, 0, 0, 0.8); - -webkit-border-radius: 15px; - -moz-border-radius: 15px; - border-radius: 15px; - text-shadow: 0 1px 2px #222; - color: #FFF; - font-weight: bold; - line-height: 24px; - white-space: nowrap; -} - -.fancybox-title-outside-wrap { - position: relative; - margin-top: 10px; - color: #fff; -} - -.fancybox-title-inside-wrap { - padding-top: 10px; -} - -.fancybox-title-over-wrap { - position: absolute; - bottom: 0; - left: 0; - color: #fff; - padding: 10px; - background: #000; - background: rgba(0, 0, 0, .8); +/*! fancyBox v2.1.4 fancyapps.com | fancyapps.com/fancybox/#license */ +.fancybox-wrap, +.fancybox-skin, +.fancybox-outer, +.fancybox-inner, +.fancybox-image, +.fancybox-wrap iframe, +.fancybox-wrap object, +.fancybox-nav, +.fancybox-nav span, +.fancybox-tmp +{ + padding: 0; + margin: 0; + border: 0; + outline: none; + vertical-align: top; +} + +.fancybox-wrap { + position: absolute; + top: 0; + left: 0; + z-index: 8020; +} + +.fancybox-skin { + position: relative; + background: #f9f9f9; + color: #444; + text-shadow: none; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.fancybox-opened { + z-index: 8030; +} + +.fancybox-opened .fancybox-skin { + -webkit-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); + -moz-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); + box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); +} + +.fancybox-outer, .fancybox-inner { + position: relative; +} + +.fancybox-inner { + overflow: hidden; +} + +.fancybox-type-iframe .fancybox-inner { + overflow-scrolling: touch; +} + +.fancybox-error { + color: #444; + font: 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif; + margin: 0; + padding: 15px; + white-space: nowrap; +} + +.fancybox-image, .fancybox-iframe { + display: block; + width: 100%; + height: 100%; +} + +.fancybox-image { + max-width: 100%; + max-height: 100%; +} + +#fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span { + background-image: url('fancybox_sprite.png'); +} + +#fancybox-loading { + position: fixed; + top: 50%; + left: 50%; + margin-top: -22px; + margin-left: -22px; + background-position: 0 -108px; + opacity: 0.8; + cursor: pointer; + z-index: 8060; +} + +#fancybox-loading div { + width: 44px; + height: 44px; + background: url('fancybox_loading.gif') center center no-repeat; +} + +.fancybox-close { + position: absolute; + top: -18px; + right: -18px; + width: 36px; + height: 36px; + cursor: pointer; + z-index: 8040; +} + +.fancybox-nav { + position: absolute; + top: 0; + width: 40%; + height: 100%; + cursor: pointer; + text-decoration: none; + background: transparent url('blank.gif'); /* helps IE */ + -webkit-tap-highlight-color: rgba(0,0,0,0); + z-index: 8040; +} + +.fancybox-prev { + left: 0; +} + +.fancybox-next { + right: 0; +} + +.fancybox-nav span { + position: absolute; + top: 50%; + width: 36px; + height: 34px; + margin-top: -18px; + cursor: pointer; + z-index: 8040; + visibility: hidden; +} + +.fancybox-prev span { + left: 10px; + background-position: 0 -36px; +} + +.fancybox-next span { + right: 10px; + background-position: 0 -72px; +} + +.fancybox-nav:hover span { + visibility: visible; +} + +.fancybox-tmp { + position: absolute; + top: -99999px; + left: -99999px; + visibility: hidden; + max-width: 99999px; + max-height: 99999px; + overflow: visible !important; +} + +/* Overlay helper */ + +.fancybox-lock { + overflow: hidden; +} + +.fancybox-overlay { + position: absolute; + top: 0; + left: 0; + overflow: hidden; + display: none; + z-index: 8010; + background: url('fancybox_overlay.png'); +} + +.fancybox-overlay-fixed { + position: fixed; + bottom: 0; + right: 0; +} + +.fancybox-lock .fancybox-overlay { + overflow: auto; + overflow-y: scroll; +} + +/* Title helper */ + +.fancybox-title { + visibility: hidden; + font: normal 13px/20px "Helvetica Neue",Helvetica,Arial,sans-serif; + position: relative; + text-shadow: none; + z-index: 8050; +} + +.fancybox-opened .fancybox-title { + visibility: visible; +} + +.fancybox-title-float-wrap { + position: absolute; + bottom: 0; + right: 50%; + margin-bottom: -35px; + z-index: 8050; + text-align: center; +} + +.fancybox-title-float-wrap .child { + display: inline-block; + margin-right: -100%; + padding: 2px 20px; + background: transparent; /* Fallback for web browsers that doesn't support RGBa */ + background: rgba(0, 0, 0, 0.8); + -webkit-border-radius: 15px; + -moz-border-radius: 15px; + border-radius: 15px; + text-shadow: 0 1px 2px #222; + color: #FFF; + font-weight: bold; + line-height: 24px; + white-space: nowrap; +} + +.fancybox-title-outside-wrap { + position: relative; + margin-top: 10px; + color: #fff; +} + +.fancybox-title-inside-wrap { + padding-top: 10px; +} + +.fancybox-title-over-wrap { + position: absolute; + bottom: 0; + left: 0; + color: #fff; + padding: 10px; + background: #000; + background: rgba(0, 0, 0, .8); } \ No newline at end of file From 9e4b2fbca9c0e1499de347f0da0a65f80fa7942a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 31 May 2013 09:22:17 -0400 Subject: [PATCH 045/239] removed Invalid CSS property name: -webkit-overflow-scrolling --- lib/client/viewer/fancyBox/source/jquery.fancybox.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/client/viewer/fancyBox/source/jquery.fancybox.css b/lib/client/viewer/fancyBox/source/jquery.fancybox.css index 6f307ec6..b0b9f7e2 100644 --- a/lib/client/viewer/fancyBox/source/jquery.fancybox.css +++ b/lib/client/viewer/fancyBox/source/jquery.fancybox.css @@ -52,10 +52,6 @@ overflow: hidden; } -.fancybox-type-iframe .fancybox-inner { - overflow-scrolling: touch; -} - .fancybox-error { color: #444; font: 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif; From 40f9768546b694da3c77eb0ab68d8014523a3d78 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 31 May 2013 10:10:54 -0400 Subject: [PATCH 046/239] Functions maked private: ajaxload, changeLinks, createFileTable, getJSONfromFileTable --- ChangeLog | 3 +++ lib/client.js | 55 ++++++++++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 02c45e08..3e9b72ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -39,6 +39,9 @@ dispatch * Renamed: set -> setBinded, unSet -> unsetBinded, get -> isBinded. +* Functions maked private: ajaxload, changeLinks, createFileTable, +getJSONfromFileTable. + 2012.04.22, v0.2.0 diff --git a/lib/client.js b/lib/client.js index 90945975..c78e8945 100644 --- a/lib/client.js +++ b/lib/client.js @@ -7,7 +7,9 @@ var Util, DOM, CloudFunc, CloudCmd; (function(Util, DOM){ 'use strict'; - var Key, Config, Modules, FileTemplate, PathTemplate, Events = DOM.Events; + var Key, Config, Modules, FileTemplate, PathTemplate, + Events = DOM.Events, + Cache = DOM.Cache; /* Клиентский обьект, содержащий функциональную часть*/ CloudCmd = { @@ -61,7 +63,7 @@ var Util, DOM, CloudFunc, CloudCmd; DOM.Images.showLoad(pNeedRefresh ? {top:true} : null); /* загружаем содержимое каталога */ - CloudCmd._ajaxLoad(lLink, { refresh: pNeedRefresh }); + ajaxLoad(lLink, { refresh: pNeedRefresh }); } DOM.preventDefault(pEvent); @@ -69,12 +71,13 @@ var Util, DOM, CloudFunc, CloudCmd; }; - /** функция устанавливает курсор на каталог + /** + * @description функция устанавливает курсор на каталог * с которого мы пришли, если мы поднялись * в верх по файловой структуре * @param pDirName - имя каталога с которого мы пришли */ - CloudCmd._currentToParent = function(pDirName){ + function currentToParent(pDirName){ /* убираем слэш с имени каталога */ pDirName = Util.removeStr(pDirName, '/'); @@ -259,21 +262,20 @@ var Util, DOM, CloudFunc, CloudCmd; var lPath = pEvent.state + '?json'; if(lPath) - CloudCmd._ajaxLoad(lPath, {nohistory: true}); + ajaxLoad(lPath, {nohistory: true}); return true; }); - /* меняем ссылки на ajax'овые */ - CloudCmd._changeLinks(CloudFunc.LEFTPANEL); - CloudCmd._changeLinks(CloudFunc.RIGHTPANEL); + changeLinks(CloudFunc.LEFTPANEL); + changeLinks(CloudFunc.RIGHTPANEL); /* устанавливаем переменную доступности кэша */ - DOM.Cache.setAllowed(true); + Cache.setAllowed(true); /* Устанавливаем кэш корневого каталога */ var lDirPath = DOM.getCurrentDirPath(); - if( !DOM.Cache.get(lDirPath) ) - DOM.Cache.set(lDirPath, CloudCmd._getJSONfromFileTable()); + if( !Cache.get(lDirPath) ) + Cache.set(lDirPath, getJSONfromFileTable()); }); /* выделяем строку с первым файлом */ @@ -354,11 +356,14 @@ var Util, DOM, CloudFunc, CloudCmd; }; - /* функция меняет ссыки на ajax-овые */ - CloudCmd._changeLinks = function(pPanelID){ + /** + * @description функция меняет ссыки на ajax-овые + * @param pPanelID + */ + function changeLinks(pPanelID){ /* назначаем кнопку очистить кэш и показываем её */ var lClearcache = DOM.getById('clear-cache'); - Events.addClick(DOM.Cache.clear, lClearcache); + Events.addClick(Cache.clear, lClearcache); /* меняем ссылки на ajax-запросы */ var lPanel = DOM.getById(pPanelID), @@ -484,7 +489,7 @@ var Util, DOM, CloudFunc, CloudCmd; * @param pOptions * { refresh, nohistory } - необходимость обновить данные о каталоге */ - CloudCmd._ajaxLoad = function(pPath, pOptions){ + function ajaxLoad(pPath, pOptions){ if(!pOptions) pOptions = {}; @@ -516,12 +521,12 @@ var Util, DOM, CloudFunc, CloudCmd; */ var lRet = pOptions.refresh; if(!lRet){ - var lJSON = DOM.Cache.get(lCleanPath); + var lJSON = Cache.get(lCleanPath); if (lJSON){ /* переводим из текста в JSON */ lJSON = Util.parseJSON(lJSON); - CloudCmd._createFileTable(lPanel, lJSON); + createFileTable(lPanel, lJSON); } else lRet = true; @@ -536,7 +541,7 @@ var Util, DOM, CloudFunc, CloudCmd; }, success : function(pData){ - CloudCmd._createFileTable(lPanel, pData); + createFileTable(lPanel, pData); /* переводим таблицу файлов в строку, для * * сохранения в localStorage */ @@ -546,17 +551,17 @@ var Util, DOM, CloudFunc, CloudCmd; /* если размер данных не очень бошьой * * сохраняем их в кэше */ if(lJSON_s.length < 50000 ) - DOM.Cache.set(lCleanPath, lJSON_s); + Cache.set(lCleanPath, lJSON_s); } }); - }; + } /** * Функция строит файловую таблицу * @param pEleme - родительский элемент * @param pJSON - данные о файлах */ - CloudCmd._createFileTable = function(pElem, pJSON){ + function createFileTable(pElem, pJSON){ var lElem = DOM.getById(pElem), /* getting current element if was refresh */ lPath = DOM.getByClass('path', lElem), @@ -601,19 +606,19 @@ var Util, DOM, CloudFunc, CloudCmd; DOM.setCurrentFile(lCurrent); - CloudCmd._changeLinks(pElem); + changeLinks(pElem); if(lParent === '..' && lDir !== '/') - CloudCmd._currentToParent(lDir); + currentToParent(lDir); }); }); - }; + } /** * Функция генерирует JSON из html-таблицы файлов и * используеться при первом заходе в корень */ - CloudCmd._getJSONfromFileTable = function(){ + function getJSONfromFileTable(){ var lLeft = DOM.getById('left'), lPath = DOM.getByClass('path')[0].textContent, From 055c777f2d3eccbf58ccd91527d28e71167f835d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 31 May 2013 10:28:38 -0400 Subject: [PATCH 047/239] refactored --- lib/client.js | 12 +++++------- lib/client/menu.js | 6 +++--- lib/client/storage/_github.js | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/client.js b/lib/client.js index c78e8945..13b85ed9 100644 --- a/lib/client.js +++ b/lib/client.js @@ -72,7 +72,7 @@ var Util, DOM, CloudFunc, CloudCmd; /** - * @description функция устанавливает курсор на каталог + * функция устанавливает курсор на каталог * с которого мы пришли, если мы поднялись * в верх по файловой структуре * @param pDirName - имя каталога с которого мы пришли @@ -357,7 +357,7 @@ var Util, DOM, CloudFunc, CloudCmd; /** - * @description функция меняет ссыки на ajax-овые + * функция меняет ссыки на ajax-овые * @param pPanelID */ function changeLinks(pPanelID){ @@ -480,7 +480,7 @@ var Util, DOM, CloudFunc, CloudCmd; '(' + pPanelID + ')'; } } - }; + } /** * Функция загружает json-данные о Файловой Системе @@ -567,11 +567,9 @@ var Util, DOM, CloudFunc, CloudCmd; lPath = DOM.getByClass('path', lElem), lCurrent = DOM.getCurrentFile(), - lCurrentLink = DOM.getCurrentLink(lCurrent), - lParent = lCurrentLink.textContent, lDir = DOM.getCurrentDirName(), - lName = DOM.getCurrentName(lName), + lName = DOM.getCurrentName(lCurrent), lWasRefresh_b = lPath[0].textContent === pJSON[0].path; CloudCmd.getFileTemplate(function(pTemplate){ @@ -608,7 +606,7 @@ var Util, DOM, CloudFunc, CloudCmd; changeLinks(pElem); - if(lParent === '..' && lDir !== '/') + if(lName === '..' && lDir !== '/') currentToParent(lDir); }); }); diff --git a/lib/client/menu.js b/lib/client/menu.js index 80d18f29..7eae56d0 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -186,7 +186,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; var m = "clicked: " + key; Util.log(m, options); - Key.set(); + Key.setBind(); }, // define the elements of the menu @@ -248,7 +248,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.setCurrentFile(lElement); } - Key.set(); + Key.setBind(); } } @@ -308,7 +308,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; } } else if (lKey === lESC) - Key.set(); + Key.setBind(); } }; diff --git a/lib/client/storage/_github.js b/lib/client/storage/_github.js index 773bbffd..9ee2b8e4 100644 --- a/lib/client/storage/_github.js +++ b/lib/client/storage/_github.js @@ -115,7 +115,7 @@ var CloudCmd, Util, DOM, $, Github, cb; var lGist = GithubLocal.getGist(), lFiles = {}, - lHost = CloudCommander.HOST, + lHost = CloudCmd.HOST, lOptions = { description: 'Uplouded by Cloud Commander from ' + lHost, public: true From 9e105f56bd85eb91fe456f4bb3294fd09d0d318e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 3 Jun 2013 03:36:58 -0400 Subject: [PATCH 048/239] moved CloudCmd.KEY object data to prototype of CloudCmd.Key --- ChangeLog | 2 + lib/client/editor/_ace.js | 6 +-- lib/client/editor/_codemirror.js | 2 +- lib/client/key.js | 63 ++++++++++++++++---------------- lib/client/menu.js | 5 +-- lib/client/terminal.js | 5 +-- lib/client/viewer.js | 5 +-- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3e9b72ca..b758edec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -42,6 +42,8 @@ dispatch * Functions maked private: ajaxload, changeLinks, createFileTable, getJSONfromFileTable. +* Moved CloudCmd.KEY object data to prototype of CloudCmd.Key. + 2012.04.22, v0.2.0 diff --git a/lib/client/editor/_ace.js b/lib/client/editor/_ace.js index 989f68be..c0f15ca9 100644 --- a/lib/client/editor/_ace.js +++ b/lib/client/editor/_ace.js @@ -170,9 +170,9 @@ var CloudCmd, CloudFunc, ace; /* если клавиши можно обрабатывать */ if( lBinded ){ /* if f4 or f3 pressed */ - var lF3 = cloudcmd.KEY.F3; - var lF4 = cloudcmd.KEY.F4; - var lShow = Util.bind(lThis.show, lThis); + var lF3 = Key.F3, + lF4 = Key.F4, + lShow = Util.bind(lThis.show, lThis); if(!pEvent.shiftKey){ if(pEvent.keyCode === lF4) diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index 361897bd..d5bf2f3a 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -191,7 +191,7 @@ var CloudCmd, Util, DOM, CodeMirror; var lIsBind = Key.isBind(); if (lIsBind) { - var lF4 = CloudCmd.KEY.F4, + var lF4 = Key.F4, lKey = pEvent.keyCode; if(lKey === lF4) diff --git a/lib/client/key.js b/lib/client/key.js index 4f02f60b..f12b5eb3 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -2,7 +2,7 @@ var CloudCmd, Util, DOM; (function(CloudCmd, Util, DOM){ 'use strict'; - CloudCmd.KEY = { + var KEY = { TAB : 9, ENTER : 13, ESC : 27, @@ -43,10 +43,12 @@ var CloudCmd, Util, DOM; TRA : 192 /* Typewritten Reverse Apostrophe (`) */ }; + KeyProto.prototype = KEY; CloudCmd.Key = new KeyProto(); function KeyProto(){ - var Binded, + var Key = this, + Binded, lTabPanel = { left : 0, right : 0 @@ -69,7 +71,6 @@ var CloudCmd, Util, DOM; function listener(pEvent){ /* получаем выдленный файл*/ var i, n, lCurrent = DOM.getCurrentFile(), - KEY = CloudCmd.KEY, lKeyCode = pEvent.keyCode, lShift = pEvent.shiftKey, lAlt = pEvent.altKey, @@ -77,7 +78,7 @@ var CloudCmd, Util, DOM; /* если клавиши можно обрабатывать*/ if(Binded){ switch(lKeyCode){ - case KEY.TAB: + case Key.TAB: /* changing parent panel of curent-file */ var lPanel = DOM.getPanel(), lId = lPanel.id; @@ -98,12 +99,12 @@ var CloudCmd, Util, DOM; DOM.preventDefault(pEvent);//запрет на дальнейшее действие break; - case KEY.INSERT: + case Key.INSERT: DOM.setSelectedFile( lCurrent ); DOM.setCurrentFile( lCurrent.nextSibling ); break; - case KEY.DELETE: + case Key.DELETE: if(lShift){ var lUrl = DOM.getCurrentPath(lCurrent); @@ -118,60 +119,60 @@ var CloudCmd, Util, DOM; DOM.promptDeleteSelected(lCurrent); break; - case KEY.F1: + case Key.F1: DOM.preventDefault(pEvent); break; - case KEY.F2: + case Key.F2: DOM.renameCurrent(lCurrent); break; - case KEY.F3: + case Key.F3: Util.exec(CloudCmd.Viewer); DOM.preventDefault(pEvent); break; - case KEY.F4: + case Key.F4: DOM.Images.showLoad(); Util.exec(CloudCmd.Editor); DOM.preventDefault(pEvent); break; - case KEY.F5: + case Key.F5: DOM.copyCurrent(lCurrent); DOM.preventDefault(pEvent); break; - case KEY.F6: + case Key.F6: DOM.moveCurrent(lCurrent); DOM.preventDefault(pEvent); break; - case KEY.F7: + case Key.F7: DOM.promptNewDir(); break; - case KEY.F8: + case Key.F8: DOM.promptDeleteSelected(lCurrent); break; - case KEY.F: + case Key.F: DOM.promptDeleteCurrent(lCurrent); break; - case KEY.F10: + case Key.F10: if(lShift){ Util.exec(CloudCmd.Menu); DOM.preventDefault(pEvent); } break; - case KEY.TRA: + case Key.TRA: DOM.Images.showLoad({top: true}); Util.exec(CloudCmd.Terminal); break; - case KEY.SPACE: + case Key.SPACE: var lSelected = DOM.isSelected(lCurrent), lDir = DOM.isCurrentIsDir(lCurrent), lName = DOM.getCurrentName(lCurrent); @@ -192,7 +193,7 @@ var CloudCmd, Util, DOM; /* навигация по таблице файлов * * если нажали клавишу вверх * * выделяем предыдущую строку */ - case KEY.UP: + case Key.UP: if(lShift) DOM.setSelectedFile(lCurrent); @@ -202,7 +203,7 @@ var CloudCmd, Util, DOM; /* если нажали клавишу в низ * * выделяем следующую строку */ - case KEY.DOWN: + case Key.DOWN: if(lShift) DOM.setSelectedFile(lCurrent); @@ -213,21 +214,21 @@ var CloudCmd, Util, DOM; /* если нажали клавишу Home * * переходим к самому верхнему * * элементу */ - case KEY.HOME: + case Key.HOME: DOM.setCurrentFile( lCurrent.parentElement.firstChild ); DOM.preventDefault(pEvent); break; /* если нажали клавишу End * выделяем последний элемент */ - case KEY.END: + case Key.END: DOM.setCurrentFile( lCurrent.parentElement.lastElementChild ); DOM.preventDefault( pEvent ); break; /* если нажали клавишу page down * проматываем экран */ - case KEY.PAGE_DOWN: + case Key.PAGE_DOWN: DOM.scrollByPages( DOM.getPanel(), 1 ); for(i=0; i<30; i++){ @@ -240,7 +241,7 @@ var CloudCmd, Util, DOM; break; /* если нажали клавишу page up проматываем экран */ - case KEY.PAGE_UP: + case Key.PAGE_UP: DOM.scrollByPages( DOM.getPanel(), -1 ); var lC = lCurrent, @@ -264,12 +265,12 @@ var CloudCmd, Util, DOM; break; /* открываем папку*/ - case KEY.ENTER: + case Key.ENTER: if( DOM.isCurrentIsDir() ) Util.exec( CloudCmd.loadDir() ); break; - case KEY.A: + case Key.A: if(pEvent.ctrlKey){ var lParent = lCurrent.parentElement, lNodes = lParent.childNodes; @@ -288,7 +289,7 @@ var CloudCmd, Util, DOM; * при этом данные берём всегда с * сервера, а не из кэша * (обновляем кэш)*/ - case KEY.R: + case Key.R: if(lCtrl){ Util.log('+r pressed\n' + 'reloading page...\n' + @@ -300,7 +301,7 @@ var CloudCmd, Util, DOM; break; /* чистим кэш */ - case KEY.D: + case Key.D: if(lCtrl){ Util.log('+d pressed\n' + 'clearing cache...\n' + @@ -313,7 +314,7 @@ var CloudCmd, Util, DOM; /* убираем все обработчики * нажатий клавиш */ - case KEY.Q: + case Key.Q: if(lAlt){ Util.log('+q pressed\n' + '+r reload key-handerl - removed' + @@ -331,7 +332,7 @@ var CloudCmd, Util, DOM; /* устанавливаем все обработчики * нажатий клавиш */ - else if(lKeyCode === KEY.S && lAlt){ + else if(lKeyCode === Key.S && lAlt){ /* обрабатываем нажатия на клавиши*/ Binded = true; Util.log('+s pressed\n' + @@ -340,7 +341,7 @@ var CloudCmd, Util, DOM; 'press +q to remove them'); DOM.preventDefault(pEvent); } - }; + } } })(CloudCmd, Util, DOM); \ No newline at end of file diff --git a/lib/client/menu.js b/lib/client/menu.js index 7eae56d0..a202363f 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -294,9 +294,8 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.Events.addKey( lListener ); function lListener(pEvent){ - var lKEY = CloudCmd.KEY, - lF10 = lKEY.F10, - lESC = lKEY.ESC, + var lF10 = Key.F10, + lESC = Key.ESC, lKey = pEvent.keyCode, lShift = pEvent.shiftKey, lIsBind = Key.isBind(); diff --git a/lib/client/terminal.js b/lib/client/terminal.js index df039658..cd2ccf96 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -112,9 +112,8 @@ var CloudCmd, Util, DOM, $; function lListener(pEvent){ var lRet = true, - lKEY = CloudCmd.KEY, - lESC = lKEY.ESC, - lTRA = lKEY.TRA, + lESC = Key.ESC, + lTRA = Key.TRA, lKey = pEvent.keyCode, lIsBind = Key.isBind(); diff --git a/lib/client/viewer.js b/lib/client/viewer.js index 54c6021f..416d7990 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -132,9 +132,8 @@ var CloudCmd, Util, DOM, CloudFunc, $; } function lListener(pEvent){ - var lKEY = CloudCmd.KEY, - lF3 = lKEY.F3, - lF1 = lKEY.F1, + var lF3 = Key.F3, + lF1 = Key.F1, lIsBind = Key.isBind(), lKey = pEvent.keyCode; From 962948caa8d60bb7cdde2edd58f3288a5aa5555a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 3 Jun 2013 10:53:51 -0400 Subject: [PATCH 049/239] simpified plugins id's --- ChangeLog | 2 + lib/client.js | 7 ++- lib/client/{editor => edit}/_ace.js | 0 lib/client/{editor => edit}/_codemirror.js | 50 +++++++----------- lib/client/{editor => edit}/ace/ChangeLog.txt | 0 lib/client/{editor => edit}/ace/LICENSE | 0 lib/client/{editor => edit}/ace/README.md | 0 lib/client/{editor => edit}/ace/ace.js | 0 .../{editor => edit}/ace/mode-coffee.js | 0 .../{editor => edit}/ace/mode-javascript.js | 0 lib/client/{editor => edit}/ace/mode-json.js | 0 .../{editor => edit}/ace/theme-monokai.js | 0 .../ace/theme-tomorrow_night_blue.js | 0 .../{editor => edit}/ace/worker-coffee.js | 0 .../{editor => edit}/ace/worker-javascript.js | 0 .../{editor => edit}/ace/worker-json.js | 0 .../{editor => edit}/codemirror/LICENSE | 0 .../{editor => edit}/codemirror/README.md | 0 .../codemirror/codemirror.css | 0 .../{editor => edit}/codemirror/codemirror.js | 0 .../codemirror/mode/javascript.js | 0 .../{editor => edit}/codemirror/mode/xml.js | 0 .../{editor => edit}/codemirror/package.json | 0 .../codemirror/theme/night.css | 0 .../{editor => edit}/codemirror3/LICENSE | 0 .../{editor => edit}/codemirror3/README.md | 0 .../codemirror3/codemirror.css | 0 .../codemirror3/codemirror.js | 0 .../codemirror3/mode/javascript.js | 0 .../{editor => edit}/codemirror3/mode/xml.js | 0 .../{editor => edit}/codemirror3/package.json | 0 .../codemirror3/theme/night.css | 0 lib/client/terminal.js | 18 +++---- lib/client/{viewer.js => view.js} | 10 ++-- .../{viewer => view}/fancyBox/.gitattributes | 0 .../{viewer => view}/fancyBox/CHANGELOG.md | 0 .../{viewer => view}/fancyBox/README.md | 0 .../{viewer => view}/fancyBox/demo/1_b.jpg | Bin .../{viewer => view}/fancyBox/demo/1_s.jpg | Bin .../{viewer => view}/fancyBox/demo/2_b.jpg | Bin .../{viewer => view}/fancyBox/demo/2_s.jpg | Bin .../{viewer => view}/fancyBox/demo/3_b.jpg | Bin .../{viewer => view}/fancyBox/demo/3_s.jpg | Bin .../{viewer => view}/fancyBox/demo/4_b.jpg | Bin .../{viewer => view}/fancyBox/demo/4_s.jpg | Bin .../{viewer => view}/fancyBox/demo/5_b.jpg | Bin .../{viewer => view}/fancyBox/demo/5_s.jpg | Bin .../{viewer => view}/fancyBox/demo/ajax.txt | 0 .../fancyBox/demo/iframe.html | 0 .../{viewer => view}/fancyBox/demo/index.html | 0 .../fancyBox/lib/jquery-1.9.0.min.js | 0 .../lib/jquery.mousewheel-3.0.6.pack.js | 0 .../fancyBox/source/blank.gif | Bin .../fancyBox/source/fancybox_loading.gif | Bin .../fancyBox/source/fancybox_overlay.png | Bin .../fancyBox/source/fancybox_sprite.png | Bin .../source/helpers/fancybox_buttons.png | Bin .../helpers/jquery.fancybox-buttons.css | 0 .../source/helpers/jquery.fancybox-buttons.js | 0 .../source/helpers/jquery.fancybox-media.js | 0 .../source/helpers/jquery.fancybox-thumbs.css | 0 .../source/helpers/jquery.fancybox-thumbs.js | 0 .../fancyBox/source/jquery.fancybox.css | 0 .../fancyBox/source/jquery.fancybox.js | 0 .../fancyBox/source/jquery.fancybox.pack.js | 0 65 files changed, 36 insertions(+), 51 deletions(-) rename lib/client/{editor => edit}/_ace.js (100%) rename lib/client/{editor => edit}/_codemirror.js (80%) rename lib/client/{editor => edit}/ace/ChangeLog.txt (100%) rename lib/client/{editor => edit}/ace/LICENSE (100%) rename lib/client/{editor => edit}/ace/README.md (100%) rename lib/client/{editor => edit}/ace/ace.js (100%) rename lib/client/{editor => edit}/ace/mode-coffee.js (100%) rename lib/client/{editor => edit}/ace/mode-javascript.js (100%) rename lib/client/{editor => edit}/ace/mode-json.js (100%) rename lib/client/{editor => edit}/ace/theme-monokai.js (100%) rename lib/client/{editor => edit}/ace/theme-tomorrow_night_blue.js (100%) rename lib/client/{editor => edit}/ace/worker-coffee.js (100%) rename lib/client/{editor => edit}/ace/worker-javascript.js (100%) rename lib/client/{editor => edit}/ace/worker-json.js (100%) rename lib/client/{editor => edit}/codemirror/LICENSE (100%) rename lib/client/{editor => edit}/codemirror/README.md (100%) rename lib/client/{editor => edit}/codemirror/codemirror.css (100%) rename lib/client/{editor => edit}/codemirror/codemirror.js (100%) rename lib/client/{editor => edit}/codemirror/mode/javascript.js (100%) rename lib/client/{editor => edit}/codemirror/mode/xml.js (100%) rename lib/client/{editor => edit}/codemirror/package.json (100%) rename lib/client/{editor => edit}/codemirror/theme/night.css (100%) rename lib/client/{editor => edit}/codemirror3/LICENSE (100%) rename lib/client/{editor => edit}/codemirror3/README.md (100%) rename lib/client/{editor => edit}/codemirror3/codemirror.css (100%) rename lib/client/{editor => edit}/codemirror3/codemirror.js (100%) rename lib/client/{editor => edit}/codemirror3/mode/javascript.js (100%) rename lib/client/{editor => edit}/codemirror3/mode/xml.js (100%) rename lib/client/{editor => edit}/codemirror3/package.json (100%) rename lib/client/{editor => edit}/codemirror3/theme/night.css (100%) rename lib/client/{viewer.js => view.js} (94%) rename lib/client/{viewer => view}/fancyBox/.gitattributes (100%) rename lib/client/{viewer => view}/fancyBox/CHANGELOG.md (100%) rename lib/client/{viewer => view}/fancyBox/README.md (100%) rename lib/client/{viewer => view}/fancyBox/demo/1_b.jpg (100%) rename lib/client/{viewer => view}/fancyBox/demo/1_s.jpg (100%) rename lib/client/{viewer => view}/fancyBox/demo/2_b.jpg (100%) rename lib/client/{viewer => view}/fancyBox/demo/2_s.jpg (100%) rename lib/client/{viewer => view}/fancyBox/demo/3_b.jpg (100%) rename lib/client/{viewer => view}/fancyBox/demo/3_s.jpg (100%) rename lib/client/{viewer => view}/fancyBox/demo/4_b.jpg (100%) rename lib/client/{viewer => view}/fancyBox/demo/4_s.jpg (100%) rename lib/client/{viewer => view}/fancyBox/demo/5_b.jpg (100%) rename lib/client/{viewer => view}/fancyBox/demo/5_s.jpg (100%) rename lib/client/{viewer => view}/fancyBox/demo/ajax.txt (100%) rename lib/client/{viewer => view}/fancyBox/demo/iframe.html (100%) rename lib/client/{viewer => view}/fancyBox/demo/index.html (100%) rename lib/client/{viewer => view}/fancyBox/lib/jquery-1.9.0.min.js (100%) rename lib/client/{viewer => view}/fancyBox/lib/jquery.mousewheel-3.0.6.pack.js (100%) rename lib/client/{viewer => view}/fancyBox/source/blank.gif (100%) rename lib/client/{viewer => view}/fancyBox/source/fancybox_loading.gif (100%) rename lib/client/{viewer => view}/fancyBox/source/fancybox_overlay.png (100%) rename lib/client/{viewer => view}/fancyBox/source/fancybox_sprite.png (100%) rename lib/client/{viewer => view}/fancyBox/source/helpers/fancybox_buttons.png (100%) rename lib/client/{viewer => view}/fancyBox/source/helpers/jquery.fancybox-buttons.css (100%) rename lib/client/{viewer => view}/fancyBox/source/helpers/jquery.fancybox-buttons.js (100%) rename lib/client/{viewer => view}/fancyBox/source/helpers/jquery.fancybox-media.js (100%) rename lib/client/{viewer => view}/fancyBox/source/helpers/jquery.fancybox-thumbs.css (100%) rename lib/client/{viewer => view}/fancyBox/source/helpers/jquery.fancybox-thumbs.js (100%) rename lib/client/{viewer => view}/fancyBox/source/jquery.fancybox.css (100%) rename lib/client/{viewer => view}/fancyBox/source/jquery.fancybox.js (100%) rename lib/client/{viewer => view}/fancyBox/source/jquery.fancybox.pack.js (100%) diff --git a/ChangeLog b/ChangeLog index b758edec..96b4eae6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -44,6 +44,8 @@ getJSONfromFileTable. * Moved CloudCmd.KEY object data to prototype of CloudCmd.Key. +* Simpified plugins id's. + 2012.04.22, v0.2.0 diff --git a/lib/client.js b/lib/client.js index 13b85ed9..8b65feb5 100644 --- a/lib/client.js +++ b/lib/client.js @@ -92,7 +92,7 @@ var Util, DOM, CloudFunc, CloudCmd; DOM.setCurrentFile(lRootDir); DOM.scrollIntoViewIfNeeded(lRootDir, true); } - }; + } /** * function load modules @@ -133,6 +133,7 @@ var Util, DOM, CloudFunc, CloudCmd; }; } } + /** Конструктор CloudClient, который * выполняет весь функционал по * инициализации @@ -153,8 +154,6 @@ var Util, DOM, CloudFunc, CloudCmd; DOM.retJSLoad(lSrc, pCallBack) ); }; - - //Util.socketLoad(); Util.ifExec(document.body.scrollIntoViewIfNeeded, lCallBack, lFunc); }; @@ -181,7 +180,7 @@ var Util, DOM, CloudFunc, CloudCmd; lDoBefore = { 'editor/_codemirror' : lShowLoadFunc, - 'viewer' : lShowLoadFunc + 'view' : lShowLoadFunc }, lLoad = function(pName, pPath, pDoBefore){ diff --git a/lib/client/editor/_ace.js b/lib/client/edit/_ace.js similarity index 100% rename from lib/client/editor/_ace.js rename to lib/client/edit/_ace.js diff --git a/lib/client/editor/_codemirror.js b/lib/client/edit/_codemirror.js similarity index 80% rename from lib/client/editor/_codemirror.js rename to lib/client/edit/_codemirror.js index d5bf2f3a..53c9afab 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/edit/_codemirror.js @@ -3,14 +3,13 @@ var CloudCmd, Util, DOM, CodeMirror; (function(CloudCmd, Util, DOM){ 'use strict'; - var Key = CloudCmd.Key, - CodeMirrorEditor = {}, + var Key = CloudCmd.Key, + Editor = {}, FM, - CodeMirrorElement, - CodeMirrorLoaded = false, - /* indicator says CodeMirror still loads */ - Loading = false, - ReadOnly = false, + Element, + CodeMirrorLoaded = false, + Loading = false, + ReadOnly = false, CallBacks = [ hide, @@ -19,18 +18,10 @@ var CloudCmd, Util, DOM, CodeMirror; load ]; - CloudCmd.Editor = { - get : (function(){ - return this.CodeMirror; - }) - }; - - /* private functions */ - function setCSS(){ var lPosition = DOM.getPanel().id, lRet = DOM.cssSet({ - id : 'editor', + id : 'editor-css', inner : '.CodeMirror{' + 'font-family' + ': \'Droid Sans Mono\';' + 'font-size' + ': 15px;' + @@ -38,7 +29,7 @@ var CloudCmd, Util, DOM, CodeMirror; '.CodeMirror-scroll{' + 'height' + ':' + CloudCmd.HEIGHT + 'px' + '}' + - '#CodeMirrorEditor{' + + '#editor{' + 'float' + ':' + lPosition + '}' }); @@ -58,19 +49,18 @@ var CloudCmd, Util, DOM, CodeMirror; lCurrent = DOM.getCurrentFile(), lPath = DOM.getCurrentPath( lCurrent ); - CodeMirrorElement = DOM.anyload({ + Element = DOM.anyload({ name : 'div', - id : 'CodeMirrorEditor', + id : 'editor', className : 'panel', parent : FM }); - var lEditor = CodeMirrorEditor.CodeMirror = new CodeMirror(CodeMirrorElement,{ + var lEditor = Editor.CodeMirror = new CodeMirror(Element, { mode : 'javascript', value : pParams && pParams.data && pParams.data.data, theme : 'night', lineNumbers : true, - //переносим длинные строки lineWrapping: false, autofocus : true, extraKeys: { @@ -157,8 +147,8 @@ var CloudCmd, Util, DOM, CodeMirror; function hide() { Key.setBind(); - if(CodeMirrorElement && FM) - FM.removeChild(CodeMirrorElement); + if(Element && FM) + FM.removeChild(Element); DOM.showPanel(); } @@ -166,7 +156,7 @@ var CloudCmd, Util, DOM, CodeMirror; /** * function calls all CodeMirror editor functions */ - CodeMirrorEditor.show = function(){ + Editor.show = function(){ DOM.Images.showLoad(); Util.loadOnLoad( CallBacks ); }; @@ -174,18 +164,18 @@ var CloudCmd, Util, DOM, CodeMirror; /** * function hides CodeMirror editor */ - CodeMirrorEditor.hide = hide; + Editor.hide = hide; /** * function bind keys */ CloudCmd.Editor.init = function(){ - CodeMirrorEditor.show(); + Editor.show(); CallBacks.pop(); /* добавляем обработчик клавишь */ - DOM.Events.addKey( lListener ); - DOM.setButtonKey('f4', CodeMirrorEditor.show); + DOM.Events.addKey(lListener); + DOM.setButtonKey('f4', Editor.show); function lListener(pEvent){ var lIsBind = Key.isBind(); @@ -195,11 +185,11 @@ var CloudCmd, Util, DOM, CodeMirror; lKey = pEvent.keyCode; if(lKey === lF4) - CodeMirrorEditor.show(); + Editor.show(); } } }; - CloudCmd.Editor.CodeMirror = CodeMirrorEditor; + CloudCmd.Editor.CodeMirror = Editor; })(CloudCmd, Util, DOM); diff --git a/lib/client/editor/ace/ChangeLog.txt b/lib/client/edit/ace/ChangeLog.txt similarity index 100% rename from lib/client/editor/ace/ChangeLog.txt rename to lib/client/edit/ace/ChangeLog.txt diff --git a/lib/client/editor/ace/LICENSE b/lib/client/edit/ace/LICENSE similarity index 100% rename from lib/client/editor/ace/LICENSE rename to lib/client/edit/ace/LICENSE diff --git a/lib/client/editor/ace/README.md b/lib/client/edit/ace/README.md similarity index 100% rename from lib/client/editor/ace/README.md rename to lib/client/edit/ace/README.md diff --git a/lib/client/editor/ace/ace.js b/lib/client/edit/ace/ace.js similarity index 100% rename from lib/client/editor/ace/ace.js rename to lib/client/edit/ace/ace.js diff --git a/lib/client/editor/ace/mode-coffee.js b/lib/client/edit/ace/mode-coffee.js similarity index 100% rename from lib/client/editor/ace/mode-coffee.js rename to lib/client/edit/ace/mode-coffee.js diff --git a/lib/client/editor/ace/mode-javascript.js b/lib/client/edit/ace/mode-javascript.js similarity index 100% rename from lib/client/editor/ace/mode-javascript.js rename to lib/client/edit/ace/mode-javascript.js diff --git a/lib/client/editor/ace/mode-json.js b/lib/client/edit/ace/mode-json.js similarity index 100% rename from lib/client/editor/ace/mode-json.js rename to lib/client/edit/ace/mode-json.js diff --git a/lib/client/editor/ace/theme-monokai.js b/lib/client/edit/ace/theme-monokai.js similarity index 100% rename from lib/client/editor/ace/theme-monokai.js rename to lib/client/edit/ace/theme-monokai.js diff --git a/lib/client/editor/ace/theme-tomorrow_night_blue.js b/lib/client/edit/ace/theme-tomorrow_night_blue.js similarity index 100% rename from lib/client/editor/ace/theme-tomorrow_night_blue.js rename to lib/client/edit/ace/theme-tomorrow_night_blue.js diff --git a/lib/client/editor/ace/worker-coffee.js b/lib/client/edit/ace/worker-coffee.js similarity index 100% rename from lib/client/editor/ace/worker-coffee.js rename to lib/client/edit/ace/worker-coffee.js diff --git a/lib/client/editor/ace/worker-javascript.js b/lib/client/edit/ace/worker-javascript.js similarity index 100% rename from lib/client/editor/ace/worker-javascript.js rename to lib/client/edit/ace/worker-javascript.js diff --git a/lib/client/editor/ace/worker-json.js b/lib/client/edit/ace/worker-json.js similarity index 100% rename from lib/client/editor/ace/worker-json.js rename to lib/client/edit/ace/worker-json.js diff --git a/lib/client/editor/codemirror/LICENSE b/lib/client/edit/codemirror/LICENSE similarity index 100% rename from lib/client/editor/codemirror/LICENSE rename to lib/client/edit/codemirror/LICENSE diff --git a/lib/client/editor/codemirror/README.md b/lib/client/edit/codemirror/README.md similarity index 100% rename from lib/client/editor/codemirror/README.md rename to lib/client/edit/codemirror/README.md diff --git a/lib/client/editor/codemirror/codemirror.css b/lib/client/edit/codemirror/codemirror.css similarity index 100% rename from lib/client/editor/codemirror/codemirror.css rename to lib/client/edit/codemirror/codemirror.css diff --git a/lib/client/editor/codemirror/codemirror.js b/lib/client/edit/codemirror/codemirror.js similarity index 100% rename from lib/client/editor/codemirror/codemirror.js rename to lib/client/edit/codemirror/codemirror.js diff --git a/lib/client/editor/codemirror/mode/javascript.js b/lib/client/edit/codemirror/mode/javascript.js similarity index 100% rename from lib/client/editor/codemirror/mode/javascript.js rename to lib/client/edit/codemirror/mode/javascript.js diff --git a/lib/client/editor/codemirror/mode/xml.js b/lib/client/edit/codemirror/mode/xml.js similarity index 100% rename from lib/client/editor/codemirror/mode/xml.js rename to lib/client/edit/codemirror/mode/xml.js diff --git a/lib/client/editor/codemirror/package.json b/lib/client/edit/codemirror/package.json similarity index 100% rename from lib/client/editor/codemirror/package.json rename to lib/client/edit/codemirror/package.json diff --git a/lib/client/editor/codemirror/theme/night.css b/lib/client/edit/codemirror/theme/night.css similarity index 100% rename from lib/client/editor/codemirror/theme/night.css rename to lib/client/edit/codemirror/theme/night.css diff --git a/lib/client/editor/codemirror3/LICENSE b/lib/client/edit/codemirror3/LICENSE similarity index 100% rename from lib/client/editor/codemirror3/LICENSE rename to lib/client/edit/codemirror3/LICENSE diff --git a/lib/client/editor/codemirror3/README.md b/lib/client/edit/codemirror3/README.md similarity index 100% rename from lib/client/editor/codemirror3/README.md rename to lib/client/edit/codemirror3/README.md diff --git a/lib/client/editor/codemirror3/codemirror.css b/lib/client/edit/codemirror3/codemirror.css similarity index 100% rename from lib/client/editor/codemirror3/codemirror.css rename to lib/client/edit/codemirror3/codemirror.css diff --git a/lib/client/editor/codemirror3/codemirror.js b/lib/client/edit/codemirror3/codemirror.js similarity index 100% rename from lib/client/editor/codemirror3/codemirror.js rename to lib/client/edit/codemirror3/codemirror.js diff --git a/lib/client/editor/codemirror3/mode/javascript.js b/lib/client/edit/codemirror3/mode/javascript.js similarity index 100% rename from lib/client/editor/codemirror3/mode/javascript.js rename to lib/client/edit/codemirror3/mode/javascript.js diff --git a/lib/client/editor/codemirror3/mode/xml.js b/lib/client/edit/codemirror3/mode/xml.js similarity index 100% rename from lib/client/editor/codemirror3/mode/xml.js rename to lib/client/edit/codemirror3/mode/xml.js diff --git a/lib/client/editor/codemirror3/package.json b/lib/client/edit/codemirror3/package.json similarity index 100% rename from lib/client/editor/codemirror3/package.json rename to lib/client/edit/codemirror3/package.json diff --git a/lib/client/editor/codemirror3/theme/night.css b/lib/client/edit/codemirror3/theme/night.css similarity index 100% rename from lib/client/editor/codemirror3/theme/night.css rename to lib/client/edit/codemirror3/theme/night.css diff --git a/lib/client/terminal.js b/lib/client/terminal.js index cd2ccf96..c311d20e 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -11,8 +11,6 @@ var CloudCmd, Util, DOM, $; JqueryTerminal = {}; CloudCmd.Terminal = {}; - - /* PRIVATE FUNCTIONS */ /** * function loads jquery-terminal @@ -32,24 +30,22 @@ var CloudCmd, Util, DOM, $; DOM.anyLoadOnLoad([lFiles, lJqueryMigrate], function(){ Util.timeEnd('terminal load'); init(); - $(function($, undefined) { + $(function($) { Term = JqueryTerminal.Term = $('#terminal').terminal(function(command, term){ term.echo(''); CloudCmd.Socket.send(command); }, { - greetings : '[[;#729FCF;]Cloud Commander Terminal]', + greetings : '[[;#729FCF;]CloudCmd Terminal]', prompt : '[[;#729FCF;]cloudcmd> ]', color : '#729FCF;' }); }); /* removing resize function, no need for us */ - Term.resize = function(){}; - $(window).unbind('resize'); Util.exec(pCallBack); - }).cssSet({id:'terminalStyle', - inner: '.cloudTerminal{' + + }).cssSet({id:'terminal-css', + inner: '.terminal{' + 'height: 720px;' + '};' }); @@ -63,13 +59,11 @@ var CloudCmd, Util, DOM, $; TerminalId = DOM.anyload({ name : 'div', id : 'terminal', - className : 'panel cloudTerminal', + className : 'panel terminal', parent : DOM.getFM() }); } - /* PUBLIC FUNCTIONS */ - /** * functin show jquery-terminal */ @@ -108,7 +102,7 @@ var CloudCmd, Util, DOM, $; DOM.jqueryLoad, ]); - DOM.Events.addKey( lListener ); + DOM.Events.addKey(lListener); function lListener(pEvent){ var lRet = true, diff --git a/lib/client/viewer.js b/lib/client/view.js similarity index 94% rename from lib/client/viewer.js rename to lib/client/view.js index 416d7990..fd1aa546 100644 --- a/lib/client/viewer.js +++ b/lib/client/view.js @@ -15,7 +15,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; }, afterShow : function(){ - var lEditor = DOM.getById('CloudViewer'); + var lEditor = DOM.getById('View'); if(lEditor) lEditor.focus(); }, @@ -57,12 +57,12 @@ var CloudCmd, Util, DOM, CloudFunc, $; Util.timeEnd('fancybox load'); Util.exec( pCallBack ); }) - .cssSet({id:'viewer', - inner : '#CloudViewer{' + + .cssSet({id:'view-css', + inner : '#view{' + 'font-size: 16px;' + 'white-space :pre' + '}' + - '#CloudViewer::selection{' + + '#view::selection{' + /* 'background: #fe57a1;' 'color: #fff;' @@ -108,7 +108,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; $.fancybox.open({ href : lPath }, Config); else DOM.getCurrentData(function(pParams){ - $.fancybox('
' + + $.fancybox('
' + pParams.data + '
', Config); }); diff --git a/lib/client/viewer/fancyBox/.gitattributes b/lib/client/view/fancyBox/.gitattributes similarity index 100% rename from lib/client/viewer/fancyBox/.gitattributes rename to lib/client/view/fancyBox/.gitattributes diff --git a/lib/client/viewer/fancyBox/CHANGELOG.md b/lib/client/view/fancyBox/CHANGELOG.md similarity index 100% rename from lib/client/viewer/fancyBox/CHANGELOG.md rename to lib/client/view/fancyBox/CHANGELOG.md diff --git a/lib/client/viewer/fancyBox/README.md b/lib/client/view/fancyBox/README.md similarity index 100% rename from lib/client/viewer/fancyBox/README.md rename to lib/client/view/fancyBox/README.md diff --git a/lib/client/viewer/fancyBox/demo/1_b.jpg b/lib/client/view/fancyBox/demo/1_b.jpg similarity index 100% rename from lib/client/viewer/fancyBox/demo/1_b.jpg rename to lib/client/view/fancyBox/demo/1_b.jpg diff --git a/lib/client/viewer/fancyBox/demo/1_s.jpg b/lib/client/view/fancyBox/demo/1_s.jpg similarity index 100% rename from lib/client/viewer/fancyBox/demo/1_s.jpg rename to lib/client/view/fancyBox/demo/1_s.jpg diff --git a/lib/client/viewer/fancyBox/demo/2_b.jpg b/lib/client/view/fancyBox/demo/2_b.jpg similarity index 100% rename from lib/client/viewer/fancyBox/demo/2_b.jpg rename to lib/client/view/fancyBox/demo/2_b.jpg diff --git a/lib/client/viewer/fancyBox/demo/2_s.jpg b/lib/client/view/fancyBox/demo/2_s.jpg similarity index 100% rename from lib/client/viewer/fancyBox/demo/2_s.jpg rename to lib/client/view/fancyBox/demo/2_s.jpg diff --git a/lib/client/viewer/fancyBox/demo/3_b.jpg b/lib/client/view/fancyBox/demo/3_b.jpg similarity index 100% rename from lib/client/viewer/fancyBox/demo/3_b.jpg rename to lib/client/view/fancyBox/demo/3_b.jpg diff --git a/lib/client/viewer/fancyBox/demo/3_s.jpg b/lib/client/view/fancyBox/demo/3_s.jpg similarity index 100% rename from lib/client/viewer/fancyBox/demo/3_s.jpg rename to lib/client/view/fancyBox/demo/3_s.jpg diff --git a/lib/client/viewer/fancyBox/demo/4_b.jpg b/lib/client/view/fancyBox/demo/4_b.jpg similarity index 100% rename from lib/client/viewer/fancyBox/demo/4_b.jpg rename to lib/client/view/fancyBox/demo/4_b.jpg diff --git a/lib/client/viewer/fancyBox/demo/4_s.jpg b/lib/client/view/fancyBox/demo/4_s.jpg similarity index 100% rename from lib/client/viewer/fancyBox/demo/4_s.jpg rename to lib/client/view/fancyBox/demo/4_s.jpg diff --git a/lib/client/viewer/fancyBox/demo/5_b.jpg b/lib/client/view/fancyBox/demo/5_b.jpg similarity index 100% rename from lib/client/viewer/fancyBox/demo/5_b.jpg rename to lib/client/view/fancyBox/demo/5_b.jpg diff --git a/lib/client/viewer/fancyBox/demo/5_s.jpg b/lib/client/view/fancyBox/demo/5_s.jpg similarity index 100% rename from lib/client/viewer/fancyBox/demo/5_s.jpg rename to lib/client/view/fancyBox/demo/5_s.jpg diff --git a/lib/client/viewer/fancyBox/demo/ajax.txt b/lib/client/view/fancyBox/demo/ajax.txt similarity index 100% rename from lib/client/viewer/fancyBox/demo/ajax.txt rename to lib/client/view/fancyBox/demo/ajax.txt diff --git a/lib/client/viewer/fancyBox/demo/iframe.html b/lib/client/view/fancyBox/demo/iframe.html similarity index 100% rename from lib/client/viewer/fancyBox/demo/iframe.html rename to lib/client/view/fancyBox/demo/iframe.html diff --git a/lib/client/viewer/fancyBox/demo/index.html b/lib/client/view/fancyBox/demo/index.html similarity index 100% rename from lib/client/viewer/fancyBox/demo/index.html rename to lib/client/view/fancyBox/demo/index.html diff --git a/lib/client/viewer/fancyBox/lib/jquery-1.9.0.min.js b/lib/client/view/fancyBox/lib/jquery-1.9.0.min.js similarity index 100% rename from lib/client/viewer/fancyBox/lib/jquery-1.9.0.min.js rename to lib/client/view/fancyBox/lib/jquery-1.9.0.min.js diff --git a/lib/client/viewer/fancyBox/lib/jquery.mousewheel-3.0.6.pack.js b/lib/client/view/fancyBox/lib/jquery.mousewheel-3.0.6.pack.js similarity index 100% rename from lib/client/viewer/fancyBox/lib/jquery.mousewheel-3.0.6.pack.js rename to lib/client/view/fancyBox/lib/jquery.mousewheel-3.0.6.pack.js diff --git a/lib/client/viewer/fancyBox/source/blank.gif b/lib/client/view/fancyBox/source/blank.gif similarity index 100% rename from lib/client/viewer/fancyBox/source/blank.gif rename to lib/client/view/fancyBox/source/blank.gif diff --git a/lib/client/viewer/fancyBox/source/fancybox_loading.gif b/lib/client/view/fancyBox/source/fancybox_loading.gif similarity index 100% rename from lib/client/viewer/fancyBox/source/fancybox_loading.gif rename to lib/client/view/fancyBox/source/fancybox_loading.gif diff --git a/lib/client/viewer/fancyBox/source/fancybox_overlay.png b/lib/client/view/fancyBox/source/fancybox_overlay.png similarity index 100% rename from lib/client/viewer/fancyBox/source/fancybox_overlay.png rename to lib/client/view/fancyBox/source/fancybox_overlay.png diff --git a/lib/client/viewer/fancyBox/source/fancybox_sprite.png b/lib/client/view/fancyBox/source/fancybox_sprite.png similarity index 100% rename from lib/client/viewer/fancyBox/source/fancybox_sprite.png rename to lib/client/view/fancyBox/source/fancybox_sprite.png diff --git a/lib/client/viewer/fancyBox/source/helpers/fancybox_buttons.png b/lib/client/view/fancyBox/source/helpers/fancybox_buttons.png similarity index 100% rename from lib/client/viewer/fancyBox/source/helpers/fancybox_buttons.png rename to lib/client/view/fancyBox/source/helpers/fancybox_buttons.png diff --git a/lib/client/viewer/fancyBox/source/helpers/jquery.fancybox-buttons.css b/lib/client/view/fancyBox/source/helpers/jquery.fancybox-buttons.css similarity index 100% rename from lib/client/viewer/fancyBox/source/helpers/jquery.fancybox-buttons.css rename to lib/client/view/fancyBox/source/helpers/jquery.fancybox-buttons.css diff --git a/lib/client/viewer/fancyBox/source/helpers/jquery.fancybox-buttons.js b/lib/client/view/fancyBox/source/helpers/jquery.fancybox-buttons.js similarity index 100% rename from lib/client/viewer/fancyBox/source/helpers/jquery.fancybox-buttons.js rename to lib/client/view/fancyBox/source/helpers/jquery.fancybox-buttons.js diff --git a/lib/client/viewer/fancyBox/source/helpers/jquery.fancybox-media.js b/lib/client/view/fancyBox/source/helpers/jquery.fancybox-media.js similarity index 100% rename from lib/client/viewer/fancyBox/source/helpers/jquery.fancybox-media.js rename to lib/client/view/fancyBox/source/helpers/jquery.fancybox-media.js diff --git a/lib/client/viewer/fancyBox/source/helpers/jquery.fancybox-thumbs.css b/lib/client/view/fancyBox/source/helpers/jquery.fancybox-thumbs.css similarity index 100% rename from lib/client/viewer/fancyBox/source/helpers/jquery.fancybox-thumbs.css rename to lib/client/view/fancyBox/source/helpers/jquery.fancybox-thumbs.css diff --git a/lib/client/viewer/fancyBox/source/helpers/jquery.fancybox-thumbs.js b/lib/client/view/fancyBox/source/helpers/jquery.fancybox-thumbs.js similarity index 100% rename from lib/client/viewer/fancyBox/source/helpers/jquery.fancybox-thumbs.js rename to lib/client/view/fancyBox/source/helpers/jquery.fancybox-thumbs.js diff --git a/lib/client/viewer/fancyBox/source/jquery.fancybox.css b/lib/client/view/fancyBox/source/jquery.fancybox.css similarity index 100% rename from lib/client/viewer/fancyBox/source/jquery.fancybox.css rename to lib/client/view/fancyBox/source/jquery.fancybox.css diff --git a/lib/client/viewer/fancyBox/source/jquery.fancybox.js b/lib/client/view/fancyBox/source/jquery.fancybox.js similarity index 100% rename from lib/client/viewer/fancyBox/source/jquery.fancybox.js rename to lib/client/view/fancyBox/source/jquery.fancybox.js diff --git a/lib/client/viewer/fancyBox/source/jquery.fancybox.pack.js b/lib/client/view/fancyBox/source/jquery.fancybox.pack.js similarity index 100% rename from lib/client/viewer/fancyBox/source/jquery.fancybox.pack.js rename to lib/client/view/fancyBox/source/jquery.fancybox.pack.js From b4ee751730a99183436b699b1726d07fce44d20e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 3 Jun 2013 10:56:30 -0400 Subject: [PATCH 050/239] fixed editor path --- lib/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index 8b65feb5..7d1003c4 100644 --- a/lib/client.js +++ b/lib/client.js @@ -179,7 +179,7 @@ var Util, DOM, CloudFunc, CloudCmd; lShowLoadFunc = Util.retFunc( DOM.Images.showLoad ), lDoBefore = { - 'editor/_codemirror' : lShowLoadFunc, + 'edit/_codemirror' : lShowLoadFunc, 'view' : lShowLoadFunc }, From 1fa39b2389f9fad0fcc0adf3ccb79617f397b7f0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 3 Jun 2013 11:01:45 -0400 Subject: [PATCH 051/239] minor changes --- lib/client.js | 4 ++-- lib/client/view.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/client.js b/lib/client.js index 7d1003c4..5d35d1ee 100644 --- a/lib/client.js +++ b/lib/client.js @@ -221,8 +221,8 @@ var Util, DOM, CloudFunc, CloudCmd; null, null, /* f1 */ DOM.renameCurrent, /* f2 */ - CloudCmd.Viewer, /* f3 */ - CloudCmd.Editor, /* f4 */ + CloudCmd.View, /* f3 */ + CloudCmd.Edit, /* f4 */ DOM.copyCurrent, /* f5 */ DOM.moveCurrent, /* f6 */ DOM.promptNewDir, /* f7 */ diff --git a/lib/client/view.js b/lib/client/view.js index fd1aa546..d8bfd558 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -36,7 +36,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; padding : 0 }; - CloudCmd.Viewer = { + CloudCmd.View = { get: function(){ return this.FancyBox; } @@ -49,7 +49,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; */ FancyBox.load = function(pCallBack){ Util.time('fancybox load'); - var lDir = CloudCmd.LIBDIRCLIENT + 'viewer/fancyBox/source/', + var lDir = CloudCmd.LIBDIRCLIENT + 'view/fancyBox/source/', lFiles = [ lDir + 'jquery.fancybox.css', lDir + 'jquery.fancybox.js' ]; @@ -115,7 +115,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; Util.exec(pCallBack); }; - CloudCmd.Viewer.init = function(pCallBack){ + CloudCmd.View.init = function(pCallBack){ Util.loadOnLoad([ pCallBack, FancyBox.show, @@ -153,6 +153,6 @@ var CloudCmd, Util, DOM, CloudFunc, $; } }; - CloudCmd.Viewer.FancyBox = FancyBox; + CloudCmd.View.FancyBox = FancyBox; })(CloudCmd, Util, DOM, CloudFunc); From ef1ab0ef86a1b5ea9934dc8025ca2adbc9c3cf66 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 4 Jun 2013 07:34:28 -0400 Subject: [PATCH 052/239] refactored --- json/modules.json | 4 ++-- lib/client.js | 22 ++++++++------------- lib/client/edit/_codemirror.js | 36 +++++++++++++++++----------------- lib/client/key.js | 4 ++-- lib/client/menu.js | 9 ++++----- 5 files changed, 34 insertions(+), 41 deletions(-) diff --git a/json/modules.json b/json/modules.json index 28b5e6db..8ea623b7 100644 --- a/json/modules.json +++ b/json/modules.json @@ -1,7 +1,7 @@ [ - "editor/_codemirror", + "edit/_codemirror", "menu", - "viewer", + "view", "terminal", { "name": "storage", "data": [{ diff --git a/lib/client.js b/lib/client.js index 5d35d1ee..d53d8a1c 100644 --- a/lib/client.js +++ b/lib/client.js @@ -11,16 +11,12 @@ var Util, DOM, CloudFunc, CloudCmd; Events = DOM.Events, Cache = DOM.Cache; - /* Клиентский обьект, содержащий функциональную часть*/ CloudCmd = { - /* КОНСТАНТЫ*/ LIBDIR : '/lib/', LIBDIRCLIENT : '/lib/client/', JSONDIR : '/json/', HTMLDIR : '/html/', - /* height of Cloud Commander - * seting up in init() - */ + /* height of Cloud Commander seting up in */ HEIGHT : 0, MIN_ONE_PANEL_WIDTH : 1155, OLD_BROWSER : false, @@ -175,12 +171,12 @@ var Util, DOM, CloudFunc, CloudCmd; CloudCmd.Menu.ENABLED || DOM.preventDefault(pEvent); }, document); - var lStorage = 'storage', + var i, n, lStorage = 'storage', lShowLoadFunc = Util.retFunc( DOM.Images.showLoad ), lDoBefore = { - 'edit/_codemirror' : lShowLoadFunc, - 'view' : lShowLoadFunc + 'edit/_codemirror' : lShowLoadFunc, + 'view' : lShowLoadFunc }, lLoad = function(pName, pPath, pDoBefore){ @@ -191,7 +187,7 @@ var Util, DOM, CloudFunc, CloudCmd; }); }; - for(var i = 0, n = pModules.length; i < n ; i++){ + for(i = 0, n = pModules.length; i < n ; i++){ var lModule = pModules[i]; if( Util.isString(lModule) ) @@ -624,7 +620,7 @@ var Util, DOM, CloudFunc, CloudCmd; size : 'dir' }], - lLI = lLeft.getElementsByTagName('li'), + lLI = DOM.getByTag('li', lLeft), i, n, j = 1; /* счётчик реальных файлов */ /* счётчик элементов файлов в DOM @@ -638,9 +634,7 @@ var Util, DOM, CloudFunc, CloudCmd; var lCurrent = lLI[i], lName = DOM.getCurrentName(lCurrent), lSize = DOM.getCurrentSize(lCurrent), - /* переводим права доступа в цыфровой вид - * для хранения в localStorage - */ + lMode = DOM.getCurrentMode(lCurrent); lMode = CloudFunc.getNumericPermissions(lMode); @@ -652,7 +646,7 @@ var Util, DOM, CloudFunc, CloudCmd; }; } return Util.stringifyJSON(lFileTable); - }; + } Events.addOneTime('load', function(){ /* базовая инициализация*/ diff --git a/lib/client/edit/_codemirror.js b/lib/client/edit/_codemirror.js index 53c9afab..d433c441 100644 --- a/lib/client/edit/_codemirror.js +++ b/lib/client/edit/_codemirror.js @@ -3,17 +3,17 @@ var CloudCmd, Util, DOM, CodeMirror; (function(CloudCmd, Util, DOM){ 'use strict'; - var Key = CloudCmd.Key, - Editor = {}, + var Key = CloudCmd.Key, + Edit = {}, FM, Element, - CodeMirrorLoaded = false, - Loading = false, - ReadOnly = false, + Loaded = false, + Loading = false, + ReadOnly = false, CallBacks = [ hide, - initCodeMirror, + init, show, load ]; @@ -41,7 +41,7 @@ var CloudCmd, Util, DOM, CodeMirror; * function initialize CodeMirror * @param {value, callback} */ - function initCodeMirror(pParams){ + function init(pParams){ if(!FM) FM = DOM.getFM(); @@ -56,7 +56,7 @@ var CloudCmd, Util, DOM, CodeMirror; parent : FM }); - var lEditor = Editor.CodeMirror = new CodeMirror(Element, { + var lEditor = Edit.CodeMirror = new CodeMirror(Element, { mode : 'javascript', value : pParams && pParams.data && pParams.data.data, theme : 'night', @@ -87,7 +87,7 @@ var CloudCmd, Util, DOM, CodeMirror; */ function load(pCallBack){ Util.time('codemirror load'); - var lDir = CloudCmd.LIBDIRCLIENT + 'editor/codemirror/', + var lDir = CloudCmd.LIBDIRCLIENT + 'edit/codemirror/', lFiles = [ [ @@ -101,7 +101,7 @@ var CloudCmd, Util, DOM, CodeMirror; DOM.anyLoadOnLoad(lFiles, function(){ Util.timeEnd('codemirror load'); - CodeMirrorLoaded = true; + Loaded = true; Util.exec(pCallBack); }); } @@ -156,7 +156,7 @@ var CloudCmd, Util, DOM, CodeMirror; /** * function calls all CodeMirror editor functions */ - Editor.show = function(){ + Edit.show = function(){ DOM.Images.showLoad(); Util.loadOnLoad( CallBacks ); }; @@ -164,18 +164,18 @@ var CloudCmd, Util, DOM, CodeMirror; /** * function hides CodeMirror editor */ - Editor.hide = hide; + Edit.hide = hide; /** * function bind keys */ - CloudCmd.Editor.init = function(){ - Editor.show(); + CloudCmd.Edit.init = function(){ + Edit.show(); CallBacks.pop(); /* добавляем обработчик клавишь */ DOM.Events.addKey(lListener); - DOM.setButtonKey('f4', Editor.show); + DOM.setButtonKey('f4', Edit.show); function lListener(pEvent){ var lIsBind = Key.isBind(); @@ -185,11 +185,11 @@ var CloudCmd, Util, DOM, CodeMirror; lKey = pEvent.keyCode; if(lKey === lF4) - Editor.show(); + Edit.show(); } } + + CloudCmd.Edit = Edit; }; - - CloudCmd.Editor.CodeMirror = Editor; })(CloudCmd, Util, DOM); diff --git a/lib/client/key.js b/lib/client/key.js index f12b5eb3..bb09a819 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -128,13 +128,13 @@ var CloudCmd, Util, DOM; break; case Key.F3: - Util.exec(CloudCmd.Viewer); + Util.exec(CloudCmd.View); DOM.preventDefault(pEvent); break; case Key.F4: DOM.Images.showLoad(); - Util.exec(CloudCmd.Editor); + Util.exec(CloudCmd.Edit); DOM.preventDefault(pEvent); break; diff --git a/lib/client/menu.js b/lib/client/menu.js index a202363f..03e90d6b 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -23,13 +23,12 @@ var CloudCmd, Util, DOM, CloudFunc, $; */ function showEditor(pReadOnly){ DOM.Images.showLoad(); - var lEditor = CloudCmd[pReadOnly ? 'Viewer' : 'Editor'], - lResult = Util.exec(lEditor, pReadOnly); + + var lEditor = CloudCmd[pReadOnly ? 'View' : 'Edit'], + lResult = Util.exec(lEditor); if(!lResult){ - lEditor = lEditor.get(); - if(lEditor) - Util.exec(lEditor.show); + Util.exec(lEditor.show); } } From b767b005ea1c423b0a5d9fef1b46cf6f3911d45e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 5 Jun 2013 07:23:02 -0400 Subject: [PATCH 053/239] minor changes --- json/config.json | 2 +- lib/client.js | 2 - lib/client/edit/_codemirror.js | 337 +++++++++++++++++---------------- lib/client/key.js | 10 +- 4 files changed, 178 insertions(+), 173 deletions(-) diff --git a/json/config.json b/json/config.json index ca98c321..de652952 100644 --- a/json/config.json +++ b/json/config.json @@ -4,7 +4,7 @@ "minification" : { "js" : false, "css" : false, - "html" : true, + "html" : false, "img" : true }, "cache" : true, diff --git a/lib/client.js b/lib/client.js index d53d8a1c..ce7f490f 100644 --- a/lib/client.js +++ b/lib/client.js @@ -16,7 +16,6 @@ var Util, DOM, CloudFunc, CloudCmd; LIBDIRCLIENT : '/lib/client/', JSONDIR : '/json/', HTMLDIR : '/html/', - /* height of Cloud Commander seting up in */ HEIGHT : 0, MIN_ONE_PANEL_WIDTH : 1155, OLD_BROWSER : false, @@ -519,7 +518,6 @@ var Util, DOM, CloudFunc, CloudCmd; var lJSON = Cache.get(lCleanPath); if (lJSON){ - /* переводим из текста в JSON */ lJSON = Util.parseJSON(lJSON); createFileTable(lPanel, lJSON); } diff --git a/lib/client/edit/_codemirror.js b/lib/client/edit/_codemirror.js index d433c441..ecc3c91f 100644 --- a/lib/client/edit/_codemirror.js +++ b/lib/client/edit/_codemirror.js @@ -3,180 +3,47 @@ var CloudCmd, Util, DOM, CodeMirror; (function(CloudCmd, Util, DOM){ 'use strict'; - var Key = CloudCmd.Key, - Edit = {}, - FM, - Element, - Loaded = false, - Loading = false, - ReadOnly = false, - - CallBacks = [ - hide, - init, - show, - load - ]; + CloudCmd.Edit = new EditProto(CloudCmd, Util, DOM); - function setCSS(){ - var lPosition = DOM.getPanel().id, - lRet = DOM.cssSet({ - id : 'editor-css', - inner : '.CodeMirror{' + - 'font-family' + ': \'Droid Sans Mono\';' + - 'font-size' + ': 15px;' + - '}' + - '.CodeMirror-scroll{' + - 'height' + ':' + CloudCmd.HEIGHT + 'px' + - '}' + - '#editor{' + - 'float' + ':' + lPosition + - '}' - }); + function EditProto(CloudCmd, Util, DOM){ + var Key = CloudCmd.Key, + Edit = this, + FM, + Element, + Loaded = false, + Loading = false, + ReadOnly = false, + + CallBacks = [ + hide, + init, + _show, + load + ]; - return lRet; - } - - /** - * function initialize CodeMirror - * @param {value, callback} - */ - function init(pParams){ - if(!FM) - FM = DOM.getFM(); - - var lCSS = setCSS(), - lCurrent = DOM.getCurrentFile(), - lPath = DOM.getCurrentPath( lCurrent ); - - Element = DOM.anyload({ - name : 'div', - id : 'editor', - className : 'panel', - parent : FM - }); - - var lEditor = Edit.CodeMirror = new CodeMirror(Element, { - mode : 'javascript', - value : pParams && pParams.data && pParams.data.data, - theme : 'night', - lineNumbers : true, - lineWrapping: false, - autofocus : true, - extraKeys: { - /* Exit */ - 'Esc': function(){ - Util.exec(pParams); - DOM.remove(lCSS, document.head); - }, - - /* Save */ - 'Ctrl-S': function(){ - var lValue = lEditor.getValue(); - - DOM.setCurrentSize( lValue.length, lCurrent ); - DOM.RESTfull.save( lPath, lValue ); - } - }, - readOnly : ReadOnly - }); - } - - /** - * function loads CodeMirror js and css files - */ - function load(pCallBack){ - Util.time('codemirror load'); - var lDir = CloudCmd.LIBDIRCLIENT + 'edit/codemirror/', - lFiles = - [ - [ - lDir + 'codemirror.css', - lDir + 'theme/night.css', - lDir + 'mode/javascript.js', - ], - - lDir + 'codemirror.js' - ]; - - DOM.anyLoadOnLoad(lFiles, function(){ - Util.timeEnd('codemirror load'); - Loaded = true; - Util.exec(pCallBack); - }); - } - - /** - * function shows CodeMirror editor - */ - function show(pCallBack){ - - /* if CodeMirror function show already - * called do not call it again - * if f4 key pressed couple times + /** + * function calls all CodeMirror editor functions */ - if(!Loading){ - /* checking is this link is to directory - * when folder view is no need to edit data */ - ReadOnly = DOM.isCurrentIsDir(); - - Loading = true; - - setTimeout(lFalseLoading, 400); - - DOM.getCurrentData({ - error : lFalseLoading, - success : function(data){ - if( DOM.hidePanel() ){ - Util.exec(pCallBack, data); - Key.unsetBind(); - } - - DOM.Images.hideLoad(); - lFalseLoading(); - } - }); - } + this.show = show; + /** + * function hides CodeMirror editor + */ + this.hide = hide; - function lFalseLoading(){ Loading = false; } - } - - /** - * function hides CodeMirror editor - */ - function hide() { - Key.setBind(); + /** + * function bind keys + */ + this.init = function(){ + CloudCmd.Edit = Edit; + }; - if(Element && FM) - FM.removeChild(Element); - - DOM.showPanel(); - } - - /** - * function calls all CodeMirror editor functions - */ - Edit.show = function(){ - DOM.Images.showLoad(); - Util.loadOnLoad( CallBacks ); - }; - - /** - * function hides CodeMirror editor - */ - Edit.hide = hide; - - /** - * function bind keys - */ - CloudCmd.Edit.init = function(){ - Edit.show(); + show(); CallBacks.pop(); /* добавляем обработчик клавишь */ DOM.Events.addKey(lListener); DOM.setButtonKey('f4', Edit.show); - + function lListener(pEvent){ var lIsBind = Key.isBind(); @@ -189,7 +56,145 @@ var CloudCmd, Util, DOM, CodeMirror; } } - CloudCmd.Edit = Edit; - }; + function setCSS(){ + var lPosition = DOM.getPanel().id, + lRet = DOM.cssSet({ + id : 'edit-css', + inner : '.CodeMirror{' + + 'font-family' + ': \'Droid Sans Mono\';' + + 'font-size' + ': 15px;' + + '}' + + '.CodeMirror-scroll{' + + 'height' + ':' + CloudCmd.HEIGHT + 'px' + + '}' + + '#edit{' + + 'float' + ':' + lPosition + + '}' + }); + + return lRet; + } + + /** + * function initialize CodeMirror + * @param {value, callback} + */ + function init(pParams){ + if(!FM) + FM = DOM.getFM(); + + var lCSS = setCSS(), + lCurrent = DOM.getCurrentFile(), + lPath = DOM.getCurrentPath( lCurrent ); + + Element = DOM.anyload({ + name : 'div', + id : 'edit', + className : 'panel', + parent : FM + }); + + var lEdit = Edit.CodeMirror = new CodeMirror(Element, { + mode : 'javascript', + value : pParams && pParams.data && pParams.data.data, + theme : 'night', + lineNumbers : true, + lineWrapping: false, + autofocus : true, + extraKeys: { + /* Exit */ + 'Esc': function(){ + Util.exec(pParams); + DOM.remove(lCSS, document.head); + }, + + /* Save */ + 'Ctrl-S': function(){ + var lValue = lEdit.getValue(); + + DOM.setCurrentSize( lValue.length, lCurrent ); + DOM.RESTfull.save( lPath, lValue ); + } + }, + readOnly : ReadOnly + }); + } + + /** + * function loads CodeMirror js and css files + */ + function load(pCallBack){ + Util.time('codemirror load'); + var lDir = CloudCmd.LIBDIRCLIENT + 'edit/codemirror/', + lFiles = + [ + [ + lDir + 'codemirror.css', + lDir + 'theme/night.css', + lDir + 'mode/javascript.js', + ], + + lDir + 'codemirror.js' + ]; + + DOM.anyLoadOnLoad(lFiles, function(){ + Util.timeEnd('codemirror load'); + Loaded = true; + Util.exec(pCallBack); + }); + } + + /** + * function shows CodeMirror editor + */ + function _show(pCallBack){ + + /* if CodeMirror function show already + * called do not call it again + * if f4 key pressed couple times + */ + if(!Loading){ + /* checking is this link is to directory + * when folder view is no need to edit data */ + ReadOnly = DOM.isCurrentIsDir(); + + Loading = true; + + setTimeout(lFalseLoading, 400); + + DOM.getCurrentData({ + error : lFalseLoading, + success : function(data){ + if( DOM.hidePanel() ){ + Util.exec(pCallBack, data); + Key.unsetBind(); + } + + DOM.Images.hideLoad(); + lFalseLoading(); + } + }); + } + + function lFalseLoading(){ Loading = false; } + } + + function show() { + DOM.Images.showLoad(); + Util.loadOnLoad( CallBacks ); + } + + /** + * function hides CodeMirror editor + */ + function hide() { + Key.setBind(); + + if(Element && FM) + FM.removeChild(Element); + + DOM.showPanel(); + } + } })(CloudCmd, Util, DOM); diff --git a/lib/client/key.js b/lib/client/key.js index bb09a819..4262bd7f 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -44,9 +44,9 @@ var CloudCmd, Util, DOM; }; KeyProto.prototype = KEY; - CloudCmd.Key = new KeyProto(); + CloudCmd.Key = new KeyProto(CloudCmd, Util, DOM); - function KeyProto(){ + function KeyProto(CloudCmd, Util, DOM){ var Key = this, Binded, lTabPanel = { @@ -284,11 +284,13 @@ var CloudCmd, Util, DOM; break; - /* обновляем страницу, + /* + * обновляем страницу, * загружаем содержимое каталога * при этом данные берём всегда с * сервера, а не из кэша - * (обновляем кэш)*/ + * (обновляем кэш) + */ case Key.R: if(lCtrl){ Util.log('+r pressed\n' + From fb0aa4d55ccd5dbdb8407da218c0dc02a2fcfbe6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 5 Jun 2013 11:17:52 -0400 Subject: [PATCH 054/239] refactored --- lib/client/edit/_codemirror.js | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/lib/client/edit/_codemirror.js b/lib/client/edit/_codemirror.js index ecc3c91f..1b411c08 100644 --- a/lib/client/edit/_codemirror.js +++ b/lib/client/edit/_codemirror.js @@ -17,34 +17,31 @@ var CloudCmd, Util, DOM, CodeMirror; CallBacks = [ hide, init, - _show, + show, load ]; /** * function calls all CodeMirror editor functions */ - this.show = show; + this.show = function(){ + DOM.Images.showLoad(); + Util.loadOnLoad( CallBacks ); + }; /** * function hides CodeMirror editor */ this.hide = hide; - /** - * function bind keys - */ this.init = function(){ - CloudCmd.Edit = Edit; + Edit.show(); + CallBacks.pop(); + + DOM.Events.addKey(listener); + DOM.setButtonKey('f4', Edit.show); }; - - show(); - CallBacks.pop(); - - /* добавляем обработчик клавишь */ - DOM.Events.addKey(lListener); - DOM.setButtonKey('f4', Edit.show); - function lListener(pEvent){ + function listener(pEvent){ var lIsBind = Key.isBind(); if (lIsBind) { @@ -147,7 +144,7 @@ var CloudCmd, Util, DOM, CodeMirror; /** * function shows CodeMirror editor */ - function _show(pCallBack){ + function show(pCallBack){ /* if CodeMirror function show already * called do not call it again @@ -179,11 +176,6 @@ var CloudCmd, Util, DOM, CodeMirror; function lFalseLoading(){ Loading = false; } } - function show() { - DOM.Images.showLoad(); - Util.loadOnLoad( CallBacks ); - } - /** * function hides CodeMirror editor */ From bb8013c818833b9416ccb5786c03be69060fea7f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 5 Jun 2013 11:19:04 -0400 Subject: [PATCH 055/239] added hide method to view module --- ChangeLog | 4 + lib/client/view.js | 249 ++++++++++++++++++++++----------------------- 2 files changed, 127 insertions(+), 126 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96b4eae6..bd9889d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -46,6 +46,10 @@ getJSONfromFileTable. * Simpified plugins id's. +* Rewrited _codemirror and view modules with prototypes. + +* Added hide method to view module. + 2012.04.22, v0.2.0 diff --git a/lib/client/view.js b/lib/client/view.js index d8bfd558..94d0979e 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -1,137 +1,136 @@ var CloudCmd, Util, DOM, CloudFunc, $; -/* object contains viewer FancyBox - * https://github.com/fancyapps/fancyBox - */ + (function(CloudCmd, Util, DOM, CloudFunc){ 'use strict'; - var Key = CloudCmd.Key, - FancyBox = {}, + CloudCmd.View = new ViewProto(CloudCmd, Util, DOM, CloudFunc); - Config = { - beforeShow : function(){ - DOM.Images.hideLoad(); - Key.unsetBind(); - }, + function ViewProto(CloudCmd, Util, DOM, CloudFunc){ + var Key = CloudCmd.Key, + FancyBox = this, - afterShow : function(){ - var lEditor = DOM.getById('View'); - if(lEditor) - lEditor.focus(); - }, - - beforeClose : Util.retFunc( Key.setBind ), - - openEffect : 'none', - closeEffect : 'none', - autoSize : false, - height : window.innerHeight, - helpers : { - overlay : { - css : { - 'background' : 'rgba(255, 255, 255, 0.1)' - } - } - }, - padding : 0 - }; - - CloudCmd.View = { - get: function(){ - return this.FancyBox; - } - }; - - /** - * function loads css and js of FancyBox - * @pParent - this - * @pCallBack - executes, when everything loaded - */ - FancyBox.load = function(pCallBack){ - Util.time('fancybox load'); - var lDir = CloudCmd.LIBDIRCLIENT + 'view/fancyBox/source/', - lFiles = [ lDir + 'jquery.fancybox.css', - lDir + 'jquery.fancybox.js' ]; - - DOM.anyLoadOnLoad([lFiles], function(){ - Util.timeEnd('fancybox load'); - Util.exec( pCallBack ); - }) - .cssSet({id:'view-css', - inner : '#view{' + - 'font-size: 16px;' + - 'white-space :pre' + - '}' + - '#view::selection{' + - /* - 'background: #fe57a1;' - 'color: #fff;' - */ - 'background: #b3d4fc;' + - 'text-shadow: none;' + - '}' - }); - - }; - - - FancyBox.showHelp = function(){ - DOM.Images.showLoad(); - DOM.ajax({ - url: '/README.md', - success: function (pData){ - var lData = {text: pData}; - DOM.ajax({ - method : 'post', - url : 'https://api.github.com/markdown', - data : Util.stringifyJSON(lData), - success:function(pResult){ - DOM.Images.hideLoad(); - $.fancybox(pResult, Config); - }, + Config = { + beforeShow : function(){ + DOM.Images.hideLoad(); + Key.unsetBind(); + }, - error: DOM.Images.showError - }); - }, + afterShow : function(){ + var lEditor = DOM.getById('View'); + if(lEditor) + lEditor.focus(); + }, + + beforeClose : Util.retFunc( Key.setBind ), + + openEffect : 'none', + closeEffect : 'none', + autoSize : false, + height : window.innerHeight, + helpers : { + overlay : { + css : { + 'background' : 'rgba(255, 255, 255, 0.1)' + } + } + }, + padding : 0 + }; + + this.init = function(pCallBack){ + Util.loadOnLoad([ + pCallBack, + FancyBox.show, + load, + DOM.jqueryLoad + ]); - error:DOM.Images.showError - }); - }; - - /** - * function shows FancyBox - */ - FancyBox.show = function(pCallBack){ - var lPath = CloudFunc.FS + DOM.getCurrentPath(); + DOM.Events.addKey(listener); + DOM.setButtonKey('f3', view); + }; - if( Util.checkExtension(lPath, ['png','jpg', 'gif','ico']) ) - $.fancybox.open({ href : lPath }, Config); - else - DOM.getCurrentData(function(pParams){ - $.fancybox('
' + - pParams.data + '
', Config); - }); - - Util.exec(pCallBack); - }; - - CloudCmd.View.init = function(pCallBack){ - Util.loadOnLoad([ - pCallBack, - FancyBox.show, - FancyBox.load, - DOM.jqueryLoad - ]); - - DOM.Events.addKey(lListener); - DOM.setButtonKey('f3', lView); - - function lView(){ + this.showHelp = function(){ DOM.Images.showLoad(); - FancyBox.show( DOM.getCurrentFile() ); + DOM.ajax({ + url: '/README.md', + success: function (pData){ + var lData = {text: pData}; + DOM.ajax({ + method : 'post', + url : 'https://api.github.com/markdown', + data : Util.stringifyJSON(lData), + success:function(pResult){ + DOM.Images.hideLoad(); + $.fancybox(pResult, Config); + }, + + error: DOM.Images.showError + }); + }, + + error:DOM.Images.showError + }); + }; + + /** + * function shows FancyBox + */ + this.show = function(pCallBack){ + var lPath = CloudFunc.FS + DOM.getCurrentPath(); + + if( Util.checkExtension(lPath, ['png','jpg', 'gif','ico']) ) + $.fancybox.open({ href : lPath }, Config); + else + DOM.getCurrentData(function(pParams){ + $.fancybox('
' + + pParams.data + '
', Config); + }); + + Util.exec(pCallBack); + }; + + this.hide = function(){ + $.fancybox.close(); + }; + + /** + * function loads css and js of FancyBox + * @pParent - this + * @pCallBack - executes, when everything loaded + */ + function load(pCallBack){ + Util.time('fancybox load'); + var lDir = CloudCmd.LIBDIRCLIENT + 'view/fancyBox/source/', + lFiles = [ lDir + 'jquery.fancybox.css', + lDir + 'jquery.fancybox.js' ]; + + DOM.anyLoadOnLoad([lFiles], function(){ + Util.timeEnd('fancybox load'); + Util.exec( pCallBack ); + }) + .cssSet({id:'view-css', + inner : '#view{' + + 'font-size: 16px;' + + 'white-space :pre' + + '}' + + '#view::selection{' + + /* + 'background: #fe57a1;' + 'color: #fff;' + */ + 'background: #b3d4fc;' + + 'text-shadow: none;' + + '}' + }); + } - function lListener(pEvent){ + function view(){ + DOM.Images.showLoad(); + FancyBox.show( DOM.getCurrentFile() ); + } + + function listener(pEvent){ var lF3 = Key.F3, lF1 = Key.F1, lIsBind = Key.isBind(), @@ -141,7 +140,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; if (lIsBind) { switch(lKey){ case lF3: - lView(); + view(); DOM.preventDefault(pEvent); break; @@ -151,8 +150,6 @@ var CloudCmd, Util, DOM, CloudFunc, $; } } } - }; - - CloudCmd.View.FancyBox = FancyBox; + } })(CloudCmd, Util, DOM, CloudFunc); From a6fe50db9c5d71d6020608ae130fd9be2596ba0f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 6 Jun 2013 11:32:29 -0400 Subject: [PATCH 056/239] minor changes --- lib/client/edit/_codemirror.js | 16 +++++++--------- lib/client/view.js | 8 ++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/client/edit/_codemirror.js b/lib/client/edit/_codemirror.js index 1b411c08..80cf34cc 100644 --- a/lib/client/edit/_codemirror.js +++ b/lib/client/edit/_codemirror.js @@ -10,7 +10,6 @@ var CloudCmd, Util, DOM, CodeMirror; Edit = this, FM, Element, - Loaded = false, Loading = false, ReadOnly = false, @@ -24,10 +23,10 @@ var CloudCmd, Util, DOM, CodeMirror; /** * function calls all CodeMirror editor functions */ - this.show = function(){ + this.show = function(){ DOM.Images.showLoad(); Util.loadOnLoad( CallBacks ); - }; + }; /** * function hides CodeMirror editor */ @@ -40,13 +39,13 @@ var CloudCmd, Util, DOM, CodeMirror; DOM.Events.addKey(listener); DOM.setButtonKey('f4', Edit.show); }; - + function listener(pEvent){ - var lIsBind = Key.isBind(); + var lF4, lKey, lIsBind = Key.isBind(); if (lIsBind) { - var lF4 = Key.F4, - lKey = pEvent.keyCode; + lF4 = Key.F4, + lKey = pEvent.keyCode; if(lKey === lF4) Edit.show(); @@ -54,7 +53,7 @@ var CloudCmd, Util, DOM, CodeMirror; } function setCSS(){ - var lPosition = DOM.getPanel().id, + var lPosition = DOM.getPanel().id, lRet = DOM.cssSet({ id : 'edit-css', inner : '.CodeMirror{' + @@ -136,7 +135,6 @@ var CloudCmd, Util, DOM, CodeMirror; DOM.anyLoadOnLoad(lFiles, function(){ Util.timeEnd('codemirror load'); - Loaded = true; Util.exec(pCallBack); }); } diff --git a/lib/client/view.js b/lib/client/view.js index 94d0979e..0303da1d 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -126,10 +126,10 @@ var CloudCmd, Util, DOM, CloudFunc, $; } function view(){ - DOM.Images.showLoad(); - FancyBox.show( DOM.getCurrentFile() ); - } - + DOM.Images.showLoad(); + FancyBox.show( DOM.getCurrentFile() ); + } + function listener(pEvent){ var lF3 = Key.F3, lF1 = Key.F1, From 39db3022ddfa100ed32f261e920dd48cdb601b30 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 10 Jun 2013 04:52:01 -0400 Subject: [PATCH 057/239] Util.retFunc( Key.setBind ) -> Key.setBind --- lib/client/view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/view.js b/lib/client/view.js index 0303da1d..610b49ea 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -21,7 +21,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; lEditor.focus(); }, - beforeClose : Util.retFunc( Key.setBind ), + beforeClose : Key.setBind, openEffect : 'none', closeEffect : 'none', From fa56259a78eb91e8379364acd2947b74669427c5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 10 Jun 2013 06:15:34 -0400 Subject: [PATCH 058/239] updated socket.io to v0.9.16 --- ChangeLog | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bd9889d7..0b300551 100644 --- a/ChangeLog +++ b/ChangeLog @@ -50,6 +50,8 @@ getJSONfromFileTable. * Added hide method to view module. +* Updated socket.io to v0.9.16. + 2012.04.22, v0.2.0 diff --git a/package.json b/package.json index 31355ad9..55c5650d 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "dependencies": { "dropbox": "0.9.2", "minify": "0.2.0", - "socket.io": "0.9.14" + "socket.io": "0.9.16" }, "devDependencies": {}, "engines": { From d1ef8b723e47372c4e0fac1b0b191ee9674f8f40 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 10 Jun 2013 06:51:06 -0400 Subject: [PATCH 059/239] removed init property from view and edit --- ChangeLog | 2 ++ lib/client/edit/_codemirror.js | 2 ++ lib/client/view.js | 12 +++++++----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b300551..8cda2460 100644 --- a/ChangeLog +++ b/ChangeLog @@ -52,6 +52,8 @@ getJSONfromFileTable. * Updated socket.io to v0.9.16. +* Removed init property from view and edit. + 2012.04.22, v0.2.0 diff --git a/lib/client/edit/_codemirror.js b/lib/client/edit/_codemirror.js index 80cf34cc..1a82e1ea 100644 --- a/lib/client/edit/_codemirror.js +++ b/lib/client/edit/_codemirror.js @@ -38,6 +38,8 @@ var CloudCmd, Util, DOM, CodeMirror; DOM.Events.addKey(listener); DOM.setButtonKey('f4', Edit.show); + + delete Edit.init; }; function listener(pEvent){ diff --git a/lib/client/view.js b/lib/client/view.js index 610b49ea..8fb02e20 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -6,8 +6,8 @@ var CloudCmd, Util, DOM, CloudFunc, $; CloudCmd.View = new ViewProto(CloudCmd, Util, DOM, CloudFunc); function ViewProto(CloudCmd, Util, DOM, CloudFunc){ - var Key = CloudCmd.Key, - FancyBox = this, + var Key = CloudCmd.Key, + View = this, Config = { beforeShow : function(){ @@ -40,13 +40,15 @@ var CloudCmd, Util, DOM, CloudFunc, $; this.init = function(pCallBack){ Util.loadOnLoad([ pCallBack, - FancyBox.show, + View.show, load, DOM.jqueryLoad ]); DOM.Events.addKey(listener); DOM.setButtonKey('f3', view); + + delete View.init; }; this.showHelp = function(){ @@ -127,7 +129,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; function view(){ DOM.Images.showLoad(); - FancyBox.show( DOM.getCurrentFile() ); + View.show( DOM.getCurrentFile() ); } function listener(pEvent){ @@ -145,7 +147,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; break; case lF1: - FancyBox.showHelp(); + View.showHelp(); break; } } From df831c32e7bd7952c95d7785bae8cc2b89a1ac88 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 10 Jun 2013 06:51:50 -0400 Subject: [PATCH 060/239] filePicker gets key from modules.json --- ChangeLog | 2 ++ lib/client/storage/_filepicker.js | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8cda2460..c7760eac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -54,6 +54,8 @@ getJSONfromFileTable. * Removed init property from view and edit. +* FilePicker gets key from modules.json. + 2012.04.22, v0.2.0 diff --git a/lib/client/storage/_filepicker.js b/lib/client/storage/_filepicker.js index d029fc59..c9f1c898 100644 --- a/lib/client/storage/_filepicker.js +++ b/lib/client/storage/_filepicker.js @@ -1,5 +1,4 @@ var CloudCmd, Util, DOM, $, filepicker; -/* module for work with filepicker */ (function(CloudCmd, Util, DOM){ 'use strict'; @@ -43,14 +42,20 @@ var CloudCmd, Util, DOM, $, filepicker; function load(pCallBack){ console.time('filepicker load'); - var lHTTP = "https:"===document.location.protocol? "https:" : "http:"; + var lHTTP = document.location.protocol; DOM.jsload(lHTTP + '//api.filepicker.io/v1/filepicker.js', function(){ - filepicker.setKey('AACq5fTfzRY2E_Rw_4kyaz'); - DOM.Images.hideLoad(); - console.timeEnd('filepicker loaded'); - Util.exec(pCallBack); - }); + CloudCmd.getModules(function(pModules){ + var lStorage = Util.findObjByNameInArr(pModules, 'storage'), + lFilePicker = Util.findObjByNameInArr(lStorage, 'FilePicker'), + lKey = lFilePicker && lFilePicker.key; + + filepicker.setKey(lKey); + DOM.Images.hideLoad(); + console.timeEnd('filepicker loaded'); + Util.exec(pCallBack); + }); + }); } }; From dc9bf4ec91bd54214157043d388114b87abf78e5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 10 Jun 2013 10:48:04 -0400 Subject: [PATCH 061/239] this -> Cmd in Cmd --- lib/client/dom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 86ae760d..1bc64405 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1041,8 +1041,8 @@ var CloudCmd, Util, DOM, CloudFunc; lName = '', lMsgAsk = 'Do you really want to delete the ', lMsgSel = 'selected ', - lFiles = this.getSelectedFiles(), - lSelected = this.getSelectedNames(lFiles), + lFiles = Cmd.getSelectedFiles(), + lSelected = Cmd.getSelectedNames(lFiles), i, n = lSelected && lSelected.length; if (n > 1){ From 3b79ae40fd15a8c912d06568d75382533998fd78 Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Wed, 12 Jun 2013 05:47:05 -0700 Subject: [PATCH 062/239] added ability to put callback to view --- ChangeLog | 2 ++ lib/client/view.js | 52 +++++++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index c7760eac..44c31fc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -56,6 +56,8 @@ getJSONfromFileTable. * FilePicker gets key from modules.json. +* Added ability to put callback to view. + 2012.04.22, v0.2.0 diff --git a/lib/client/view.js b/lib/client/view.js index 8fb02e20..2979d2af 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -7,15 +7,13 @@ var CloudCmd, Util, DOM, CloudFunc, $; function ViewProto(CloudCmd, Util, DOM, CloudFunc){ var Key = CloudCmd.Key, + Images = DOM.Images, View = this, Config = { - beforeShow : function(){ - DOM.Images.hideLoad(); - Key.unsetBind(); - }, + beforeShow : Key.unsetBind, - afterShow : function(){ + afterShow : function(){ var lEditor = DOM.getById('View'); if(lEditor) lEditor.focus(); @@ -39,8 +37,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; this.init = function(pCallBack){ Util.loadOnLoad([ - pCallBack, - View.show, + pCallBack || View.show, load, DOM.jqueryLoad ]); @@ -52,7 +49,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; }; this.showHelp = function(){ - DOM.Images.showLoad(); + Images.showLoad(); DOM.ajax({ url: '/README.md', success: function (pData){ @@ -62,33 +59,39 @@ var CloudCmd, Util, DOM, CloudFunc, $; url : 'https://api.github.com/markdown', data : Util.stringifyJSON(lData), success:function(pResult){ - DOM.Images.hideLoad(); + Images.hideLoad(); $.fancybox(pResult, Config); }, - error: DOM.Images.showError + error: Images.showError }); }, - error:DOM.Images.showError + error:Images.showError }); }; /** * function shows FancyBox */ - this.show = function(pCallBack){ - var lPath = CloudFunc.FS + DOM.getCurrentPath(); + this.show = function(pData){ + var lPath; - if( Util.checkExtension(lPath, ['png','jpg', 'gif','ico']) ) - $.fancybox.open({ href : lPath }, Config); - else - DOM.getCurrentData(function(pParams){ - $.fancybox('
' + - pParams.data + '
', Config); - }); - - Util.exec(pCallBack); + if(pData) + $.fancybox('
' + pData + '
', Config); + else { + lPath = CloudFunc.FS + DOM.getCurrentPath(); + if( Util.checkExtension(lPath, ['png','jpg', 'gif','ico']) ) { + Images.hideLoad(); + $.fancybox.open({ href : lPath }, Config); + } + else + DOM.getCurrentData(function(pParams){ + Images.hideLoad(); + $.fancybox('
' + + pParams.data + '
', Config); + }); + } }; this.hide = function(){ @@ -109,6 +112,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.anyLoadOnLoad([lFiles], function(){ Util.timeEnd('fancybox load'); Util.exec( pCallBack ); + Images.hideLoad(); }) .cssSet({id:'view-css', inner : '#view{' + @@ -128,8 +132,8 @@ var CloudCmd, Util, DOM, CloudFunc, $; } function view(){ - DOM.Images.showLoad(); - View.show( DOM.getCurrentFile() ); + Images.showLoad(); + View.show(); } function listener(pEvent){ From ea53592673106dfec13205c0ff6a0f2987ba8a36 Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Wed, 12 Jun 2013 06:23:44 -0700 Subject: [PATCH 063/239] fixed bug with view show --- lib/client/view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/view.js b/lib/client/view.js index 2979d2af..92e36a38 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -37,7 +37,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; this.init = function(pCallBack){ Util.loadOnLoad([ - pCallBack || View.show, + pCallBack || Util.retExec(View.show, null), load, DOM.jqueryLoad ]); From 5b6d353ed5d40a9a389b944a199840b30f2d1d5a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 12 Jun 2013 10:46:25 -0400 Subject: [PATCH 064/239] added help module --- ChangeLog | 2 ++ json/modules.json | 1 + lib/client/view.js | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 44c31fc2..35cde65a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -58,6 +58,8 @@ getJSONfromFileTable. * Added ability to put callback to view. +* Added help module. + 2012.04.22, v0.2.0 diff --git a/json/modules.json b/json/modules.json index 8ea623b7..a37640b7 100644 --- a/json/modules.json +++ b/json/modules.json @@ -2,6 +2,7 @@ "edit/_codemirror", "menu", "view", + "help", "terminal", { "name": "storage", "data": [{ diff --git a/lib/client/view.js b/lib/client/view.js index 92e36a38..0d35e08b 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -36,8 +36,9 @@ var CloudCmd, Util, DOM, CloudFunc, $; }; this.init = function(pCallBack){ + debugger; Util.loadOnLoad([ - pCallBack || Util.retExec(View.show, null), + pCallBack || View.show, load, DOM.jqueryLoad ]); From 9e62551a3490e504c05b113e9c43a1c81c1d4104 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 12 Jun 2013 10:52:39 -0400 Subject: [PATCH 065/239] Revert "added help module" This reverts commit eec5e461f8c427dc7bef692eef136becf1b73a0b. --- ChangeLog | 2 -- json/modules.json | 1 - lib/client/view.js | 3 +-- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 35cde65a..44c31fc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -58,8 +58,6 @@ getJSONfromFileTable. * Added ability to put callback to view. -* Added help module. - 2012.04.22, v0.2.0 diff --git a/json/modules.json b/json/modules.json index a37640b7..8ea623b7 100644 --- a/json/modules.json +++ b/json/modules.json @@ -2,7 +2,6 @@ "edit/_codemirror", "menu", "view", - "help", "terminal", { "name": "storage", "data": [{ diff --git a/lib/client/view.js b/lib/client/view.js index 0d35e08b..92e36a38 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -36,9 +36,8 @@ var CloudCmd, Util, DOM, CloudFunc, $; }; this.init = function(pCallBack){ - debugger; Util.loadOnLoad([ - pCallBack || View.show, + pCallBack || Util.retExec(View.show, null), load, DOM.jqueryLoad ]); From 53d7a0cb7b80a97494c8302edc865a70f1a13d4b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 12 Jun 2013 10:55:06 -0400 Subject: [PATCH 066/239] added help module --- ChangeLog | 2 ++ json/modules.json | 1 + lib/client/help.js | 67 ++++++++++++++++++++++++++++++++++++++++++++++ lib/client/view.js | 3 ++- 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 lib/client/help.js diff --git a/ChangeLog b/ChangeLog index 44c31fc2..35cde65a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -58,6 +58,8 @@ getJSONfromFileTable. * Added ability to put callback to view. +* Added help module. + 2012.04.22, v0.2.0 diff --git a/json/modules.json b/json/modules.json index 8ea623b7..a37640b7 100644 --- a/json/modules.json +++ b/json/modules.json @@ -2,6 +2,7 @@ "edit/_codemirror", "menu", "view", + "help", "terminal", { "name": "storage", "data": [{ diff --git a/lib/client/help.js b/lib/client/help.js new file mode 100644 index 00000000..438c087a --- /dev/null +++ b/lib/client/help.js @@ -0,0 +1,67 @@ +var CloudCmd, Util, DOM; +(function(CloudCmd, Util, DOM){ + 'use strict'; + + CloudCmd.Help = new HelpProto(CloudCmd, Util, DOM); + + function HelpProto(CloudCmd, Util, DOM){ + var Key = CloudCmd.Key, + Images = DOM.Images, + Help = this; + + this.init = function(pCallBack){ + Util.loadOnLoad([ + Help.show, + CloudCmd.View, + ]); + + DOM.Events.addKey(listener); + DOM.setButtonKey('f1', Help.show); + + delete Help.init; + }; + + this.show = function(){ + Images.showLoad(); + DOM.ajax({ + url: '/README.md', + success: function (pData){ + var lData = {text: pData}; + DOM.ajax({ + method : 'post', + url : 'https://api.github.com/markdown', + data : Util.stringifyJSON(lData), + success:function(pResult){ + Images.hideLoad(); + CloudCmd.View.Show(pResult); + }, + + error: Images.showError + }); + }, + + error:Images.showError + }); + }; + + + this.hide = CloudCmd.View.hide; + + function listener(pEvent){ + var lF1 = Key.F1, + lIsBind = Key.isBind(), + lKey = pEvent.keyCode; + + /* если клавиши можно обрабатывать */ + if (lIsBind) { + switch(lKey){ + + case lF1: + Help.show(); + break; + } + } + } + } + +})(CloudCmd, Util, DOM); \ No newline at end of file diff --git a/lib/client/view.js b/lib/client/view.js index 92e36a38..0d35e08b 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -36,8 +36,9 @@ var CloudCmd, Util, DOM, CloudFunc, $; }; this.init = function(pCallBack){ + debugger; Util.loadOnLoad([ - pCallBack || Util.retExec(View.show, null), + pCallBack || View.show, load, DOM.jqueryLoad ]); From 3002819ef387c11b9263144de9373a503366e503 Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Wed, 12 Jun 2013 08:07:58 -0700 Subject: [PATCH 067/239] moved out showHelp function from view to help --- lib/client/help.js | 2 +- lib/client/view.js | 41 ++++------------------------------------- 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/lib/client/help.js b/lib/client/help.js index 438c087a..f26a7001 100644 --- a/lib/client/help.js +++ b/lib/client/help.js @@ -33,7 +33,7 @@ var CloudCmd, Util, DOM; data : Util.stringifyJSON(lData), success:function(pResult){ Images.hideLoad(); - CloudCmd.View.Show(pResult); + CloudCmd.View.show(pResult); }, error: Images.showError diff --git a/lib/client/view.js b/lib/client/view.js index 0d35e08b..da1af750 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -36,9 +36,8 @@ var CloudCmd, Util, DOM, CloudFunc, $; }; this.init = function(pCallBack){ - debugger; Util.loadOnLoad([ - pCallBack || View.show, + pCallBack || Util.retExec(View.show, null), load, DOM.jqueryLoad ]); @@ -49,29 +48,6 @@ var CloudCmd, Util, DOM, CloudFunc, $; delete View.init; }; - this.showHelp = function(){ - Images.showLoad(); - DOM.ajax({ - url: '/README.md', - success: function (pData){ - var lData = {text: pData}; - DOM.ajax({ - method : 'post', - url : 'https://api.github.com/markdown', - data : Util.stringifyJSON(lData), - success:function(pResult){ - Images.hideLoad(); - $.fancybox(pResult, Config); - }, - - error: Images.showError - }); - }, - - error:Images.showError - }); - }; - /** * function shows FancyBox */ @@ -139,22 +115,13 @@ var CloudCmd, Util, DOM, CloudFunc, $; function listener(pEvent){ var lF3 = Key.F3, - lF1 = Key.F1, lIsBind = Key.isBind(), lKey = pEvent.keyCode; /* если клавиши можно обрабатывать */ - if (lIsBind) { - switch(lKey){ - case lF3: - view(); - DOM.preventDefault(pEvent); - break; - - case lF1: - View.showHelp(); - break; - } + if (lIsBind && lKey === lF3) { + view(); + DOM.preventDefault(pEvent); } } } From 5ecf4fccf6a51ce08ada6ad0e5e7ff264c6e6d35 Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Wed, 12 Jun 2013 08:08:08 -0700 Subject: [PATCH 068/239] minor changes --- .../view/fancyBox/source/jquery.fancybox.css | 488 +++++++++--------- 1 file changed, 244 insertions(+), 244 deletions(-) diff --git a/lib/client/view/fancyBox/source/jquery.fancybox.css b/lib/client/view/fancyBox/source/jquery.fancybox.css index b0b9f7e2..cc3c5591 100644 --- a/lib/client/view/fancyBox/source/jquery.fancybox.css +++ b/lib/client/view/fancyBox/source/jquery.fancybox.css @@ -1,245 +1,245 @@ -/*! fancyBox v2.1.4 fancyapps.com | fancyapps.com/fancybox/#license */ -.fancybox-wrap, -.fancybox-skin, -.fancybox-outer, -.fancybox-inner, -.fancybox-image, -.fancybox-wrap iframe, -.fancybox-wrap object, -.fancybox-nav, -.fancybox-nav span, -.fancybox-tmp -{ - padding: 0; - margin: 0; - border: 0; - outline: none; - vertical-align: top; -} - -.fancybox-wrap { - position: absolute; - top: 0; - left: 0; - z-index: 8020; -} - -.fancybox-skin { - position: relative; - background: #f9f9f9; - color: #444; - text-shadow: none; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} - -.fancybox-opened { - z-index: 8030; -} - -.fancybox-opened .fancybox-skin { - -webkit-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); - -moz-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); - box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); -} - -.fancybox-outer, .fancybox-inner { - position: relative; -} - -.fancybox-inner { - overflow: hidden; -} - -.fancybox-error { - color: #444; - font: 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif; - margin: 0; - padding: 15px; - white-space: nowrap; -} - -.fancybox-image, .fancybox-iframe { - display: block; - width: 100%; - height: 100%; -} - -.fancybox-image { - max-width: 100%; - max-height: 100%; -} - -#fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span { - background-image: url('fancybox_sprite.png'); -} - -#fancybox-loading { - position: fixed; - top: 50%; - left: 50%; - margin-top: -22px; - margin-left: -22px; - background-position: 0 -108px; - opacity: 0.8; - cursor: pointer; - z-index: 8060; -} - -#fancybox-loading div { - width: 44px; - height: 44px; - background: url('fancybox_loading.gif') center center no-repeat; -} - -.fancybox-close { - position: absolute; - top: -18px; - right: -18px; - width: 36px; - height: 36px; - cursor: pointer; - z-index: 8040; -} - -.fancybox-nav { - position: absolute; - top: 0; - width: 40%; - height: 100%; - cursor: pointer; - text-decoration: none; - background: transparent url('blank.gif'); /* helps IE */ - -webkit-tap-highlight-color: rgba(0,0,0,0); - z-index: 8040; -} - -.fancybox-prev { - left: 0; -} - -.fancybox-next { - right: 0; -} - -.fancybox-nav span { - position: absolute; - top: 50%; - width: 36px; - height: 34px; - margin-top: -18px; - cursor: pointer; - z-index: 8040; - visibility: hidden; -} - -.fancybox-prev span { - left: 10px; - background-position: 0 -36px; -} - -.fancybox-next span { - right: 10px; - background-position: 0 -72px; -} - -.fancybox-nav:hover span { - visibility: visible; -} - -.fancybox-tmp { - position: absolute; - top: -99999px; - left: -99999px; - visibility: hidden; - max-width: 99999px; - max-height: 99999px; - overflow: visible !important; -} - -/* Overlay helper */ - -.fancybox-lock { - overflow: hidden; -} - -.fancybox-overlay { - position: absolute; - top: 0; - left: 0; - overflow: hidden; - display: none; - z-index: 8010; - background: url('fancybox_overlay.png'); -} - -.fancybox-overlay-fixed { - position: fixed; - bottom: 0; - right: 0; -} - -.fancybox-lock .fancybox-overlay { - overflow: auto; - overflow-y: scroll; -} - -/* Title helper */ - -.fancybox-title { - visibility: hidden; - font: normal 13px/20px "Helvetica Neue",Helvetica,Arial,sans-serif; - position: relative; - text-shadow: none; - z-index: 8050; -} - -.fancybox-opened .fancybox-title { - visibility: visible; -} - -.fancybox-title-float-wrap { - position: absolute; - bottom: 0; - right: 50%; - margin-bottom: -35px; - z-index: 8050; - text-align: center; -} - -.fancybox-title-float-wrap .child { - display: inline-block; - margin-right: -100%; - padding: 2px 20px; - background: transparent; /* Fallback for web browsers that doesn't support RGBa */ - background: rgba(0, 0, 0, 0.8); - -webkit-border-radius: 15px; - -moz-border-radius: 15px; - border-radius: 15px; - text-shadow: 0 1px 2px #222; - color: #FFF; - font-weight: bold; - line-height: 24px; - white-space: nowrap; -} - -.fancybox-title-outside-wrap { - position: relative; - margin-top: 10px; - color: #fff; -} - -.fancybox-title-inside-wrap { - padding-top: 10px; -} - -.fancybox-title-over-wrap { - position: absolute; - bottom: 0; - left: 0; - color: #fff; - padding: 10px; - background: #000; - background: rgba(0, 0, 0, .8); +/*! fancyBox v2.1.4 fancyapps.com | fancyapps.com/fancybox/#license */ +.fancybox-wrap, +.fancybox-skin, +.fancybox-outer, +.fancybox-inner, +.fancybox-image, +.fancybox-wrap iframe, +.fancybox-wrap object, +.fancybox-nav, +.fancybox-nav span, +.fancybox-tmp +{ + padding: 0; + margin: 0; + border: 0; + outline: none; + vertical-align: top; +} + +.fancybox-wrap { + position: absolute; + top: 0; + left: 0; + z-index: 8020; +} + +.fancybox-skin { + position: relative; + background: #f9f9f9; + color: #444; + text-shadow: none; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +.fancybox-opened { + z-index: 8030; +} + +.fancybox-opened .fancybox-skin { + -webkit-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); + -moz-box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); + box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5); +} + +.fancybox-outer, .fancybox-inner { + position: relative; +} + +.fancybox-inner { + overflow: hidden; +} + +.fancybox-error { + color: #444; + font: 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif; + margin: 0; + padding: 15px; + white-space: nowrap; +} + +.fancybox-image, .fancybox-iframe { + display: block; + width: 100%; + height: 100%; +} + +.fancybox-image { + max-width: 100%; + max-height: 100%; +} + +#fancybox-loading, .fancybox-close, .fancybox-prev span, .fancybox-next span { + background-image: url('fancybox_sprite.png'); +} + +#fancybox-loading { + position: fixed; + top: 50%; + left: 50%; + margin-top: -22px; + margin-left: -22px; + background-position: 0 -108px; + opacity: 0.8; + cursor: pointer; + z-index: 8060; +} + +#fancybox-loading div { + width: 44px; + height: 44px; + background: url('fancybox_loading.gif') center center no-repeat; +} + +.fancybox-close { + position: absolute; + top: -18px; + right: -18px; + width: 36px; + height: 36px; + cursor: pointer; + z-index: 8040; +} + +.fancybox-nav { + position: absolute; + top: 0; + width: 40%; + height: 100%; + cursor: pointer; + text-decoration: none; + background: transparent url('blank.gif'); /* helps IE */ + -webkit-tap-highlight-color: rgba(0,0,0,0); + z-index: 8040; +} + +.fancybox-prev { + left: 0; +} + +.fancybox-next { + right: 0; +} + +.fancybox-nav span { + position: absolute; + top: 50%; + width: 36px; + height: 34px; + margin-top: -18px; + cursor: pointer; + z-index: 8040; + visibility: hidden; +} + +.fancybox-prev span { + left: 10px; + background-position: 0 -36px; +} + +.fancybox-next span { + right: 10px; + background-position: 0 -72px; +} + +.fancybox-nav:hover span { + visibility: visible; +} + +.fancybox-tmp { + position: absolute; + top: -99999px; + left: -99999px; + visibility: hidden; + max-width: 99999px; + max-height: 99999px; + overflow: visible !important; +} + +/* Overlay helper */ + +.fancybox-lock { + overflow: hidden; +} + +.fancybox-overlay { + position: absolute; + top: 0; + left: 0; + overflow: hidden; + display: none; + z-index: 8010; + background: url('fancybox_overlay.png'); +} + +.fancybox-overlay-fixed { + position: fixed; + bottom: 0; + right: 0; +} + +.fancybox-lock .fancybox-overlay { + overflow: auto; + overflow-y: scroll; +} + +/* Title helper */ + +.fancybox-title { + visibility: hidden; + font: normal 13px/20px "Helvetica Neue",Helvetica,Arial,sans-serif; + position: relative; + text-shadow: none; + z-index: 8050; +} + +.fancybox-opened .fancybox-title { + visibility: visible; +} + +.fancybox-title-float-wrap { + position: absolute; + bottom: 0; + right: 50%; + margin-bottom: -35px; + z-index: 8050; + text-align: center; +} + +.fancybox-title-float-wrap .child { + display: inline-block; + margin-right: -100%; + padding: 2px 20px; + background: transparent; /* Fallback for web browsers that doesn't support RGBa */ + background: rgba(0, 0, 0, 0.8); + -webkit-border-radius: 15px; + -moz-border-radius: 15px; + border-radius: 15px; + text-shadow: 0 1px 2px #222; + color: #FFF; + font-weight: bold; + line-height: 24px; + white-space: nowrap; +} + +.fancybox-title-outside-wrap { + position: relative; + margin-top: 10px; + color: #fff; +} + +.fancybox-title-inside-wrap { + padding-top: 10px; +} + +.fancybox-title-over-wrap { + position: absolute; + bottom: 0; + left: 0; + color: #fff; + padding: 10px; + background: #000; + background: rgba(0, 0, 0, .8); } \ No newline at end of file From d172696f8877d2232210ee743325d82f11011982 Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Wed, 12 Jun 2013 08:11:17 -0700 Subject: [PATCH 069/239] added ability to show help on F1 --- ChangeLog | 2 ++ lib/client/key.js | 1 + 2 files changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 35cde65a..f64291eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -60,6 +60,8 @@ getJSONfromFileTable. * Added help module. +* Added ability to show help on F1. + 2012.04.22, v0.2.0 diff --git a/lib/client/key.js b/lib/client/key.js index 4262bd7f..6428b2fe 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -120,6 +120,7 @@ var CloudCmd, Util, DOM; break; case Key.F1: + Util.exec(CloudCmd.Help); DOM.preventDefault(pEvent); break; From 46449628e68934e7bc2f8874c15107c5a49592fb Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Thu, 13 Jun 2013 01:27:11 -0700 Subject: [PATCH 070/239] added ability to show help on F1 button click --- lib/client.js | 8 ++++---- lib/client/help.js | 10 ++-------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/client.js b/lib/client.js index ce7f490f..2a03aa8a 100644 --- a/lib/client.js +++ b/lib/client.js @@ -214,10 +214,10 @@ var Util, DOM, CloudFunc, CloudCmd; lFuncs =[ null, - null, /* f1 */ + CloudCmd.Help, /* f1 */ DOM.renameCurrent, /* f2 */ - CloudCmd.View, /* f3 */ - CloudCmd.Edit, /* f4 */ + CloudCmd.View, /* f3 */ + CloudCmd.Edit, /* f4 */ DOM.copyCurrent, /* f5 */ DOM.moveCurrent, /* f6 */ DOM.promptNewDir, /* f7 */ @@ -227,7 +227,7 @@ var Util, DOM, CloudFunc, CloudCmd; for(var i = 1; i <= 8; i++){ var lButton = 'f' + i, lEl = DOM.getById('f' + i); - if( i === 3 || i === 4) + if( i === 1 || i === 3 || i === 4) Events.addOneTime('click', lFuncs[i], lEl); else Events.addClick(lFuncs[i], lEl); diff --git a/lib/client/help.js b/lib/client/help.js index f26a7001..eb27fca8 100644 --- a/lib/client/help.js +++ b/lib/client/help.js @@ -53,14 +53,8 @@ var CloudCmd, Util, DOM; lKey = pEvent.keyCode; /* если клавиши можно обрабатывать */ - if (lIsBind) { - switch(lKey){ - - case lF1: - Help.show(); - break; - } - } + if (lIsBind && lKey === lF1) + Help.show(); } } From f24b976167e3028693a16ede8e2a54f45561a6e1 Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Thu, 13 Jun 2013 01:53:52 -0700 Subject: [PATCH 071/239] changed position of loading spinner --- lib/client.js | 2 +- lib/client/help.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client.js b/lib/client.js index 2a03aa8a..88d39ba6 100644 --- a/lib/client.js +++ b/lib/client.js @@ -171,7 +171,7 @@ var Util, DOM, CloudFunc, CloudCmd; }, document); var i, n, lStorage = 'storage', - lShowLoadFunc = Util.retFunc( DOM.Images.showLoad ), + lShowLoadFunc = Util.retFunc( DOM.Images.showLoad, {top:true} ), lDoBefore = { 'edit/_codemirror' : lShowLoadFunc, diff --git a/lib/client/help.js b/lib/client/help.js index eb27fca8..c0de9822 100644 --- a/lib/client/help.js +++ b/lib/client/help.js @@ -22,7 +22,7 @@ var CloudCmd, Util, DOM; }; this.show = function(){ - Images.showLoad(); + Images.showLoad({top:true}); DOM.ajax({ url: '/README.md', success: function (pData){ From ed5518f4ff3b360c4a1e189c818f8f66c7acc3bf Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Thu, 13 Jun 2013 02:45:49 -0700 Subject: [PATCH 072/239] fixed logo path --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fd6a288d..488acd9b 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ DEMO: Google PageSpeed Score : [100](//developers.google.com/speed/pagespeed/insights#url=http_3A_2F_2Fcloudcmd.aws.af.cm_2F&mobile=false "score") (out of 100) (or 96 if js or css minification disabled in config.json). -![Cloud Commander](img/logo/cloudcmd.png "Cloud Commander") +![Cloud Commander](/img/logo/cloudcmd.png "Cloud Commander") Benefits --------------- From 89d74da216cc81cf3862d50de0b9330ea3fc6c08 Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Thu, 13 Jun 2013 07:05:47 -0700 Subject: [PATCH 073/239] console.time -> Util.time; console.timeEnd -> Util.timeEnd --- lib/client/menu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/menu.js b/lib/client/menu.js index 03e90d6b..ac7d3e98 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -202,7 +202,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; * @param pCallBack */ function load(pCallBack){ - console.time('menu load'); + Util.time('menu load'); var lDir = Menu.dir, lFiles = [ @@ -211,7 +211,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; ]; DOM.anyLoadInParallel(lFiles, function(){ - console.timeEnd('menu load'); + Util.timeEnd('menu load'); $.contextMenu.handle.keyStop = $.noop; Util.exec(pCallBack); }); From 16d7bd31dcd17dee8614a9a6769bf93397bef3d6 Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Fri, 14 Jun 2013 04:27:39 -0700 Subject: [PATCH 074/239] added Console module --- json/modules.json | 1 + lib/client/console.js | 96 +++ lib/client/terminal/jquery-console/.gitignore | 20 + lib/client/terminal/jquery-console/README | 78 ++ .../jquery-console/jquery.console.css | 40 + .../terminal/jquery-console/jquery.console.js | 716 ++++++++++++++++++ lib/client/view.js | 2 +- 7 files changed, 952 insertions(+), 1 deletion(-) create mode 100644 lib/client/console.js create mode 100644 lib/client/terminal/jquery-console/.gitignore create mode 100644 lib/client/terminal/jquery-console/README create mode 100644 lib/client/terminal/jquery-console/jquery.console.css create mode 100644 lib/client/terminal/jquery-console/jquery.console.js diff --git a/json/modules.json b/json/modules.json index a37640b7..ba9ec419 100644 --- a/json/modules.json +++ b/json/modules.json @@ -3,6 +3,7 @@ "menu", "view", "help", + "console", "terminal", { "name": "storage", "data": [{ diff --git a/lib/client/console.js b/lib/client/console.js new file mode 100644 index 00000000..45d48161 --- /dev/null +++ b/lib/client/console.js @@ -0,0 +1,96 @@ +var CloudCmd, Util, DOM, $; +(function(CloudCmd, Util, DOM){ + 'use strict'; + + CloudCmd.Console = new ConsoleProto(CloudCmd, Util, DOM); + + function ConsoleProto(CloudCmd, Util, DOM){ + var Name = 'Console', + Key = CloudCmd.Key, + Images = DOM.Images, + Console = this; + + this.init = function(pCallBack){ + Util.loadOnLoad([ + Console.show, + load, + CloudCmd.View, + DOM.jqueryLoad, + ]); + + DOM.Events.addKey(listener); + DOM.setButtonKey('f10', Console.show); + + delete Console.init; + }; + + this.show = function(){ + var lElement; + + Images.showLoad({top:true}); + + lElement = DOM.anyload({ + name : 'div', + className : 'console', + }); + + $(lElement).console({ + promptLabel: '# ', + commandValidate : function(line){ + var lRet = line !== ""; + + return lRet; + }, + commandHandle : function(line){ + return line; + }, + autofocus : true, + animateScroll : true, + promptHistory : true, + }); + + CloudCmd.View.show(lElement); + }; + + + this.hide = function(){ + CloudCmd.View.hide; + }; + + function load(pCallBack){ + Util.time(Name + ' load'); + + var lDir = CloudCmd.LIBDIRCLIENT + 'terminal/jquery-console/', + lFiles = [ + lDir + 'jquery.console.js', + lDir + 'jquery.console.css' + ]; + + DOM.anyLoadInParallel(lFiles, function(){ + console.timeEnd(Name + ' load'); + + Util.exec(pCallBack); + }); + } + + function listener(pEvent){ + var lF10 = Key.F10, + lESC = Key.ESC, + lIsBind = Key.isBind(), + lKey = pEvent.keyCode; + + /* если клавиши можно обрабатывать */ + if (lIsBind) + switch(lKey){ + case lF10: + Console.show(); + break; + case lESC: + Console.hide(); + break; + } + + } + } + +})(CloudCmd, Util, DOM); \ No newline at end of file diff --git a/lib/client/terminal/jquery-console/.gitignore b/lib/client/terminal/jquery-console/.gitignore new file mode 100644 index 00000000..ac8f9688 --- /dev/null +++ b/lib/client/terminal/jquery-console/.gitignore @@ -0,0 +1,20 @@ +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +*.pyc + +# Logs and databases # +###################### +*.log + +# OS generated files # +###################### +.DS_Store* +ehthumbs.db +Icon? +Thumbs.db diff --git a/lib/client/terminal/jquery-console/README b/lib/client/terminal/jquery-console/README new file mode 100644 index 00000000..ac29694c --- /dev/null +++ b/lib/client/terminal/jquery-console/README @@ -0,0 +1,78 @@ +INTRODUCTION + +See demo.html. Or here: http://chrisdone.com/jquery-console/ + +Options available: + + autofocus bool Autofocus the terminal, rather than + having to click on it. + + promptHistory bool Provide history support (kind of crappy, + needs doing properly.) + + historyPreserveColumn bool Preserve the column you were one when + switching between history. + + welcomeMessage string Just a first message to display on the + terminal. + + promptLabel string Prompt string like 'JavaScript> '. + + cols integer the number of cols, this value is only + used by the command completion to format + the list of results. + + commandValidate function When user hits return, validate + whether to trigger commandHandle and + re-prompt. + + commandHandle function Handle the command line, return a + string, boolean, or list + of {msg:"foo",className:"my-css-class"}. + commandHandle(line,report) is + called. Report function is for you + to report a result of the command + asynchronously. + + commandComplete function Handle the command completion when the + tab key is pressed. It returns a list + of string completion suffixes. + + animateScroll bool Whether to animate the scroll to + top. Currently disabled. + + charInsertTrigger function Predicate for whether to allow + character insertion. + charInsertTrigger(char,line) is called. + + cancelHandle function Handle a user-signaled interrupt. + +LICENSE + +Copyright 2010 Chris Done, Simon David Pratt. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above + copyright notice, this list of conditions and the following + disclaimer. + + 2. Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials + provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/client/terminal/jquery-console/jquery.console.css b/lib/client/terminal/jquery-console/jquery.console.css new file mode 100644 index 00000000..e925be63 --- /dev/null +++ b/lib/client/terminal/jquery-console/jquery.console.css @@ -0,0 +1,40 @@ +.console { + word-wrap: break-word; +} + +.console { + font-size: 16px; +} +.jquery-console-inner { + width:900px; + height:200px; + padding:0.5em; + overflow:auto +} +.jquery-console-prompt-box { + color:black; + font-family:monospace; +} +.jquery-console-cursor { + color:#333; + font-weight:bold; +} +.jquery-console-message-error { + color:#ef0505; + font-family:sans-serif; + font-weight:bold; + padding:0.1em; +} +.jquery-console-message-value { + color:#1ad027; + font-family:monospace; + padding:0.1em; +} +.jquery-console-message-type { + color:#52666f; + font-family:monospace; + padding:0.1em; +} +.jquery-console-prompt-label { + font-weight:bold; +} \ No newline at end of file diff --git a/lib/client/terminal/jquery-console/jquery.console.js b/lib/client/terminal/jquery-console/jquery.console.js new file mode 100644 index 00000000..4c20925d --- /dev/null +++ b/lib/client/terminal/jquery-console/jquery.console.js @@ -0,0 +1,716 @@ +// JQuery Console 1.0 +// Sun Feb 21 20:28:47 GMT 2010 +// +// Copyright 2010 Chris Done, Simon David Pratt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// +// 1. Redistributions of source code must retain the above +// copyright notice, this list of conditions and the following +// disclaimer. +// +// 2. Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +// TESTED ON +// Internet Explorer 6 +// Opera 10.01 +// Chromium 4.0.237.0 (Ubuntu build 31094) +// Firefox 3.5.8, 3.6.2 (Mac) +// Safari 4.0.5 (6531.22.7) (Mac) +// Google Chrome 5.0.375.55 (Mac) + +(function($){ + var isWebkit = !!~navigator.userAgent.indexOf(' AppleWebKit/'); + + $.fn.console = function(config){ + //////////////////////////////////////////////////////////////////////// + // Constants + // Some are enums, data types, others just for optimisation + var keyCodes = { + // left + 37: moveBackward, + // right + 39: moveForward, + // up + 38: previousHistory, + // down + 40: nextHistory, + // backspace + 8: backDelete, + // delete + 46: forwardDelete, + // end + 35: moveToEnd, + // start + 36: moveToStart, + // return + 13: commandTrigger, + // tab + 18: doNothing, + // tab + 9: doComplete + }; + var ctrlCodes = { + // C-a + 65: moveToStart, + // C-e + 69: moveToEnd, + // C-d + 68: forwardDelete, + // C-n + 78: nextHistory, + // C-p + 80: previousHistory, + // C-b + 66: moveBackward, + // C-f + 70: moveForward, + // C-k + 75: deleteUntilEnd + }; + if(config.ctrlCodes) { + $.extend(ctrlCodes, config.ctrlCodes); + } + var altCodes = { + // M-f + 70: moveToNextWord, + // M-b + 66: moveToPreviousWord, + // M-d + 68: deleteNextWord + }; + var cursor = ' '; + + //////////////////////////////////////////////////////////////////////// + // Globals + var container = $(this); + var inner = $('
'); + // erjiang: changed this from a text input to a textarea so we + // can get pasted newlines + var typer = $(''); + // Prompt + var promptBox; + var prompt; + var promptLabel = config && config.promptLabel? config.promptLabel : "> "; + var continuedPromptLabel = config && config.continuedPromptLabel? + config.continuedPromptLabel : "> "; + var column = 0; + var promptText = ''; + var restoreText = ''; + var continuedText = ''; + // Prompt history stack + var history = []; + var ringn = 0; + // For reasons unknown to The Sword of Michael himself, Opera + // triggers and sends a key character when you hit various + // keys like PgUp, End, etc. So there is no way of knowing + // when a user has typed '#' or End. My solution is in the + // typer.keydown and typer.keypress functions; I use the + // variable below to ignore the keypress event if the keydown + // event succeeds. + var cancelKeyPress = 0; + // When this value is false, the prompt will not respond to input + var acceptInput = true; + // When this value is true, the command has been canceled + var cancelCommand = false; + + // External exports object + var extern = {}; + + //////////////////////////////////////////////////////////////////////// + // Main entry point + (function(){ + container.append(inner); + inner.append(typer); + typer.css({position:'absolute',top:0,left:'-9999px'}); + if (config.welcomeMessage) + message(config.welcomeMessage,'jquery-console-welcome'); + newPromptBox(); + if (config.autofocus) { + inner.addClass('jquery-console-focus'); + typer.focus(); + setTimeout(function(){ + inner.addClass('jquery-console-focus'); + typer.focus(); + },100); + } + extern.inner = inner; + extern.typer = typer; + extern.scrollToBottom = scrollToBottom; + })(); + + //////////////////////////////////////////////////////////////////////// + // Reset terminal + extern.reset = function(){ + var welcome = (typeof config.welcomeMessage != 'undefined'); + inner.parent().fadeOut(function(){ + inner.find('div').each(function(){ + if (!welcome) { + $(this).remove(); + } else { + welcome = false; + } + }); + newPromptBox(); + inner.parent().fadeIn(function(){ + inner.addClass('jquery-console-focus'); + typer.focus(); + }); + }); + }; + + //////////////////////////////////////////////////////////////////////// + // Reset terminal + extern.notice = function(msg,style){ + var n = $('
').append($('
').text(msg)) + .css({visibility:'hidden'}); + container.append(n); + var focused = true; + if (style=='fadeout') + setTimeout(function(){ + n.fadeOut(function(){ + n.remove(); + }); + },4000); + else if (style=='prompt') { + var a = $('
'); + n.append(a); + focused = false; + a.click(function(){ n.fadeOut(function(){ n.remove();inner.css({opacity:1}) }); }); + } + var h = n.height(); + n.css({height:'0px',visibility:'visible'}) + .animate({height:h+'px'},function(){ + if (!focused) inner.css({opacity:0.5}); + }); + n.css('cursor','default'); + return n; + }; + + //////////////////////////////////////////////////////////////////////// + // Make a new prompt box + function newPromptBox() { + column = 0; + promptText = ''; + ringn = 0; // Reset the position of the history ring + enableInput(); + promptBox = $('
'); + var label = $(''); + var labelText = extern.continuedPrompt? continuedPromptLabel : promptLabel; + promptBox.append(label.text(labelText).show()); + label.html(label.html().replace(' ',' ')); + prompt = $(''); + promptBox.append(prompt); + inner.append(promptBox); + updatePromptDisplay(); + }; + + //////////////////////////////////////////////////////////////////////// + // Handle setting focus + container.click(function(){ + inner.addClass('jquery-console-focus'); + inner.removeClass('jquery-console-nofocus'); + if (isWebkit) { + typer.focusWithoutScrolling(); + } else { + typer.css('position', 'fixed').focus(); + } + scrollToBottom(); + return false; + }); + + //////////////////////////////////////////////////////////////////////// + // Handle losing focus + typer.blur(function(){ + inner.removeClass('jquery-console-focus'); + inner.addClass('jquery-console-nofocus'); + }); + + //////////////////////////////////////////////////////////////////////// + // Bind to the paste event of the input box so we know when we + // get pasted data + typer.bind('paste', function(e) { + // wipe typer input clean just in case + typer.val(""); + // this timeout is required because the onpaste event is + // fired *before* the text is actually pasted + setTimeout(function() { + typer.consoleInsert(typer.val()); + typer.val(""); + }, 0); + }); + + //////////////////////////////////////////////////////////////////////// + // Handle key hit before translation + // For picking up control characters like up/left/down/right + + typer.keydown(function(e){ + cancelKeyPress = 0; + var keyCode = e.keyCode; + // C-c: cancel the execution + if(e.ctrlKey && keyCode == 67) { + cancelKeyPress = keyCode; + cancelExecution(); + return false; + } + if (acceptInput) { + if (keyCode in keyCodes) { + cancelKeyPress = keyCode; + (keyCodes[keyCode])(); + return false; + } else if (e.ctrlKey && keyCode in ctrlCodes) { + cancelKeyPress = keyCode; + (ctrlCodes[keyCode])(); + return false; + } else if (e.altKey && keyCode in altCodes) { + cancelKeyPress = keyCode; + (altCodes[keyCode])(); + return false; + } + } + }); + + //////////////////////////////////////////////////////////////////////// + // Handle key press + typer.keypress(function(e){ + var keyCode = e.keyCode || e.which; + if (isIgnorableKey(e)) { + return false; + } + // C-v: don't insert on paste event + if ((e.ctrlKey || e.metaKey) && String.fromCharCode(keyCode).toLowerCase() == 'v') { + return true; + } + if (acceptInput && cancelKeyPress != keyCode && keyCode >= 32){ + if (cancelKeyPress) return false; + if ( + typeof config.charInsertTrigger == 'undefined' || ( + typeof config.charInsertTrigger == 'function' && + config.charInsertTrigger(keyCode,promptText) + ) + ){ + typer.consoleInsert(keyCode); + } + } + if (isWebkit) return false; + }); + + function isIgnorableKey(e) { + // for now just filter alt+tab that we receive on some platforms when + // user switches windows (goes away from the browser) + return ((e.keyCode == keyCodes.tab || e.keyCode == 192) && e.altKey); + }; + + //////////////////////////////////////////////////////////////////////// + // Rotate through the command history + function rotateHistory(n){ + if (history.length == 0) return; + ringn += n; + if (ringn < 0) ringn = history.length; + else if (ringn > history.length) ringn = 0; + var prevText = promptText; + if (ringn == 0) { + promptText = restoreText; + } else { + promptText = history[ringn - 1]; + } + if (config.historyPreserveColumn) { + if (promptText.length < column + 1) { + column = promptText.length; + } else if (column == 0) { + column = promptText.length; + } + } else { + column = promptText.length; + } + updatePromptDisplay(); + }; + + function previousHistory() { + rotateHistory(-1); + }; + + function nextHistory() { + rotateHistory(1); + }; + + // Add something to the history ring + function addToHistory(line){ + history.push(line); + restoreText = ''; + }; + + // Delete the character at the current position + function deleteCharAtPos(){ + if (column < promptText.length){ + promptText = + promptText.substring(0,column) + + promptText.substring(column+1); + restoreText = promptText; + return true; + } else return false; + }; + + function backDelete() { + if (moveColumn(-1)){ + deleteCharAtPos(); + updatePromptDisplay(); + } + }; + + function forwardDelete() { + if (deleteCharAtPos()){ + updatePromptDisplay(); + } + }; + + function deleteUntilEnd() { + while(deleteCharAtPos()) { + updatePromptDisplay(); + } + }; + + function deleteNextWord() { + // A word is defined within this context as a series of alphanumeric + // characters. + // Delete up to the next alphanumeric character + while( + column < promptText.length && + !isCharAlphanumeric(promptText[column]) + ) { + deleteCharAtPos(); + updatePromptDisplay(); + } + // Then, delete until the next non-alphanumeric character + while( + column < promptText.length && + isCharAlphanumeric(promptText[column]) + ) { + deleteCharAtPos(); + updatePromptDisplay(); + } + }; + + //////////////////////////////////////////////////////////////////////// + // Validate command and trigger it if valid, or show a validation error + function commandTrigger() { + var line = promptText; + if (typeof config.commandValidate == 'function') { + var ret = config.commandValidate(line); + if (ret == true || ret == false) { + if (ret) { + handleCommand(); + } + } else { + commandResult(ret,"jquery-console-message-error"); + } + } else { + handleCommand(); + } + }; + + // Scroll to the bottom of the view + function scrollToBottom() { + if (jQuery.fn.jquery > "1.6") { + inner.prop({ scrollTop: inner.prop("scrollHeight") }); + } + else { + inner.attr({ scrollTop: inner.attr("scrollHeight") }); + } + }; + + function cancelExecution() { + if(typeof config.cancelHandle == 'function') { + config.cancelHandle(); + } + } + + //////////////////////////////////////////////////////////////////////// + // Handle a command + function handleCommand() { + if (typeof config.commandHandle == 'function') { + disableInput(); + addToHistory(promptText); + var text = promptText; + if (extern.continuedPrompt) { + if (continuedText) + continuedText += '\n' + promptText; + else continuedText = promptText; + } else continuedText = undefined; + if (continuedText) text = continuedText; + var ret = config.commandHandle(text,function(msgs){ + commandResult(msgs); + }); + if (extern.continuedPrompt && !continuedText) + continuedText = promptText; + if (typeof ret == 'boolean') { + if (ret) { + // Command succeeded without a result. + commandResult(); + } else { + commandResult( + 'Command failed.', + "jquery-console-message-error" + ); + } + } else if (typeof ret == "string") { + commandResult(ret,"jquery-console-message-success"); + } else if (typeof ret == 'object' && ret.length) { + commandResult(ret); + } else if (extern.continuedPrompt) { + commandResult(); + } + } + }; + + //////////////////////////////////////////////////////////////////////// + // Disable input + function disableInput() { + acceptInput = false; + }; + + // Enable input + function enableInput() { + acceptInput = true; + } + + //////////////////////////////////////////////////////////////////////// + // Reset the prompt in invalid command + function commandResult(msg,className) { + column = -1; + updatePromptDisplay(); + if (typeof msg == 'string') { + message(msg,className); + } else if ($.isArray(msg)) { + for (var x in msg) { + var ret = msg[x]; + message(ret.msg,ret.className); + } + } else { // Assume it's a DOM node or jQuery object. + inner.append(msg); + } + newPromptBox(); + }; + + //////////////////////////////////////////////////////////////////////// + // Display a message + function message(msg,className) { + var mesg = $('
'); + if (className) mesg.addClass(className); + mesg.filledText(msg).hide(); + inner.append(mesg); + mesg.show(); + }; + + //////////////////////////////////////////////////////////////////////// + // Handle normal character insertion + // data can either be a number, which will be interpreted as the + // numeric value of a single character, or a string + typer.consoleInsert = function(data){ + // TODO: remove redundant indirection + var text = isNaN(data) ? data : String.fromCharCode(data); + var before = promptText.substring(0,column); + var after = promptText.substring(column); + promptText = before + text + after; + moveColumn(text.length); + restoreText = promptText; + updatePromptDisplay(); + }; + + //////////////////////////////////////////////////////////////////////// + // Move to another column relative to this one + // Negative means go back, positive means go forward. + function moveColumn(n){ + if (column + n >= 0 && column + n <= promptText.length){ + column += n; + return true; + } else return false; + }; + + function moveForward() { + if(moveColumn(1)) { + updatePromptDisplay(); + return true; + } + return false; + }; + + function moveBackward() { + if(moveColumn(-1)) { + updatePromptDisplay(); + return true; + } + return false; + }; + + function moveToStart() { + if (moveColumn(-column)) + updatePromptDisplay(); + }; + + function moveToEnd() { + if (moveColumn(promptText.length-column)) + updatePromptDisplay(); + }; + + function moveToNextWord() { + while( + column < promptText.length && + !isCharAlphanumeric(promptText[column]) && + moveForward() + ) {} + while( + column < promptText.length && + isCharAlphanumeric(promptText[column]) && + moveForward() + ) {} + }; + + function moveToPreviousWord() { + // Move backward until we find the first alphanumeric + while( + column -1 >= 0 && + !isCharAlphanumeric(promptText[column-1]) && + moveBackward() + ) {} + // Move until we find the first non-alphanumeric + while( + column -1 >= 0 && + isCharAlphanumeric(promptText[column-1]) && + moveBackward() + ) {} + }; + + function isCharAlphanumeric(charToTest) { + if(typeof charToTest == 'string') { + var code = charToTest.charCodeAt(); + return (code >= 'A'.charCodeAt() && code <= 'Z'.charCodeAt()) || + (code >= 'a'.charCodeAt() && code <= 'z'.charCodeAt()) || + (code >= '0'.charCodeAt() && code <= '9'.charCodeAt()); + } + return false; + }; + + function doComplete() { + if(typeof config.completeHandle == 'function') { + var completions = config.completeHandle(promptText); + var len = completions.length; + if (len === 1) { + extern.promptText(promptText + completions[0]); + } else if (len > 1 && config.cols) { + var prompt = promptText; + // Compute the number of rows that will fit in the width + var max = 0; + for (var i = 0;i < len;i++) { + max = Math.max(max, completions[i].length); + } + max += 2; + var n = Math.floor(config.cols / max); + var buffer = ""; + var col = 0; + for (i = 0;i < len;i++) { + var completion = completions[i]; + buffer += completions[i]; + for (var j = completion.length;j < max;j++) { + buffer += " "; + } + if (++col >= n) { + buffer += "\n"; + col = 0; + } + } + commandResult(buffer,"jquery-console-message-value"); + extern.promptText(prompt); + } + } + }; + + function doNothing() {}; + + extern.promptText = function(text){ + if (typeof text === 'string') { + promptText = text; + column = promptText.length; + updatePromptDisplay(); + } + return promptText; + }; + + //////////////////////////////////////////////////////////////////////// + // Update the prompt display + function updatePromptDisplay(){ + var line = promptText; + var html = ''; + if (column > 0 && line == ''){ + // When we have an empty line just display a cursor. + html = cursor; + } else if (column == promptText.length){ + // We're at the end of the line, so we need to display + // the text *and* cursor. + html = htmlEncode(line) + cursor; + } else { + // Grab the current character, if there is one, and + // make it the current cursor. + var before = line.substring(0, column); + var current = line.substring(column,column+1); + if (current){ + current = + '' + + htmlEncode(current) + + ''; + } + var after = line.substring(column+1); + html = htmlEncode(before) + current + htmlEncode(after); + } + prompt.html(html); + scrollToBottom(); + }; + + // Simple HTML encoding + // Simply replace '<', '>' and '&' + // TODO: Use jQuery's .html() trick, or grab a proper, fast + // HTML encoder. + function htmlEncode(text){ + return ( + text.replace(/&/g,'&') + .replace(/') + ); + }; + + return extern; + }; + // Simple utility for printing messages + $.fn.filledText = function(txt){ + $(this).text(txt); + $(this).html($(this).html().replace(/\n/g,'
')); + return this; + }; + + // Alternative method for focus without scrolling + $.fn.focusWithoutScrolling = function(){ + var x = window.scrollX, y = window.scrollY; + $(this).focus(); + window.scrollTo(x, y); + }; +})(jQuery); diff --git a/lib/client/view.js b/lib/client/view.js index da1af750..531bd576 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -55,7 +55,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; var lPath; if(pData) - $.fancybox('
' + pData + '
', Config); + $.fancybox(pData, Config); else { lPath = CloudFunc.FS + DOM.getCurrentPath(); if( Util.checkExtension(lPath, ['png','jpg', 'gif','ico']) ) { From 3f8aa846e8a750ee3eb6bfc6927afd9cda9cced3 Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Fri, 14 Jun 2013 04:49:51 -0700 Subject: [PATCH 075/239] added ability to set attributes in Loader.anyload --- ChangeLog | 2 ++ lib/client/dom.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f64291eb..fc73ef66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -62,6 +62,8 @@ getJSONfromFileTable. * Added ability to show help on F1. +* Added ability to set attributes in Loader.anyload. + 2012.04.22, v0.2.0 diff --git a/lib/client/dom.js b/lib/client/dom.js index 1bc64405..73b6ca2b 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -735,6 +735,7 @@ var CloudCmd, Util, DOM, CloudFunc; * } */ this.anyload = function(pParams_o){ + var i, n, lElements_a; if ( !pParams_o ) return; @@ -743,14 +744,15 @@ var CloudCmd, Util, DOM, CloudFunc; * and quit */ if ( Util.isArray(pParams_o) ){ - var lElements_a = []; - for(var i = 0, n = pParams_o.length; i < n ; i++) + lElements_a = []; + for(i = 0, n = pParams_o.length; i < n ; i++) lElements_a[i] = this.anyload(pParams_o[i]); return lElements_a; } var lName = pParams_o.name, + lAttr = pParams_o.attribute, lID = pParams_o.id, lClass = pParams_o.className, lSrc = pParams_o.src, @@ -838,6 +840,10 @@ var CloudCmd, Util, DOM, CloudFunc; Events.add('load', lLoad, lElement); Events.addError(lError, lElement); + if (lAttr) + for(i in lAttr) + lElement.setAttribute(i, lAttr[i]); + if (lStyle) lElement.style.cssText = lStyle; From 59acb899a284ea204cbf832e9e2ac65c577aef76 Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Fri, 14 Jun 2013 04:50:37 -0700 Subject: [PATCH 076/239] add parent element to console div --- lib/client/console.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/client/console.js b/lib/client/console.js index 45d48161..723f31b1 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -25,14 +25,24 @@ var CloudCmd, Util, DOM, $; }; this.show = function(){ - var lElement; + var lElement, lViewElement; Images.showLoad({top:true}); - lElement = DOM.anyload({ + lViewElement = DOM.anyload({ + name : 'div', + id : 'view', + attribute : { + tabindex : 0 + }, + not_append : true + }), + + lElement = DOM.anyload({ name : 'div', className : 'console', - }); + parent : lViewElement + }), $(lElement).console({ promptLabel: '# ', @@ -49,7 +59,7 @@ var CloudCmd, Util, DOM, $; promptHistory : true, }); - CloudCmd.View.show(lElement); + CloudCmd.View.show(lViewElement); }; From 48d340c0f9ed640aa1d755d15de7b3f5019b4dcc Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Fri, 14 Jun 2013 04:54:24 -0700 Subject: [PATCH 077/239] CloudCmd.View.hide -> CloudCmd.View.hide() --- lib/client/console.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/console.js b/lib/client/console.js index 723f31b1..f4b7cff2 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -64,7 +64,7 @@ var CloudCmd, Util, DOM, $; this.hide = function(){ - CloudCmd.View.hide; + CloudCmd.View.hide(); }; function load(pCallBack){ From 35e85edaa07af9def5328d8d53651eba5eb88b1f Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Fri, 14 Jun 2013 05:04:38 -0700 Subject: [PATCH 078/239] removed DOM.setButtonKey(f10, Console.show); from Console init --- lib/client/console.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/client/console.js b/lib/client/console.js index f4b7cff2..f9aad89e 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -19,7 +19,6 @@ var CloudCmd, Util, DOM, $; ]); DOM.Events.addKey(listener); - DOM.setButtonKey('f10', Console.show); delete Console.init; }; From 78d7cf7886282c3f68dfe4814dc2e5170a34426a Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Fri, 14 Jun 2013 05:06:15 -0700 Subject: [PATCH 079/239] moved Images.hideLoad(); to beforeShow --- lib/client/view.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/client/view.js b/lib/client/view.js index 531bd576..abb95ca9 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -11,8 +11,10 @@ var CloudCmd, Util, DOM, CloudFunc, $; View = this, Config = { - beforeShow : Key.unsetBind, - + beforeShow : function(){ + Images.hideLoad(); + Key.unsetBind(); + }, afterShow : function(){ var lEditor = DOM.getById('View'); if(lEditor) @@ -59,12 +61,10 @@ var CloudCmd, Util, DOM, CloudFunc, $; else { lPath = CloudFunc.FS + DOM.getCurrentPath(); if( Util.checkExtension(lPath, ['png','jpg', 'gif','ico']) ) { - Images.hideLoad(); $.fancybox.open({ href : lPath }, Config); } else DOM.getCurrentData(function(pParams){ - Images.hideLoad(); $.fancybox('
' + pParams.data + '
', Config); }); From 8446a63ac63fc2d31c47874865ea21ada0e43c61 Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Fri, 14 Jun 2013 05:08:11 -0700 Subject: [PATCH 080/239] removed lIsBind from listener --- lib/client/console.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/client/console.js b/lib/client/console.js index f9aad89e..bc9525d7 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -88,16 +88,14 @@ var CloudCmd, Util, DOM, $; lIsBind = Key.isBind(), lKey = pEvent.keyCode; - /* если клавиши можно обрабатывать */ - if (lIsBind) - switch(lKey){ - case lF10: - Console.show(); - break; - case lESC: - Console.hide(); - break; - } + switch(lKey){ + case lF10: + Console.show(); + break; + case lESC: + Console.hide(); + break; + } } } From 80b5db2d0b07d27a41a8b47513034e8ce421f1e0 Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Mon, 17 Jun 2013 01:07:16 -0700 Subject: [PATCH 081/239] changed time of gapi.auth object creating --- lib/client/storage/_gdrive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/storage/_gdrive.js b/lib/client/storage/_gdrive.js index 21aad69f..114d523e 100644 --- a/lib/client/storage/_gdrive.js +++ b/lib/client/storage/_gdrive.js @@ -40,7 +40,7 @@ var CloudCmd, Util, DOM, gapi; }); }); - }, 500); + }, 1500); }); }); } From 137296542365ff0026c2f6728b59fd107fdab75b Mon Sep 17 00:00:00 2001 From: coderaiaser Date: Mon, 17 Jun 2013 04:38:07 -0700 Subject: [PATCH 082/239] fixed upload function of filepicker --- ChangeLog | 2 ++ lib/client/storage/_filepicker.js | 10 +++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index fc73ef66..ea2f0161 100644 --- a/ChangeLog +++ b/ChangeLog @@ -64,6 +64,8 @@ getJSONfromFileTable. * Added ability to set attributes in Loader.anyload. +* Fixed upload function of filepicker. + 2012.04.22, v0.2.0 diff --git a/lib/client/storage/_filepicker.js b/lib/client/storage/_filepicker.js index c9f1c898..a1b0e9d6 100644 --- a/lib/client/storage/_filepicker.js +++ b/lib/client/storage/_filepicker.js @@ -16,14 +16,10 @@ var CloudCmd, Util, DOM, $, filepicker; var lContent = pParams.data, lName = pParams.name; - filepicker.store(lContent, {filename: lName}, function(new_fpfile){ - console.log(new_fpfile); - }); - - filepicker.pick(function(FPFile){ - console.log(FPFile.url); + filepicker.store(lContent, {filename: lName}, function(pFPFile){ + console.log(pFPFile); - Util.exec(pCallBack); + filepicker.exportFile(pFPFile, Util.log, Util.log); }); }; From 1cfaa5a0ee31e00dfca0530d1375d8b59f73caf7 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 18 Jun 2013 17:10:08 +0300 Subject: [PATCH 083/239] added MIT License --- LICENSE | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..b9f49cb1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2013 Coderaiser + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 16bb1ec6cb243079212f487836d174d05bb0a60d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 19 Jun 2013 11:01:31 +0000 Subject: [PATCH 084/239] refactor(console) remove view element --- lib/client/console.js | 194 ++++++++++++++++++++---------------------- 1 file changed, 92 insertions(+), 102 deletions(-) diff --git a/lib/client/console.js b/lib/client/console.js index bc9525d7..9ba73d4e 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -1,103 +1,93 @@ -var CloudCmd, Util, DOM, $; -(function(CloudCmd, Util, DOM){ - 'use strict'; - - CloudCmd.Console = new ConsoleProto(CloudCmd, Util, DOM); - - function ConsoleProto(CloudCmd, Util, DOM){ - var Name = 'Console', - Key = CloudCmd.Key, - Images = DOM.Images, - Console = this; - - this.init = function(pCallBack){ - Util.loadOnLoad([ - Console.show, - load, - CloudCmd.View, - DOM.jqueryLoad, - ]); - - DOM.Events.addKey(listener); - - delete Console.init; - }; - - this.show = function(){ - var lElement, lViewElement; - - Images.showLoad({top:true}); - - lViewElement = DOM.anyload({ - name : 'div', - id : 'view', - attribute : { - tabindex : 0 - }, - not_append : true - }), - - lElement = DOM.anyload({ - name : 'div', - className : 'console', - parent : lViewElement - }), - - $(lElement).console({ - promptLabel: '# ', - commandValidate : function(line){ - var lRet = line !== ""; - - return lRet; - }, - commandHandle : function(line){ - return line; - }, - autofocus : true, - animateScroll : true, - promptHistory : true, - }); - - CloudCmd.View.show(lViewElement); - }; - - - this.hide = function(){ - CloudCmd.View.hide(); - }; - - function load(pCallBack){ - Util.time(Name + ' load'); - - var lDir = CloudCmd.LIBDIRCLIENT + 'terminal/jquery-console/', - lFiles = [ - lDir + 'jquery.console.js', - lDir + 'jquery.console.css' - ]; - - DOM.anyLoadInParallel(lFiles, function(){ - console.timeEnd(Name + ' load'); - - Util.exec(pCallBack); - }); - } - - function listener(pEvent){ - var lF10 = Key.F10, - lESC = Key.ESC, - lIsBind = Key.isBind(), - lKey = pEvent.keyCode; - - switch(lKey){ - case lF10: - Console.show(); - break; - case lESC: - Console.hide(); - break; - } - - } - } - +var CloudCmd, Util, DOM, $; +(function(CloudCmd, Util, DOM){ + 'use strict'; + + CloudCmd.Console = new ConsoleProto(CloudCmd, Util, DOM); + + function ConsoleProto(CloudCmd, Util, DOM){ + var Name = 'Console', + Key = CloudCmd.Key, + Images = DOM.Images, + Console = this; + + this.init = function(pCallBack){ + Util.loadOnLoad([ + Console.show, + load, + CloudCmd.View, + DOM.jqueryLoad, + ]); + + DOM.Events.addKey(listener); + + delete Console.init; + }; + + this.show = function(){ + var lElement; + + Images.showLoad({top:true}); + + lElement = DOM.anyload({ + name : 'div', + className : 'console' + }); + + $(lElement).console({ + promptLabel: '# ', + commandValidate : function(line){ + var lRet = line !== ""; + + return lRet; + }, + commandHandle : function(line){ + return line; + }, + autofocus : true, + animateScroll : false, + promptHistory : true, + }); + + CloudCmd.View.show(lElement); + }; + + + this.hide = function(){ + CloudCmd.View.hide(); + }; + + function load(pCallBack){ + Util.time(Name + ' load'); + + var lDir = CloudCmd.LIBDIRCLIENT + 'terminal/jquery-console/', + lFiles = [ + lDir + 'jquery.console.js', + lDir + 'jquery.console.css' + ]; + + DOM.anyLoadInParallel(lFiles, function(){ + console.timeEnd(Name + ' load'); + + Util.exec(pCallBack); + }); + } + + function listener(pEvent){ + var lF10 = Key.F10, + lESC = Key.ESC, + lIsBind = Key.isBind(), + lKey = pEvent.keyCode; + + switch(lKey){ + case lF10: + Console.show(); + break; + case lESC: + Console.hide(); + break; + } + + } + } + })(CloudCmd, Util, DOM); \ No newline at end of file From 38e98f58b5639a6870a915f00d2954ed5f58eb79 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 19 Jun 2013 11:02:49 +0000 Subject: [PATCH 085/239] refactor(console) remove size css --- .../jquery-console/jquery.console.css | 72 +++++++++---------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/lib/client/terminal/jquery-console/jquery.console.css b/lib/client/terminal/jquery-console/jquery.console.css index e925be63..0bc50483 100644 --- a/lib/client/terminal/jquery-console/jquery.console.css +++ b/lib/client/terminal/jquery-console/jquery.console.css @@ -1,40 +1,34 @@ -.console { - word-wrap: break-word; -} - -.console { - font-size: 16px; -} -.jquery-console-inner { - width:900px; - height:200px; - padding:0.5em; - overflow:auto -} -.jquery-console-prompt-box { - color:black; - font-family:monospace; -} -.jquery-console-cursor { - color:#333; - font-weight:bold; -} -.jquery-console-message-error { - color:#ef0505; - font-family:sans-serif; - font-weight:bold; - padding:0.1em; -} -.jquery-console-message-value { - color:#1ad027; - font-family:monospace; - padding:0.1em; -} -.jquery-console-message-type { - color:#52666f; - font-family:monospace; - padding:0.1em; -} -.jquery-console-prompt-label { - font-weight:bold; +.console { + word-wrap: break-word; +} + +.jquery-console-inner { + padding:0.5em; +} +.jquery-console-prompt-box { + color:black; + font-family:monospace; +} +.jquery-console-cursor { + color:#333; + font-weight:bold; +} +.jquery-console-message-error { + color:#ef0505; + font-family:sans-serif; + font-weight:bold; + padding:0.1em; +} +.jquery-console-message-value { + color:#1ad027; + font-family:monospace; + padding:0.1em; +} +.jquery-console-message-type { + color:#52666f; + font-family:monospace; + padding:0.1em; +} +.jquery-console-prompt-label { + font-weight:bold; } \ No newline at end of file From ba08ab62526d2c765f4419c78929297c04f8b4cb Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 19 Jun 2013 11:09:08 +0000 Subject: [PATCH 086/239] fix(DOM) this.promptNewFile -> Cmd.promptNewFile --- lib/client/dom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 73b6ca2b..e2e4dacf 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1012,7 +1012,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @pCurrentFile */ this.promptNewDir = function(){ - this.promptNewFile('directory', '?dir'); + Cmd.promptNewFile('directory', '?dir'); }; /** @@ -1868,4 +1868,4 @@ var CloudCmd, Util, DOM, CloudFunc; DOM = new DOMFunc(); -})(Util); \ No newline at end of file +})(Util); From 905487efa7c5a75d2e5afbbf3754f9568b6b839e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 19 Jun 2013 11:17:36 +0000 Subject: [PATCH 087/239] Revert "fix(DOM) this.promptNewFile -> Cmd.promptNewFile" This reverts commit 5a07f09ffea18252903c6eacc7e1c0a6cc399baf. --- lib/client/dom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index e2e4dacf..73b6ca2b 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1012,7 +1012,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @pCurrentFile */ this.promptNewDir = function(){ - Cmd.promptNewFile('directory', '?dir'); + this.promptNewFile('directory', '?dir'); }; /** @@ -1868,4 +1868,4 @@ var CloudCmd, Util, DOM, CloudFunc; DOM = new DOMFunc(); -})(Util); +})(Util); \ No newline at end of file From d3f3d9f081515db1adf9e507c9bdda8a391300b4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 19 Jun 2013 11:43:09 +0000 Subject: [PATCH 088/239] fix(DOM) this.promptNewFile -> Cmd.promptNewFile --- ChangeLog | 2 ++ lib/client/dom.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea2f0161..19c7a9b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -66,6 +66,8 @@ getJSONfromFileTable. * Fixed upload function of filepicker. +* fix(DOM) this.promptNewFile -> Cmd.promptNewFile + 2012.04.22, v0.2.0 diff --git a/lib/client/dom.js b/lib/client/dom.js index 73b6ca2b..e2e4dacf 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1012,7 +1012,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @pCurrentFile */ this.promptNewDir = function(){ - this.promptNewFile('directory', '?dir'); + Cmd.promptNewFile('directory', '?dir'); }; /** @@ -1868,4 +1868,4 @@ var CloudCmd, Util, DOM, CloudFunc; DOM = new DOMFunc(); -})(Util); \ No newline at end of file +})(Util); From 3f6db8bc5ec9df03026b25613b1df13d608c9626 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 19 Jun 2013 14:29:20 +0000 Subject: [PATCH 089/239] feautre(console) add jq-console --- json/modules.json | 2 +- lib/client/jq_console.js | 130 ++ lib/client/terminal/jq-console/jqconsole.css | 45 + lib/client/terminal/jq-console/jqconsole.js | 1512 ++++++++++++++++++ 4 files changed, 1688 insertions(+), 1 deletion(-) create mode 100644 lib/client/jq_console.js create mode 100644 lib/client/terminal/jq-console/jqconsole.css create mode 100644 lib/client/terminal/jq-console/jqconsole.js diff --git a/json/modules.json b/json/modules.json index ba9ec419..95fbefaa 100644 --- a/json/modules.json +++ b/json/modules.json @@ -3,7 +3,7 @@ "menu", "view", "help", - "console", + "jq_console", "terminal", { "name": "storage", "data": [{ diff --git a/lib/client/jq_console.js b/lib/client/jq_console.js new file mode 100644 index 00000000..b1afb060 --- /dev/null +++ b/lib/client/jq_console.js @@ -0,0 +1,130 @@ +var CloudCmd, Util, DOM, $; +(function(CloudCmd, Util, DOM){ + 'use strict'; + + CloudCmd.Jq_console = new ConsoleProto(CloudCmd, Util, DOM); + + function ConsoleProto(CloudCmd, Util, DOM){ + var Name = 'Console', + Key = CloudCmd.Key, + Images = DOM.Images, + Console = this; + + this.init = function(pCallBack){ + Util.loadOnLoad([ + Console.show, + load, + CloudCmd.View, + DOM.jqueryLoad, + ]); + + DOM.Events.addKey(listener); + + delete Console.init; + }; + + this.show = function(){ + var lElement, jqconsole; + + Images.showLoad({top:true}); + + lElement = DOM.anyload({ + name : 'div', + className : 'console' + }); + + jqconsole = $(lElement).jqconsole('header', 'JS> '); + + // Abort prompt on Ctrl+Z. + jqconsole.RegisterShortcut('Z', function() { + jqconsole.AbortPrompt(); + handler(); + }); + + // Move to line start Ctrl+A. + jqconsole.RegisterShortcut('A', function() { + jqconsole.MoveToStart(); + handler(); + }); + + // Move to line end Ctrl+E. + jqconsole.RegisterShortcut('E', function() { + jqconsole.MoveToEnd(); + handler(); + }); + + jqconsole.RegisterMatching('{', '}', 'brace'); + jqconsole.RegisterMatching('(', ')', 'paran'); + jqconsole.RegisterMatching('[', ']', 'bracket'); + // Handle a command. + var handler = function(command) { + if (command) { + try { + jqconsole.Write('==> ' + window.eval(command) + '\n'); + } catch (e) { + jqconsole.Write('ERROR: ' + e.message + '\n'); + } + } + jqconsole.Prompt(true, handler, function(command) { + // Continue line if can't compile the command. + try { + Function(command); + } catch (e) { + if (/[\[\{\(]$/.test(command)) { + return 1; + } else { + return 0; + } + } + return false; + }); + }; + + // Initiate the first prompt. + handler(); + + + CloudCmd.View.show(lElement); + }; + + + this.hide = function(){ + CloudCmd.View.hide(); + }; + + function load(pCallBack){ + Util.time(Name + ' load'); + + var lDir = CloudCmd.LIBDIRCLIENT + 'terminal/jq-console/', + lFiles = [ + lDir + 'jqconsole.js', + lDir + 'jqconsole.css', + CloudCmd.LIBDIRCLIENT + 'terminal/jquery-terminal/jquery-migrate-1.0.0.js' + ]; + + DOM.anyLoadInParallel(lFiles, function(){ + console.timeEnd(Name + ' load'); + + Util.exec(pCallBack); + }); + } + + function listener(pEvent){ + var lF10 = Key.F10, + lESC = Key.ESC, + lIsBind = Key.isBind(), + lKey = pEvent.keyCode; + + switch(lKey){ + case lF10: + Console.show(); + break; + case lESC: + Console.hide(); + break; + } + + } + } + +})(CloudCmd, Util, DOM); \ No newline at end of file diff --git a/lib/client/terminal/jq-console/jqconsole.css b/lib/client/terminal/jq-console/jqconsole.css new file mode 100644 index 00000000..b5fb0696 --- /dev/null +++ b/lib/client/terminal/jq-console/jqconsole.css @@ -0,0 +1,45 @@ +#console { + height: 400px; + width: 750px; + position:relative; + background-color: black; + border: 2px solid #CCC; + margin: 0 auto; + margin-top: 50px; +} +.jqconsole { + padding: 10px; + padding-bottom: 10px; +} +.jqconsole-cursor { + background-color: #999; +} +.jqconsole-blurred .jqconsole-cursor { + background-color: #666; +} +.jqconsole-prompt { + color: #0d0; +} +.jqconsole-old-prompt { + color: #0b0; + font-weight: normal; +} +.jqconsole-input { + color: #dd0; +} +.jqconsole-old-input { + color: #bb0; + font-weight: normal; +} +.brace { + color: #00FFFF; +} +.paran { + color: #FF00FF; +} +.bracket { + color: #FFFF00; +} +.jqconsole-composition { + background-color: red; +} \ No newline at end of file diff --git a/lib/client/terminal/jq-console/jqconsole.js b/lib/client/terminal/jq-console/jqconsole.js new file mode 100644 index 00000000..dc1c0bfb --- /dev/null +++ b/lib/client/terminal/jq-console/jqconsole.js @@ -0,0 +1,1512 @@ +// Generated by CoffeeScript 1.3.3 + +/* +Copyrights 2011, the repl.it project. +Licensed under the MIT license +*/ + + +(function() { + var $, Ansi, CLASS_ANSI, CLASS_BLURRED, CLASS_CURSOR, CLASS_HEADER, CLASS_INPUT, CLASS_OLD_PROMPT, CLASS_PREFIX, CLASS_PROMPT, DEFAULT_INDENT_WIDTH, DEFAULT_PROMPT_CONINUE_LABEL, DEFAULT_PROMPT_LABEL, EMPTY_DIV, EMPTY_SELECTOR, EMPTY_SPAN, ESCAPE_CHAR, ESCAPE_SYNTAX, E_KEYPRESS, JQConsole, KEY_BACKSPACE, KEY_DELETE, KEY_DOWN, KEY_END, KEY_ENTER, KEY_HOME, KEY_LEFT, KEY_PAGE_DOWN, KEY_PAGE_UP, KEY_RIGHT, KEY_TAB, KEY_UP, NEWLINE, STATE_INPUT, STATE_OUTPUT, STATE_PROMPT, spanHtml, + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + __slice = [].slice; + + $ = jQuery; + + STATE_INPUT = 0; + + STATE_OUTPUT = 1; + + STATE_PROMPT = 2; + + KEY_ENTER = 13; + + KEY_TAB = 9; + + KEY_DELETE = 46; + + KEY_BACKSPACE = 8; + + KEY_LEFT = 37; + + KEY_RIGHT = 39; + + KEY_UP = 38; + + KEY_DOWN = 40; + + KEY_HOME = 36; + + KEY_END = 35; + + KEY_PAGE_UP = 33; + + KEY_PAGE_DOWN = 34; + + CLASS_PREFIX = 'jqconsole-'; + + CLASS_CURSOR = "" + CLASS_PREFIX + "cursor"; + + CLASS_HEADER = "" + CLASS_PREFIX + "header"; + + CLASS_PROMPT = "" + CLASS_PREFIX + "prompt"; + + CLASS_OLD_PROMPT = "" + CLASS_PREFIX + "old-prompt"; + + CLASS_INPUT = "" + CLASS_PREFIX + "input"; + + CLASS_BLURRED = "" + CLASS_PREFIX + "blurred"; + + E_KEYPRESS = 'keypress'; + + EMPTY_SPAN = ''; + + EMPTY_DIV = '
'; + + EMPTY_SELECTOR = ':empty'; + + NEWLINE = '\n'; + + DEFAULT_PROMPT_LABEL = '>>> '; + + DEFAULT_PROMPT_CONINUE_LABEL = '... '; + + DEFAULT_INDENT_WIDTH = 2; + + CLASS_ANSI = "" + CLASS_PREFIX + "ansi-"; + + ESCAPE_CHAR = '\x1B'; + + ESCAPE_SYNTAX = /\[(\d*)(?:;(\d*))*m/; + + Ansi = (function() { + + Ansi.prototype.COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white']; + + function Ansi() { + this.stylize = __bind(this.stylize, this); + + this._closeSpan = __bind(this._closeSpan, this); + + this._openSpan = __bind(this._openSpan, this); + + this.getClasses = __bind(this.getClasses, this); + + this._style = __bind(this._style, this); + + this._color = __bind(this._color, this); + + this._remove = __bind(this._remove, this); + + this._append = __bind(this._append, this); + this.klasses = []; + } + + Ansi.prototype._append = function(klass) { + klass = "" + CLASS_ANSI + klass; + if (this.klasses.indexOf(klass) === -1) { + return this.klasses.push(klass); + } + }; + + Ansi.prototype._remove = function() { + var cls, klass, klasses, _i, _len, _results; + klasses = 1 <= arguments.length ? __slice.call(arguments, 0) : []; + _results = []; + for (_i = 0, _len = klasses.length; _i < _len; _i++) { + klass = klasses[_i]; + if (klass === 'fonts' || klass === 'color' || klass === 'background-color') { + _results.push(this.klasses = (function() { + var _j, _len1, _ref, _results1; + _ref = this.klasses; + _results1 = []; + for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { + cls = _ref[_j]; + if (cls.indexOf(klass) !== CLASS_ANSI.length) { + _results1.push(cls); + } + } + return _results1; + }).call(this)); + } else { + klass = "" + CLASS_ANSI + klass; + _results.push(this.klasses = (function() { + var _j, _len1, _ref, _results1; + _ref = this.klasses; + _results1 = []; + for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { + cls = _ref[_j]; + if (cls !== klass) { + _results1.push(cls); + } + } + return _results1; + }).call(this)); + } + } + return _results; + }; + + Ansi.prototype._color = function(i) { + return this.COLORS[i]; + }; + + Ansi.prototype._style = function(code) { + if (code === '') { + code = 0; + } + code = parseInt(code); + if (isNaN(code)) { + return; + } + switch (code) { + case 0: + return this.klasses = []; + case 1: + return this._append('bold'); + case 2: + return this._append('lighter'); + case 3: + return this._append('italic'); + case 4: + return this._append('underline'); + case 5: + return this._append('blink'); + case 6: + return this._append('blink-rapid'); + case 8: + return this._append('hidden'); + case 9: + return this._append('line-through'); + case 10: + return this._remove('fonts'); + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + this._remove('fonts'); + return this._append("fonts-" + (code - 10)); + case 20: + return this._append('fraktur'); + case 21: + return this._remove('bold', 'lighter'); + case 22: + return this._remove('bold', 'lighter'); + case 23: + return this._remove('italic', 'fraktur'); + case 24: + return this._remove('underline'); + case 25: + return this._remove('blink', 'blink-rapid'); + case 28: + return this._remove('hidden'); + case 29: + return this._remove('line-through'); + case 30: + case 31: + case 32: + case 33: + case 34: + case 35: + case 36: + case 37: + this._remove('color'); + return this._append('color-' + this._color(code - 30)); + case 39: + return this._remove('color'); + case 40: + case 41: + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + this._remove('background-color'); + return this._append('background-color-' + this._color(code - 40)); + case 49: + return this._remove('background-color'); + case 51: + return this._append('framed'); + case 53: + return this._append('overline'); + case 54: + return this._remove('framed'); + case 55: + return this._remove('overline'); + } + }; + + Ansi.prototype.getClasses = function() { + return this.klasses.join(' '); + }; + + Ansi.prototype._openSpan = function(text) { + return "" + text; + }; + + Ansi.prototype._closeSpan = function(text) { + return "" + text + ""; + }; + + Ansi.prototype.stylize = function(text) { + var code, d, i, _i, _len, _ref; + text = this._openSpan(text); + i = 0; + while ((i = text.indexOf(ESCAPE_CHAR, i)) && i !== -1) { + if (d = text.slice(i).match(ESCAPE_SYNTAX)) { + _ref = d.slice(1); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + code = _ref[_i]; + this._style(code); + } + text = this._closeSpan(text.slice(0, i)) + this._openSpan(text.slice(i + 1 + d[0].length)); + } else { + i++; + } + } + return this._closeSpan(text); + }; + + return Ansi; + + })(); + + spanHtml = function(klass, content) { + return "" + (content || '') + ""; + }; + + JQConsole = (function() { + + function JQConsole(container, header, prompt_label, prompt_continue_label) { + this.container = container; + this._HideComposition = __bind(this._HideComposition, this); + + this._ShowComposition = __bind(this._ShowComposition, this); + + this._UpdateComposition = __bind(this._UpdateComposition, this); + + this._EndComposition = __bind(this._EndComposition, this); + + this._StartComposition = __bind(this._StartComposition, this); + + this._CheckComposition = __bind(this._CheckComposition, this); + + this._ProcessMatch = __bind(this._ProcessMatch, this); + + this._HandleKey = __bind(this._HandleKey, this); + + this._HandleChar = __bind(this._HandleChar, this); + + this.isMobile = !!navigator.userAgent.match(/iPhone|iPad|iPod|Android/i); + this.isIos = !!navigator.userAgent.match(/iPhone|iPad|iPod/i); + this.isAndroid = !!navigator.userAgent.match(/Android/i); + this.$window = $(window); + this.header = header || ''; + this.prompt_label_main = typeof prompt_label === 'string' ? prompt_label : DEFAULT_PROMPT_LABEL; + this.prompt_label_continue = prompt_continue_label || DEFAULT_PROMPT_CONINUE_LABEL; + this.indent_width = DEFAULT_INDENT_WIDTH; + this.state = STATE_OUTPUT; + this.input_queue = []; + this.input_callback = null; + this.multiline_callback = null; + this.history = []; + this.history_index = 0; + this.history_new = ''; + this.history_active = false; + this.shortcuts = {}; + this.$console = $('
').appendTo(this.container);
+      this.$console.css({
+        position: 'absolute',
+        top: 0,
+        bottom: 0,
+        right: 0,
+        left: 0,
+        margin: 0,
+        overflow: 'auto'
+      });
+      this.$console_focused = true;
+      this.$input_container = $(EMPTY_DIV).appendTo(this.container);
+      this.$input_container.css({
+        position: 'relative',
+        width: 1,
+        height: 0,
+        overflow: 'hidden'
+      });
+      this.$input_source = $('');
-		// Prompt
-		var promptBox;
-		var prompt;
-		var promptLabel = config && config.promptLabel? config.promptLabel : "> ";
-		var continuedPromptLabel = config && config.continuedPromptLabel?
-		config.continuedPromptLabel : "> ";
-		var column = 0;
-		var promptText = '';
-		var restoreText = '';
-		var continuedText = '';
-		// Prompt history stack
-		var history = [];
-		var ringn = 0;
-		// For reasons unknown to The Sword of Michael himself, Opera
-		// triggers and sends a key character when you hit various
-		// keys like PgUp, End, etc. So there is no way of knowing
-		// when a user has typed '#' or End. My solution is in the
-		// typer.keydown and typer.keypress functions; I use the
-		// variable below to ignore the keypress event if the keydown
-		// event succeeds.
-		var cancelKeyPress = 0;
-		// When this value is false, the prompt will not respond to input
-		var acceptInput = true;
-		// When this value is true, the command has been canceled
-		var cancelCommand = false;
-
-		// External exports object
-		var extern = {};
-
-		////////////////////////////////////////////////////////////////////////
-		// Main entry point
-		(function(){
-			container.append(inner);
-			inner.append(typer);
-			typer.css({position:'absolute',top:0,left:'-9999px'});
-			if (config.welcomeMessage)
-				message(config.welcomeMessage,'jquery-console-welcome');
-			newPromptBox();
-			if (config.autofocus) {
-				inner.addClass('jquery-console-focus');
-				typer.focus();
-				setTimeout(function(){
-					inner.addClass('jquery-console-focus');
-					typer.focus();
-				},100);
-			}
-			extern.inner = inner;
-			extern.typer = typer;
-			extern.scrollToBottom = scrollToBottom;
-		})();
-
-		////////////////////////////////////////////////////////////////////////
-		// Reset terminal
-		extern.reset = function(){
-			var welcome = (typeof config.welcomeMessage != 'undefined');
-			inner.parent().fadeOut(function(){
-				inner.find('div').each(function(){
-					if (!welcome) {
-						$(this).remove();
-			} else {
-			welcome = false;
-			}
-				});
-				newPromptBox();
-				inner.parent().fadeIn(function(){
-					inner.addClass('jquery-console-focus');
-					typer.focus();
-				});
-			});
-		};
-
-		////////////////////////////////////////////////////////////////////////
-		// Reset terminal
-		extern.notice = function(msg,style){
-			var n = $('
').append($('
').text(msg)) - .css({visibility:'hidden'}); - container.append(n); - var focused = true; - if (style=='fadeout') - setTimeout(function(){ - n.fadeOut(function(){ - n.remove(); - }); - },4000); - else if (style=='prompt') { - var a = $('
'); - n.append(a); - focused = false; - a.click(function(){ n.fadeOut(function(){ n.remove();inner.css({opacity:1}) }); }); - } - var h = n.height(); - n.css({height:'0px',visibility:'visible'}) - .animate({height:h+'px'},function(){ - if (!focused) inner.css({opacity:0.5}); - }); - n.css('cursor','default'); - return n; - }; - - //////////////////////////////////////////////////////////////////////// - // Make a new prompt box - function newPromptBox() { - column = 0; - promptText = ''; - ringn = 0; // Reset the position of the history ring - enableInput(); - promptBox = $('
'); - var label = $(''); - var labelText = extern.continuedPrompt? continuedPromptLabel : promptLabel; - promptBox.append(label.text(labelText).show()); - label.html(label.html().replace(' ',' ')); - prompt = $(''); - promptBox.append(prompt); - inner.append(promptBox); - updatePromptDisplay(); - }; - - //////////////////////////////////////////////////////////////////////// - // Handle setting focus - container.click(function(){ - inner.addClass('jquery-console-focus'); - inner.removeClass('jquery-console-nofocus'); - if (isWebkit) { - typer.focusWithoutScrolling(); - } else { - typer.css('position', 'fixed').focus(); - } - scrollToBottom(); - return false; - }); - - //////////////////////////////////////////////////////////////////////// - // Handle losing focus - typer.blur(function(){ - inner.removeClass('jquery-console-focus'); - inner.addClass('jquery-console-nofocus'); - }); - - //////////////////////////////////////////////////////////////////////// - // Bind to the paste event of the input box so we know when we - // get pasted data - typer.bind('paste', function(e) { - // wipe typer input clean just in case - typer.val(""); - // this timeout is required because the onpaste event is - // fired *before* the text is actually pasted - setTimeout(function() { - typer.consoleInsert(typer.val()); - typer.val(""); - }, 0); - }); - - //////////////////////////////////////////////////////////////////////// - // Handle key hit before translation - // For picking up control characters like up/left/down/right - - typer.keydown(function(e){ - cancelKeyPress = 0; - var keyCode = e.keyCode; - // C-c: cancel the execution - if(e.ctrlKey && keyCode == 67) { - cancelKeyPress = keyCode; - cancelExecution(); - return false; - } - if (acceptInput) { - if (keyCode in keyCodes) { - cancelKeyPress = keyCode; - (keyCodes[keyCode])(); - return false; - } else if (e.ctrlKey && keyCode in ctrlCodes) { - cancelKeyPress = keyCode; - (ctrlCodes[keyCode])(); - return false; - } else if (e.altKey && keyCode in altCodes) { - cancelKeyPress = keyCode; - (altCodes[keyCode])(); - return false; - } - } - }); - - //////////////////////////////////////////////////////////////////////// - // Handle key press - typer.keypress(function(e){ - var keyCode = e.keyCode || e.which; - if (isIgnorableKey(e)) { - return false; - } - // C-v: don't insert on paste event - if ((e.ctrlKey || e.metaKey) && String.fromCharCode(keyCode).toLowerCase() == 'v') { - return true; - } - if (acceptInput && cancelKeyPress != keyCode && keyCode >= 32){ - if (cancelKeyPress) return false; - if ( - typeof config.charInsertTrigger == 'undefined' || ( - typeof config.charInsertTrigger == 'function' && - config.charInsertTrigger(keyCode,promptText) - ) - ){ - typer.consoleInsert(keyCode); - } - } - if (isWebkit) return false; - }); - - function isIgnorableKey(e) { - // for now just filter alt+tab that we receive on some platforms when - // user switches windows (goes away from the browser) - return ((e.keyCode == keyCodes.tab || e.keyCode == 192) && e.altKey); - }; - - //////////////////////////////////////////////////////////////////////// - // Rotate through the command history - function rotateHistory(n){ - if (history.length == 0) return; - ringn += n; - if (ringn < 0) ringn = history.length; - else if (ringn > history.length) ringn = 0; - var prevText = promptText; - if (ringn == 0) { - promptText = restoreText; - } else { - promptText = history[ringn - 1]; - } - if (config.historyPreserveColumn) { - if (promptText.length < column + 1) { - column = promptText.length; - } else if (column == 0) { - column = promptText.length; - } - } else { - column = promptText.length; - } - updatePromptDisplay(); - }; - - function previousHistory() { - rotateHistory(-1); - }; - - function nextHistory() { - rotateHistory(1); - }; - - // Add something to the history ring - function addToHistory(line){ - history.push(line); - restoreText = ''; - }; - - // Delete the character at the current position - function deleteCharAtPos(){ - if (column < promptText.length){ - promptText = - promptText.substring(0,column) + - promptText.substring(column+1); - restoreText = promptText; - return true; - } else return false; - }; - - function backDelete() { - if (moveColumn(-1)){ - deleteCharAtPos(); - updatePromptDisplay(); - } - }; - - function forwardDelete() { - if (deleteCharAtPos()){ - updatePromptDisplay(); - } - }; - - function deleteUntilEnd() { - while(deleteCharAtPos()) { - updatePromptDisplay(); - } - }; - - function deleteNextWord() { - // A word is defined within this context as a series of alphanumeric - // characters. - // Delete up to the next alphanumeric character - while( - column < promptText.length && - !isCharAlphanumeric(promptText[column]) - ) { - deleteCharAtPos(); - updatePromptDisplay(); - } - // Then, delete until the next non-alphanumeric character - while( - column < promptText.length && - isCharAlphanumeric(promptText[column]) - ) { - deleteCharAtPos(); - updatePromptDisplay(); - } - }; - - //////////////////////////////////////////////////////////////////////// - // Validate command and trigger it if valid, or show a validation error - function commandTrigger() { - var line = promptText; - if (typeof config.commandValidate == 'function') { - var ret = config.commandValidate(line); - if (ret == true || ret == false) { - if (ret) { - handleCommand(); - } - } else { - commandResult(ret,"jquery-console-message-error"); - } - } else { - handleCommand(); - } - }; - - // Scroll to the bottom of the view - function scrollToBottom() { - if (jQuery.fn.jquery > "1.6") { - inner.prop({ scrollTop: inner.prop("scrollHeight") }); - } - else { - inner.attr({ scrollTop: inner.attr("scrollHeight") }); - } - }; - - function cancelExecution() { - if(typeof config.cancelHandle == 'function') { - config.cancelHandle(); - } - } - - //////////////////////////////////////////////////////////////////////// - // Handle a command - function handleCommand() { - if (typeof config.commandHandle == 'function') { - disableInput(); - addToHistory(promptText); - var text = promptText; - if (extern.continuedPrompt) { - if (continuedText) - continuedText += '\n' + promptText; - else continuedText = promptText; - } else continuedText = undefined; - if (continuedText) text = continuedText; - var ret = config.commandHandle(text,function(msgs){ - commandResult(msgs); - }); - if (extern.continuedPrompt && !continuedText) - continuedText = promptText; - if (typeof ret == 'boolean') { - if (ret) { - // Command succeeded without a result. - commandResult(); - } else { - commandResult( - 'Command failed.', - "jquery-console-message-error" - ); - } - } else if (typeof ret == "string") { - commandResult(ret,"jquery-console-message-success"); - } else if (typeof ret == 'object' && ret.length) { - commandResult(ret); - } else if (extern.continuedPrompt) { - commandResult(); - } - } - }; - - //////////////////////////////////////////////////////////////////////// - // Disable input - function disableInput() { - acceptInput = false; - }; - - // Enable input - function enableInput() { - acceptInput = true; - } - - //////////////////////////////////////////////////////////////////////// - // Reset the prompt in invalid command - function commandResult(msg,className) { - column = -1; - updatePromptDisplay(); - if (typeof msg == 'string') { - message(msg,className); - } else if ($.isArray(msg)) { - for (var x in msg) { - var ret = msg[x]; - message(ret.msg,ret.className); - } - } else { // Assume it's a DOM node or jQuery object. - inner.append(msg); - } - newPromptBox(); - }; - - //////////////////////////////////////////////////////////////////////// - // Display a message - function message(msg,className) { - var mesg = $('
'); - if (className) mesg.addClass(className); - mesg.filledText(msg).hide(); - inner.append(mesg); - mesg.show(); - }; - - //////////////////////////////////////////////////////////////////////// - // Handle normal character insertion - // data can either be a number, which will be interpreted as the - // numeric value of a single character, or a string - typer.consoleInsert = function(data){ - // TODO: remove redundant indirection - var text = isNaN(data) ? data : String.fromCharCode(data); - var before = promptText.substring(0,column); - var after = promptText.substring(column); - promptText = before + text + after; - moveColumn(text.length); - restoreText = promptText; - updatePromptDisplay(); - }; - - //////////////////////////////////////////////////////////////////////// - // Move to another column relative to this one - // Negative means go back, positive means go forward. - function moveColumn(n){ - if (column + n >= 0 && column + n <= promptText.length){ - column += n; - return true; - } else return false; - }; - - function moveForward() { - if(moveColumn(1)) { - updatePromptDisplay(); - return true; - } - return false; - }; - - function moveBackward() { - if(moveColumn(-1)) { - updatePromptDisplay(); - return true; - } - return false; - }; - - function moveToStart() { - if (moveColumn(-column)) - updatePromptDisplay(); - }; - - function moveToEnd() { - if (moveColumn(promptText.length-column)) - updatePromptDisplay(); - }; - - function moveToNextWord() { - while( - column < promptText.length && - !isCharAlphanumeric(promptText[column]) && - moveForward() - ) {} - while( - column < promptText.length && - isCharAlphanumeric(promptText[column]) && - moveForward() - ) {} - }; - - function moveToPreviousWord() { - // Move backward until we find the first alphanumeric - while( - column -1 >= 0 && - !isCharAlphanumeric(promptText[column-1]) && - moveBackward() - ) {} - // Move until we find the first non-alphanumeric - while( - column -1 >= 0 && - isCharAlphanumeric(promptText[column-1]) && - moveBackward() - ) {} - }; - - function isCharAlphanumeric(charToTest) { - if(typeof charToTest == 'string') { - var code = charToTest.charCodeAt(); - return (code >= 'A'.charCodeAt() && code <= 'Z'.charCodeAt()) || - (code >= 'a'.charCodeAt() && code <= 'z'.charCodeAt()) || - (code >= '0'.charCodeAt() && code <= '9'.charCodeAt()); - } - return false; - }; - - function doComplete() { - if(typeof config.completeHandle == 'function') { - var completions = config.completeHandle(promptText); - var len = completions.length; - if (len === 1) { - extern.promptText(promptText + completions[0]); - } else if (len > 1 && config.cols) { - var prompt = promptText; - // Compute the number of rows that will fit in the width - var max = 0; - for (var i = 0;i < len;i++) { - max = Math.max(max, completions[i].length); - } - max += 2; - var n = Math.floor(config.cols / max); - var buffer = ""; - var col = 0; - for (i = 0;i < len;i++) { - var completion = completions[i]; - buffer += completions[i]; - for (var j = completion.length;j < max;j++) { - buffer += " "; - } - if (++col >= n) { - buffer += "\n"; - col = 0; - } - } - commandResult(buffer,"jquery-console-message-value"); - extern.promptText(prompt); - } - } - }; - - function doNothing() {}; - - extern.promptText = function(text){ - if (typeof text === 'string') { - promptText = text; - column = promptText.length; - updatePromptDisplay(); - } - return promptText; - }; - - //////////////////////////////////////////////////////////////////////// - // Update the prompt display - function updatePromptDisplay(){ - var line = promptText; - var html = ''; - if (column > 0 && line == ''){ - // When we have an empty line just display a cursor. - html = cursor; - } else if (column == promptText.length){ - // We're at the end of the line, so we need to display - // the text *and* cursor. - html = htmlEncode(line) + cursor; - } else { - // Grab the current character, if there is one, and - // make it the current cursor. - var before = line.substring(0, column); - var current = line.substring(column,column+1); - if (current){ - current = - '' + - htmlEncode(current) + - ''; - } - var after = line.substring(column+1); - html = htmlEncode(before) + current + htmlEncode(after); - } - prompt.html(html); - scrollToBottom(); - }; - - // Simple HTML encoding - // Simply replace '<', '>' and '&' - // TODO: Use jQuery's .html() trick, or grab a proper, fast - // HTML encoder. - function htmlEncode(text){ - return ( - text.replace(/&/g,'&') - .replace(/') - ); - }; - - return extern; - }; - // Simple utility for printing messages - $.fn.filledText = function(txt){ - $(this).text(txt); - $(this).html($(this).html().replace(/\n/g,'
')); - return this; - }; - - // Alternative method for focus without scrolling - $.fn.focusWithoutScrolling = function(){ - var x = window.scrollX, y = window.scrollY; - $(this).focus(); - window.scrollTo(x, y); - }; -})(jQuery); diff --git a/lib/client/terminal/jquery-terminal/CHANGELOG b/lib/client/terminal/jquery-terminal/CHANGELOG deleted file mode 100644 index 305b1b9c..00000000 --- a/lib/client/terminal/jquery-terminal/CHANGELOG +++ /dev/null @@ -1,88 +0,0 @@ -0.4.20 Add exec, greetings, onClear, onBlur, onFocus, onTerminalChange -0.4.19 add support for ANSI terminal formatting, fix cancelable ajax on - CTRL+D, replace emails with link mailto, remove formatting processing - from command line, add text glow option to formatting -0.4.18 fix scrollbar, better exceptions in chrome, replace urls with links - one style for font and color in root .terminal class -0.4.17 fix IE formatting issue by adding cross-browser split -0.4.16 add reverse history search on CTRL+R - - fix cancel ajax call on CTRL+D -0.4.15 only one command from multiply commands is added to history - CTRL+D is handled even if exit is false -0.4.14 terminal don't add space after prompt (prompt need to add this space) - fix historyFilter - remove livequery -0.4.12 history return history object - add historyFilter - new event onCommandChange that execute scroll_to_bottom - add event onBeforeLogin -0.4.11 fix blank lines when echo longer strings -0.4.10 fix long line formatting and linebreak in the middle of formatting -0.4.9 fix wrap first line when prompt contain formatting -0.4.8 fix alt+d and ctrl+u -0.4.7 fix inserting special characters in Webkit on Windows -0.4.6 remove undocumented pipe operator - refreash prompt on resume -0.4.5 fix line wrapping when text contains tabulations -0.4.4 fix line wrapping with scrollbars -0.4.3 fix JSON-RPC when use without login -0.4.2 fix formatting when text contain empty lines -0.4.1 fix formatting when text contains newline characters -0.4 fix text formating when text splited into more then one line - you can pass nested objects as first argument - add tab completion with object passed as first argument -0.3.8 fix cursor manipulation when command contain new line characters -0.3.7 fix function terminal.login_name -0.3.6 fix switch between terminals - when terminal is not visible scroll to current terminal -0.3.5 fix scrolling in jQuery 1.6 -0.3.3 fixing PAGE UP/DOWN -0.3.2 fixing cursor in long lines -0.3.1 fixing small bugs, speed up resizing -0.3 fix resizing on start and issue with greetings - add formating strings to set style of text. - add to echo a function which will be called when terminal - is resized -0.3-RC2 fix manipulation of long line commands -0.3-RC1 add callbacks and new functions - you can now overwrite keyboard shortcuts - resizing recalculates lines lenght and redraw content - if you create plugin for elements that are not in the DOM - and then append it to DOM it's display corectly - put all dependencies in one file - Default greetings show terminal signature depending on - width of terminal - use Local Sorage for command line history if posible - remove access to command line (cmd plugin) and add interface - to allow interact with it - -0.2.3.9 fix append enter character (0x0D) to the command (thanks to marat - for reporting the bug) - -0.2.3.8 update mousewheel plugin which fix scrolling in Opera (Thanks for - Alexey Dubovtsev for reporting the bug) - -0.2.3.7 fix cursor in IE in tilda example - -0.2.3.6 fix json serialization in IE - -0.2.3.5 fix demos and clipboard textarea transparency in IE - -0.2.3.4 fix long lines in command line issue - -0.2.3.3 fix Terminal in Internet Exporer - -0.2.3.2 fix blank line issue (thanks to Chris Janicki for finding the - bug) and fix CTRL + Arrows scroll on CTRL+V - -0.2.3.1 allow CTRL+W CTRL+T - -0.2.3 fix for "(#$%.{" characters on Opera/Chrome, add cursor move - with CTRL+P, CTRL+N, CTRL+F, CTRL+B which also work in Chrome. - Fix Arrow Keys on Chrome (for cursor move and command line - history). Change License to LGPL3. - -0.2.2 fix down-arrow/open parentises issue in Opera and Chrome - -0.2.1 add support for paste from clipboard with CTRL+V (Copy to - clipboard is alway enabled on websites) \ No newline at end of file diff --git a/lib/client/terminal/jquery-terminal/README b/lib/client/terminal/jquery-terminal/README deleted file mode 100644 index 16957789..00000000 --- a/lib/client/terminal/jquery-terminal/README +++ /dev/null @@ -1,69 +0,0 @@ - __ _____ ________ __ - / // _ /__ __ _____ ___ __ _/__ ___/__ ___ ______ __ __ __ ___ / / - __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ / - / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__ - \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/ - \/ /____/ version 0.4.22 - - -http://terminal.jcubic.pl - -Licensed under GNU LGPL Version 3 license http://www.gnu.org/licenses/lgpl.html -Copyright (c) 2011-2012 Jakub Jankiewicz - -JQuery Terminal Emulator is a plugin for creating command line interpreters in -your applications. It can automatically call JSON-RPC service when user type -commands or you can provide you own function in which you can parse user -command. It's ideal if you want to provide additional functionality for power -users. It can also be used to debug your aplication. - -Features: - - * You can create interpreter for your JSON-RPC service with one line - of code. - - * Support for authentication (you can provide function when user enter - login and password or if you use JSON-RPC it can automatically call - login function on the server and pass token to all functions) - - * Stack of interpreters - you can create commands that trigger additional - interpreters (eg. you can use couple of JSON-RPC service and run them - when user type command) - - * Command Tree - you can use nested objects. Each command will invoke a - function, if the value is an object it will create new interpreter and - use function from that object as commands. You can use as much nested - object/commands as you like. If the value is a string it will create - JSON-RPC service. - - * Support for command line history it use Local Storage if posible - - * Support for tab completion if you create terminal from an object - - * Include keyboard shortcut from bash like CTRL+A, CTRL+D, CTRL+E etc. - - * Multiply terminals on one page (every terminal can have different - command, it's own authentication function and it's own command history) - - * It catch all exceptions and display error messages in terminal - (you can see errors in your javascript and php code in terminal if they - are in interpreter function) - - -Example of usage (javascript interpreter) - -jQuery(function($, undefined) { - $('#term_demo').terminal(function(command, term) { - if (command !== '') { - var result = window.eval(command); - if (result != undefined) { - term.echo(String(result)); - } - } - }, { - greetings: 'Javascript Interpreter', - name: 'js_demo', - height: 200, - width: 450, - prompt: 'js> '}); -}); \ No newline at end of file diff --git a/lib/client/terminal/jquery-terminal/dterm.js b/lib/client/terminal/jquery-terminal/dterm.js deleted file mode 100644 index 7506d2fc..00000000 --- a/lib/client/terminal/jquery-terminal/dterm.js +++ /dev/null @@ -1,63 +0,0 @@ -/*! - * Example plugin using JQuery Terminal Emulator - * Copyright (C) 2010 Jakub Jankiewicz - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ -(function($) { - $.extend_if_has = function(desc, source, array) { - for (var i=array.length;i--;) { - if (typeof source[array[i]] != 'undefined') { - desc[array[i]] = source[array[i]]; - } - } - return desc; - }; - $.fn.dterm = function(eval, options) { - var op = $.extend_if_has({}, options, - ['greetings', 'prompt', 'onInit', - 'onExit', 'clear', - 'login', 'name', 'exit']); - op.enabled = false; - var terminal = this.terminal(eval, op).css('overflow', 'hidden'); - if (!options.title) { - options.title = 'JQuery Terminal Emulator'; - } - if (options.logoutOnClose) { - options.close = function(e, ui) { - terminal.logout(); - terminal.clear(); - }; - } else { - options.close = function(e, ui) { - terminal.disable(); - }; - } - var self = this; - var dialog = this.dialog($.extend(options, { - resizeStop: function(e, ui) { - var content = self.find('.ui-dialog-content'); - terminal.resize(content.width(), content.height()); - }, - open: function(e, ui) { - terminal.focus(); - terminal.resize(); - }, - show: 'fade', - closeOnEscape: false - })); - self.terminal = terminal; - return self; - }; -})(jQuery); diff --git a/lib/client/terminal/jquery-terminal/index.html b/lib/client/terminal/jquery-terminal/index.html deleted file mode 100644 index 37496a42..00000000 --- a/lib/client/terminal/jquery-terminal/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - -
- \ No newline at end of file diff --git a/lib/client/terminal/jquery-terminal/jquery.mousewheel.js b/lib/client/terminal/jquery-terminal/jquery.mousewheel.js deleted file mode 100644 index c7b28217..00000000 --- a/lib/client/terminal/jquery-terminal/jquery.mousewheel.js +++ /dev/null @@ -1,84 +0,0 @@ -/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net) - * Licensed under the MIT License (LICENSE.txt). - * - * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. - * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. - * Thanks to: Seamus Leahy for adding deltaX and deltaY - * - * Version: 3.0.6 - * - * Requires: 1.2.2+ - */ - -(function($) { - -var types = ['DOMMouseScroll', 'mousewheel']; - -if ($.event.fixHooks) { - for ( var i=types.length; i; ) { - $.event.fixHooks[ types[--i] ] = $.event.mouseHooks; - } -} - -$.event.special.mousewheel = { - setup: function() { - if ( this.addEventListener ) { - for ( var i=types.length; i; ) { - this.addEventListener( types[--i], handler, false ); - } - } else { - this.onmousewheel = handler; - } - }, - - teardown: function() { - if ( this.removeEventListener ) { - for ( var i=types.length; i; ) { - this.removeEventListener( types[--i], handler, false ); - } - } else { - this.onmousewheel = null; - } - } -}; - -$.fn.extend({ - mousewheel: function(fn) { - return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); - }, - - unmousewheel: function(fn) { - return this.unbind("mousewheel", fn); - } -}); - - -function handler(event) { - var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; - event = $.event.fix(orgEvent); - event.type = "mousewheel"; - - // Old school scrollwheel delta - if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; } - if ( orgEvent.detail ) { delta = -orgEvent.detail/3; } - - // New school multidimensional scroll (touchpads) deltas - deltaY = delta; - - // Gecko - if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) { - deltaY = 0; - deltaX = -1*delta; - } - - // Webkit - if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; } - if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; } - - // Add event and delta to the front of the arguments - args.unshift(event, delta, deltaX, deltaY); - - return ($.event.dispatch || $.event.handle).apply(this, args); -} - -})(jQuery); \ No newline at end of file diff --git a/lib/client/terminal/jquery-terminal/jquery.terminal.css b/lib/client/terminal/jquery-terminal/jquery.terminal.css deleted file mode 100644 index 8eb2cee7..00000000 --- a/lib/client/terminal/jquery-terminal/jquery.terminal.css +++ /dev/null @@ -1,74 +0,0 @@ -.terminal .clipboard { - position: absolute; - bottom: 0; - left: 0; - opacity: 0.01; - filter: alpha(opacity = 0.01); - filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0.01); - width: 2px; -} -.cmd > .clipboard { - position: fixed; -} -.terminal { - padding: 10px; - position: relative; - overflow: hidden; -} -.cmd { - padding: 0; - margin: 0; - height: 1.3em; -} -.terminal .terminal-output div div, .terminal .prompt { - display: block; - /* line-height: 9px; */ - height: 14px; -} -.terminal { - font-family: FreeMono, monospace; - color: #aaa; - background-color: #000; - /* font-size: 12px; */ - /* line-height: 14px; */ - line-height: 16px; - /* removing breaking the lines */ -} -.terminal .terminal-output div span { - display: inline-block; -} -.terminal .cmd span { - display: inline-block; -} -.terminal .cmd span.inverted { - background-color: #aaa; - color: #000; -} -.terminal .terminal-output div div::-moz-selection, .terminal .terminal-output div span::-moz-selection { - background-color: #aaa; - color: #000; -} -.terminal .terminal-output div div::selection, .terminal .terminal-output div span::selection, -.terminal .cmd > span::selection, .terminal .prompt span::selection { - background-color: #aaa; - color: #000; -} -.terminal .terminal-output div.error, .terminal .terminal-output div.error div { - color: red; -} -.tilda { - position: fixed; - top: 0; - left: 0; - width: 100%; - z-index: 1100; -} -.clear { - clear: both; -} -.terminal a { - color: #0F60FF; -} -.terminal a:hover { - color: red; -} \ No newline at end of file diff --git a/lib/client/terminal/jquery-terminal/jquery.terminal.js b/lib/client/terminal/jquery-terminal/jquery.terminal.js deleted file mode 100644 index b8af09fe..00000000 --- a/lib/client/terminal/jquery-terminal/jquery.terminal.js +++ /dev/null @@ -1,2712 +0,0 @@ -/**@license - *| __ _____ ________ __ - *| / // _ /__ __ _____ ___ __ _/__ ___/__ ___ ______ __ __ __ ___ / / - *| __ / // // // // // _ // _// // / / // _ // _// // // \/ // _ \/ / - *| / / // // // // // ___// / / // / / // ___// / / / / // // /\ // // / /__ - *| \___//____ \\___//____//_/ _\_ / /_//____//_/ /_/ /_//_//_/ /_/ \__\_\___/ - *| \/ /____/ version 0.4.22 - * http://terminal.jcubic.pl - * - * Licensed under GNU LGPL Version 3 license - * Copyright (c) 2011-2012 Jakub Jankiewicz - * - * Includes: - * - * Storage plugin Distributed under the MIT License - * Copyright (c) 2010 Dave Schindler - * - * jQuery Timers licenced with the WTFPL - * - * - * Cross-Browser Split 1.1.1 - * Copyright 2007-2012 Steven Levithan - * Available under the MIT License - * - * Date: Thu, 15 Nov 2012 07:12:21 +0000 - */ - -/* - - TODO: - add destroy method to terminal (cmd alrady have it) - - add support for - $(...).each(function() { ... }); - - $.fn.pluginname = function(options) { - var settings = $.extend({}, $.fn.pluginname.defaultOptions, options); - - return this.each(function() { - var $this = $(this); - }); - $.fn.pluginname.defaultOptions = { - }; - }; - - distinguish between paused and disabled - paused should block keydown in terminal it should disable command line - disable - -*/ - - - -(function($, undefined) { - "use strict"; - - // map object to object - $.omap = function(o, fn) { - var result = {}; - $.each(o, function(k, v) { - result[k] = fn.call(o, k, v); - }); - return result; - }; - // debug function - function get_stack(caller) { - "use strict"; - if (caller) { - return [caller.toString().match(/.*\n.*\n/)]. - concat(get_stack(caller.caller)); - } else { - return []; - } - } - // ---------------------------------------- - // START Storage plugin - // ---------------------------------------- - // Private data - var isLS = typeof window.localStorage !== 'undefined'; - // Private functions - function wls(n, v) { - var c; - if (typeof n === 'string' && typeof v === 'string') { - localStorage[n] = v; - return true; - } else if (typeof n === 'object' && typeof v === 'undefined') { - for (c in n) { - if (n.hasOwnProperty(c)) { - localStorage[c] = n[c]; - } - } - return true; - } - return false; - } - function wc(n, v) { - var dt, e, c; - dt = new Date(); - dt.setTime(dt.getTime() + 31536000000); - e = '; expires=' + dt.toGMTString(); - if (typeof n === 'string' && typeof v === 'string') { - document.cookie = n + '=' + v + e + '; path=/'; - return true; - } else if (typeof n === 'object' && typeof v === 'undefined') { - for (c in n) { - if (n.hasOwnProperty(c)) { - document.cookie = c + '=' + n[c] + e + '; path=/'; - } - } - return true; - } - return false; - } - function rls(n) { - return localStorage[n]; - } - function rc(n) { - var nn, ca, i, c; - nn = n + '='; - ca = document.cookie.split(';'); - for (i = 0; i < ca.length; i++) { - c = ca[i]; - while (c.charAt(0) === ' ') { - c = c.substring(1, c.length); - } - if (c.indexOf(nn) === 0) { - return c.substring(nn.length, c.length); - } - } - return null; - } - function dls(n) { - return delete localStorage[n]; - } - function dc(n) { - return wc(n, '', -1); - } - /** - * Public API - * $.Storage.set("name", "value") - * $.Storage.set({"name1":"value1", "name2":"value2", etc}) - * $.Storage.get("name") - * $.Storage.remove("name") - */ - $.extend({ - Storage: { - set: isLS ? wls : wc, - get: isLS ? rls : rc, - remove: isLS ? dls : dc - } - }); - // ---------------------------------------- - // END Storage plugin - // ---------------------------------------- - // START jQuery Timers - // ---------------------------------------- - jQuery.fn.extend({ - everyTime: function(interval, label, fn, times, belay) { - return this.each(function() { - jQuery.timer.add(this, interval, label, fn, times, belay); - }); - }, - oneTime: function(interval, label, fn) { - return this.each(function() { - jQuery.timer.add(this, interval, label, fn, 1); - }); - }, - stopTime: function(label, fn) { - return this.each(function() { - jQuery.timer.remove(this, label, fn); - }); - } - }); - - jQuery.extend({ - timer: { - guid: 1, - global: {}, - regex: /^([0-9]+)\s*(.*s)?$/, - powers: { - // Yeah this is major overkill... - 'ms': 1, - 'cs': 10, - 'ds': 100, - 's': 1000, - 'das': 10000, - 'hs': 100000, - 'ks': 1000000 - }, - timeParse: function(value) { - if (value === undefined || value === null) { - return null; - } - var result = this.regex.exec(jQuery.trim(value.toString())); - if (result[2]) { - var num = parseInt(result[1], 10); - var mult = this.powers[result[2]] || 1; - return num * mult; - } else { - return value; - } - }, - add: function(element, interval, label, fn, times, belay) { - var counter = 0; - - if (jQuery.isFunction(label)) { - if (!times) { - times = fn; - } - fn = label; - label = interval; - } - - interval = jQuery.timer.timeParse(interval); - - if (typeof interval !== 'number' || - isNaN(interval) || - interval <= 0) { - return; - } - if (times && times.constructor !== Number) { - belay = !!times; - times = 0; - } - - times = times || 0; - belay = belay || false; - - if (!element.$timers) { - element.$timers = {}; - } - if (!element.$timers[label]) { - element.$timers[label] = {}; - } - fn.$timerID = fn.$timerID || this.guid++; - - var handler = function() { - if (belay && handler.inProgress) { - return; - } - handler.inProgress = true; - if ((++counter > times && times !== 0) || - fn.call(element, counter) === false) { - jQuery.timer.remove(element, label, fn); - } - handler.inProgress = false; - }; - - handler.$timerID = fn.$timerID; - - if (!element.$timers[label][fn.$timerID]) { - element.$timers[label][fn.$timerID] = window.setInterval(handler, interval); - } - - if (!this.global[label]) { - this.global[label] = []; - } - this.global[label].push(element); - - }, - remove: function(element, label, fn) { - var timers = element.$timers, ret; - - if (timers) { - - if (!label) { - for (var lab in timers) { - if (timers.hasOwnProperty(lab)) { - this.remove(element, lab, fn); - } - } - } else if (timers[label]) { - if (fn) { - if (fn.$timerID) { - window.clearInterval(timers[label][fn.$timerID]); - delete timers[label][fn.$timerID]; - } - } else { - for (var _fn in timers[label]) { - if (timers[label].hasOwnProperty(_fn)) { - window.clearInterval(timers[label][_fn]); - delete timers[label][_fn]; - } - } - } - - for (ret in timers[label]) { - if (timers[label].hasOwnProperty(ret)) { - break; - } - } - if (!ret) { - ret = null; - delete timers[label]; - } - } - - for (ret in timers) { - if (timers.hasOwnProperty(ret)) { - break; - } - } - if (!ret) { - element.$timers = null; - } - } - } - } - }); - - if (jQuery.browser.msie) { - jQuery(window).one('unload', function() { - var global = jQuery.timer.global; - for (var label in global) { - if (global.hasOwnProperty(label)) { - var els = global[label], i = els.length; - while (--i) { - jQuery.timer.remove(els[i], label); - } - } - } - }); - } - // ---------------------------------------- - // START CROSS BROWSER SPLIT - // ---------------------------------------- - - (function(undef) { - - // prevent double include - - if (!String.prototype.split.toString().match(/\[native/)) { - return; - } - - var nativeSplit = String.prototype.split, - compliantExecNpcg = /()??/.exec("")[1] === undef, // NPCG: nonparticipating capturing group - self; - - self = function (str, separator, limit) { - // If `separator` is not a regex, use `nativeSplit` - if (Object.prototype.toString.call(separator) !== "[object RegExp]") { - return nativeSplit.call(str, separator, limit); - } - var output = [], - flags = (separator.ignoreCase ? "i" : "") + - (separator.multiline ? "m" : "") + - (separator.extended ? "x" : "") + // Proposed for ES6 - (separator.sticky ? "y" : ""), // Firefox 3+ - lastLastIndex = 0, - // Make `global` and avoid `lastIndex` issues by working with a copy - separator2, match, lastIndex, lastLength; - separator = new RegExp(separator.source, flags + "g"); - str += ""; // Type-convert - if (!compliantExecNpcg) { - // Doesn't need flags gy, but they don't hurt - separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags); - } - /* Values for `limit`, per the spec: - * If undefined: 4294967295 // Math.pow(2, 32) - 1 - * If 0, Infinity, or NaN: 0 - * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296; - * If negative number: 4294967296 - Math.floor(Math.abs(limit)) - * If other: Type-convert, then use the above rules - */ - // ? Math.pow(2, 32) - 1 : ToUint32(limit) - limit = limit === undef ? -1 >>> 0 : limit >>> 0; - while (match = separator.exec(str)) { - // `separator.lastIndex` is not reliable cross-browser - lastIndex = match.index + match[0].length; - if (lastIndex > lastLastIndex) { - output.push(str.slice(lastLastIndex, match.index)); - // Fix browsers whose `exec` methods don't consistently return `undefined` for - // nonparticipating capturing groups - if (!compliantExecNpcg && match.length > 1) { - match[0].replace(separator2, function () { - for (var i = 1; i < arguments.length - 2; i++) { - if (arguments[i] === undef) { - match[i] = undef; - } - } - }); - } - if (match.length > 1 && match.index < str.length) { - Array.prototype.push.apply(output, match.slice(1)); - } - lastLength = match[0].length; - lastLastIndex = lastIndex; - if (output.length >= limit) { - break; - } - } - if (separator.lastIndex === match.index) { - separator.lastIndex++; // Avoid an infinite loop - } - } - if (lastLastIndex === str.length) { - if (lastLength || !separator.test("")) { - output.push(""); - } - } else { - output.push(str.slice(lastLastIndex)); - } - return output.length > limit ? output.slice(0, limit) : output; - }; - - // For convenience - String.prototype.split = function (separator, limit) { - return self(this, separator, limit); - }; - - return self; - - })(); - - // ----------------------------------------------------------------------- - /* - function decodeHTML(str) { - if (typeof str === 'string') { - str = str.replace(/&/g, '&'); - str = str.replace(/</g, '<').replace(/>/g, '>'); - str = str.replace(/ /g, '\t'); - str = str.replace(//g, '\n').replace(/ /g, ' '); - return str; - } else { - return ''; - } - } - */ - //split string to array of strings with the same length - function str_parts(str, length) { - var result = []; - var len = str.length; - if (len < length) { - return [str]; - } - for (var i = 0; i < len; i += length) { - result.push(str.substring(i, i + length)); - } - return result; - } - - - // ----------------------------------------------------------------------- - - function skipFormattingCount(string) { - return $('
' + $.terminal.strip(string) + '
').text().length; - } - - // ----------------------------------------------------------------------- - function formattingCount(string) { - return string.length - skipFormattingCount(string); - } - - // ----------------------------------------------------------------------- - // CYCLE DATA STRUCTURE - // ----------------------------------------------------------------------- - function Cycle(init) { - var data = init ? [init] : []; - var pos = 0; - $.extend(this, { - rotate: function() { - if (data.length === 1) { - return data[0]; - } else { - if (pos === data.length - 1) { - pos = 0; - } else { - ++pos; - } - return data[pos]; - } - }, - length: function() { - return data.length; - }, - set: function(item) { - for (var i = data.length; i--;) { - if (data[i] === item) { - pos = i; - return; - } - } - this.append(item); - }, - front: function() { - return data[pos]; - }, - append: function(item) { - data.push(item); - } - }); - } - // ----------------------------------------------------------------------- - // :: BCYCLE DATA STRUCTURE // Two way cycle - // ----------------------------------------------------------------------- - function BCycle(init) { - var data = init instanceof Array ? init : init ? [init] : []; - var pos = 0; - $.extend(this, { - left: function() { - if (pos === 0) { - pos = data.length - 1; - } else { - --pos; - } - return data[pos]; - }, - right: function() { - if (pos === data.length - 1) { - pos = 0; - } else { - ++pos; - } - return data[pos]; - }, - current: function() { - return data[pos]; - }, - data: function() { - return data; - }, - length: function() { - return data.length; - }, - reset: function() { - pos = 0; - }, - append: function(item) { - data.push(item); - this.reset(); - } - }); - } - // ----------------------------------------------------------------------- - // :: STACK DATA STRUCTURE - // ----------------------------------------------------------------------- - function Stack(init) { - var data = init ? [init] : []; - $.extend(this, { - size: function() { - return data.length; - }, - pop: function() { - if (data.length === 0) { - return null; - } else { - var value = data[data.length - 1]; - data = data.slice(0, data.length - 1); - return value; - } - }, - push: function(value) { - data = data.concat([value]); - return value; - }, - top: function() { - return data.length > 0 ? data[data.length - 1] : null; - } - }); - } - // serialize object myself (biwascheme or prototype library do something - // wiked with JSON serialization for Arrays) - $.json_stringify = function(object, level) { - var result = '', i; - level = level === undefined ? 1 : level; - var type = typeof object; - switch (type) { - case 'function': - result += object; - break; - case 'boolean': - result += object ? 'true' : 'false'; - break; - case 'object': - if (object === null) { - result += 'null'; - } else if (object instanceof Array) { - result += '['; - var len = object.length; - for (i = 0; i < len - 1; ++i) { - result += $.json_stringify(object[i], level + 1); - } - result += $.json_stringify(object[len - 1], level + 1) + ']'; - } else { - result += '{'; - for (var property in object) { - if (object.hasOwnProperty(property)) { - result += '"' + property + '":' + - $.json_stringify(object[property], level + 1); - } - } - result += '}'; - } - break; - case 'string': - var str = object; - var repl = { - '\\\\': '\\\\', - '"': '\\"', - '/': '\\/', - '\\n': '\\n', - '\\r': '\\r', - '\\t': '\\t'}; - for (i in repl) { - if (repl.hasOwnProperty(i)) { - str = str.replace(new RegExp(i, 'g'), repl[i]); - } - } - result += '"' + str + '"'; - break; - case 'number': - result += String(object); - break; - } - result += (level > 1 ? ',' : ''); - // quick hacks below - if (level === 1) { - // fix last comma - result = result.replace(/,([\]}])/g, '$1'); - } - // fix comma before array or object - return result.replace(/([\[{]),/g, '$1'); - }; - // ----------------------------------------------------------------------- - // :: HISTORY CLASS - // ----------------------------------------------------------------------- - function History(name) { - var enabled = true; - if (typeof name === 'string' && name !== '') { - name += '_'; - } - var data = $.Storage.get(name + 'commands'); - var bc = new BCycle(data ? eval('(' + data + ')') : ['']); - - $.extend(this, { - append: function(item) { - if (enabled) { - bc.append(item); - $.Storage.set(name + 'commands', $.json_stringify(bc.data())); - } - }, - data: function() { - return bc.data(); - }, - next: function() { - return bc.right(); - }, - last: function() { - bc.reset(); - }, - previous: function() { - return bc.left(); - }, - clear: function() { - bc = new BCycle(); - $.Storage.remove(name + 'commands'); - }, - enable: function() { - enabled = true; - }, - disable: function() { - enabled = false; - } - }); - } - // ----------------------------------------------------------------------- - // :: COMMAND LINE PLUGIN - // ----------------------------------------------------------------------- - $.fn.cmd = function(options) { - var self = this; - self.addClass('cmd'); - self.append('' + - ' '); - var clip = $('