');
$('#dialog_fm_add').dialog({
dialogClass: "dialog_fm_add",
resizable: false,
draggable: false,
close: function () {
$('#dialog_fm_add').remove();
load(o.path);
}
});
var files = [];
$('.fm_dropbox_text').click(function () {
$('#fm_open_file').trigger('click');
});
$('#fm_open_file').change(function (event) {
try {
$.each(event.target.files, function () {
files.push(this);
});
if (files.length) {
read(o, files, uploadArray);
}
return false;
}
catch (err) {
alert(err);
return false;
}
});
$('#fm_add_dropzone').bind('drop', function (e) {
try {
$.each(e.dataTransfer.files, function () {
files.push(this);
});
$('.dialog_fm_add > *').css({cursor: "wait"});
read(o, files, uploadArray);
return false;
}
catch (err) {
alert(err);
return false;
}
});
try {
$('#btn_fm_add_ok').button().click(function () {
function upload() {
try {
var name = uploadArray[0].name.split('.');
// convert extension to lower case
name[name.length - 1] = name[name.length - 1].toLowerCase();
name = name.join('.');
fmConn.writeFile64(o.path + name, uploadArray[0].value.split('base64,')[1], function (err, data) {
// TODO Leerzeichem im Dateinmaen Berucksichtigen (da in classen keine leertzeichen sein dürfen)
var class_name = uploadArray[0].name.split('.')[0].replace(" ", "_");
$("." + class_name).remove();
uploadArray.shift();
if (uploadArray.length > 0) {
upload();
} else {
$('.dialog_fm_add > *').css({cursor: "default"});
}
});
} catch
(err) {
console.log(err);
$('.dialog_fm_add > *').css({cursor: "default"});
}
}
$('.dialog_fm_add > *').css({cursor: "wait"});
upload();
});
$('#btn_fm_add_close').button().click(function () {
$('#dialog_fm_add').remove();
load(o.path);
});
} catch (err) {
alert(err);
}
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
if (id == "fm_bar_addfolder") {
try {
$('#dialog_fm').append(
'
' +
' ' +
'' +
'
' +
'
');
$('#dialog_fm_folder').dialog({
dialogClass: "dialog_fm_rename",
resizable: false,
draggable: false,
modal: true,
close: function () {
$('#dialog_fm_folder').remove();
}
});
$('#fm_btn_folder').button().click(function () {
var new_folder = $('#fm_inp_folder').val();
$('#dialog_fm_folder').remove();
if (new_folder !== '' || new_folder !== undefined) {
fmConn.mkdir(o.path + new_folder, function (err) {
if (err) {
console.log(err);
alert(fmTranslate('Cannot create folder'));
} else {
load(o.path);
}
});
}
});
} catch (err) {
alert(err);
}
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
if (id === 'fm_bar_down') {
try {
fmConn.readFile64(o.path + selFile, function (err, data) {
console.log(data);
$('body').append('');
document.getElementById('fm_download').click();
document.getElementById('fm_download').remove();
});
} catch (err) {
alert(err);
}
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
if (id === 'fm_bar_rename') {
try {
$('#dialog_fm').append(
'
' +
' ' +
'' +
'
' +
'
');
$('#dialog_fm_rename').dialog({
dialogClass: "dialog_fm_rename",
resizable: false,
draggable: false,
modal: true,
close: function () {
$('#dialog_fm_rename').remove();
}
});
$('#fm_btn_rename').button().click(function () {
var new_name = $('#fm_inp_rename').val();
$('#dialog_fm_rename').remove();
if (new_name !== "" || new_name !== undefined) {
fmConn.renameFile(o.path + selFile, o.path + new_name, function (err) {
if (err) {
console.log(err);
alert(fmTranslate('Cannot rename'));
} else {
load(o.path);
}
});
}
});
} catch (err) {
alert(err);
}
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
if (id === 'fm_bar_del') {
try {
fmConn.unlink(o.path + selFile, function (err) {
if (err) {
console.log(err);
alert(fmTranslate('Delete failed'));
}
load(o.path);
});
} catch (err) {
alert('ordner \n' + err);
}
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
if (id === 'fm_bar_list') {
o.view = 'table';
build(o);
}
if (id == "fm_bar_prev") {
o.view = "prev";
build(o);
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
if (id === 'fm_bar_play') {
if (document.getElementById('fm_sound_play')) {
document.getElementById('fm_sound_play').remove();
}
$('#dialog_fm').append('');
document.getElementById('fm_sound_play').play();
}
if (id == 'fm_bar_stop') {
document.getElementById('fm_sound_play').remove();
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
$(this).effect('highlight');
});
$('#fm_btn_cancel').button().click(function () {
config.path = o.path;
config.view = o.view;
config.all = $('#fm_bar_all').hasClass('ui-state-error');
config.background = $('#fm_bar_background').hasClass('ui-state-error') ? 'fm-dark-background' : ($('#fm_bar_background').hasClass('ui-state-highlight') ? 'fm-light-background' : '');
if (typeof storage != 'undefined') storage.set('visFM', JSON.stringify(config));
$('#dialog_fm').remove();
});
$('#fm_btn_open').button().click(function () {
$('#dialog_fm').remove();
config.path = o.path;
config.view = o.view;
config.all = $('#fm_bar_all').hasClass('ui-state-error');
config.background = $('#fm_bar_background').hasClass('ui-state-error') ? 'fm-dark-background' : ($('#fm_bar_background').hasClass('ui-state-highlight') ? 'fm-light-background' : '');
if (typeof storage != 'undefined') {
storage.set('visFM', JSON.stringify(config));
}
return callback({
path: o.path,
file: selFile
}, o.userArg);
});
$('#fm_btn_save').button().click(function () {
var file = $('#fm_inp_save').val();
$('#dialog_fm').remove();
config.path = o.path;
config.view = o.view;
config.all = $('#fm_bar_all').hasClass('ui-state-error');
config.background = $('#fm_bar_background').hasClass('ui-state-error') ? 'fm-dark-background' : ($('#fm_bar_background').hasClass('ui-state-highlight') ? 'fm-light-background' : '');
if (typeof storage != 'undefined') {
storage.set('visFM', JSON.stringify(config));
}
return callback({
path: o.path,
file: file
}, o.userArg);
});
};
})
(jQuery);
jQuery.fn.sortElements = (function () {
var sort = [].sort;
return function (comparator, getSortable) {
getSortable = getSortable || function () {
return this;
};
var placements = this.map(function () {
var sortElement = getSortable.call(this),
parentNode = sortElement.parentNode,
// Since the element itself will change position, we have
// to have some way of storing it's original position in
// the DOM. The easiest way is to have a 'flag' node:
nextSibling = parentNode.insertBefore(
document.createTextNode(''),
sortElement.nextSibling
);
return function () {
if (parentNode === this) {
throw new Error(
"You can't sort elements if any one is a descendant of another."
);
}
// Insert before flag:
parentNode.insertBefore(this, nextSibling);
// Remove flag:
parentNode.removeChild(nextSibling);
};
});
return sort.call(this, comparator).each(function (i) {
placements[i].call(getSortable.call(this));
});
};
})();
//--------------- https://github.com/waslos/jquery-clearsearch/blob/master/src/jquery.clearsearch.js ----------------------
/* ============================================================================
* jquery.clearsearch.js v1.0.3
* https://github.com/waslos/jquery-clearsearch
* ============================================================================
* Copyright (c) 2012, Was los.de GmbH & Co. KG
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the "Was los.de GmbH & Co. KG" nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* ========================================================================= */
(function($) {
$.fn.clearSearch = function(options) {
if (options == 'update') {
return this.each(function() {
var $this = $(this);
var width = $this.outerWidth(), height = $this
.outerHeight();
var btn = $this.next();
btn.css({
top : height / 2 - btn.height() / 2,
left : width - height / 2 - btn.height() / 2
});
});
}
var settings = $.extend({
'clearClass' : 'clear_input',
'focusAfterClear' : true,
'linkText' : '×'
}, options);
return this.each(function() {
var $this = $(this), btn,
divClass = settings.clearClass + '_div';
if (!$this.parent().hasClass(divClass)) {
$this.wrap('
' + $this.html() + '
');
$this.after('' + settings.linkText + '');
}
btn = $this.next();
function clearField() {
$this.val('').change();
triggerBtn();
if (settings.focusAfterClear) {
$this.focus();
}
if (typeof (settings.callback) === "function") {
settings.callback();
}
}
function triggerBtn() {
if (hasText()) {
btn.show();
} else {
btn.hide();
}
update();
}
function hasText() {
return $this.val().replace(/^\s+|\s+$/g, '').length > 0;
}
function update() {
var width = $this.outerWidth(), height = $this
.outerHeight();
btn.css({
top : height / 2 - btn.height() / 2,
left : width - height / 2 - btn.height() / 2
});
}
btn.on('click', clearField);
$this.on('keyup keydown change focus', triggerBtn);
triggerBtn();
});
};
})(jQuery);