客户端CGI——结合javascript、dhtml实现bbs的backoffice(三)

发表于:2007-06-30来源:作者:点击数: 标签:
//第四步,实现对栏目及相关论坛的排序,基本思路就是对数组进行重新组合排序。 function On_OrderUp() { var CategoryIndex = frmManager.selCategoryName.selectedIndex ; var ForumIndex = frmManager.selForumName.selectedIndex ; if (ForumIndex == -1
//第四步,实现对栏目及相关论坛的排序,基本思路就是对数组进行重新组合排序。

function On_OrderUp()
    {
      var CategoryIndex = frmManager.selCategoryName.selectedIndex ;

      var ForumIndex = frmManager.selForumName.selectedIndex ;
      if (ForumIndex == -1 && CategoryIndex > 0)
        {
          for (var i = 0 ; i < aCategory.length ; i ++)
              {
                if (aCategory[i].CategoryID == frmManager.selCategoryName[CategoryIndex].value)
                   {
                    var temp = new MakeCategory(aCategory[i].CategoryID , aCategory[i].CategoryName , aCategory[i-1].OrderNum)
                    aCategory[i].CategoryID = aCategory[i-1].CategoryID
                    aCategory[i].CategoryName = aCategory[i-1].CategoryName
                    aCategory[i].OrderNum = aCategory[i].OrderNum
                    aCategory[i-1] = temp                     
                    On_Load()
                    frmManager.selCategoryName.selectedIndex = i - 1
                    On_CategoryChange()
                    return true ;
                   }
               }
        }
      if (ForumIndex != -1 && ForumIndex > 0)
        {
          for (var i = 0 ; i < aForum.length ; i ++)
              {
                if (aForum[i].CategoryID == frmManager.selForumName[ForumIndex].value)
                   {
                    var temp = new MakeForum(aForum[i].CategoryID , aForum[i].CategoryName , aForum[i-1].OrderNum , aForum[i].RootCategoryID , aForum[i].Description , aForum[i].MasterID)
                    aForum[i].CategoryID = aForum[i-1].CategoryID
                    aForum[i].CategoryName = aForum[i-1].CategoryName
                    aForum[i].RootCategoryID = aForum[i-1].RootCategoryID
                    aForum[i].Description = aForum[i-1].Description
                    aForum[i].MasterID = aForum[i-1].MasterID
                    aForum[i-1] = temp
                    frmManager.selForumName.selectedIndex = i - 1 ;
                    On_CategoryChange()
                   }
               }
        }
    }
function On_OrderDown()
    {
      var CategoryIndex = frmManager.selCategoryName.selectedIndex ;
      var ForumIndex = frmManager.selForumName.selectedIndex ;
      if (ForumIndex == -1 && CategoryIndex < frmManager.selCategoryName.length - 1)
        {
          for (var i = 0 ; i < aCategory.length ; i ++)
              {
                if (aCategory[i].CategoryID == frmManager.selCategoryName[CategoryIndex].value)
                   {
                    var temp = new MakeCategory(aCategory[i].CategoryID , aCategory[i].CategoryName , aCategory[i+1].OrderNum)
                    aCategory[i].CategoryID = aCategory[i+1].CategoryID
                    aCategory[i].CategoryName = aCategory[i+1].CategoryName
                    aCategory[i+1] = temp
                    On_Load()
                    frmManager.selCategoryName.selectedIndex= i + 1
                    On_CategoryChange();
                   }
               }
        }
      if (ForumIndex != -1 && ForumIndex < frmManager.selForumName.length - 1)
        {
          for (var i = 0 ; i < aForum.length ; i ++)
              {
                if (aForum[i].CategoryID == frmManager.selForumName[ForumIndex].value)
                   {
                    var temp = new MakeForum(aForum[i].CategoryID , aForum[i].CategoryName , aForum[i+1].OrderNum , aForum[i].RootCategoryID , aForum[i].Description , aForum[i].MasterID)
                    aForum[i].CategoryID = aForum[i+1].CategoryID
                    aForum[i].CategoryName = aForum[i+1].CategoryName
                    aForum[i].RootCategoryID = aForum[i+1].RootCategoryID
                    aForum[i].Description = aForum[i+1].Description
                    aForum[i].MasterID = aForum[i+1].MasterID
                    aForum[i+1] = temp
                    frmManager.selForumName.selectedIndex= i + 1
                    On_CategoryChange()
                   }
               }
        }
    }

    
