[Kimchi-devel] [PATCH] UI: change some code of storage add page
shaohef at linux.vnet.ibm.com
shaohef at linux.vnet.ibm.com
Tue Apr 1 02:48:35 UTC 2014
From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
Actually there is no bug.
But we think, we can improve the codes.
We can remove the reduplicate codes.
Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
Signed-off-by: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
---
ui/js/src/kimchi.storagepool_add_main.js | 42 +++++++++-----------------------
1 file changed, 11 insertions(+), 31 deletions(-)
diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js
index ea9f68b..86dbe7f 100644
--- a/ui/js/src/kimchi.storagepool_add_main.js
+++ b/ui/js/src/kimchi.storagepool_add_main.js
@@ -123,37 +123,17 @@ kimchi.initStorageAddPage = function() {
});
$('#poolTypeInputId').change(function() {
- if ($(this).val() === 'dir') {
- $('.path-section').removeClass('tmpl-html');
- $('.logical-section').addClass('tmpl-html');
- $('.nfs-section').addClass('tmpl-html');
- $('.iscsi-section').addClass('tmpl-html');
- $('.scsi-section').addClass('tmpl-html');
- } else if ($(this).val() === 'netfs') {
- $('.path-section').addClass('tmpl-html');
- $('.logical-section').addClass('tmpl-html');
- $('.nfs-section').removeClass('tmpl-html');
- $('.iscsi-section').addClass('tmpl-html');
- $('.scsi-section').addClass('tmpl-html');
- } else if ($(this).val() === 'iscsi') {
- $('.path-section').addClass('tmpl-html');
- $('.logical-section').addClass('tmpl-html');
- $('.nfs-section').addClass('tmpl-html');
- $('.iscsi-section').removeClass('tmpl-html');
- $('.scsi-section').addClass('tmpl-html');
- } else if ($(this).val() === 'logical') {
- $('.path-section').addClass('tmpl-html');
- $('.logical-section').removeClass('tmpl-html');
- $('.nfs-section').addClass('tmpl-html');
- $('.iscsi-section').addClass('tmpl-html');
- $('.scsi-section').addClass('tmpl-html');
- } else if ($(this).val() === 'scsi') {
- $('.scsi-section').removeClass('tmpl-html');
- $('.path-section').addClass('tmpl-html');
- $('.logical-section').addClass('tmpl-html');
- $('.nfs-section').addClass('tmpl-html');
- $('.iscsi-section').addClass('tmpl-html');
- }
+ var poolObject = {'dir': ".path-section", 'netfs': '.nfs-section',
+ 'iscsi': '.iscsi-section', 'scsi': '.scsi-section',
+ 'logical': '.logical-section'}
+ var selectType = $(this).val();
+ $.each(poolObject, function(type, value) {
+ if(selectType == type){
+ $(value).removeClass('tmpl-html');
+ } else {
+ $(value).addClass('tmpl-html');
+ }
+ });
});
$('#authId').click(function() {
if ($(this).prop("checked")) {
--
1.8.5.3
More information about the Kimchi-devel
mailing list