views:

15

answers:

0

I 'm devoloping a web page which has multi simalar inputs(lots of dropdownlist,text) grouped by some type selection (for example an imagetype input has some dropdowns,text inputs alse an other type has similar dropdowns ,text inputs also... ) these inputs will be selected over a treenode. when a node selected,input values of the selected node will be opened for edit... I devoloped a structure like code snippet below...Each kind has a div and have their own inputs by clicking a node node's type div 's display set to inline and values loaded to înputs inside selected div..... but it's gonna be complex..so may someone tell me how to make this code more simple...?

//holds currently selectednodevalue
   var selectedNodeGUIDClientID = '<%= selectedNodeGUID.ClientID %>';
         //menuItemType vars
         var menuItemTypeNameInputClientID = '<%= menuItemTypeNameInput.ClientID %>';
         var menuItemTypeUrlInputClientID = '<%= menuItemTypeUrlInput.ClientID %>';
         var deleteMenuItemDivClientID='<%= deleteMenuItemDiv.ClientID %>';
     //textType vars
         var textTypeTextInputClientID = '<%= textTypeTextInput.ClientID %>';
         var textTypeTitleInputClientID = '<%= textTypeTitleInput.ClientID %>'
         var textTypePromptInputClientID = '<%= textTypePromptInput.ClientID %>';
         var deleteInputTypeButtonDivClientID = '<%=deleteInputTypeButtonDiv.ClientID %>';
         var InputTypeSoftKey1ClientID = '<%= InputTypeSoftKey1.ClientID %>';
         var InputTypeSoftKey2ClientID = '<%= InputTypeSoftKey2.ClientID %>';
         var InputTypeSoftKey3ClientID = '<%= InputTypeSoftKey3.ClientID %>';
         var InputTypeSoftKey4ClientID = '<%= InputTypeSoftKey4.ClientID %>';
         var InputTypeSoftKey5ClientID = '<%= InputTypeSoftKey5.ClientID %>';
         //softKey var
         var softKetTitleInputClientID = '<%= softKetTitleInput.ClientID%>';
         var softKeyUrlInputClientID = '<%= softKeyUrlInput.ClientID %>';
         var deelteSoftKeyDivClientID = '<%= deelteSoftKeyDiv.ClientID %>';
     //image Type vars
         var imageTypeTitleInputClientID = '<%= imageTypeTitleInput.ClientID %>';
         var imageTypePromptInputClientID = '<%= imageTypePromptInput.ClientID %>';
         var imageTypeUrlInputClientID = '<%=imageTypeUrlInput.ClientID %>';
         var imageDeleteButonDivClientID = '<%= imageDeleteButonDiv.ClientID %>';
         var ImageInputSoftKey1ClientID = '<%= ImageInputSoftKey1.ClientID %>';
         var ImageInputSoftKey2ClientID = '<%= ImageInputSoftKey2.ClientID %>';
         var ImageInputSoftKey3ClientID = '<%= ImageInputSoftKey3.ClientID %>';
         var ImageInputSoftKey4ClientID = '<%= ImageInputSoftKey4.ClientID %>';
         var ImageInputSoftKey5ClientID = '<%= ImageInputSoftKey5.ClientID %>';
         var PhotoShowerClientID = '<%= PhotoShower.ClientID %>';

function OnLoadOperations(sender, eventArgs) {
             var submittedByImageLoadValue = document.getElementById('<%= submittedByImageLoad.ClientID %>').value;
             if (submittedByImageLoadValue=='0') {
                 var tree = $find("<%= playListItemTreeView.ClientID %>");
                 if (tree != null) {
                     var selectedParentNodeGUIDClientIDValue = document.getElementById(selectedParentNodeGUIDClientID).value;
                     var selectedNodeGuidValue = document.getElementById(selectedNodeGUIDClientID).value;
                     if (selectedNodeGuidValue != '') {
                         var node = tree.findNodeByAttribute("GUID", selectedNodeGuidValue); 
                         if (node != null) {
                             node.get_parent().expand();
                             var parentNodeText = node.get_parent().get_text();
                             var parentNodeType = PlayListEditor.InputType.parse(parentNodeText);
                             // alert(parentNodeType);
                             loadNodeValues(node, parentNodeType);
                             OptimizeVisibiltyOfOperationDivs(parentNodeType);
                             node.select();
                         }
                     }
                     else {
                         if (selectedParentNodeGUIDClientIDValue != '') {
                             var node = tree.findNodeByText(selectedParentNodeGUIDClientIDValue);
                             if (node != null) {
                                 node.expand();
                                 node.select();
                                 var nodeText = node.get_text();
                                 var nodeType = PlayListEditor.InputType.parse(nodeText);
                                 InitPageForNewInput(nodeType);
                             }
                         }
                     }
                 }
             }
             else {
                 document.getElementById('<%= submittedByImageLoad.ClientID %>').value = '0';
             }
         }

 function OptimizeVisibiltyOfOperationDivs(typeofDiv) {
         //debugger
             var textInputDivClientID = '<%= textInputDiv.ClientID %>';
             var imageInputDivClientID = '<%= imageInputDiv.ClientID %>';
             var imageFileMenuDivClientID = '<%= imageFileMenuDiv.ClientID %>';
             var menuItemDivClientID = '<%= menuItemDiv.ClientID%>';
             var softKeyDivClientID = '<%= softKeyDiv.ClientID %>';
             var softKeyQuickListDivClientID = '<%= softKeyQuickListDiv.ClientID %>';
             switch (typeofDiv) {
                 case PlayListEditor.InputType.Image:
                     $get(imageInputDivClientID).style.display = 'inline';
                     $get(textInputDivClientID).style.display = 'none';
                     $get(imageFileMenuDivClientID).style.display = 'none';
                     $get(menuItemDivClientID).style.display = 'none';
                     $get(softKeyDivClientID).style.display = 'none';
                     $get(softKeyQuickListDivClientID).style.display = 'none';
                     break;
                 case PlayListEditor.InputType.Menu:
                     $get(imageInputDivClientID).style.display = 'none';
                     $get(textInputDivClientID).style.display = 'none';
                     $get(imageFileMenuDivClientID).style.display = 'inline';
                     $get(menuItemDivClientID).style.display = 'none';
                     $get(softKeyDivClientID).style.display = 'none';
                     $get(softKeyQuickListDivClientID).style.display = 'none';
                     break;
.....