Added hints for db usernames, similar to ftp usernames

This commit is contained in:
dmitry.malishev 2013-07-17 14:54:33 +03:00
commit 9aca19d773
5 changed files with 62 additions and 0 deletions

View file

@ -44,6 +44,7 @@ var Error = {FATAL: 1, WARNING: 0, NORMAL: -1};
// //
GLOBAL = {}; GLOBAL = {};
GLOBAL.FTP_USER_PREFIX = 'admin_'; GLOBAL.FTP_USER_PREFIX = 'admin_';
GLOBAL.DB_USER_PREFIX = 'admin_';
GLOBAL.AJAX_URL = ''; GLOBAL.AJAX_URL = '';
/** /**
@ -77,6 +78,7 @@ var App = {
Core: {}, Core: {},
// Actions. More widly used funcs // Actions. More widly used funcs
Actions: { Actions: {
DB: {},
WEB: {} WEB: {}
}, },
// Utilities // Utilities
@ -88,6 +90,7 @@ var App = {
}, },
i18n: {}, i18n: {},
Listeners: { Listeners: {
DB: {},
WEB: {} WEB: {}
}, },
View:{ View:{

23
web/js/pages/add.db.js Normal file
View file

@ -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();

23
web/js/pages/edit.db.js Normal file
View file

@ -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();

View file

@ -81,6 +81,7 @@
<tr> <tr>
<td> <td>
<input type="text" size="20" class="vst-input" name="v_dbuser" <?php if (!empty($v_dbuser)) echo "value=".$v_dbuser; ?>> <input type="text" size="20" class="vst-input" name="v_dbuser" <?php if (!empty($v_dbuser)) echo "value=".$v_dbuser; ?>>
<small class="hint"></small>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -182,3 +183,9 @@
</tr> </tr>
</table> </table>
</form> </form>
<script type="text/javascript">
GLOBAL.DB_USER_PREFIX = '<?php echo $user; ?>_';
</script>
<script type="text/javascript" src="/js/pages/add.db.js"></script>

View file

@ -83,6 +83,7 @@
<tr> <tr>
<td> <td>
<input type="text" size="20" class="vst-input" name="v_dbuser" <?php if (!empty($v_dbuser)) echo "value=".$v_dbuser; ?> disabled> <input type="text" size="20" class="vst-input" name="v_dbuser" <?php if (!empty($v_dbuser)) echo "value=".$v_dbuser; ?> disabled>
<small class="hint"></small>
</td> </td>
</tr> </tr>
<tr> <tr>
@ -140,3 +141,8 @@
</tr> </tr>
</table> </table>
</form> </form>
<script type="text/javascript">
GLOBAL.DB_USER_PREFIX = '<?php echo $user; ?>_';
</script>
<script type="text/javascript" src="/js/pages/add.db.js"></script>