Skip to content

Commit 9aca19d

Browse files
committed
Added hints for db usernames, similar to ftp usernames
1 parent afffd18 commit 9aca19d

File tree

5 files changed

+62
-0
lines changed

5 files changed

+62
-0
lines changed

web/js/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ var Error = {FATAL: 1, WARNING: 0, NORMAL: -1};
4444
//
4545
GLOBAL = {};
4646
GLOBAL.FTP_USER_PREFIX = 'admin_';
47+
GLOBAL.DB_USER_PREFIX = 'admin_';
4748
GLOBAL.AJAX_URL = '';
4849

4950
/**
@@ -77,6 +78,7 @@ var App = {
7778
Core: {},
7879
// Actions. More widly used funcs
7980
Actions: {
81+
DB: {},
8082
WEB: {}
8183
},
8284
// Utilities
@@ -88,6 +90,7 @@ var App = {
8890
},
8991
i18n: {},
9092
Listeners: {
93+
DB: {},
9194
WEB: {}
9295
},
9396
View:{

web/js/pages/add.db.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
App.Actions.DB.update_db_username_hint = function(elm, hint) {
2+
if (hint.trim() == '') {
3+
$(elm).parent().find('.hint').html('');
4+
}
5+
if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) {
6+
hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length);
7+
}
8+
$(elm).parent().find('.hint').html(GLOBAL.DB_USER_PREFIX + hint);
9+
}
10+
11+
App.Listeners.DB.keypress_db_username = function() {
12+
$('input[name="v_dbuser"]').bind('keypress', function(evt) {
13+
clearTimeout(window.frp_usr_tmt);
14+
window.frp_usr_tmt = setTimeout(function() {
15+
var elm = $(evt.target);
16+
App.Actions.DB.update_db_username_hint(elm, $(elm).val());
17+
}, 100);
18+
});
19+
}
20+
21+
//
22+
// Page entry point
23+
App.Listeners.DB.keypress_db_username();

web/js/pages/edit.db.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
App.Actions.DB.update_db_username_hint = function(elm, hint) {
2+
if (hint.trim() == '') {
3+
$(elm).parent().find('.hint').html('');
4+
}
5+
if (hint.indexOf(GLOBAL.DB_USER_PREFIX) == 0) {
6+
hint = hint.slice(GLOBAL.DB_USER_PREFIX.length, hint.length);
7+
}
8+
$(elm).parent().find('.hint').html(GLOBAL.DB_USER_PREFIX + hint);
9+
}
10+
11+
App.Listeners.DB.keypress_db_username = function() {
12+
$('input[name="v_dbuser"]').bind('keypress', function(evt) {
13+
clearTimeout(window.frp_usr_tmt);
14+
window.frp_usr_tmt = setTimeout(function() {
15+
var elm = $(evt.target);
16+
App.Actions.DB.update_db_username_hint(elm, $(elm).val());
17+
}, 100);
18+
});
19+
}
20+
21+
//
22+
// Page entry point
23+
App.Listeners.DB.keypress_db_username();

web/templates/admin/add_db.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
<tr>
8282
<td>
8383
<input type="text" size="20" class="vst-input" name="v_dbuser" <?php if (!empty($v_dbuser)) echo "value=".$v_dbuser; ?>>
84+
<small class="hint"></small>
8485
</td>
8586
</tr>
8687
<tr>
@@ -182,3 +183,9 @@
182183
</tr>
183184
</table>
184185
</form>
186+
187+
188+
<script type="text/javascript">
189+
GLOBAL.DB_USER_PREFIX = '<?php echo $user; ?>_';
190+
</script>
191+
<script type="text/javascript" src="/js/pages/add.db.js"></script>

web/templates/admin/edit_db.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<tr>
8484
<td>
8585
<input type="text" size="20" class="vst-input" name="v_dbuser" <?php if (!empty($v_dbuser)) echo "value=".$v_dbuser; ?> disabled>
86+
<small class="hint"></small>
8687
</td>
8788
</tr>
8889
<tr>
@@ -140,3 +141,8 @@
140141
</tr>
141142
</table>
142143
</form>
144+
145+
<script type="text/javascript">
146+
GLOBAL.DB_USER_PREFIX = '<?php echo $user; ?>_';
147+
</script>
148+
<script type="text/javascript" src="/js/pages/add.db.js"></script>

0 commit comments

Comments
 (0)