| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
- if (hint.trim() == '') {
- $(elm).parent().find('.hint').html('');
- }
- hint = hint.replace(/[^\w\d]/gi, '');
- if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) {
- 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);
- }
- App.Listeners.WEB.keypress_ftp_username = function() {
- var ftp_user_inputs = $('.v-ftp-user');
- $.each(ftp_user_inputs, function(i, ref) {
- var ref = $(ref);
- 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) {
- 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 input', 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());
- var domain = $('.ftp-path-prefix').text(GLOBAL.FTP_USER_PREPATH + '/' + $('#v_domain').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;
- }
- 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 input', 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
- App.Listeners.WEB.keypress_ftp_username();
- App.Listeners.WEB.keypress_ftp_path();
- App.Listeners.WEB.keypress_domain_name();
|