Parcourir la source

Added hints for db usernames, similar to ftp usernames

dmitry.malishev il y a 12 ans
Parent
commit
9aca19d773

+ 3 - 0
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:{

+ 23 - 0
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();

+ 23 - 0
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();

+ 7 - 0
web/templates/admin/add_db.html

@@ -81,6 +81,7 @@
                             <tr>
                                 <td>
                                     <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>
                             </tr>
                             <tr>
@@ -182,3 +183,9 @@
                 </tr>
             </table>
         </form>
+
+
+    <script type="text/javascript">
+        GLOBAL.DB_USER_PREFIX = '<?php echo $user; ?>_';
+    </script>
+    <script type="text/javascript" src="/js/pages/add.db.js"></script>

+ 6 - 0
web/templates/admin/edit_db.html

@@ -83,6 +83,7 @@
                             <tr>
                                 <td>
                                     <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>
                             </tr>
                             <tr>
@@ -140,3 +141,8 @@
                 </tr>
             </table>
         </form>
+
+    <script type="text/javascript">
+        GLOBAL.DB_USER_PREFIX = '<?php echo $user; ?>_';
+    </script>
+    <script type="text/javascript" src="/js/pages/add.db.js"></script>