diff --git a/web/js/app.js b/web/js/app.js index 86d86276..0cb06f36 100644 --- a/web/js/app.js +++ b/web/js/app.js @@ -44,6 +44,7 @@ var Error = {FATAL: 1, WARNING: 0, NORMAL: -1}; // GLOBAL = {}; GLOBAL.FTP_USER_PREFIX = 'admin_'; +GLOBAL.DB_USER_PREFIX = 'admin_'; GLOBAL.AJAX_URL = ''; /** @@ -77,6 +78,7 @@ var App = { Core: {}, // Actions. More widly used funcs Actions: { + DB: {}, WEB: {} }, // Utilities @@ -88,6 +90,7 @@ var App = { }, i18n: {}, Listeners: { + DB: {}, WEB: {} }, View:{ diff --git a/web/js/pages/add.db.js b/web/js/pages/add.db.js new file mode 100644 index 00000000..c9c4c2fd --- /dev/null +++ b/web/js/pages/add.db.js @@ -0,0 +1,23 @@ +App.Actions.DB.update_db_username_hint = function(elm, hint) { + if (hint.trim() == '') { + $(elm).parent().find('.hint').html(''); + } + if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) { + hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length); + } + $(elm).parent().find('.hint').html(GLOBAL.DB_USER_PREFIX + hint); +} + +App.Listeners.DB.keypress_db_username = function() { + $('input[name="v_dbuser"]').bind('keypress', function(evt) { + clearTimeout(window.frp_usr_tmt); + window.frp_usr_tmt = setTimeout(function() { + var elm = $(evt.target); + App.Actions.DB.update_db_username_hint(elm, $(elm).val()); + }, 100); + }); +} + +// +// Page entry point +App.Listeners.DB.keypress_db_username(); diff --git a/web/js/pages/edit.db.js b/web/js/pages/edit.db.js new file mode 100644 index 00000000..c9c4c2fd --- /dev/null +++ b/web/js/pages/edit.db.js @@ -0,0 +1,23 @@ +App.Actions.DB.update_db_username_hint = function(elm, hint) { + if (hint.trim() == '') { + $(elm).parent().find('.hint').html(''); + } + if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) { + hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length); + } + $(elm).parent().find('.hint').html(GLOBAL.DB_USER_PREFIX + hint); +} + +App.Listeners.DB.keypress_db_username = function() { + $('input[name="v_dbuser"]').bind('keypress', function(evt) { + clearTimeout(window.frp_usr_tmt); + window.frp_usr_tmt = setTimeout(function() { + var elm = $(evt.target); + App.Actions.DB.update_db_username_hint(elm, $(elm).val()); + }, 100); + }); +} + +// +// Page entry point +App.Listeners.DB.keypress_db_username(); diff --git a/web/templates/admin/add_db.html b/web/templates/admin/add_db.html index 9e9a49b7..4dfbb545 100644 --- a/web/templates/admin/add_db.html +++ b/web/templates/admin/add_db.html @@ -81,6 +81,7 @@ @@ -182,3 +183,9 @@ + + + + diff --git a/web/templates/admin/edit_db.html b/web/templates/admin/edit_db.html index 7e5e70cb..d5cafde6 100644 --- a/web/templates/admin/edit_db.html +++ b/web/templates/admin/edit_db.html @@ -83,6 +83,7 @@ @@ -140,3 +141,8 @@ + + +