function On_ChangeDescription()
    {
    
    
      //如果没有论坛被选中,则退出
      if (frmManager.selForumName .selectedIndex == -1)
        {
          return 0 ;
        }  
      if (frmManager.btnModifyDescription.value == "修改" && frmManager.txtDescription .value != "")
        {
          frmManager.btnModifyDescription .value = "确定" ;
          frmManager.btnChangeName  .disabled  = true ;
          frmManager.btnDown .disabled         = true ;
          frmManager.btnUp .disabled           = true ;
          frmManager.btnAddForum .disabled     = true ;
          frmManager.btnDeleteForum .disabled  = true ;
          frmManager.btnChangeMaster .disabled = true ;
          frmManager.btnSubmit .disabled       = true ;
          frmManager.selCategoryName .disabled = true ;
          frmManager.selForumName .disabled    = true ;
          frmManager.txtDescription .disabled  = false ;
        }
      else
        {
          frmManager.btnModifyDescription .value = "修改" ;
          frmManager.txtDescription .disabled  = true ;
          frmManager.selCategoryName .disabled = false ;
          frmManager.selForumName .disabled = false ;
          
          var intForumIndex ;
          for (var i = 0 ; i < aForum.length ; i ++)
             {
              if (frmManager.selForumName[frmManager.selForumName.selectedIndex].value == aForum[i].CategoryID )
                {
                  intForumIndex = i ;
                  break ;
                }  
             }    
          aForum[i].Description = frmManager.txtDescription .value ;
          On_ForumChange();
          frmManager.btnSubmit .disabled       = false ;
                   
         }           
        
    }
    
function On_ChangeMaster()
    {
      //如果没有论坛被选中,则退出
      if (frmManager.selForumName .selectedIndex == -1)
        {
          return 0 ;
        }
          
      if (frmManager.btnChangeMaster .value == "修改")
        {
          frmManager.btnChangeName  .disabled       = true ;
          frmManager.btnDown .disabled              = true ;
          frmManager.btnUp .disabled                = true ;
          frmManager.btnModifyDescription .disabled = true ;
          frmManager.btnAddForum .disabled          = true ;
          frmManager.btnDeleteForum .disabled       = true ;
          frmManager.btnSubmit .disabled            =true ;
          frmManager.selCategoryName .disabled      = true ;
          frmManager.selForumName .disabled         = true ;
          frmManager.selMaster .disabled            = false ;
          frmManager.btnChangeMaster.value          = "确定" ;
          return 0 ;
        }
      else
        {
          frmManager.btnChangeMaster.value          = "修改" ;
          frmManager.selCategoryName .disabled      = false ;
          frmManager.selForumName .disabled         = false ;
          frmManager.selMaster .disabled            = true ;
          frmManager.btnSubmit .disabled            = false ;
          var intForumIndex ;
          for (var i = 0 ; i < aForum.length ; i ++)
             {
              if (frmManager.selForumName[frmManager.selForumName.selectedIndex].value == aForum[i].CategoryID )
                {
                  intForumIndex = i ;
                  break ;
                }  
             }    
          aForum[i].MasterID = frmManager.selMaster  .value ;
         }
         
         On_ForumChange() ;
   }           

//第五步,修改论坛的描述
function On_ChangeDescription()
    {
    
    
      //如果没有论坛被选中,则退出
      if (frmManager.selForumName .selectedIndex == -1)
        {
          return 0 ;
        }  
      if (frmManager.btnModifyDescription.value == "修改" && frmManager.txtDescription .value != "")
        {
          frmManager.btnModifyDescription .value = "确定" ;
          frmManager.btnChangeName  .disabled  = true ;
          frmManager.btnDown .disabled         = true ;
          frmManager.btnUp .disabled           = true ;
          frmManager.btnAddForum .disabled     = true ;
          frmManager.btnDeleteForum .disabled  = true ;
          frmManager.btnChangeMaster .disabled = true ;
          frmManager.btnSubmit .disabled       = true ;
          frmManager.selCategoryName .disabled = true ;
          frmManager.selForumName .disabled    = true ;
          frmManager.txtDescription .disabled  = false ;
        }
      else
        {
          frmManager.btnModifyDescription .value = "修改" ;
          frmManager.txtDescription .disabled  = true ;
          frmManager.selCategoryName .disabled = false ;
          frmManager.selForumName .disabled = false ;
          
          var intForumIndex ;
          for (var i = 0 ; i < aForum.length ; i ++)
             {
              if (frmManager.selForumName[frmManager.selForumName.selectedIndex].value == aForum[i].CategoryID )
                {
                  intForumIndex = i ;
                  break ;
                }  
             }    
          aForum[i].Description = frmManager.txtDescription .value ;
          On_ForumChange();
          frmManager.btnSubmit .disabled       = false ;
                   
         }           
        
    }

原文转自:http://www.ltesting.net