mirror of
https://github.com/myvesta/vesta
synced 2025-07-14 09:03:23 -07:00
Multiple FTP Account Support
This commit is contained in:
parent
0797ddfddb
commit
393d97fdfc
3 changed files with 262 additions and 32 deletions
|
@ -1,37 +1,158 @@
|
||||||
//
|
|
||||||
//
|
|
||||||
// Updates ftp username dynamically, showing its prefix
|
|
||||||
App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
|
App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
|
||||||
if (hint.trim() == '') {
|
if (hint.trim() == '') {
|
||||||
$(elm).parent().find('.hint').html('');
|
$(elm).parent().find('.hint').html('');
|
||||||
}
|
}
|
||||||
// remove prefix from value in order to eliminate duplicates
|
|
||||||
|
hint = hint.replace(/[^\w\d]/gi, '');
|
||||||
|
|
||||||
if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) {
|
if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) {
|
||||||
hint = hint.slice(GLOBAL.FTP_USER_PREFIX.length, hint.length);
|
hint = hint.slice(GLOBAL.FTP_USER_PREFIX.length, hint.length);
|
||||||
}
|
}
|
||||||
|
$(elm).parent().find('.v-ftp-user').val(hint);
|
||||||
$(elm).parent().find('.hint').text(GLOBAL.FTP_USER_PREFIX + hint);
|
$(elm).parent().find('.hint').text(GLOBAL.FTP_USER_PREFIX + hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// listener that triggers ftp user hint updating
|
|
||||||
App.Listeners.WEB.keypress_ftp_username = function() {
|
App.Listeners.WEB.keypress_ftp_username = function() {
|
||||||
var ref = $('input[name="v_ftp_user"]');
|
var ftp_user_inputs = $('.v-ftp-user');
|
||||||
var current_val = ref.val();
|
$.each(ftp_user_inputs, function(i, ref) {
|
||||||
if (current_val.trim() != '') {
|
var ref = $(ref);
|
||||||
App.Actions.DB.update_ftp_username_hint(ref, current_val);
|
var current_val = ref.val();
|
||||||
}
|
if (current_val.trim() != '') {
|
||||||
|
App.Actions.WEB.update_ftp_username_hint(ref, current_val);
|
||||||
ref.bind('keypress input', function(evt) {
|
}
|
||||||
|
|
||||||
|
ref.bind('keypress', function(evt) {
|
||||||
|
clearTimeout(window.frp_usr_tmt);
|
||||||
|
window.frp_usr_tmt = setTimeout(function() {
|
||||||
|
var elm = $(evt.target);
|
||||||
|
App.Actions.WEB.update_ftp_username_hint(elm, $(elm).val());
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
App.Listeners.WEB.keypress_domain_name = function() {
|
||||||
|
$('#v_domain').bind('keypress', function(evt) {
|
||||||
clearTimeout(window.frp_usr_tmt);
|
clearTimeout(window.frp_usr_tmt);
|
||||||
window.frp_usr_tmt = setTimeout(function() {
|
window.frp_usr_tmt = setTimeout(function() {
|
||||||
var elm = $(evt.target);
|
//var elm = $(evt.target);
|
||||||
App.Actions.WEB.update_ftp_username_hint(elm, $(elm).val());
|
//App.Actions.WEB.update_ftp_username_hint(elm, $(elm).val());
|
||||||
|
var domain = $('.ftp-path-prefix').text(GLOBAL.FTP_USER_PREPATH + '/' + $('#v_domain').val());
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
App.Actions.WEB.update_ftp_path_hint = function(elm, hint) {
|
||||||
|
if (hint.trim() == '') {
|
||||||
|
$(elm).parent().find('.v-ftp-path-hint').html('');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hint[0] != '/') {
|
||||||
|
hint = '/' + hint;
|
||||||
|
}
|
||||||
|
hint = hint.replace(/\/(\/+)/g, '/');
|
||||||
|
|
||||||
|
$(elm).parent().find('.v-ftp-path-hint').text(hint);
|
||||||
|
}
|
||||||
|
|
||||||
|
App.Listeners.WEB.keypress_ftp_path = function() {
|
||||||
|
var ftp_path_inputs = $('.v-ftp-path');
|
||||||
|
$.each(ftp_path_inputs, function(i, ref) {
|
||||||
|
var ref = $(ref);
|
||||||
|
var current_val = ref.val();
|
||||||
|
if (current_val.trim() != '') {
|
||||||
|
App.Actions.WEB.update_ftp_path_hint(ref, current_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
ref.bind('keypress', function(evt) {
|
||||||
|
clearTimeout(window.frp_usr_tmt);
|
||||||
|
window.frp_usr_tmt = setTimeout(function() {
|
||||||
|
var elm = $(evt.target);
|
||||||
|
App.Actions.WEB.update_ftp_path_hint(elm, $(elm).val());
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
App.Actions.WEB.add_ftp_user_form = function() {
|
||||||
|
var ref = $('#templates').find('.ftptable').clone(true);
|
||||||
|
var index = $('.data-col2 .ftptable').length + 1;
|
||||||
|
|
||||||
|
ref.find('input').each(function(i, elm) {
|
||||||
|
var attr_value = $(elm).attr('name').replace('%INDEX%', index);
|
||||||
|
$(elm).attr('name', attr_value);
|
||||||
|
});
|
||||||
|
|
||||||
|
ref.find('.ftp-user-number').text(index);
|
||||||
|
|
||||||
|
$('.data-col2 .ftptable:last').after(ref);
|
||||||
|
|
||||||
|
var index = 1;
|
||||||
|
$('.data-col2 .ftp-user-number:visible').each(function(i, o) {
|
||||||
|
$(o).text(index);
|
||||||
|
index += 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
App.Actions.WEB.remove_ftp_user = function(elm) {
|
||||||
|
var ref = $(elm).parents('.ftptable');
|
||||||
|
ref.remove();
|
||||||
|
|
||||||
|
var index = 1;
|
||||||
|
$('.data-col2 .ftp-user-number:visible').each(function(i, o) {
|
||||||
|
$(o).text(index);
|
||||||
|
index += 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($('.ftptable-nrm:visible').length == 0) {
|
||||||
|
$('.v-add-new-user').hide();
|
||||||
|
$('input[name="v_ftp"]').attr('checked', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
App.Actions.WEB.toggle_additional_ftp_accounts = function(elm) {
|
||||||
|
if ($(elm).attr('checked')) {
|
||||||
|
$('.ftptable-nrm, .v-add-new-user, .add-new-ftp-user-button').show();
|
||||||
|
$('.ftptable-nrm').each(function(i, elm) {
|
||||||
|
var login = $(elm).find('.v-ftp-user');
|
||||||
|
if (login.val().trim() != '') {
|
||||||
|
$(elm).find('.v-ftp-user-deleted').val(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('.ftptable-nrm, .v-add-new-user, .add-new-ftp-user-button').hide();
|
||||||
|
$('.ftptable-nrm').each(function(i, elm) {
|
||||||
|
var login = $(elm).find('.v-ftp-user');
|
||||||
|
if (login.val().trim() != '') {
|
||||||
|
$(elm).find('.v-ftp-user-deleted').val(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($('.ftptable-nrm:visible').length == 0) {
|
||||||
|
var ref = $('#templates').find('.ftptable').clone(true);
|
||||||
|
var index = $('.data-col2 .ftptable').length + 1;
|
||||||
|
|
||||||
|
ref.find('input').each(function(i, elm) {
|
||||||
|
var attr_value = $(elm).attr('name').replace('%INDEX%', index);
|
||||||
|
$(elm).attr('name', attr_value);
|
||||||
|
});
|
||||||
|
|
||||||
|
ref.find('.ftp-user-number').text(index);
|
||||||
|
|
||||||
|
$('.v-add-new-user').parent('tr').prev().find('td').html(ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Page entry point
|
// Page entry point
|
||||||
// Trigger listeners
|
|
||||||
App.Listeners.WEB.keypress_ftp_username();
|
App.Listeners.WEB.keypress_ftp_username();
|
||||||
|
App.Listeners.WEB.keypress_ftp_path();
|
||||||
|
App.Listeners.WEB.keypress_domain_name();
|
||||||
|
|
|
@ -1,29 +1,138 @@
|
||||||
App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
|
App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
|
||||||
if (hint.trim() == '') {
|
if (hint.trim() == '') {
|
||||||
$(elm).parent().find('.hint').html('');
|
$(elm).parent().find('.hint').html('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hint = hint.replace(/[^\w\d]/gi, '');
|
||||||
|
|
||||||
if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) {
|
if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) {
|
||||||
hint = hint.slice(GLOBAL.FTP_USER_PREFIX.length, hint.length);
|
hint = hint.slice(GLOBAL.FTP_USER_PREFIX.length, hint.length);
|
||||||
}
|
}
|
||||||
|
$(elm).parent().find('.v-ftp-user').val(hint);
|
||||||
$(elm).parent().find('.hint').text(GLOBAL.FTP_USER_PREFIX + hint);
|
$(elm).parent().find('.hint').text(GLOBAL.FTP_USER_PREFIX + hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
App.Listeners.WEB.keypress_ftp_username = function() {
|
App.Listeners.WEB.keypress_ftp_username = function() {
|
||||||
var ref = $('input[name="v_ftp_user"]');
|
var ftp_user_inputs = $('.v-ftp-user');
|
||||||
var current_val = ref.val();
|
$.each(ftp_user_inputs, function(i, ref) {
|
||||||
if (current_val.trim() != '') {
|
var ref = $(ref);
|
||||||
App.Actions.DB.update_ftp_username_hint(ref, current_val);
|
var current_val = ref.val();
|
||||||
|
if (current_val.trim() != '') {
|
||||||
|
App.Actions.WEB.update_ftp_username_hint(ref, current_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
ref.bind('keypress', function(evt) {
|
||||||
|
clearTimeout(window.frp_usr_tmt);
|
||||||
|
window.frp_usr_tmt = setTimeout(function() {
|
||||||
|
var elm = $(evt.target);
|
||||||
|
App.Actions.WEB.update_ftp_username_hint(elm, $(elm).val());
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
App.Actions.WEB.update_ftp_path_hint = function(elm, hint) {
|
||||||
|
if (hint.trim() == '') {
|
||||||
|
$(elm).parent().find('.v-ftp-path-hint').html('');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hint[0] != '/') {
|
||||||
|
hint = '/' + hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
ref.bind('keypress', function(evt) {
|
hint = hint.replace(/\/(\/+)/g, '/');
|
||||||
clearTimeout(window.frp_usr_tmt);
|
|
||||||
window.frp_usr_tmt = setTimeout(function() {
|
$(elm).parent().find('.v-ftp-path-hint').text(hint);
|
||||||
var elm = $(evt.target);
|
}
|
||||||
App.Actions.WEB.update_ftp_username_hint(elm, $(elm).val());
|
|
||||||
}, 100);
|
App.Listeners.WEB.keypress_ftp_path = function() {
|
||||||
|
var ftp_path_inputs = $('.v-ftp-path');
|
||||||
|
$.each(ftp_path_inputs, function(i, ref) {
|
||||||
|
var ref = $(ref);
|
||||||
|
var current_val = ref.val();
|
||||||
|
if (current_val.trim() != '') {
|
||||||
|
App.Actions.WEB.update_ftp_path_hint(ref, current_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
ref.bind('keypress', function(evt) {
|
||||||
|
clearTimeout(window.frp_usr_tmt);
|
||||||
|
window.frp_usr_tmt = setTimeout(function() {
|
||||||
|
var elm = $(evt.target);
|
||||||
|
App.Actions.WEB.update_ftp_path_hint(elm, $(elm).val());
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
App.Actions.WEB.add_ftp_user_form = function() {
|
||||||
|
var ref = $('#templates').find('.ftptable').clone(true);
|
||||||
|
var index = $('.data-col2 .ftptable').length + 1;
|
||||||
|
|
||||||
|
ref.find('input').each(function(i, elm) {
|
||||||
|
var attr_value = $(elm).attr('name').replace('%INDEX%', index);
|
||||||
|
$(elm).attr('name', attr_value);
|
||||||
|
});
|
||||||
|
|
||||||
|
ref.find('.ftp-user-number').text(index);
|
||||||
|
|
||||||
|
$('.data-col2 .ftptable:last').after(ref);
|
||||||
|
|
||||||
|
var index = 1;
|
||||||
|
$('.data-col2 .ftp-user-number:visible').each(function(i, o) {
|
||||||
|
$(o).text(index);
|
||||||
|
index += 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
App.Actions.WEB.remove_ftp_user = function(elm) {
|
||||||
|
var ref = $(elm).parents('.ftptable');
|
||||||
|
ref.find('.v-ftp-user-deleted').val('1');
|
||||||
|
if (ref.find('.v-ftp-user-is-new').val() == 1) {
|
||||||
|
ref.remove();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ref.removeClass('ftptable-nrm');
|
||||||
|
ref.hide();
|
||||||
|
|
||||||
|
var index = 1;
|
||||||
|
$('.data-col2 .ftp-user-number:visible').each(function(i, o) {
|
||||||
|
$(o).text(index);
|
||||||
|
index += 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($('.ftptable-nrm:visible').length == 0) {
|
||||||
|
$('.add-new-ftp-user-button').hide();
|
||||||
|
$('input[name="v_ftp"]').attr('checked', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
App.Actions.WEB.toggle_additional_ftp_accounts = function(elm) {
|
||||||
|
if ($(elm).attr('checked')) {
|
||||||
|
$('.ftptable-nrm, .v-add-new-user, .add-new-ftp-user-button').show();
|
||||||
|
$('.ftptable-nrm').each(function(i, elm) {
|
||||||
|
var login = $(elm).find('.v-ftp-user');
|
||||||
|
if (login.val().trim() != '') {
|
||||||
|
$(elm).find('.v-ftp-user-deleted').val(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('.ftptable-nrm, .v-add-new-user, .add-new-ftp-user-button').hide();
|
||||||
|
$('.ftptable-nrm').each(function(i, elm) {
|
||||||
|
var login = $(elm).find('.v-ftp-user');
|
||||||
|
if (login.val().trim() != '') {
|
||||||
|
$(elm).find('.v-ftp-user-deleted').val(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Page entry point
|
// Page entry point
|
||||||
App.Listeners.WEB.keypress_ftp_username();
|
App.Listeners.WEB.keypress_ftp_username();
|
||||||
|
App.Listeners.WEB.keypress_ftp_path();
|
||||||
|
|
|
@ -66,7 +66,7 @@ var Templator = function()
|
||||||
{
|
{
|
||||||
'undefined' == typeof App.Templates._indexes[key] ? App.Templates._indexes[key] = {} : false;
|
'undefined' == typeof App.Templates._indexes[key] ? App.Templates._indexes[key] = {} : false;
|
||||||
'undefined' == typeof App.Templates._indexes[key][ref_key] ?
|
'undefined' == typeof App.Templates._indexes[key][ref_key] ?
|
||||||
App.Templates._indexes[key][ref_key] = {} : false;
|
App.Templates._indexes[key][ref_key] = {} : false;
|
||||||
|
|
||||||
jQuery(tpl).each(function(index, o) {
|
jQuery(tpl).each(function(index, o) {
|
||||||
if (':' == o.charAt(0)) {
|
if (':' == o.charAt(0)) {
|
||||||
|
@ -84,8 +84,8 @@ var Templator = function()
|
||||||
|
|
||||||
Templator.getTemplate = function(ns, key){
|
Templator.getTemplate = function(ns, key){
|
||||||
return [
|
return [
|
||||||
App.Templates._indexes[ns][key],
|
App.Templates._indexes[ns][key],
|
||||||
App.Templates.html[ns][key].slice(0)
|
App.Templates.html[ns][key].slice(0)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
// init templator
|
// init templator
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue