';
}
diva.html(divaHtml);
diva.dialog({title: 'Clipboard', modal: true, buttons: {
"Clear": function() {
gs_clipboard = new Array(); $('#gsclipboardContent').html(''); $("#gsClipBoard").html('0 items');
$(this).dialog('close');
}
}
});
return false;
}
function gs_makeUrl(root, params){
if (root.indexOf('?') !=-1) {
return root + '&' + params;
} else {
return root + '?' + params;
}
}
var gs_filemanager_languages = new Array();
gs_filemanager_languages['en'] = new Array();
gs_filemanager_languages['en'][1] = 'Current Dir';
gs_filemanager_languages['en'][2] = 'Clipboard';
gs_filemanager_languages['en'][3] = 'Upload';
gs_filemanager_languages['en'][4] = 'New File';
gs_filemanager_languages['en'][5] = 'New Directory';
gs_filemanager_languages['en'][6] = 'Paste';
gs_filemanager_languages['en'][7] = 'Name';
gs_filemanager_languages['en'][8] = 'Type';
gs_filemanager_languages['en'][9] = 'Size';
gs_filemanager_languages['en'][10] = 'Last Modified';
gs_filemanager_languages['en'][11] = 'Open with';
gs_filemanager_languages['en'][12] = 'Notepad';
gs_filemanager_languages['en'][13] = 'ImageViewer';
gs_filemanager_languages['en'][14] = 'Copy';
gs_filemanager_languages['en'][15] = 'Cut';
gs_filemanager_languages['en'][16] = 'Rename';
gs_filemanager_languages['en'][17] = 'Copy AS';
gs_filemanager_languages['en'][18] = 'Download';
gs_filemanager_languages['en'][19] = 'Delete';
gs_filemanager_languages['en'][20] = 'Open';
gs_filemanager_languages['en'][21] = 'CKeditor';
gs_filemanager_languages['en'][22] = 'JCrop';
gs_filemanager_languages['en'][23] = 'Select all';
gs_filemanager_languages['en'][24] = 'Deselect all';
gs_filemanager_languages['en'][25] = 'Invert selection';
gs_filemanager_languages['en'][26] = 'Width';
gs_filemanager_languages['en'][27] = 'Height';
gs_filemanager_languages['en'][28] = 'Cancel';
gs_filemanager_languages['en'][29] = 'Upload File';
gs_filemanager_languages['en'][30] = 'Items';
gs_filemanager_languages['en'][31] = 'Save';
gs_filemanager_languages['en'][32] = 'Resize';
gs_filemanager_languages['en'][33] = 'Crop';
gs_filemanager_languages['en'][34] = 'As name';
gs_filemanager_languages['en'][35] = 'New name';
gs_filemanager_languages['en'][36] = 'File name';
gs_filemanager_languages['en'][37] = 'Directory name';
gs_filemanager_languages['en'][38] = 'Are you sure that you want to deleted selected items?';
gs_filemanager_languages['en'][39] = 'Zip directory';
gs_filemanager_languages['en'][40] = 'Zip file';
gs_filemanager_languages['en'][41] = 'Zip archive name';
gs_filemanager_languages['en'][42] = 'UnZip';
gs_filemanager_languages['en'][43] = 'UnZip Name';
gs_filemanager_languages['en'][44] = 'Lock sizes';
gs_filemanager_languages['en'][45] = 'Add upload field';
gs_filemanager_languages['en'][46] = 'Remove';
gs_filemanager_languages['en'][47] = 'Invalid name, name can not contains \ / . * ? " < > |';
gs_filemanager_languages['en'][101] = 'Properties';
gs_filemanager_languages['en'][102] = 'Save';
gs_filemanager_languages['en'][103] = 'Close';
function gs_getTranslation(lg, code){
result = null;
if (typeof(gs_filemanager_languages[lg]) != 'undefined') {
if (typeof(gs_filemanager_languages[lg][code]) != 'undefined') {
result = gs_filemanager_languages[lg][code];
}
}
return result;
}
var gs_cur_items = new Array();
var gs_clipboard = new Array();
var gs_ext_editables = new Array();
gs_ext_editables['txt'] = '1';
gs_ext_editables['php'] = '1';
gs_ext_editables['doc'] = '1';
gs_ext_editables['js'] = '1';
gs_ext_editables['html'] = '1';
gs_ext_editables['htm'] = '1';
gs_ext_editables['rtf'] = '1';
gs_ext_editables['css'] = '1';
gs_ext_editables['java'] = '1';
gs_ext_editables['asp'] = '1';
gs_ext_editables['xml'] = '1';
gs_ext_editables['xls'] = '1';
gs_ext_editables['sql'] = '1';
gs_ext_editables['log'] = '1';
var gs_ext_pictures = new Array();
gs_ext_pictures['png'] = '1';
gs_ext_pictures['jpg'] = '1';
gs_ext_pictures['jpeg'] = '1';
gs_ext_pictures['gif'] = '1';
gs_ext_pictures['pdf'] = '1';
gs_ext_pictures['ico'] = '1';
var gs_ext_arhives = new Array();
gs_ext_arhives['zip'] = '1';
var gs_forbitten_ext_mapping = new Array();
gs_forbitten_ext_mapping['editable'] = '15,16,17,23';
gs_forbitten_ext_mapping['picture'] = '12,18,23';
gs_forbitten_ext_mapping['unknown'] = '12,15,16,17,18,23';
gs_forbitten_ext_mapping['archive'] = '12,15,16,17,18,19';
if (jQuery) (function(jQuery){
$.extend(jQuery.fn, {
gsFileManager: function(o) {
if( !o ) var o = {};
if( o.root == undefined ) o.root = '/';
if( o.language == undefined ) o.language = 'en';
if( o.script == undefined ) o.script = 'jqueryFileTree.php';
if( o.expandSpeed == undefined ) o.expandSpeed= 500;
if( o.collapseSpeed == undefined ) o.collapseSpeed= 500;
if( o.expandEasing == undefined ) o.expandEasing = null;
if( o.collapseEasing == undefined ) o.collapseEasing = null;
if( o.loadMessage == undefined ) o.loadMessage = 'Loading...';
wrapperHtml = '';
$(this).html(wrapperHtml);
$('#gs_image_x').bind('blur', function(){gsmanageImgSizes('x')});
$('#gs_image_y').bind('blur', function(){gsmanageImgSizes('y')});
$('#gs_dir_content').contextMenu({
menu: 'gsContentMenu',
addSelectedClass: false
},
function(action, el, pos) {
$(el).doGSAction({action: action, script: o.script, type: 'context', lg: o.language});
});
$('#gs_uploadbutton').click(function (e){
e.stopPropagation();
$('#gs_uploadsFiledsHolder').html('');
$('#gs_uploadAddField').click();
$('#gsuploadfiles').bind('dragover drop', function(event) {
event.stopPropagation();
event.preventDefault();
if (event.type == 'drop') {
//console.log(event.originalEvent.dataTransfer.files);
var uploadsFieldsHolder = $('#gs_uploadsFiledsHolder');
$.each(event.originalEvent.dataTransfer.files, function(key, file_uploaded) {
let list = new DataTransfer();
list.items.add(file_uploaded);
let field_name = '';
let file_name = '';
let l_already_uploaded = false;
$.each($('input:file'), function(k, file_input) {
//console.log(k);
//console.log(file_input);
//console.log('length='+file_input.files.length);
if(file_input.files.length==0) {
field_name = file_input.name;
return false;
} else {
file_name = file_input.files[0].name;
if(file_name===file_uploaded.name) {
l_already_uploaded = true;
return false;
}
}
});
//console.log('1.file_name'+file_name);
//console.log('2.file_name'+file_uploaded.name);
if(!l_already_uploaded) {
if(!field_name) {
field_name = add_uploadsFieldsHolder();
//console.log('2.field_name=' + field_name);
}
$('input[name="'+field_name+'"]').prop("files", list.files);
}
});
}
});
$(this).doGSAction({action: 14, script: o.script, type: 'file', lg: o.language});
});
$('#gs_newfilebutton').click(function (e){
e.stopPropagation();
$(this).doGSAction({action: 2, script: o.script, type: 'file', lg: o.language});
});
$('#gs_newdirbutton').click(function (e){
e.stopPropagation();
$(this).doGSAction({action: 3, script: o.script, type: 'dir', lg: o.language});
});
$('#gs_refreshbutton').click(function (e){
e.stopPropagation();
var curDir = $("#curDir").val();
showTree(curDir);
});
$('#gs_search').click(function (e){
e.stopPropagation();
var curDir = $("#curDir").val();
showSearch(curDir);
});
$('#gs_pastebutton').click(function (e){
e.stopPropagation();
$(this).doGSAction({script: o.script, action: 9, lg: o.language});
});
$('#gs_selectallbutton').click(function (e){
e.stopPropagation();
$(this).doGSAction({action: 20, script: o.script, type: 'context', lg: o.language});
});
$('#gs_deselectbutton').click(function (e){
e.stopPropagation();
$(this).doGSAction({action: 21, script: o.script, type: 'context', lg: o.language});
});
$('#gs_invertselectbutton').click(function (e){
e.stopPropagation();
return $(this).doGSAction({action: 22, script: o.script, type: 'context', lg: o.language});
});
$('#gs_uploadAddField').click(function (e){
e.stopPropagation();
e.preventDefault();
add_uploadsFieldsHolder('');
});
/*
$('#gs_jcrop_form').ajaxForm({
beforeSubmit: function () {
$('#gsimagecropzoom').append('
');
},
success: function (responseText, statusText, xhr, $form) {
gsCheckResponce(responseText);
filenamea = $('#gs_jcrop_filename').val();
dira = escape($('#gs_jcrop_dir').val());
var imageSrc = gs_makeUrl(o.script, "opt=15&filename=" + filenamea +"&dir=" + dira + "&time="+ new Date().getTime());
$('#gs_jcrop_div_container').html('
');
$('#gsjcrop_target').load(function(){
$('#gsjcrop_target').Jcrop({onSelect: updateCoords});
});
},
dataType: 'text'
});
*/
jQuery('#gsUploadForm').ajaxForm({
beforeSubmit: function () {
jQuery('#gsuploadfiles').append('
');
},
success: function (responseText, statusText, xhr, $form) {
gsCheckResponce(responseText);
jQuery('#gsuploadfiles').find('div.loadingDiv').remove();
jQuery('#gsuploadfiles').dialog('close');
$('#gs_refreshbutton').trigger('click');
},
dataType: 'text'
});
function add_uploadsFieldsHolder(filename) {
var uploadsFieldsHolder = $('#gs_uploadsFiledsHolder');
var uploadsFieldsLength = $('#gs_uploadsFiledsHolder input').length;
field_name = 'filename_' + uploadsFieldsLength;
uploadsFieldsHolder.append(
'
');
return field_name;
}
function gsmanageImgSizes(direction){
var Xelement = $('#gs_image_x');
var Yelement = $('#gs_image_y');
if (direction == 'x') {
var oldVal = parseInt(Xelement.attr('rel'));
if (isNaN(oldVal) || oldVal <= 0) {
return;
}
var curVal = parseInt(Xelement.val());
Xelement.attr('rel', curVal);
if ($('#lock_sizes:checked').length < 1) {
return;
}
var radio = curVal / oldVal;
if (radio == 1) {
return;
}
var newValue = parseInt(parseInt(Yelement.val()) * radio);
Yelement.attr('rel', newValue);
Yelement.val(newValue);
}
if (direction == 'y') {
var oldVal = parseInt(Yelement.attr('rel'));
if (isNaN(oldVal) || oldVal <= 0) {
return;
}
var curVal = parseInt(Yelement.val());
Yelement.attr('rel', curVal);
if ($('#lock_sizes:checked').length < 1) {
return;
}
var radio = curVal / oldVal;
if (radio == 0) {
return;
}
var newValue = parseInt(parseInt(Xelement.val()) * radio);
Xelement.attr('rel', newValue);
Xelement.val(newValue);
}
}
function manageGsMenu (srcElement, menu){
if (srcElement.hasClass('up')) {
return false;
}
return true;
}
function bindContent (t) {
$('tr.f').contextMenu({
menu: 'gsFileMenu'
},
function(action, el, pos) {
$(el).doGSAction({action: action, script: o.script, type: 'file', lg: o.language});
},
manageGsMenu);
$('#gs_content_table tr.d').bind('click', function(e){
var rel = $(this).attr('rel');
$(".contextMenu").hide();
showTree(rel);
return false;
});
$('#gs_content_table tr.f').bind('click', function(e){
$(".contextMenu").hide();
$(this).doGSAction({action: 11, script: o.script, type: 'file',lg: o.language});
return false;
});
$('tr.d').contextMenu({
menu: 'gsDirMenu'
},
function(action, el, pos) {
$(el).doGSAction({action: action, script: o.script, type: 'dir',lg: o.language});
},
manageGsMenu);
$('span.curDir').bind('click', function(e){
var rel = $(this).attr('rel');
showTree(rel);
});
$('#gs_startsearch').click(function (e){
e.stopPropagation();
var filename = $("#filename").val();
localStorage.setItem("gfSearch", filename);
showSearchResult(filename);
});
}
function showTree(t) {
gs_show_loading();
$(".jqueryFileTree.start").remove();
jQuery.ajax({
type: 'POST', //GET
url: o.script,
data: { dir: t },
dataType: 'json',
contentType : 'application/x-www-form-urlencoded; charset=utf-8',
success: function(data) {
$('#scurDir').html(data.scurdir);
$('#curDir').val(data.curdir);
$('#gs_dir_content').html(data.content);
bindContent(unescape(t));
}});
}
function showSearch(t) {
$filename = (localStorage.getItem("gfSearch") !== null ? localStorage.getItem("gfSearch") : '');
$('#gs_dir_content').html('Please enter file name or a part: '+'
'+
'
');
bindContent(unescape(t));
}
function showSearchResult(t) {
//alert('showSearchResult');
if (t.length < 1) {
showTree(t)
} else {
gs_show_loading();
$(".jqueryFileTree.start").remove();
jQuery.ajax({
type: 'POST', //GET
url: o.script,
data: { file_search: t },
dataType: 'html',
contentType : 'application/x-www-form-urlencoded; charset=utf-8',
success: function(data) {
//console.log(data);
$('#gs_dir_content').html(data);
bindContent(unescape(t));
}});
}
}
function showRoot(){
showTree(escape(o.root));
//$(this).parent().parent().find('UL').slideUp({ duration: o.collapseSpeed, easing: o.collapseEasing });
//$(this).parent().parent().find('LI.directory').removeClass('expanded').addClass('collapsed');
}
var cusElement = $('#gs_dir_list');
// Loading message
cusElement.html('
');
// Get the initial file list
cusElement.prepend('
root');
cusElement.find('#rootLink').bind('click', showRoot);
showRoot();
},
doGSAction: function(o) {
var curDir = $("#curDir").val();
var dataForSend = null;
var name = '';
var dir = $(this).find('div.directory');
var file = $(this).find('div.file');
var searchresult = $(this).find('div.searchresult');
if(dir.length>0) {
name = dir.html();
} else {
name = file.html();
if(searchresult.length>0) {
curDir = $(this).attr('rel');
}
}
//function (type, name, path, size, id, exta, lastMod) {
gsitem = new gsItem('', name, '', '', '', '');
//var gsitem = gs_get_cur_item($(this).attr('rel'));
if (gsitem == null) {
//alert('no gsitem');
}
if (o.action == '23') { // zip
unZipItem(o, curDir, gsitem);
return;
}
if (o.action == '12') { // show notepad
showNotePad(o, curDir, gsitem);
return;
}
if (o.action == '13') { // copy as
copyAs(o, curDir, gsitem);
return;
}
if (o.action == '14') { // show upload
$('#gsuploadfiles').dialog({title: gs_getTranslation(o.lg, 29), modal: true, width: 460, height: 460,
buttons: [ {text: gs_getTranslation(o.lg, 28),
click: function() {
$(this).dialog("close");
}
},
{
text: gs_getTranslation(o.lg, 3),
click: function() {
$(this).find("input[name=dir]").val(curDir);
$('#gsUploadForm').submit();
}
}]
});
return;
}
if (o.action == '15') { // show image viewer
showImageViewer(o, curDir, gsitem);
return;
}
if (o.action == '16') { // show crop zoom image
showJcrop(o, curDir, gsitem);
return;
}
if (o.action == '18') { // ckeditor
showCKEditor(o, curDir, gsitem);
return;
}
if (o.action == '19') { // zip
zipItem(o, curDir, gsitem);
return;
}
if (o.action == '7') { // copy
var clipBoard = $("#gsClipBoard");
gs_storeSelectedItems();
clipBoard.html('(Copy) ' + gs_clipboard.length + ' ' + gs_getTranslation(o.lg, 30));
clipBoard.attr('rel', o.action);
return;
}
if (o.action == '8') { // cut
var clipBoard = $("#gsClipBoard");
gs_storeSelectedItems();
clipBoard.html('(Cut) ' + gs_clipboard.length + ' ' + gs_getTranslation(o.lg, 30));
clipBoard.attr('rel', o.action);
return;
}
if (o.action == '9') { //paste
pasteItems(o, curDir, gsitem);
return;
}
if (o.action == '10') { //rename
renameItem(o, curDir, gsitem);
return;
}
if (o.action == '101') { //properties
propertiesItem(o, curDir, gsitem);
return;
}
if (o.action == '11') { //download
//console.log(gsitem);
dataForSend = {opt: 8, filename: gsitem.name, dir: curDir};
//20160615
var ext = gsitem.name.slice(-4);
ext.toLowerCase();
if(ext == '.pdf') {
window.open(gs_makeUrl(o.script, jQuery.param(dataForSend)));
} else {
location.href= gs_makeUrl(o.script, jQuery.param(dataForSend));
}
return;
}
if (o.action == '111') { //download from search
dataForSend = {opt: 8, filename: gsitem.name, dir: curDir};
//20160615
var ext = gsitem.name.slice(-4);
ext.toLowerCase();
if(ext == '.pdf') {
window.open(gs_makeUrl(o.script, jQuery.param(dataForSend)));
} else {
location.href= gs_makeUrl(o.script, jQuery.param(dataForSend));
}
return;
}
if (o.action == '2') { //new file
newFile(o, curDir, gsitem);
return;
}
if (o.action == '3') { //new dir
newDir(o, curDir, gsitem);
return;
}
if (o.action == '4' || o.action == '6') { //delete item
deleteItem(o, curDir, gsitem);
return;
}
if (o.action == '5') { //open dir
$('#' + gsitem.id).trigger('click');
return;
}
function showCKEditor(o, curDir, gsitem){
var height = parseInt($(window).height()) - 100;
var width = parseInt($(window).width()) - 100;
$('#gsckeditor').dialog({title: 'CKEditor ' + gsitem.name, modal: true, width: width, height: height,
buttons: [ {
click: function() { $(this).dialog("close"); $('#gs_ckeditor_content').html(''); },
text: gs_getTranslation(o.lg, 28)
},
{
text: gs_getTranslation(o.lg, 31),
click: function() {
$('#gs_ckeditor_content').hide();
$(this).append('
');
//$(this).doGSAction({action: 13, type: 'file', script: o.script});
texta = $('#gsckeditor').find('textarea');
targetFile = texta.attr('rel');
content = CKEDITOR.instances.gsFileContent.getData();
dataForSend = {opt: 10, filename: targetFile, dir: curDir, filenContent: content};
sendAndRefresh(o, dataForSend, true, function(data) {
$('#gs_ckeditor_content').find('div.loadingDiv').remove();
$('#gs_ckeditor_content').show();
});
}
}]
});
$('#gs_ckeditor_content').html('
');
dataForSend = {opt: 9, filename: gsitem.name, dir: curDir};
sendAndRefresh(o, dataForSend, false, function(data) {
$('#gs_ckeditor_content').html('
');
if (typeof(CKEDITOR.instances.gsFileContent) != 'undefined') {
CKEDITOR.remove(CKEDITOR.instances['gsFileContent']);
}
CKEDITOR.replace('gsFileContent', {language: o.lg});
});
}
function showNotePad(o, curDir, gsitem){
var height = parseInt($(window).height()) - 100;
var width = parseInt($(window).width()) - 100;
var rows = parseInt(height / 30);
var cols = parseInt(width / 10);
$('#gsnotepadedit').dialog({title: 'Edit ' + gsitem.name, modal: true, width: width, height: height,
buttons: [ {
click: function() { $(this).dialog("close"); },
text: gs_getTranslation(o.lg, 28)
},
{
text: gs_getTranslation(o.lg, 31),
click: function() {
$(this).find('textarea').hide();
$(this).append('
');
texta = $('#gsnotepadedit').find('textarea');
targetFile = texta.attr('rel');
content = texta.val();
dataForSend = {opt: 10, filename: targetFile, dir: curDir, filenContent: content};
sendAndRefresh(o, dataForSend, true, function(data) {
$('#gsnotepadedit').find('div.loadingDiv').remove();
$('#gsnotepadedit').find('textarea').show();
});
}
}]
});
$('#gsnotepadedit').html('
');
dataForSend = {opt: 9, filename: encodeURIComponent(gsitem.name), dir: curDir};
sendAndRefresh(o, dataForSend, false, function(data) {
$('#gsnotepadedit').html('
');
});
}
function showImageViewer(o, curDir, gsitem){
var height = parseInt($(window).height()) - 100;
var width = parseInt($(window).width()) - 100;
$('#gsimageviewer').dialog({title: 'Image viewer ' + gsitem.name, modal: true, width: width, height: height,
buttons: [{
click: function() { $(this).dialog("close"); $('#gsimageviewer_content').html(''); },
text: gs_getTranslation(o.lg, 28)
},
{
text: gs_getTranslation(o.lg, 32),
click: function() {
$('#gsimageviewer_content').html('
');
dataForSend = {opt: 13, filename: gsitem.name, dir: curDir, new_x: $('#gs_image_x').val(), new_y: $('#gs_image_y').val()};
sendAndRefresh(o, dataForSend, true, function(data) {
dataForSend = {opt: 15, filename: gsitem.name, dir: curDir};
$('#gsimageviewer_content').html('
');
});
}
}]
});
dataForSend = {opt: 15, filename: gsitem.name, dir: curDir};
var imageSrc = gs_makeUrl(o.script, jQuery.param(dataForSend) +'&time='+ new Date().getTime());
$('#gs_image_x').val('');
$('#gs_image_y').val('');
$('#gsimageviewer_content').html('
');
$('#gs_imageviewer_image').load( function(){
var tImageelement = $(this);
$('#gs_image_x').val(tImageelement.width());
$('#gs_image_y').val(tImageelement.height());
$('#gs_image_x').attr('rel', tImageelement.width());
$('#gs_image_y').attr('rel', tImageelement.height());
});
$('#gs_imageviewer_image').attr('src', imageSrc);
}
function showJcrop(o, curDir, gsitem){
var gs_jcrop_div = $('#gs_jcrop_div');
var height = parseInt($(window).height()) - 100;
var width = parseInt($(window).width()) - 100;
gs_jcrop_div.dialog({title: 'JCrop ' + gsitem.name, width: width, height: height, modal: true,
buttons: [{
click: function() { $(this).dialog("close");},
text: gs_getTranslation(o.lg, 28)
},{
text: gs_getTranslation(o.lg, 33),
click: function() {
$('#gs_jcrop_div_container').html('
');
$('#gs_jcrop_form').submit();
}
}]
});
$('#gs_jcrop_div_container').html('
');
dataForSend = {opt: 15, filename: gsitem.name, dir: curDir};
var imageSrc = gs_makeUrl(o.script, jQuery.param(dataForSend) +'&time='+ new Date().getTime());
$('#gs_jcrop_div_container').html('
');
$('#gsjcrop_target').load( function(){
$('#gsjcrop_target').Jcrop({onSelect: updateCoords});
});
$("#gs_jcrop_dir").val(curDir);
$("#gs_jcrop_filename").val(gsitem.name);
}
function pasteItems(o, curDir, gsitem){
var clipBoard = $("#gsClipBoard");
var opt = null;
var selectedFiles = gsGetSelectedItemsPath();
if (clipBoard.attr('rel') == '7') { //copy
opt = 5;
} else if (clipBoard.attr('rel') == '8') { // paste
gs_clipboard = new Array();
clipBoard.html('0 items');
$('#gsclipboardContent').html('');
clipBoard.attr('rel', '');
opt = 7;
} else {
return;
}
if (selectedFiles != null) {
dataForSend = {opt: opt, files: selectedFiles, dir: curDir};
sendAndRefresh(o, dataForSend, true);
}
if (opt == 7) {
for (var xx in gs_clipboard) {
if (gs_clipboard[xx].getExt() == 'dir') {
$("#" + gs_clipboard[xx].id).parent().remove();
}
}
}
}
function copyAs(o, curDir, gsitem){
var newName = window.prompt(gs_getTranslation(o.lg, 34) + ': ', htmlspecialchars_decode(gsitem.name, 'ENT_QUOTES'));
if (newName == null) {
return;
}
dataForSend = {opt: 14, filename: gsitem.name, dir: curDir, newfilename: newName};
sendAndRefresh(o, dataForSend, true);
}
function unZipItem(o, curDir, gsitem){
var newName = window.prompt(gs_getTranslation(o.lg, 43) + ': ', 'unzipped_' + htmlspecialchars_decode(gsitem.name, 'ENT_QUOTES'));
if (newName == null) {
return;
}
dataForSend = {opt: 17, filename: gsitem.name, dir: curDir, newfilename: newName};
sendAndRefresh(o, dataForSend, true);
}
function zipItem(o, curDir, gsitem){
var newName = window.prompt(gs_getTranslation(o.lg, 41) + ': ', htmlspecialchars_decode(gsitem.name, 'ENT_QUOTES') + '.zip');
if (newName == null) {
return;
}
dataForSend = {opt: 16, filename: gsitem.name, dir: curDir, newfilename: newName};
sendAndRefresh(o, dataForSend, true);
}
function renameItem(o, curDir, gsitem){
var newName = window.prompt(gs_getTranslation(o.lg, 35) + ': ', htmlspecialchars_decode(gsitem.name, 'ENT_QUOTES'));
if (newName == null) {
return;
}
dataForSend = {opt: 6, filename: curDir+gsitem.name, dir: curDir, newfilename: newName};
sendAndRefresh(o, dataForSend, true);
}
function propertiesItem(o, curDir, gsitem){
var wHeight = $(window).height();
var wWidth = $(window).width();
var dWidth = "auto";
var dHeight = "auto";
// Buttons vorbereiten
var myButtons={};
myButtons[gs_getTranslation(o.lg, 102)] = function() {
var formData = $('form[name="frmNED"]').serialize()
formData = formData + '&ACT=SAVE&NV=T';
formData = formData + '&dir=' + encodeURIComponent(curDir);
formData = formData + '&filename=' + encodeURIComponent(gsitem.name);
$.ajax({
url : o.script,
type : 'POST', //GET
data : formData,
success : function(resp){
resp = $.trim(resp);
if(resp=='OK') {
newDiv.dialog('close');
newDiv.empty();
newDiv.remove();
$('#gs_refreshbutton').trigger('click');
} else {
newDiv.html(resp);
}
},
error : function(resp){
//alert(JSON.stringify(resp));
}
});
}
myButtons[gs_getTranslation(o.lg, 103)]= function() {
$( this ).empty();
$( this ).remove();
}
$( "#_ned" ).empty();
$( "#_ned" ).remove();
var newDiv = $("
");
newDiv.load(o.script + '?r=' + Math.random(),
{opt: 101, filename: curDir+gsitem.name, dir: curDir},
function() {
newDiv.dialog({
modal: true,
draggable: true,
width:dWidth, height:dHeight,
title:gs_getTranslation(o.lg, 101),
});
newDiv.dialog('option', 'buttons', myButtons);
}
);
//if(resp=='OK') {
// dataForSend =
// sendAndRefresh(o, dataForSend, true);
//}
}
function newFile(o, curDir, gsitem){
var newName = window.prompt(gs_getTranslation(o.lg, 36) + ': ');
if (newName == null || newName.length < 1) {
return;
}
dataForSend = {opt: 2, filename: newName, dir: curDir};
sendAndRefresh(o, dataForSend, true);
}
function newDir(o, curDir, gsitem){
var newName = window.prompt(gs_getTranslation(o.lg, 37) + ': ');
if (newName == null || newName.length < 1) {
return;
}
dataForSend = {opt: 3, filename: newName, dir: curDir};
sendAndRefresh(o, dataForSend, true);
}
function deleteItem(o, curDir, gsitem){
if(!window.confirm(gs_getTranslation(o.lg, 38))){
return;
}
var selectedFiles = new Array();
selectedFiles.push(gsitem.name);
if (selectedFiles != null) {
dataForSend = {opt: 4, files: encodeURIComponent(selectedFiles), dir: curDir};
}
sendAndRefresh(o, dataForSend, true);
}
function sendAndRefresh(o, dataForSend, refresh, callback, type) {
if (refresh) {
gs_show_loading();
}
if (typeof(type) == 'undefined') {
type = 'text';
}
//dataForSend.dir = encodeURIComponent(dataForSend.dir);
jQuery.ajax({
type: 'POST', //GET
url: o.script,
data: jQuery.param(dataForSend) + '&time='+ new Date().getTime(),
dataType: type,
contentType : 'application/x-www-form-urlencoded;charset=utf-8',
beforeSend : function(xhr) {
xhr.setRequestHeader('Accept', "text/html; charset=utf-8");
},
success: function(data) {
gsCheckResponce(data);
if (refresh) {
$('#gs_refreshbutton').trigger('click');
}
if (callback) {
callback(data);
}
}});
}
function htmlspecialchars_decode (string, quote_style) {
// http://kevin.vanzonneveld.net
// + original by: Mirek Slugen
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Mateusz "loonquawl" Zalega
// + input by: ReverseSyntax
// + input by: Slawomir Kaniecki
// + input by: Scott Cariss
// + input by: Francois
// + bugfixed by: Onno Marsman
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// + input by: Ratheous
// + input by: Mailfaker (http://www.weedem.fr/)
// + reimplemented by: Brett Zamir (http://brett-zamir.me)
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
// * example 1: htmlspecialchars_decode("
this -> "
", 'ENT_NOQUOTES');
// * returns 1: '
this -> "
'
// * example 2: htmlspecialchars_decode(""");
// * returns 2: '"'
var optTemp = 0,
i = 0,
noquotes = false;
if (typeof quote_style === 'undefined') {
quote_style = 2;
}
string = string.toString().replace(/</g, '<').replace(/>/g, '>');
var OPTS = {
'ENT_NOQUOTES': 0,
'ENT_HTML_QUOTE_SINGLE': 1,
'ENT_HTML_QUOTE_DOUBLE': 2,
'ENT_COMPAT': 2,
'ENT_QUOTES': 3,
'ENT_IGNORE': 4
};
if (quote_style === 0) {
noquotes = true;
}
if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags
quote_style = [].concat(quote_style);
for (i = 0; i < quote_style.length; i++) {
// Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
if (OPTS[quote_style[i]] === 0) {
noquotes = true;
} else if (OPTS[quote_style[i]]) {
optTemp = optTemp | OPTS[quote_style[i]];
}
}
quote_style = optTemp;
}
if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
string = string.replace(/*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should
// string = string.replace(/'|*27;/g, "'"); // This would also be useful here, but not a part of PHP
}
if (!noquotes) {
string = string.replace(/"/g, '"');
}
// Put this in last place to avoid escape being double-decoded
string = string.replace(/&/g, '&');
return string;
}
}
});
})(jQuery);
//jQuery Context Menu Plugin
//
// Version 1.01
//
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
//
// More info: http://abeautifulsite.net/2008/09/jquery-context-menu-plugin/
//
// Terms of Use
//
// This plugin is dual-licensed under the GNU General Public License
// and the MIT License and is copyright A Beautiful Site, LLC.
//
if(jQuery)( function() {
jQuery.extend(jQuery.fn, {
contextMenu: function(o, callback, onShowMenu) {
// Defaults
if( o.menu == undefined ) return false;
if( o.inSpeed == undefined ) o.inSpeed = 150;
if( o.addSelectedClass == undefined ) o.addSelectedClass = true;
if( o.outSpeed == undefined ) o.outSpeed = 75;
// 0 needs to be -1 for expected results (no fade)
if( o.inSpeed == 0 ) o.inSpeed = -1;
if( o.outSpeed == 0 ) o.outSpeed = -1;
// Loop each context menu
$(this).each( function() {
var el = $(this);
var offset = $(el).offset();
// Add contextMenu class
$('#' + o.menu).addClass('contextMenu');
// Simulate a true right click
$(this).mousedown( function(e) {
var evt = e;
evt.stopPropagation();
$(this).mouseup( function(e) {
e.stopPropagation();
var srcElement = $(this);
srcElement.unbind('mouseup');
if( evt.button == 2 ) {
// Hide context menus that may be showing
$(".contextMenu").hide();
// Get this context menu
var menu = $('#' + o.menu);
menu.enableContextMenuItems();
if (onShowMenu) {
if (!onShowMenu( srcElement, menu )) {
return false;
}
}
if (!srcElement.hasClass('rowSelected')){
$("#gs_content_table div.gsItem").each(function(){
$(this).removeClass('rowSelected');
});
if (o.addSelectedClass) {
srcElement.addClass('rowSelected');
}
}
var jmenu = $(menu);
if( $(el).hasClass('disabled')) {
return false;
}
// Detect mouse position
var d = {}, x, y;
if( self.innerHeight ) {
d.pageYOffset = self.pageYOffset;
d.pageXOffset = self.pageXOffset;
d.innerHeight = self.innerHeight;
d.innerWidth = self.innerWidth;
} else if( document.documentElement &&
document.documentElement.clientHeight ) {
d.pageYOffset = document.documentElement.scrollTop;
d.pageXOffset = document.documentElement.scrollLeft;
d.innerHeight = document.documentElement.clientHeight;
d.innerWidth = document.documentElement.clientWidth;
} else if( document.body ) {
d.pageYOffset = document.body.scrollTop;
d.pageXOffset = document.body.scrollLeft;
d.innerHeight = document.body.clientHeight;
d.innerWidth = document.body.clientWidth;
}
(e.pageX) ? x = e.pageX : x = e.clientX + d.scrollLeft;
(e.pageY) ? y = e.pageY : y = e.clientY + d.scrollTop;
//alert("pageX: " + e.pageX + ", pageY: " + e.pageY + '#'+x+'#'+y);
// Show the menu
$(document).unbind('click');
jmenu.css({ top: y, left: x }).fadeIn(o.inSpeed);
// Hover events
jmenu.find('A').mouseover( function() {
jmenu.find('LI.hover').removeClass('hover');
if (!$(this).parent().parent().hasClass('subContextMenu')) {
jmenu.find('UL.subContextMenu').hide();
}
$(this).parent().addClass('hover');
$(this).parent().find('UL').css({ top: 0, left: 120 }).fadeIn(o.inSpeed);
}).mouseout( function() {
jmenu.find('LI.hover').removeClass('hover');
});
// When items are selected
menu.find('A').unbind('click');
menu.find('A').bind('click', function() {
if($(this).parent().hasClass('disabled')){
return false;
}
$(".contextMenu").hide();
// Callback
if (callback) {
callback( $(this).attr('rel'), $(srcElement), {x: x - offset.left, y: y - offset.top, docX: x, docY: y} );
}
return false;
});
// Hide bindings
setTimeout( function() { // Delay for Mozilla
$(document).click( function() {
$(menu).fadeOut(o.outSpeed);
});
}, 0);
}
});
});
// Disable text selection
/*
if( jQuery.browser.mozilla ) {
$('#' + o.menu).each( function() { $(this).css({ 'MozUserSelect' : 'none' }); });
} else if( jQuery.browser.msie ) {
$('#' + o.menu).each( function() { $(this).bind('selectstart.disableTextSelect', function() { return false; }); });
} else {
$('#' + o.menu).each(function() { $(this).bind('mousedown.disableTextSelect', function() { return false; }); });
}
*/
// Disable browser context menu (requires both selectors to work in IE/Safari + FF/Chrome)
$(el).add($('UL.contextMenu')).bind('contextmenu', function() { return false; });
});
return $(this);
},
// Disable context menu items on the fly
disableContextMenuItems: function(o) {
if( o == undefined ) {
// Disable all
$(this).find('LI').addClass('disabled');
return( $(this) );
}
$(this).each( function() {
if( o != undefined ) {
var d = o.split(',');
for( var i = 0; i < d.length; i++ ) {
//alert(d[i]);
$(this).find('A[rel="' + d[i] + '"]').parent().addClass('disabled');
}
}
});
return( $(this) );
},
// Enable context menu items on the fly
enableContextMenuItems: function(o) {
if( o == undefined ) {
// Enable all
$(this).find('LI.disabled').removeClass('disabled');
return( $(this) );
}
$(this).each( function() {
if( o != undefined ) {
var d = o.split(',');
for( var i = 0; i < d.length; i++ ) {
$(this).find('A[rel="' + d[i] + '"]').parent().removeClass('disabled');
}
}
});
return( $(this) );
},
// Disable context menu(s)
disableContextMenu: function() {
$(this).each( function() {
$(this).addClass('disabled');
});
return( $(this) );
},
// Enable context menu(s)
enableContextMenu: function() {
$(this).each( function() {
$(this).removeClass('disabled');
});
return( $(this) );
},
// Destroy context menu(s)
destroyContextMenu: function() {
// Destroy specified context menus
$(this).each( function() {
// Disable action
$(this).unbind('mousedown').unbind('mouseup');
});
return( $(this) );
}
});
})(jQuery);