Current File : //etc/zpanel/panel/etc/apps/filemanager/scripts/functions.js.php |
<?php
// ensure this file is being included by a parent file
if( !defined( '_JEXEC' ) && !defined( '_VALID_MOS' ) ) die( 'Restricted access' );
/**
* @version $Id: functions.js.php 232 2014-02-13 20:08:10Z soeren $
* @package eXtplorer
* @copyright soeren 2007-2009
* @author The eXtplorer project (http://extplorer.net)
* @author The The QuiX project (http://quixplorer.sourceforge.net)
* @license
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* Alternatively, the contents of this file may be used under the terms
* of the GNU General Public License Version 2 or later (the "GPL"), in
* which case the provisions of the GPL are applicable instead of
* those above. If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision by
* deleting the provisions above and replace them with the notice and
* other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this file
* under either the MPL or the GPL."
*
*/
/**
* Layout and Application Logic Functions based on ExtJS
*/
?>
Ext.BLANK_IMAGE_URL = '<?php echo _EXT_URL ?>/scripts/extjs3/resources/images/default/s.gif';
/**
* This function is for changing into a specified directory
* It updates the tree, the grid and the ContentPanel title
*/
function chDir( directory, loadGridOnly ) {
// console.log("CHDIR SSS directory:- "+directory);
if( datastore.directory.replace( /\//g, '' ) == directory.replace( /\//g, '' )
&& datastore.getTotalCount() > 0 && directory != '') {
// Prevent double loading
return false;
}
datastore.directory = directory;
var conn = datastore.proxy.getConnection();
if( directory == '' || conn && !conn.isLoading()) {
datastore.load({params:{start:0, limit:150, dir: directory, option:'com_extplorer', action:'getdircontents', sendWhat: datastore.sendWhat }});
}
Ext.Ajax.request({
url: '<?php echo basename( $GLOBALS['script_name']) ?>',
params: { action:'chdir_event', dir: directory, option: 'com_extplorer' },
callback: function(options, success, response ) {
if( success ) {
checkLoggedOut( response ); // Check if current user is logged off. If yes, Joomla! sends a document.location redirect, which will be eval'd here
var result = Ext.decode( response.responseText );
document.title = 'Filemanager - ' + datastore.directory;
// Ext.get('bookmark_container').update( result.bookmarks );
}
}
});
// console.log("loadGridOnly:- "+loadGridOnly);
var directory1 = directory;
if(directory.indexOf("ext_root")!== -1)
directory1 = directory.replace("ext_root","");
//if(directory.indexOf(0) != "/") directory1 = "/"+directory;
//console.log("CHDir directory:- "+ directory1);
if( !loadGridOnly ) {
expandTreeToDir( null, directory1);
}
/*else {
console.log("directory.replace( '/', _RRR_ ):- "+ directory.replace(/\//g, '_RRR_' ));
var node = Ext.getCmp("dirTree").getNodeById(directory.replace(/\//g, '_RRR_' ));
console.log("directory node:- "+node);
custom_location_bar.onReload(node);
}*/
}
function expandTreeToDir( node, dir ) {
//console.log(node);
//console.log("11111111 "+node);
//console.log("expandTreeToDir( node, dir ):- "+ node+", "+dir);
dir = dir ? dir : new String('<?php echo str_replace("'", "\'", extGetParam( $_SESSION,'ext_'.$GLOBALS['file_mode'].'dir', '' )) ?>');
var dirs = dir.split('/');
if( dirs[0] == '') { dirs.shift(); }
if( dirs.length > 0 ) {
fulldirpath = '';
for( i=0; i < dirs.length; i++ ) {
fulldirpath += '_RRR_'+ dirs[i];
}
node = Ext.getCmp("dirTree").getNodeById(fulldirpath);
// custom_location_bar.sss(node);
// node.on('load', function() { expandNode( node, dir ) } );
// node = Ext.getCmp("dirTree").getNodeById("_RRR_"+dirs[0]);
// Ext.getCmp("dirTree").expandPath(node.getPath());
if( !node ) return;
else {
// console.log("333333333333333 function.js node:- "+node);
// console.log("333333333333333 function.js node:- "+node.isExpanded());
if( node.isExpanded() ) {
//custom_location_bar.initComponent();
//location.reload();
//window.location.reload(true);
// console.log("444444444444444 function.js node:- "+node);
//node.setExpanded(false);
node.select();
//node.collapse();
//expandNode(node, dir);
//node.select();
//console.log("444444444444444 function.js node:- ext_root"+node.id.replace( /_RRR_/g, '/' ));
//chDir( "ext_root"+node.id.replace( /_RRR_/g, '/' ), true );
//console.log("555555555555555 function.js node:- "+node.isExpanded());
//node.expand();
//expandNode( node, dir );
//return;
custom_location_bar.onReload(node);
}
else {
// console.log("555555555555555 function.js node:- "+node);
// console.log("666666666666666 function.js node:- "+node.id);
/*if(node.parentNode.isExpanded())
{
node.parentNode.collapse();
}*/
node.expand();
node.select();
//node.setExpanded(true);
//node.on('load', function() { expandNode( node, dir ) } );
//node.expand();
}
}
}
}
/*window.onbeforeunload = function() {
//alert("sss");
if(node) {
sessionStorage.setItem(node, "node");
}
}
window.onload = function() {
if(sessionStorage.length > 0) {
var node = sessionStorage.getItem(node);
}
}*/
function expandNode( node, dir ) {
// console.log("ssssss");
var fulldirpath, dirpath;
var dirs = dir.split('/');
if( dirs[0] == '') { dirs.shift(); }
if( dirs.length > 0 ) {
fulldirpath = '';
for( i=0; i < dirs.length; i++ ) {
fulldirpath += '_RRR_'+ dirs[i];
}
if( node.id.substr( 0, 5 ) != '_RRR_' ) {
fulldirpath = fulldirpath.substr( 5 );
}
// console.log("node.id:- "+node.id+" fulldirpath:- "+fulldirpath);
if( node.id != fulldirpath ) {
// console.log("SSS nodedirs[i]:- "+nodedirs[i]);
dirpath = '';
var nodedirs = node.id.split('_RRR_');
if( nodedirs[0] == '' ) nodedirs.shift();
for( i=0; i < dirs.length; i++ ) {
if( nodedirs[i] ) {
// console.log("1111nodedirs["+i+"]:- "+nodedirs[i]);
dirpath += '_RRR_'+ dirs[i];
} else {
dirpath += '_RRR_'+ dirs[i];
// console.log("2222nodedirs["+i+"]:- "+nodedirs[i]);
//dirpath = dirpath.substr( 5 );
var nextnode = Ext.getCmp("dirTree").getNodeById( dirpath );
if( !nextnode ) { return; }
if( nextnode.isExpanded() ) { expandNode( nextnode, dir ); return;}
nextnode.on( 'load', function() { expandNode( nextnode, dir ) } );
nextnode.expand();
break;
}
}
}
else {
// console.log("555555555555555 function.js node:- "+node.isExpanded());
if( node.isExpanded() ) {
//node.collapse();
//node.expand();
chDir( node.id.replace( /_RRR_/g, '/' ), true );
//node.setExpanded(true);
//node.expand();
//expandNode( node, dir );
//return;
}
else {
node.setExpanded(true);
//node.setExpanded(false);
//node.on('load', function() { expandNode( node, dir ) } );
node.expand();
}
//node.expand();
//node.select();
}
}
}
function handleNodeClick( node ) {
if( node && node.id ) {
chDir( node.id.replace( /_RRR_/g, '/' ) );
}
}
function checkLoggedOut( response ) {
var re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;
var match;
while(match = re.exec(response.responseText)){
if(match[2] && match[2].length > 0){
eval(match[2]);
}
}
}
function showLoadingIndicator( el, replaceContent ) {
if( !el ) return;
var loadingimg = 'components/com_extplorer/images/_indicator.gif';
var imgtag = '<' + 'img src="'+ loadingimg + '" alt="Loading..." border="0" name="Loading" align="absmiddle" />';
if( replaceContent ) {
el.innerHTML = imgtag;
}
else {
el.innerHTML += imgtag;
}
}
function getURLParam( strParamName, myWindow){
if( !myWindow ){
myWindow = window;
}
var strReturn = "";
var strHref = myWindow.location.href;
if ( strHref.indexOf("?") > -1 ){
var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
var aQueryString = strQueryString.split("&");
for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
if ( aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
var aParam = aQueryString[iParam].split("=");
strReturn = aParam[1];
break;
}
}
}
return strReturn;
}
function openActionDialog( caller, action ) {
var dialog;
var selectedRows = ext_itemgrid.getSelectionModel().getSelections();
if( selectedRows.length < 1 ) {
var selectedNode = Ext.getCmp("dirTree").getSelectionModel().getSelectedNode();
if( selectedNode ) {
selectedRows = Array( Ext.getCmp("dirTree").getSelectionModel().getSelectedNode().id.replace( /_RRR_/g, '/' ) );
}
}
var dontNeedSelection = { mkitem:1, get_about:1, ftp_authentication:1, upload:1, search:1, admin:1, ssh2_authentication: 1, extplorer_authentication: 1 };
if( dontNeedSelection[action] == null && selectedRows.length < 1 ) {
Ext.Msg.alert( '<?php echo ext_Lang::err('error', true )."','".ext_Lang::err('miscselitems', true ) ?>');
return false;
}
switch( action ) {
case 'admin':
case 'archive':
case 'chmod':
case 'copy':
case 'edit':
case 'extplorer_authentication':
case 'ftp_authentication':
case 'ssh2_authentication':
case 'get_about':
case 'mkitem':
case 'move':
case 'rename':
case 'search':
case 'upload':
case 'view':
case 'diff':
case 'move':
requestParams = getRequestParams();
requestParams.action = action;
if( action != "edit" ) {
dialog = new Ext.Window( {
id: "dialog",
autoCreate: true,
modal:true,
width:600,
height:400,
shadow:true,
minWidth:300,
minHeight:200,
proxyDrag: true,
resizable: true,
renderTo: Ext.getBody(),
keys: {
key: 27,
fn : function(){
dialog.hide();
}
},
//animateTarget: typeof caller.getEl == 'function' ? caller.getEl() : caller,
title: '<?php echo ext_Lang::msg('dialog_title', true ) ?>'
});
}
Ext.Ajax.request( { url: '<?php echo basename($GLOBALS['script_name']) ?>',
params: Ext.urlEncode( requestParams ),
scripts: true,
callback: function(oElement, bSuccess, oResponse) {
//console.log(oResponse);
if( !bSuccess ) {
msgbox = Ext.Msg.alert( "Ajax communication failure!");
msgbox.setIcon( Ext.MessageBox.ERROR );
}
if( oResponse && oResponse.responseText ) {
//alert("This is test part");
//console.log(oResponse);
//Ext.Msg.alert("Debug", oResponse.responseText );
try{
json = Ext.decode( oResponse.responseText );
if( json.error && typeof json.error != 'xml' ) {
Ext.Msg.alert( "<?php echo ext_Lang::err('error', true ) ?>", json.error );
dialog.destroy();
return false;
}
} catch(e) {
msgbox = Ext.Msg.alert( "<?php echo ext_Lang::err('error', true ) ?>", "JSON Decode Error: " + e.message );
msgbox.setIcon( Ext.MessageBox.ERROR );
return false;
}
if( action == "edit" ) {
var file_name = json.items[1].value;
var filename_todisp = file_name.substring(0, 8);
var file_name_split = file_name.split(".");
var file_extension = file_name_split[file_name_split.length-1];
var filename_todisp = "";
if(file_name_split[0].length < 12) {
filename_todisp = file_name_split[0].substring(0, 12)+".."+file_extension;
} else {
filename_todisp = file_name;
}
//var file_extension = json.items[0].plugins.config.syntax;
var file_exten="";
switch ( file_extension ) {
case 'php':
file_exten = "php"; break;
case 'js':
file_exten = "javascript"; break;
case 'java':
file_exten = "java"; break;
case 'jsp':
file_exten = "jsp"; break;
case 'css':
file_exten = "css"; break;
case 'html':
file_exten = "html"; break;
case 'ini':
file_exten = "ini"; break;
case 'io':
file_exten = "io"; break;
case 'json':
file_exten = "json"; break;
case 'less':
file_exten = "less"; break;
case 'mysql':
file_exten = "mysql"; break;
case 'sh':
file_exten = "sh"; break;
case 'sql':
file_exten = "sql"; break;
case 'twig':
file_exten = "twig"; break;
case 'xml':
file_exten = "xml"; break;
case 'yaml':
file_exten = "yaml"; break;
default:
file_exten = "php";
}
document.getElementById("gridpanel").style.display ="none";
var editor_div1 = document.getElementById('editor11');
var mainpan_edi1 = document.getElementById("mainpanel__editor1");
var editor_div2 = document.getElementById('editor12');
var mainpan_edi2 = document.getElementById("mainpanel__editor2");
var editor_div3 = document.getElementById('editor13');
var mainpan_edi3 = document.getElementById("mainpanel__editor3");
var editor_div4 = document.getElementById('editor14');
var mainpan_edi4 = document.getElementById("mainpanel__editor4");
var editor_div5 = document.getElementById('editor15');
var mainpan_edi5 = document.getElementById("mainpanel__editor5");
var edit_condition1 = mainpan_edi1 ? (mainpan_edi1.getAttribute('class')=='free' ? true : false ) : true;
var edit_condition2 = mainpan_edi2 ? (mainpan_edi2.getAttribute('class')=='free' ? true : false ) : true;
var edit_condition3 = mainpan_edi3 ? (mainpan_edi3.getAttribute('class')=='free' ? true : false ) : true;
var edit_condition4 = mainpan_edi4 ? (mainpan_edi4.getAttribute('class')=='free' ? true : false ) : true;
var edit_condition5 = mainpan_edi5 ? (mainpan_edi5.getAttribute('class')=='free' ? true : false ) : true;
//console.log("edit_condition1: "+edit_condition1+" -- edit_condition2: "+edit_condition2+" -- edit_condition3: "+edit_condition3+" --edit_condition4: "+edit_condition4+" --edit_condition5: "+edit_condition5);
//console.log(editor_div1 +"--"+ editor_div2 +"--"+ editor_div3);
if(editor_div1 === null ) {
//console.log("editor1");
var editor_tab = "editor11";
var newElement = document.createElement('div');
newElement.setAttribute('id', editor_tab);
document.getElementById("mainpanel").appendChild(newElement);
//document.getElementById("mainpanel__gridpanel").setAttribute('onclick', "showGridPanel('"+editor_tab+"')");
var dir_path = requestParams.dir;
loadToolBar(editor_tab, file_name, file_exten, dir_path);
document.getElementById('select_lang'+editor_tab).value=file_exten;
var editor = ace.edit(editor_tab);
editor.getSession().setMode("ace/mode/"+file_exten);
var htmlcontent = json.items[0].value;
editor.setValue(htmlcontent, -1);
editor.focus();
var main_edit1 = document.getElementById('mainpanel__editor1');
if (main_edit1 === null) {
Ext.getCmp("mainpanel").add(editor);
var newElement = document.createElement('div');
newElement.setAttribute('id', "editor12");
document.getElementById("mainpanel").appendChild(newElement);
editor = ace.edit("editor12");
Ext.getCmp("mainpanel").add(editor);
var newElement = document.createElement('div');
newElement.setAttribute('id', "editor13");
document.getElementById("mainpanel").appendChild(newElement);
editor = ace.edit("editor13");
Ext.getCmp("mainpanel").add(editor);
var newElement = document.createElement('div');
newElement.setAttribute('id', "editor14");
document.getElementById("mainpanel").appendChild(newElement);
editor = ace.edit("editor14");
Ext.getCmp("mainpanel").add(editor);
var newElement = document.createElement('div');
newElement.setAttribute('id', "editor15");
document.getElementById("mainpanel").appendChild(newElement);
editor = ace.edit("editor15");
Ext.getCmp("mainpanel").add(editor);
document.getElementById("mainpanel__editor2").style.display="none";
document.getElementById("mainpanel__editor3").style.display="none";
document.getElementById("mainpanel__editor4").style.display="none";
document.getElementById("mainpanel__editor5").style.display="none";
document.getElementById("editor12").setAttribute('class', 'all_editor');
document.getElementById("editor13").setAttribute('class', 'all_editor');
document.getElementById("editor14").setAttribute('class', 'all_editor');
document.getElementById("editor15").setAttribute('class', 'all_editor');
document.getElementById("editor12").classList.add('ace-tm');
document.getElementById("editor13").classList.add('ace-tm');
document.getElementById("editor14").classList.add('ace-tm');
document.getElementById("editor15").classList.add('ace-tm');
document.getElementById("mainpanel__editor1").setAttribute('onclick', "showEditor('"+editor_tab+"')");
document.getElementById("mainpanel__editor2").setAttribute('class','free');
document.getElementById("mainpanel__editor3").setAttribute('class','free');
document.getElementById("mainpanel__editor4").setAttribute('class','free');
document.getElementById("mainpanel__editor5").setAttribute('class','free');
/*CloseEditor("editor12");
CloseEditor("editor13");
CloseEditor("editor14");
CloseEditor("editor15");*/
document.getElementById("editor12").remove();
document.getElementById("editor13").remove();
document.getElementById("editor14").remove();
document.getElementById("editor15").remove();
}else {
document.getElementById("mainpanel__editor1").style.display="block";
}
document.getElementById(editor_tab).setAttribute('class', 'all_editor');
document.getElementById(editor_tab).classList.add('ace-tm');
document.getElementById("mainpanel__editor1").setAttribute('onclick', "showEditor('"+editor_tab+"')");
document.getElementById("mainpanel__editor1").setAttribute('class','edt-ttl-cls x-tab-strip-active');
mainpan_edi2 ? document.getElementById("mainpanel__editor2").classList.remove('x-tab-strip-active') : '';
mainpan_edi3 ? document.getElementById("mainpanel__editor3").classList.remove('x-tab-strip-active') : '';
mainpan_edi4 ? document.getElementById("mainpanel__editor4").classList.remove('x-tab-strip-active') : '';
mainpan_edi5 ? document.getElementById("mainpanel__editor5").classList.remove('x-tab-strip-active') : '';
document.getElementById("mainpanel__editor1").classList.remove('free');
document.getElementById("mainpanel__editor1").innerText = filename_todisp;
}
//var editor_div2 = document.getElementById('editor12');
//var mainpan_edi2 = document.getElementById("mainpanel__editor2");
//var edit_condition2 = mainpan_edi2 ? (mainpan_edi2.getAttribute('class')=='free' ? true : false ) : true;
//console.log("edit_condition2: "+edit_condition2);
else if(editor_div1 != null && editor_div2 === null && edit_condition2) {
//console.log("editor2");
document.getElementById('editor11').style.display="none";
document.getElementById('toolbar_editor11').style.display="none";
var editor_tab = "editor12";
var newElement = document.createElement('div');
newElement.setAttribute('id', editor_tab);
document.getElementById("mainpanel").appendChild(newElement);
var dir_path = requestParams.dir;
loadToolBar(editor_tab, file_name, file_exten, dir_path);
document.getElementById('select_lang'+editor_tab).value=file_exten;
var editor = ace.edit(editor_tab);
editor.getSession().setMode("ace/mode/"+file_exten);
var htmlcontent = json.items[0].value;
editor.setValue(htmlcontent, -1);
editor.focus();
var main_edit2 = document.getElementById('mainpanel__editor2');
if (main_edit2 === null) {
Ext.getCmp("mainpanel").add(editor);
}else {
document.getElementById("mainpanel__editor2").style.display="block";
}
document.getElementById(editor_tab).setAttribute('class', 'all_editor');
document.getElementById(editor_tab).classList.add('ace-tm');
document.getElementById("mainpanel__editor2").setAttribute('onclick', "showEditor('"+editor_tab+"')");
document.getElementById("mainpanel__editor2").setAttribute('class','edt-ttl-cls x-tab-strip-active');
mainpan_edi1 ? document.getElementById("mainpanel__editor1").classList.remove('x-tab-strip-active') : '';
mainpan_edi3 ? document.getElementById("mainpanel__editor3").classList.remove('x-tab-strip-active') : '';
mainpan_edi4 ? document.getElementById("mainpanel__editor4").classList.remove('x-tab-strip-active') : '';
mainpan_edi5 ? document.getElementById("mainpanel__editor5").classList.remove('x-tab-strip-active') : '';
document.getElementById("mainpanel__editor2").classList.remove('free');
document.getElementById("mainpanel__editor2").innerText = filename_todisp;
}
//var editor_div3 = document.getElementById('editor13');
//var mainpan_edi3 = document.getElementById("mainpanel__editor3");
//var edit_condition3 = mainpan_edi3 ? (mainpan_edi3.getAttribute('class')=='free' ? true : false ) : true;
//console.log("edit_condition3: "+edit_condition3);
else if(editor_div1 != null && editor_div2 != null && editor_div3 === null && edit_condition3 ) {
document.getElementById('editor11').style.display="none";
document.getElementById('editor12').style.display="none";
var editor_tab = "editor13";
var newElement = document.createElement('div');
newElement.setAttribute('id', editor_tab);
document.getElementById("mainpanel").appendChild(newElement);
var dir_path = requestParams.dir;
loadToolBar(editor_tab, file_name, file_exten, dir_path);
document.getElementById('select_lang'+editor_tab).value=file_exten;
var editor = ace.edit(editor_tab);
editor.getSession().setMode("ace/mode/"+file_exten);
var htmlcontent = json.items[0].value;
editor.setValue(htmlcontent, -1);
editor.focus();
var main_edit3 = document.getElementById('mainpanel__editor3');
//console.log("main_edit3: "+main_edit3);
if (main_edit3 === null) {
Ext.getCmp("mainpanel").add(editor);
}else {
document.getElementById("mainpanel__editor3").style.display="block";
}
document.getElementById(editor_tab).setAttribute('class', 'all_editor');
document.getElementById(editor_tab).classList.add('ace-tm');
document.getElementById("mainpanel__editor3").setAttribute('onclick', "showEditor('"+editor_tab+"')");
document.getElementById("mainpanel__editor3").setAttribute('class','edt-ttl-cls x-tab-strip-active');
mainpan_edi2 ? document.getElementById("mainpanel__editor2").classList.remove('x-tab-strip-active') : '';
mainpan_edi1 ? document.getElementById("mainpanel__editor1").classList.remove('x-tab-strip-active') : '';
mainpan_edi4 ? document.getElementById("mainpanel__editor4").classList.remove('x-tab-strip-active') : '';
mainpan_edi5 ? document.getElementById("mainpanel__editor5").classList.remove('x-tab-strip-active') : '';
document.getElementById("mainpanel__editor3").classList.remove('free');
document.getElementById("mainpanel__editor3").innerText = filename_todisp;
}
//var editor_div4 = document.getElementById('editor14');
//var mainpan_edi4 = document.getElementById("mainpanel__editor4");
//var edit_condition4 = mainpan_edi4 ? (mainpan_edi4.getAttribute('class')=='free' ? true : false ) : true;
else if(editor_div1 != null && editor_div2 != null && editor_div3 != null && editor_div4 === null && edit_condition4 )
{
//console.log("editor4");
document.getElementById('editor11').style.display="none";
document.getElementById('editor12').style.display="none";
document.getElementById('editor13').style.display="none";
var editor_tab = "editor14";
var newElement = document.createElement('div');
newElement.setAttribute('id', editor_tab);
document.getElementById("mainpanel").appendChild(newElement);
var dir_path = requestParams.dir;
loadToolBar(editor_tab, file_name, file_exten, dir_path);
document.getElementById('select_lang'+editor_tab).value=file_exten;
var editor = ace.edit(editor_tab);
editor.getSession().setMode("ace/mode/"+file_exten);
var htmlcontent = json.items[0].value;
editor.setValue(htmlcontent, -1);
editor.focus();
var main_edit4 = document.getElementById('mainpanel__editor4');
if (main_edit4 === null) {
Ext.getCmp("mainpanel").add(editor);
}else {
document.getElementById("mainpanel__editor4").style.display="block";
}
document.getElementById(editor_tab).setAttribute('class', 'all_editor');
document.getElementById(editor_tab).classList.add('ace-tm');
document.getElementById("mainpanel__editor4").setAttribute('onclick', "showEditor('"+editor_tab+"')");
document.getElementById("mainpanel__editor4").setAttribute('class','edt-ttl-cls x-tab-strip-active');
mainpan_edi2 ? document.getElementById("mainpanel__editor2").classList.remove('x-tab-strip-active') : '';
mainpan_edi3 ? document.getElementById("mainpanel__editor3").classList.remove('x-tab-strip-active') : '';
mainpan_edi1 ? document.getElementById("mainpanel__editor1").classList.remove('x-tab-strip-active') : '';
mainpan_edi5 ? document.getElementById("mainpanel__editor5").classList.remove('x-tab-strip-active') : '';
document.getElementById("mainpanel__editor4").classList.remove('free');
document.getElementById("mainpanel__editor4").innerText = filename_todisp;
}
//var editor_div5 = document.getElementById('editor15');
//var mainpan_edi5 = document.getElementById("mainpanel__editor5");
//var edit_condition5 = mainpan_edi5 ? (mainpan_edi5.getAttribute('class')=='free' ? true : false ) : true;
else if(editor_div1 != null && editor_div2 != null && editor_div3 != null && editor_div4 != null && editor_div5 === null && edit_condition5 )
{
//console.log("editor5");
document.getElementById('editor11').style.display="none";
document.getElementById('editor12').style.display="none";
document.getElementById('editor13').style.display="none";
document.getElementById('editor14').style.display="none";
var editor_tab = "editor15";
var newElement = document.createElement('div');
newElement.setAttribute('id', editor_tab);
document.getElementById("mainpanel").appendChild(newElement);
var dir_path = requestParams.dir;
loadToolBar(editor_tab, file_name, file_exten, dir_path);
document.getElementById('select_lang'+editor_tab).value=file_exten;
var editor = ace.edit(editor_tab);
editor.getSession().setMode("ace/mode/"+file_exten);
var htmlcontent = json.items[0].value;
editor.setValue(htmlcontent, -1);
editor.focus();
var main_edit5 = document.getElementById('mainpanel__editor5');
if (main_edit5 === null) {
Ext.getCmp("mainpanel").add(editor);
}else {
document.getElementById("mainpanel__editor5").style.display="block";
}
document.getElementById(editor_tab).setAttribute('class', 'all_editor');
document.getElementById(editor_tab).classList.add('ace-tm');
document.getElementById("mainpanel__editor5").setAttribute('onclick', "showEditor('"+editor_tab+"')");
document.getElementById("mainpanel__editor5").setAttribute('class','edt-ttl-cls x-tab-strip-active');
mainpan_edi2 ? document.getElementById("mainpanel__editor2").classList.remove('x-tab-strip-active') : '';
mainpan_edi3 ? document.getElementById("mainpanel__editor3").classList.remove('x-tab-strip-active') : '';
mainpan_edi4 ? document.getElementById("mainpanel__editor4").classList.remove('x-tab-strip-active') : '';
mainpan_edi1 ? document.getElementById("mainpanel__editor1").classList.remove('x-tab-strip-active') : '';
document.getElementById("mainpanel__editor5").classList.remove('free');
document.getElementById("mainpanel__editor5").innerText = filename_todisp;
}
else if(editor_div1 != null && editor_div2 != null && editor_div3 != null && editor_div4 != null && editor_div5 != null )
{
document.getElementById("gridpanel").style.display = "block";
alert("You can use the maximum of 5 editor at a time");
return false;
}
document.getElementById("mainpanel__gridpanel").setAttribute('onclick', "showGridPanel('"+editor_tab+"')");
//Ext.getCmp("mainpanel").add(editor);
// document.getElementById(editor_tab).setAttribute('class', 'all_editor');
// document.getElementById("mainpanel__editor1").setAttribute('onclick', "showEditor('"+editor_tab+"')");
// document.getElementById("mainpanel__editor1").innerText = file_name;
}
else {
dialog.add(json);
if( json.dialogtitle ) {
dialog.setTitle(json.dialogtitle);
}
try {
dialog.doLayout();
firstComponent = dialog.getComponent(0);
newWidth = firstComponent.getWidth() + dialog.getFrameWidth();
newHeight = firstComponent.getHeight() + dialog.getFrameHeight();
dialog.setSize( newWidth, newHeight );
} catch(e) {}
if( dialog.getWidth() >= Ext.getBody().getWidth() ) {
dialog.setWidth( Ext.getBody().getWidth() * 0.8 );
}
if( dialog.getHeight() >= Ext.getBody().getHeight() ) {
dialog.setHeight( Ext.getBody().getHeight() * 0.7 );
} else if( dialog.getHeight() < Ext.getBody().getHeight() * 0.3 ) {
dialog.setHeight( Ext.getBody().getHeight() * 0.5 );
}
dialog.syncSize();
dialog.center();
}
} else if( !response || !oResponse.responseText) {
msgbox = Ext.Msg.alert( "<?php echo ext_Lang::err('error', true ) ?>", "Received an empty response");
msgbox.setIcon( Ext.MessageBox.ERROR );
}
}
});
if( action != "edit" ) {
dialog.on( 'hide', function() { dialog.destroy(true); } );
dialog.show();
}
break;
case 'delete':
var num = selectedRows.length;
Ext.Msg.confirm('<?php echo ext_Lang::msg('dellink', true ) ?>?', String.format("<?php echo ext_Lang::err('miscdelitems', true ) ?>", num ), deleteFiles);
break;
case 'extract':
Ext.Msg.confirm('<?php echo ext_Lang::msg('extractlink', true ) ?>?', "<?php echo ext_Lang::msg('extract_warning', true ) ?>", extractArchive);
break;
case 'download':
document.location = '<?php echo basename($GLOBALS['script_name']) ?>?option=com_extplorer&action=download&item='+ encodeURIComponent(ext_itemgrid.getSelectionModel().getSelected().get('name')) + '&dir=' + encodeURIComponent( datastore.directory );
break;
}
}
function createEditor(editor_sss)
{
//console.log(editor_sss);
//document.getElementById('editor11').style.display="none";
//document.getElementById('toolbar_editor11').style.display="none";
var editor_tab = editor_sss;
var newElement = document.createElement('div');
newElement.setAttribute('id', editor_tab);
document.getElementById("mainpanel").appendChild(newElement);
//var dir_path = requestParams.dir;
l/oadToolBar(editor_tab, file_name, file_exten, dir_path);
document.getElementById('select_lang'+editor_tab).value=file_exten;
var editor = ace.edit(editor_tab);
editor.getSession().setMode("ace/mode/"+file_exten);
var htmlcontent = json.items[0].value;
editor.setValue(htmlcontent, -1);
editor.focus();
var main_edit2 = document.getElementById('mainpanel__editor2');
}
function showEditor(editor_tab)
{
document.getElementById("gridpanel").style.display = "none";
//document.getElementById("editor-tab").style.display="block";
document.getElementById(editor_tab).style.display="block";
document.getElementById("toolbar_"+editor_tab).style.display="block";
document.getElementById(editor_tab).setAttribute('class', 'all_editor');
document.getElementById(editor_tab).classList.add('ace-tm');
//document.getElementById(editor_tab).style.display="block";
//var editor_div2 = document.getElementById('editor2');
for(var i = 11; i<=15 ; i++) {
var toolbar_div = "toolbar_editor"+i;
var toolbar_div_to_hide = document.getElementById(toolbar_div);
if(toolbar_div != "toolbar_"+editor_tab) {
if(toolbar_div_to_hide != null) {
document.getElementById(toolbar_div).style.display="none";
}
}
var editor_div = "editor"+i;
if(editor_div != null) {
if(editor_tab != editor_div) {
var editor_div_to_hide = document.getElementById(editor_div);
if(editor_div_to_hide != null) {
document.getElementById(editor_div).style.display="none";
}
}
}
}
//if(editor_div2 != null) document.getElementById('editor2').style.display="none";
}
function showGridPanel(editor_tab)
{
//document.getElementById("gridpanel").style.display = "block";
document.getElementById("gridpanel").style.setProperty('display', 'block', 'important');
//document.getElementById("editor-tab").style.display="none";
//Ext.getCmp("mainpanel").remove(editor);
//document.getElementById(editor_tab).style.display="none";
//document.getElementById('main_panel').style.display="none";
//document.getElementById('mainpanel__gridpanel').setAttribute('class', 'x-tab-strip-active');
for(var i = 11; i<=15 ; i++) {
var toolbar_div = "toolbar_editor"+i;
var toolbar_div_to_hide = document.getElementById(toolbar_div);
if(toolbar_div_to_hide != null) {
document.getElementById(toolbar_div).style.display="none";
}
var editor_div = "editor"+i;
var editor_div_to_hide = document.getElementById(editor_div);
if(editor_div_to_hide != null) {
document.getElementById(editor_div).style.display="none";
}
}
}
function loadToolBar(editor_tab, file_name, file_exten, dir_path)
{
var load_div_id = "toolbar_"+editor_tab;
var Tab = document.createElement('div');
//Tab.setAttribute('id', "editor-tab");
Tab.setAttribute('id', load_div_id);
Tab.setAttribute('class', 'editor-tab');
document.getElementById("mainpanel").appendChild(Tab);
var filename_field = document.createElement('input');
filename_field.setAttribute('id', "filename_"+editor_tab);
filename_field.setAttribute('type', 'hidden');
filename_field.setAttribute('value', file_name);
document.getElementById("mainpanel").appendChild(filename_field);
var saveFile = document.createElement("button");
saveFile.setAttribute("id","save_btn");
saveFile.setAttribute("onClick","SaveEditor('"+editor_tab+"','"+file_name+"','"+dir_path+"')");
saveFile.innerHTML = 'Save';
document.getElementById(load_div_id).appendChild(saveFile);
//document.getElementById("editor-tab").appendChild(saveFile);
var reopenButton = document.createElement("button");
reopenButton.setAttribute("id","reopen_btn");
reopenButton.setAttribute("onClick","reOpen('"+editor_tab+"', '"+file_exten+"','"+dir_path+"')");
reopenButton.innerHTML = 'ReOpen';
document.getElementById(load_div_id).appendChild(reopenButton);
//document.getElementById("editor-tab").appendChild(reopenButton);
var cancelButton = document.createElement("button");
cancelButton.setAttribute("id","cancel_btn");
cancelButton.setAttribute("onClick","CloseEditor('"+editor_tab+"')");
cancelButton.innerHTML = 'Cancel';
document.getElementById(load_div_id).appendChild(cancelButton);
//document.getElementById("editor-tab").appendChild(cancelButton);
var findButton = document.createElement("button");
findButton.setAttribute("id","find_btn");
findButton.setAttribute("onClick","findReplace('"+editor_tab+"')");
findButton.innerHTML = 'Find/Replace';
document.getElementById(load_div_id).appendChild(findButton);
//document.getElementById("editor-tab").appendChild(findButton);
var gotoButton = document.createElement("button");
gotoButton.setAttribute("id","goto_btn");
gotoButton.setAttribute("onClick","gotoLineNo('"+editor_tab+"')");
gotoButton.innerHTML = 'Goto Line';
document.getElementById(load_div_id).appendChild(gotoButton);
//document.getElementById("editor-tab").appendChild(gotoButton);
var findButton = document.createElement("button");
findButton.setAttribute("id","undo_btn");
findButton.setAttribute("onClick","undoScript('"+editor_tab+"')");
findButton.innerHTML = 'Undo';
document.getElementById(load_div_id).appendChild(findButton);
//document.getElementById("editor-tab").appendChild(findButton);
var findButton = document.createElement("button");
findButton.setAttribute("id","redo_btn");
findButton.setAttribute("onClick","redoScript('"+editor_tab+"')");
findButton.innerHTML = 'Redo';
document.getElementById(load_div_id).appendChild(findButton);
//document.getElementById("editor-tab").appendChild(findButton);
var select_lang = document.createElement("select");
select_lang.setAttribute("id",'select_lang'+editor_tab);
select_lang.setAttribute("onchange","selectLanguage(this,"+editor_tab+")");
select_lang.innerHTML = 'SELECT LANGUAGE';
document.getElementById(load_div_id).appendChild(select_lang);
//document.getElementById("editor-tab").appendChild(select_lang);
var array = ["css","html","ini","io","java","javascript","json","jsp","less","mysql","php","sh","sql","twig","xml","yaml"];
for (var i = 0; i < array.length; i++)
{
var option = document.createElement("option");
option.value = array[i];
option.text = array[i];
select_lang.appendChild(option);
}
}
function findReplace(editor_tab)
{
var config = ace.require("./config");
var editor = ace.edit(editor_tab);
config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor);});
}
function gotoLineNo(editor_tab)
{
if (document.getElementById("goto_line"))
{
document.getElementById("goto_line").style.display ="none";
}
else
{
var goto_line_box = document.createElement("div");
goto_line_box.setAttribute("id","goto_line");
document.body.appendChild(goto_line_box);
var goto_line_div = document.createElement("div");
goto_line_div.setAttribute("id","goto_line_div");
goto_line_div.style.height = "70%";
var line_no_lbl = document.createElement("label");
line_no_lbl.style.width = "100%";
line_no_lbl.setAttribute("id","line_no_lbl");
//line_no_lbl.setAttribute("value","Enter line number:");
goto_line_div.appendChild(line_no_lbl);
//document.getElementById("line_no_lbl").innerHTML = "Enter line number:";
var line_no_txt = document.createElement("input");
line_no_txt.style.width = "100%";
line_no_txt.setAttribute("type","text");
line_no_txt.setAttribute("id","line_no_txt");
line_no_txt.setAttribute("placeholder","Enter Line No...");
goto_line_div.appendChild(line_no_txt);
//document.getElementById("line_no_txt").label = "Enter line number:";
var goto_btn_div = document.createElement("div");
goto_btn_div.setAttribute("id","goto_btn_div");
var goto_line_btn = document.createElement("input");
goto_line_btn.setAttribute("type","submit");
goto_line_btn.setAttribute("id","go_line_btn");
goto_line_btn.setAttribute("value","Ok");
goto_line_btn.setAttribute("onclick","goto('"+editor_tab+"')");
goto_btn_div.appendChild(goto_line_btn);
var goto_line_cancel_btn = document.createElement("input");
goto_line_cancel_btn.setAttribute("type","submit");
goto_line_cancel_btn.setAttribute("id","go_line_cancel_btn");
goto_line_cancel_btn.setAttribute("value","Cancel");
goto_line_cancel_btn.setAttribute("onclick","goto_line_cancel()");
goto_btn_div.appendChild(goto_line_cancel_btn);
goto_line_box.appendChild(goto_line_div);
goto_line_box.appendChild(goto_btn_div);
document.getElementById("line_no_lbl").innerHTML = "Enter line number:";
document.getElementById("goto_line").style.display ="block";
}
document.getElementById("goto_line").style.display ="show";
var wage = document.getElementById("line_no_txt");
wage.addEventListener("keydown", function (e) {
if (e.keyCode === 13) { //checks whether the pressed key is "Enter"
goto(editor_tab);
}
});
}
function goto(editor_tab)
{
var line_no = document.getElementById('line_no_txt').value;
var editor = ace.edit(editor_tab);
editor.gotoLine(line_no);
goto_line_cancel();
}
function goto_line_cancel()
{
var black_box = document.getElementById("goto_line");
document.body.removeChild(black_box);
}
function undoScript(editor_tab)
{
var editor = ace.edit(editor_tab);
editor.undo();
}
function redoScript(editor_tab)
{
var editor = ace.edit(editor_tab);
editor.redo();
}
function selectLanguage(selected_lang,editor_tab)
{
path = "./scripts/ace";
ace.config.set("workerPath",path);
var lan = selected_lang.value;
var editor = ace.edit(editor_tab);
editor.getSession().setMode("ace/mode/"+lan);
var htmlcontent = json.items[0].value;
editor.setValue(htmlcontent, -1);
editor.focus();
}
function CloseEditor(editor_tab)
{
var result = confirm('Are you sure, do you want to close?');
if(result)
{
document.getElementById("gridpanel").style.setProperty('display', 'block', 'important');
//document.getElementById("mainpanel__gridpanel").removeAttribute('onclick');
var editor = ace.edit(editor_tab);
editor.destroy();
//document.getElementById("editor-tab").remove();
document.getElementById(editor_tab).remove();
document.getElementById("toolbar_"+editor_tab).remove();
//Ext.getCmp("mainpanel").remove(editor_tab);
var mainpanel_div = "";
switch(editor_tab) {
case 'editor11':
mainpanel_div = "mainpanel__editor1";break;
case 'editor12':
mainpanel_div = "mainpanel__editor2";break;
case 'editor13':
mainpanel_div = "mainpanel__editor3";break;
case 'editor14':
mainpanel_div = "mainpanel__editor4";break;
case 'editor15':
mainpanel_div = "mainpanel__editor5";break;
}
document.getElementById(mainpanel_div).style.display = "none";
document.getElementById(mainpanel_div).setAttribute('class', 'free');
}
}
function LoadProgress(msg)
{
var ProgressTab = document.createElement('div');
ProgressTab.setAttribute('id', "ProgressTab");
document.getElementById("mainpanel").appendChild(ProgressTab);
var InnerProgress = document.createElement('div');
InnerProgress.setAttribute('id', "progress-bar");
document.getElementById("ProgressTab").appendChild(InnerProgress);
var InnerProgressBar = document.createElement('div');
InnerProgressBar.setAttribute('class', "loader-bar");
document.getElementById("progress-bar").appendChild(InnerProgressBar);
var InnerProgressTxt = document.createElement('div');
InnerProgressTxt.setAttribute('class', "loader-txt");
InnerProgressTxt.innerHTML = msg;
document.getElementById("progress-bar").appendChild(InnerProgressTxt);
}
function SaveEditor(editor_tab,fileName,dir_path)
{
requestParams = getRequestParams();
//var fileName = requestParams.item;
var Msg = "Saving File '"+ fileName+"'";
LoadProgress(Msg);
//var editor = ace.edit("editor");
var editor = ace.edit(editor_tab);
var code = editor.getValue();
requestParams.action = "edit";
requestParams.dosave = 'yes';
requestParams.code = code;
requestParams.fname = fileName;
requestParams.item = fileName;
requestParams.dir = dir_path;
//console.log(requestParams);
Ext.Ajax.request( { url: '<?php echo basename($GLOBALS['script_name']) ?>',
params: Ext.urlEncode( requestParams ),
scripts: true,
callback: function(oElement, bSuccess, oResponse) {
document.getElementById("ProgressTab").remove();
json = Ext.decode( oResponse.responseText );
var success = json.success;
if( !success )
{
msgbox = Ext.Msg.alert( "File Save Failed!");
msgbox.setIcon( Ext.MessageBox.ERROR );
}
else
{
statusBarMessage( json.message, false, true );
}
}
});
}
function reOpen(editor_tab,file_exten,dir_path)
{
requestParams = getRequestParams();
//var fileName = requestParams.item;
var Msg = "Reopening File '"+ fileName+"'";
LoadProgress(Msg);
var fileName = document.getElementById('filename_'+editor_tab).value;
//console.log(fileName);
requestParams.item = fileName;
requestParams.dir = dir_path;
requestParams.action = "edit";
requestParams.doreopen = 'yes';
Ext.Ajax.request( { url: '<?php echo basename($GLOBALS['script_name']) ?>',
params: Ext.urlEncode( requestParams ),
scripts: true,
callback: function(oElement, bSuccess, oResponse) {
json = Ext.decode( oResponse.responseText );
var success = json.success;
document.getElementById("ProgressTab").remove();
if( !success ) {
statusBarMessage( json.error, false, true );
msgbox = Ext.Msg.alert( "File Reload Failed!");
msgbox.setIcon( Ext.MessageBox.ERROR );
}
else
{
htmlcontent = json.content;
//var editor = ace.edit("editor");
var editor = ace.edit(editor_tab);
editor.getSession().setMode("ace/mode/"+file_exten);
editor.setValue(htmlcontent, -1);
statusBarMessage( json.message, false, true );
}
}
});
}
function copy_move_ajax_call(i)
{
Ext.getCmp("dialog").destroy();
create_Black_Box(function(st)
{
copy_move_file();
});
}
var stimer,ext_status = true;
function close_dialog_box()
{
if(document.getElementById("extract_black_box"))
{
//document.getElementById("extract_black_box").style.display ="none";
document.getElementById("extract_black_box").remove();
}
datastore.reload();
}
function show_extract_progress(ext_url)
{
var xmlhttpd = new XMLHttpRequest();
xmlhttpd.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if(document.getElementById("extract_dialog_content"))
{
var bd = document.getElementById("extract_black_box");
var visb = getStyle(bd,"display");
if (visb.toLowerCase() == "block")
{
var d_box = document.getElementById("extract_dialog_content");
var j_d = JSON.parse(xmlhttpd.responseText);
if(j_d.free_space > 98) {
d_box.innerHTML = "There is no space availbale in the disk. Please contact administrator";
if(!node) {
node = custom_location_bar.current_node;
} else {}
custom_location_bar.onReload(node);
} else {
if(j_d['status'] == 1)
{
if(parseInt(j_d.file_extract) == 0)
{
d_box.innerHTML ="Extracting please wait...";
}
else
{
d_box.innerHTML = "Total file extracted <br>"+ j_d.file_extract+"<br> "+j_d.free_space+"%free space still availbale <br> please wait...";
}
setTimeout(function() {
show_extract_progress(ext_url);
},10000);
}
else if (j_d['status'] == 2)
{
d_box.innerHTML = "Extraction completed sucessfully";
//datastore.reload();
if(!node) {
node = custom_location_bar.current_node;
} else {}
datastor.reload();
custom_location_bar.onReload(node);
location.reload();
}
else
{
if(document.getElementById("extract_black_box")) {
document.getElementById("extract_black_box").style.display ="none";
}
Ext.Msg.alert( 'Failure', "Server is busy try again after some time" );
}
}
}
}else { ext_status = false; }
}
else{
if(document.getElementById("extract_black_box")) {
ext_status = false;
//document.getElementById("extract_black_box").style.display ="none";
}
}
};
xmlhttpd.open("GET",ext_url, true);
xmlhttpd.send();
}
function handleCallback(requestParams, node) {
var conn = new Ext.data.Connection();
//alert(requestParams.toSource
var ac_detail = requestParams.action;
if ( ac_detail == "extract" )
{
if (document.getElementById("extract_black_box"))
{
document.getElementById("extract_black_box").style.display ="none";
}
else
{
var black_box = document.createElement("div");
black_box.setAttribute("id","extract_black_box");
document.body.appendChild(black_box);
black_box.style.width = "100%";
black_box.style.height ="100%";
black_box.style.position = "absolute";
black_box.style.left = "0px";
black_box.style.top = "0px";
}
var bl_dialog_box = document.getElementById("extract_black_box");
if(document.getElementById("extract_dialog_box"))
{
var box_id = document.getElementById("extract_dialog_box");
var disp_content = "<img src =\" <?php echo _EXT_URL ?>/images/_dialog_close.png\" style=\"postion:absolute;margin-left:280px;margin-top:0px;\" onclick = 'close_dialog_box()' >";
disp_content += "<div id =\"extract_dialog_content\" >We are extracting archive file in background ,please wait</div>";
box_id.innerHTML = disp_content;
box_id.style.display = "block";
}
else
{
var n_dialog_box = document.createElement("div");
n_dialog_box.setAttribute("id","extract_dialog_box");
bl_dialog_box.appendChild(n_dialog_box);
n_dialog_box.style.width ="300px";
n_dialog_box.style.height ="70px";
n_dialog_box.style.backgroundColor ="#3b7eb0";
n_dialog_box.style.position ="absolute";
n_dialog_box.style.borderRadius = "3px";
//n_dialog_box.style.borderColor = "red";
n_dialog_box.style.borderWidth = "3px";
n_dialog_box.style.textAlign = "center";
n_dialog_box.style.color = "#FFFFFF";
n_dialog_box.style.top = "50%";
var disp_content = "<img src =\" <?php echo _EXT_URL ?>/images/_dialog_close.png\" style=\"postion:absolute;margin-left:280px;margin-top:0px;\" onclick = 'close_dialog_box()' >";
disp_content += "<div id =\"extract_dialog_content\" >We are extracting archive file in background ,please wait</div>";
n_dialog_box.innerHTML = disp_content;
var sw = parseInt(getStyle(document.body,"width"));
var new_pos = (sw - 300)/2;
n_dialog_box.style.left = new_pos+"px";
}
var file_url_detail = "get_extract_file.php";
show_extract_progress(file_url_detail);
}
conn.request({
url: '<?php echo basename($GLOBALS['script_name']) ?>',
params: requestParams,
callback: function(options, success, response ) {
if( success ) {
if(ac_detail == "extract" ) { }
else
{
json = Ext.decode( response.responseText );
if( json.success ) {
statusBarMessage( json.message, false, true );
try {
/*if( dropEvent) {
console.log(json);
dropEvent.target.parentNode.reload();
dropEvent = null;
} else {
console.log(json);
}*/
if( node ) {
if( options.params.action == 'delete' || options.params.action == 'rename' ) {
node.parentNode.select();
}
} else {
if ( ac_detail == "extract" ) {}
else {
custom_location_bar.onReload(custom_location_bar.current_node);
datastore.reload();
}
}
if( dropEvent) {
//console.log(json);
dropEvent.target.parentNode.reload();
dropEvent = null;
} else {
//console.log(json);
}
} catch(e) { datastore.reload(); }
} else {
ext_status = false ;
if(document.getElementById("extract_black_box")) {
document.getElementById("extract_black_box").style.display ="none";
}
Ext.Msg.alert( 'Failure', json.error );
}
}
}
else {
ext_status = false ;
if(document.getElementById("extract_black_box")) {
document.getElementById("extract_black_box").style.display ="none";
}
Ext.Msg.alert( 'Error', 'Failed to connect to the server.');
}
}
});
}
function getRequestParams() {
var selitems, dir, node;
var selectedRows = ext_itemgrid.getSelectionModel().getSelections();
if( selectedRows.length < 1 ) {
node = Ext.getCmp("dirTree").getSelectionModel().getSelectedNode();
if( node ) {
var dir = Ext.getCmp("dirTree").getSelectionModel().getSelectedNode().id.replace( /_RRR_/g, '/' );
var lastSlash = dir.lastIndexOf( '/' );
if( lastSlash > 0 ) {
selitems = Array( dir.substring(lastSlash+1) );
} else {
selitems = Array( dir );
}
} else {
selitems = {};
}
dir = datastore.directory.substring( 0, datastore.directory.lastIndexOf('/'));
}
else {
selitems = Array(selectedRows.length);
if( selectedRows.length > 0 ) {
for( i=0; i < selectedRows.length;i++) {
selitems[i] = selectedRows[i].get('name');
}
}
dir = datastore.directory;
}
//Ext.Msg.alert("Debug", dir );
var requestParams = {
option: 'com_extplorer',
dir: dir,
item: selitems.length > 0 ? selitems[0]:'',
'selitems[]': selitems
};
// alert(requestParams.toSource());
return requestParams;
}
function getScrollXY() {
var scrd = new Object();
if( typeof( window.pageYOffset ) == 'number' ) {
//Netscape compliant
scrd.scrOfY = window.pageYOffset;
scrd.scrOfX = window.pageXOffset;
} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
//DOM compliant
scrd.scrOfY = document.body.scrollTop;
scrd.scrOfX = document.body.scrollLeft;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
//IE6 standards compliant mode
scrd.scrOfY = document.documentElement.scrollTop;
scrd.scrOfX = document.documentElement.scrollLeft;
}
return scrd;
}
function GetelementOffset (object, offset) {
if (!object)
return;
offset.x += object.offsetLeft;
offset.y += object.offsetTop;
GetelementOffset (object.offsetParent, offset);
}
function GetelementScrolled (object, scrolled) {
if (!object)
return;
scrolled.x += object.scrollLeft;
scrolled.y += object.scrollTop;
if (object.tagName.toLowerCase () != "html") {
GetelementScrolled (object.parentNode, scrolled);
}
}
function GetelementTopLeft (divelementobject) {
var res = new Object();
var offset = {x : 0, y : 0};
GetelementOffset (divelementobject, offset);
var scrolled = {x : 0, y : 0};
GetelementScrolled (divelementobject.parentNode, scrolled);
res.posX = offset.x - scrolled.x;
res.posY = offset.y - scrolled.y;
return res;
}
function getStyle(el, cssprop) {
if (el.currentStyle) //IE
return el.currentStyle[cssprop]
else if (document.defaultView && document.defaultView.getComputedStyle) //Firefox
return document.defaultView.getComputedStyle(el, "")[cssprop]
else //try and get inline style
return el.style[cssprop]
}
/**
* Function for actions, which don't require a form like download, extraction, deletion etc.
*/
function deleteFiles(btn) {
if( btn != 'yes') {
return;
}
requestParams = getRequestParams();
requestParams.action = 'delete';
// console.log("AAAAAAAAAAAA SSS Delete requestParams:- "+JSON.stringify(requestParams));
handleCallback(requestParams);
}
function extractArchive(btn) {
if( btn != 'yes') {
return;
}
ext_status = true;
requestParams = getRequestParams();
requestParams.action = 'extract';
var xml_httpd = new XMLHttpRequest();
xml_httpd.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var jda = JSON.parse(xml_httpd.responseText);
if(jda.status == 1)
{
handleCallback(requestParams);
}
else
{
Ext.Msg.alert( 'Failure', requestParams.item+": File is not extractable Archive" );
}
}
};
xml_httpd.open("GET","clear_temp_file_session.php?file_name="+encodeURIComponent(requestParams.item), true);
xml_httpd.send();
}
function create_Black_Box(callback) {
if (document.getElementById("extract_black_box"))
{
document.getElementById("extract_black_box").style.display ="none";
}
else
{
var black_box = document.createElement("div");
black_box.setAttribute("id","extract_black_box");
document.body.appendChild(black_box);
black_box.style.width = "100%";
black_box.style.height ="100%";
black_box.style.position = "absolute";
black_box.style.left = "0px";
black_box.style.top = "0px";
black_box.style.backgroundColor = "rgba(0,0,0,0.2)";
}
var bl_dialog_box = document.getElementById("extract_black_box");
if(document.getElementById("extract_dialog_box"))
{
}
else
{
var n_dialog_box = document.createElement("div");
n_dialog_box.setAttribute("id","extract_dialog_box");
bl_dialog_box.appendChild(n_dialog_box);
n_dialog_box.style.width ="300px";
n_dialog_box.style.height ="70px";
n_dialog_box.style.backgroundColor ="#3b7eb0";
n_dialog_box.style.position ="absolute";
n_dialog_box.style.borderRadius = "3px";
//n_dialog_box.style.borderColor = "red";
n_dialog_box.style.borderWidth = "3px";
n_dialog_box.style.textAlign = "center";
n_dialog_box.style.color = "#FFFFFF";
n_dialog_box.style.top = "50%";
}
var box_id = document.getElementById("extract_dialog_box");
var disp_content = "<img src =\" <?php echo _EXT_URL ?>/images/_dialog_close.png\" style=\"postion:absolute;margin-left:280px;margin-top:0px;\" onclick = 'close_dialog_box()' >";
disp_content += "<div id =\"extract_dialog_content\" > we are processing file in background ,please wait</div>";
box_id.innerHTML = disp_content;
box_id.style.display = "block";
box_id.innerHTML = disp_content;
var sw = parseInt(getStyle(document.body,"width"));
var new_pos = (sw - 300)/2;
box_id.style.left = new_pos+"px";
callback("1");
}
function copy_move_file() {
var xml_httpd = new XMLHttpRequest();
xml_httpd.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//console.log(xml_httpd.responseText);
var bd = document.getElementById("extract_black_box");
var visb = getStyle(bd,"display");
if (visb.toLowerCase() == "block")
{
var jda = JSON.parse(xml_httpd.responseText);
if(jda.status == 1)
{
document.getElementById("extract_dialog_content").innerHTML= jda.file_count+" file copied/Moved";
copy_move_file();
}
else if(jda.status == 2)
{
document.getElementById("extract_dialog_content").innerHTML= "File copy/move completed";
}
else
{
Ext.Msg.alert( 'Failure',"Some problem occured in copy or move");
}
}
}
};
xml_httpd.open("GET","get_file_detail.php", true);
xml_httpd.send();
}
function deleteDir( btn, node ) {
if( btn != 'yes') {
return;
}
requestParams = getRequestParams();
requestParams.dir = datastore.directory.substring( 0, datastore.directory.lastIndexOf('/'));
requestParams.selitems = Array( node.id.replace( /_RRR_/g, '/' ) );
requestParams.action = 'delete';
handleCallback(requestParams, node);
}
Ext.msgBoxSlider = function(){
var msgCt;
function createBox(t, s){
return ['<div class="msg">',
'<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>',
'<div class="x-box-ml"><div class="x-box-mr"><div id="x-box-mc-inner" class="x-box-mc"><h3>', t, '</h3>', s, '</div></div></div>',
'<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
'</div>'].join('');
}
return {
msg : function(title, format){
if(!msgCt){
msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
}
msgCt.alignTo(document, 't-t');
var s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));
var m = Ext.DomHelper.append(msgCt, {html:createBox(title, s)}, true);
m.setWidth(400 );
m.position(null, 5000 );
m.alignTo(document, 't-t');
Ext.get('x-box-mc-inner' ).setStyle('background-image', 'url("<?php echo _EXT_URL ?>/images/_accept.png")');
Ext.get('x-box-mc-inner' ).setStyle('background-position', '5px 10px');
Ext.get('x-box-mc-inner' ).setStyle('background-repeat', 'no-repeat');
Ext.get('x-box-mc-inner' ).setStyle('padding-left', '35px');
m.slideIn('t').pause(3).ghost("t", {remove:true});
}
};
}();
function statusBarMessage( msg, isLoading, success ) {
var statusBar = Ext.getCmp('statusPanel');
if( !statusBar ) return;
if( isLoading ) {
statusBar.showBusy();
}
else {
statusBar.setStatus("Done.");
}
if( success ) {
statusBar.setStatus({
text: '<?php echo ext_Lang::msg('success', true ) ?>: ' + msg,
iconCls: 'success',
clear: true
});
Ext.msgBoxSlider.msg('<?php echo ext_Lang::msg('success', true ) ?>', msg );
} else if( success != null ) {
statusBar.setStatus({
text: '<?php echo ext_Lang::err('error', true ) ?>: ' + msg,
iconCls: 'error',
clear: true
});
}
}
function selectFile( dir, file ) {
chDir( dir );
var conn = datastore.proxy.getConnection();
if( conn.isLoading() ) {
setTimeout( "selectFile(\"" + dir + "\", \""+ file + "\")", 1000 );
}
idx = datastore.find( "name", file );
if( idx >= 0 ) {
ext_itemgrid.getSelectionModel().selectRow( idx );
}
}
/**
* Debug Function, that works like print_r for Objects in Javascript
*/
function var_dump(obj) {
var vartext = "";
for (var prop in obj) {
if( isNaN( prop.toString() )) {
vartext += "\t->"+prop+" = "+ eval( "obj."+prop.toString()) +"\n";
}
}
if(typeof obj == "object") {
return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "") + "\n" + vartext;
} else {
return "Type: "+typeof(obj)+"\n" + vartext;
}
}//end function var_dump
//http://www.bazon.net/mishoo/home.epl?NEWS_ID=1345
function doGetCaretPosition (textarea) {
var txt = textarea.value;
var len = txt.length;
var erg = txt.split("\n");
var pos = -1;
if(typeof textarea.selectionStart != "undefined") { // FOR MOZILLA
pos = textarea.selectionStart;
}
else if(typeof document.selection != "undefined") { // FOR MSIE
range_sel = document.selection.createRange();
range_obj = textarea.createTextRange();
range_obj.moveToBookmark(range_sel.getBookmark());
range_obj.moveEnd('character',textarea.value.length);
pos = len - range_obj.text.length;
}
if(pos != -1) {
var ind = 0;
for(;erg.length;ind++) {
len = erg[ind].length + 1;
if(pos < len)
break;
pos -= len;
}
ind++; pos++;
return [ind, pos]; // ind = LINE, pos = COLUMN
}
}
/**
* This function allows us to change the position of the caret
* (cursor) in the textarea
* Various workarounds for IE, Firefox and Opera are included
* Firefox doesn't count empty lines, IE does...
*/
function setCaretPosition( textarea, linenum ) {
if (isNaN(linenum)) {
updatePosition( textarea );
return;
}
var txt = textarea.value;
var len = txt.length;
var erg = txt.split("\n");
var ind = 0;
var pos = 0;
var nonempty = -1;
var empty = -1;
for(;ind < linenum;ind++) {
if( !erg[ind] && pos < len ) { empty++; pos++; continue; }
else if( !erg[ind] ) break;
pos += erg[ind].length;
nonempty++;
}
try {
pos -= erg[ind-1].length;
} catch(e) {}
textarea.focus();
if(textarea.setSelectionRange)
{
pos += nonempty;
textarea.setSelectionRange(pos,pos);
}
else if (textarea.createTextRange) {
pos -= empty;
var range = textarea.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
}
/**
* Updates the Position Indicator fields
*/
function updatePosition(textBox) {
var posArray = doGetCaretPosition(textBox);
if( posArray[0] ) {
Ext.fly( 'txtLine' ).set( { value: posArray[0] } );
}
if( posArray[1] ) {
Ext.fly( 'txtColumn' ).set( { value: posArray[1] } );
}
}