Skip to content

Commit c04b47d

Browse files
committed
Added hint for database name. Similar to ftp and db username feature.
GLOBAL.DB_DBNAME_PREFIX contains user prefix, by default it is set to 'admin_' and replaced by current value inside template
1 parent 4d0591c commit c04b47d

File tree

5 files changed

+50
-3
lines changed

5 files changed

+50
-3
lines changed

web/js/app.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ var Error = {FATAL: 1, WARNING: 0, NORMAL: -1};
4343
// GLOBAL SETTINGS
4444
//
4545
GLOBAL = {};
46-
GLOBAL.FTP_USER_PREFIX = 'admin_';
47-
GLOBAL.DB_USER_PREFIX = 'admin_';
46+
GLOBAL.FTP_USER_PREFIX = 'admin_';
47+
GLOBAL.DB_USER_PREFIX = 'admin_';
48+
GLOBAL.DB_DBNAME_PREFIX = 'admin_';
4849
GLOBAL.AJAX_URL = '';
4950

5051
/**

web/js/pages/add.db.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ App.Actions.DB.update_db_username_hint = function(elm, hint) {
88
$(elm).parent().find('.hint').html(GLOBAL.DB_USER_PREFIX + hint);
99
}
1010

11+
App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
12+
if (hint.trim() == '') {
13+
$(elm).parent().find('.hint').html('');
14+
}
15+
if (hint.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
16+
hint = hint.slice(GLOBAL.DB_DBNAME_PREFIX.length, hint.length);
17+
}
18+
$(elm).parent().find('.hint').html(GLOBAL.DB_DBNAME_PREFIX + hint);
19+
}
20+
1121
App.Listeners.DB.keypress_db_username = function() {
1222
$('input[name="v_dbuser"]').bind('keypress', function(evt) {
1323
clearTimeout(window.frp_usr_tmt);
@@ -18,6 +28,17 @@ App.Listeners.DB.keypress_db_username = function() {
1828
});
1929
}
2030

31+
App.Listeners.DB.keypress_db_databasename = function() {
32+
$('input[name="v_database"]').bind('keypress', function(evt) {
33+
clearTimeout(window.frp_dbn_tmt);
34+
window.frp_dbn_tmt = setTimeout(function() {
35+
var elm = $(evt.target);
36+
App.Actions.DB.update_db_databasename_hint(elm, $(elm).val());
37+
}, 100);
38+
});
39+
}
40+
2141
//
2242
// Page entry point
2343
App.Listeners.DB.keypress_db_username();
44+
App.Listeners.DB.keypress_db_databasename();

web/js/pages/edit.db.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ App.Actions.DB.update_db_username_hint = function(elm, hint) {
88
$(elm).parent().find('.hint').html(GLOBAL.DB_USER_PREFIX + hint);
99
}
1010

11+
App.Actions.DB.update_db_databasename_hint = function(elm, hint) {
12+
if (hint.trim() == '') {
13+
$(elm).parent().find('.hint').html('');
14+
}
15+
if (hint.indexOf(GLOBAL.DB_DBNAME_PREFIX) == 0) {
16+
hint = hint.slice(GLOBAL.DB_DBNAME_PREFIX.length, hint.length);
17+
}
18+
$(elm).parent().find('.hint').html(GLOBAL.DB_DBNAME_PREFIX + hint);
19+
}
20+
1121
App.Listeners.DB.keypress_db_username = function() {
1222
$('input[name="v_dbuser"]').bind('keypress', function(evt) {
1323
clearTimeout(window.frp_usr_tmt);
@@ -18,6 +28,17 @@ App.Listeners.DB.keypress_db_username = function() {
1828
});
1929
}
2030

31+
App.Listeners.DB.keypress_db_databasename = function() {
32+
$('input[name="v_database"]').bind('keypress', function(evt) {
33+
clearTimeout(window.frp_dbn_tmt);
34+
window.frp_dbn_tmt = setTimeout(function() {
35+
var elm = $(evt.target);
36+
App.Actions.DB.update_db_databasename_hint(elm, $(elm).val());
37+
}, 100);
38+
});
39+
}
40+
2141
//
2242
// Page entry point
2343
App.Listeners.DB.keypress_db_username();
44+
App.Listeners.DB.keypress_db_databasename();

web/templates/admin/add_db.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<tr>
7272
<td>
7373
<input type="text" size="20" class="vst-input" name="v_database" <?php if (!empty($v_database)) echo "value=".$v_database; ?>>
74+
<small class="hint"></small>
7475
</td>
7576
</tr>
7677
<tr>
@@ -187,5 +188,6 @@
187188

188189
<script type="text/javascript">
189190
GLOBAL.DB_USER_PREFIX = '<?php echo $user; ?>_';
191+
GLOBAL.DB_DBNAME_PREFIX = '<?php echo $user; ?>_';
190192
</script>
191193
<script type="text/javascript" src="/js/pages/add.db.js"></script>

web/templates/admin/edit_db.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
<tr>
7474
<td>
7575
<input type="text" size="20" class="vst-input" name="v_database" <?php if (!empty($v_database)) echo "value=".$v_database; ?> disabled>
76+
<small class="hint"></small>
7677
</td>
7778
</tr>
7879
<tr>
@@ -144,5 +145,6 @@
144145

145146
<script type="text/javascript">
146147
GLOBAL.DB_USER_PREFIX = '<?php echo $user; ?>_';
148+
GLOBAL.DB_DBNAME_PREFIX = '<?php echo $user; ?>_';
147149
</script>
148-
<script type="text/javascript" src="/js/pages/add.db.js"></script>
150+
<script type="text/javascript" src="/js/pages/edit.db.js"></script>

0 commit comments

Comments
 (0)