vesta/web/js/pages/add.web.js
very-twi@github.com c50c7b2675 Updated hints to handle native browser's paste events
Hint is update in case page is reloaded and value is set (in case of form errors)
Hints are now using secure inserting into DOM avoiding xss
Dns record hint added
2014-02-12 12:08:23 +02:00

38 lines
1.1 KiB
JavaScript

//
//
// Updates ftp username dynamically, showing its prefix
App.Actions.WEB.update_ftp_username_hint = function(elm, hint) {
if (hint.trim() == '') {
$(elm).parent().find('.hint').html('');
}
// remove prefix from value in order to eliminate duplicates
if (hint.indexOf(GLOBAL.FTP_USER_PREFIX) == 0) {
hint = hint.slice(GLOBAL.FTP_USER_PREFIX.length, hint.length);
}
$(elm).parent().find('.hint').text(GLOBAL.FTP_USER_PREFIX + hint);
}
//
// listener that triggers ftp user hint updating
App.Listeners.WEB.keypress_ftp_username = function() {
var ref = $('input[name="v_ftp_user"]');
var current_val = ref.val();
if (current_val.trim() != '') {
App.Actions.DB.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);
});
}
//
// Page entry point
// Trigger listeners
App.Listeners.WEB.keypress_ftp_username();