home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / free_security / msshared / Shared_Computer_Toolkit_ENU.msi / FileInclude016 < prev    next >
Encoding:
Text (UTF-16)  |  2005-09-02  |  58.1 KB  |  961 lines

  1. ' *** 
  2. ' *** ------------------------------------------------------------------------------
  3. ' *** Filename:        SelectDrives.vbs
  4. ' *** ------------------------------------------------------------------------------
  5. ' *** Description:    UserAccounts HTA Script
  6. ' *** ------------------------------------------------------------------------------
  7. ' *** Version:        1.0
  8. ' *** Notes:        Used by SelectDrives.hta
  9. ' *** ------------------------------------------------------------------------------
  10. ' *** Copyright (C) Microsoft Corporation 2005, All Rights Reserved
  11. ' *** ------------------------------------------------------------------------------
  12. ' ***
  13.  
  14. ' ~~~ 
  15. ' ~~~ Force variables to be declared and turn off script error messages unless in DEBUG mode
  16. ' ~~~ 
  17. Option Explicit
  18.  
  19.  
  20. document.title = L_sProtectDrives_TEXT
  21.  
  22. ' ~~~ 
  23. ' ~~~ Declare global variables
  24. ' ~~~ 
  25. Dim strDivFocus, ColDrives
  26.  
  27. ' ***
  28. ' *** ------------------------------------------------------------------------------
  29. ' *** Name:            Init()
  30. ' *** ------------------------------------------------------------------------------
  31. ' *** Purpose:        This function is executed whilst the spash screen is displayed
  32. ' ***                If this function returns false, the spash screen is not removed
  33. ' *** ------------------------------------------------------------------------------
  34. ' ***
  35. Sub Init
  36.     ' ~~~ Call the sub to enable body 
  37.     Call BodyDisable(False) 
  38.     
  39. End Sub
  40.  
  41. ' ***
  42. ' *** ------------------------------------------------------------------------------
  43. ' *** Name:            DrivesMain()
  44. ' *** ------------------------------------------------------------------------------
  45. ' *** Purpose:        This function is executed on load of the HTA
  46. ' *** ------------------------------------------------------------------------------
  47. ' ***
  48. Sub DrivesMain
  49.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  50.  
  51.     ' ~~~ Disable the body on load
  52.     oBody.disabled = True
  53.         
  54.     ' ~~~ set up the screen, load controls and pages
  55.     Call Setup()
  56.  
  57.     ' ~~~ call the tool initalization function
  58.     Call Init()
  59.     
  60.     ' ~~~ Call the tool load function
  61.     Call Load()
  62.             
  63. End Sub
  64.  
  65. ' ***
  66. ' *** ------------------------------------------------------------------------------
  67. ' *** Name:            Validate()
  68. ' *** ------------------------------------------------------------------------------
  69. ' *** Purpose:        This function is executed before a wizard page is exited
  70. ' ***            If this function returns True The page is ready to close.
  71. ' *** ------------------------------------------------------------------------------
  72. ' ***
  73. Function Validate()
  74.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  75.     
  76.     Validate = True
  77. End Function
  78.  
  79. ' ***
  80. ' *** ------------------------------------------------------------------------------
  81. ' *** Name:            Action()
  82. ' *** ------------------------------------------------------------------------------
  83. ' *** Purpose:        This function is executed when enter key/ok button is pressed
  84. ' *** ------------------------------------------------------------------------------
  85. ' ***
  86. Function Action()
  87.     CloseOK()
  88. End Function
  89.  
  90. ' ***
  91. ' *** ------------------------------------------------------------------------------
  92. ' *** Name:            Load()
  93. ' *** ------------------------------------------------------------------------------
  94. ' *** Purpose:        This subroutine is executed before a wizard page is displayed
  95. ' *** ------------------------------------------------------------------------------
  96. ' ***
  97. Sub Load
  98.         
  99.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  100.     
  101.     Dim intValue, bSelected
  102.         
  103.     ' ~~~ Load the drives in left and rightpane
  104.     Call LoadDrives() 
  105.  
  106.     ' ~~~ Hide the drives in the right pane
  107.     For intValue = 65 to 90
  108.         document.all("trR" + chr(intValue)).style.display = "none"
  109.     Next 
  110.  
  111.     ' ~~~ Load the protected drives in the right pane
  112.     Call LoadProtectedDrives()
  113.  
  114.     ' ~~~ To set the first drive as selected
  115.     bSelected = False
  116.     For intValue = 65 to 90
  117.         If ( document.all("trL" + chr(intValue)).style.display <> "none" )Then
  118.             document.all("lbL" + chr(intValue)).classname = "selectuser"
  119.             bSelected = True
  120.             Exit For
  121.         End If
  122.     Next
  123.     If bSelected = False Then 
  124.         For intValue = 65 to 90 
  125.             If( document.all("trR" + chr(intValue)).currentstyle.display <> "none" )  Then
  126.                 document.all("lbR" + chr(intValue)).classname = "selectuser"
  127.                 Exit For
  128.             End If
  129.         Next
  130.     End If
  131.  
  132.     ' ~~~ Set the tab indexes for the two div's that holds the drives.
  133.     tLeft.tabindex = 0
  134.     tRight.tabindex = 0
  135.  
  136.     ' ~~~ Set the onfocus event for the two div's
  137.     Set tLeft.onfocus = GetRef("divLeftfocus")
  138.     Set tRight.onfocus = GetRef("divRightfocus")
  139.     
  140.     ' ~~~ Get the collection of drives 
  141.     Set ColDrives = document.body.GetElementsByTagName("LABEL")
  142.  
  143.     ' ~~~ To enable Esc and Enter when the hta is launched
  144.     oBody.disabled = false    
  145.     document.body.focus()
  146.  
  147. End Sub
  148.  
  149. ' ***
  150. ' *** ------------------------------------------------------------------------------
  151. ' *** Name:            HTAKeyDown()
  152. ' *** ------------------------------------------------------------------------------
  153. ' *** Purpose:        This function is called when any key is pressed while the  
  154. ' ***                       SelectDrives dialog is active
  155. ' *** ------------------------------------------------------------------------------
  156. Sub HTAKeyDown()
  157.     
  158.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  159.     
  160.     If window.event.keycode = 27 Then
  161.         self.Close()
  162.     ElseIf window.event.keycode = 37 Then
  163.         MoveLeft()
  164.     ElseIf window.event.keycode = 38 Then
  165.         moveup()
  166.     ElseIf window.event.keycode = 39 Then
  167.         MoveRight()
  168.     ElseIf window.event.keycode = 40 Then
  169.         movedown()
  170.     ElseIf window.event.keycode = 9 Then
  171.         If window.event.shiftkey Then
  172.             ShiftTabPress()
  173.         Else
  174.             TabPress()
  175.         End If
  176.     End If
  177.     
  178. End Sub
  179.  
  180. ' ***
  181. ' *** ------------------------------------------------------------------------------
  182. ' *** Name:            KeyUp()
  183. ' *** ------------------------------------------------------------------------------
  184. ' *** Purpose:        This function is called when any key is released while the  
  185. ' ***                       SelectDrives dialog is active
  186. ' *** ------------------------------------------------------------------------------
  187. ' ***
  188. Sub KeyUp()
  189.     
  190.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  191.     
  192.     If window.event.keycode = 9 Then
  193.         ShiftTabPress()
  194.     End If
  195. End Sub
  196.  
  197. ' ***
  198. ' *** ------------------------------------------------------------------------------
  199. ' *** Name:            LoadDrives()
  200. ' *** ------------------------------------------------------------------------------
  201. ' *** Purpose:        This subroutine Creates the drives in Unrestricted and 
  202. ' ***            Restricted Section.
  203. ' *** ------------------------------------------------------------------------------
  204. ' ***
  205. Sub LoadDrives()
  206.     
  207.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  208.     
  209.     Dim oRow, oCol, sHTML, intValue
  210.     
  211.     ' ~~~ Create two tables with 26 rows for drives A: to Z:
  212.     For intValue = 65 to 90 
  213.         Set oRow = document.all("tLeft").insertrow()
  214.         oRow.id = "trL" + chr(intValue)
  215.         Set oCol = oRow.insertCell()
  216.         
  217.         sHTML = "<label id=""" + "lbL" + chr(intValue) + """ class=""unselectuser"" onclick=""DriveClick(window.event.srcelement.id)"" >" + chr(intValue) + ":" + "</label>"
  218.         oCol.innerHTML = sHTML
  219.         
  220.         Set oRow = Nothing
  221.         Set oCol = Nothing
  222.     Next
  223.     
  224.     For intValue = 65 to 90 
  225.         Set oRow = document.all("tRight").insertrow()
  226.         oRow.id = "trR" + chr(intValue)
  227.         Set oCol = oRow.insertCell()
  228.  
  229.         sHTML = "<label id=""" + "lbR" + chr(intValue) + """ class=""unselectuser"" onclick=""DriveClick(window.event.srcelement.id)"" >" + chr(intValue) + ":" + "</label>"
  230.         oCol.innerHTML = sHTML
  231.  
  232.         Set oRow = Nothing
  233.         Set oCol = Nothing
  234.     Next
  235.         
  236. End Sub
  237.  
  238. ' ***
  239. ' *** ------------------------------------------------------------------------------
  240. ' *** Name:            LoadProtectedDrives()
  241. ' *** ------------------------------------------------------------------------------
  242. ' *** Purpose:        This subroutine loads the drives in the Restricted Section.
  243. ' *** ------------------------------------------------------------------------------
  244. ' ***
  245. Sub LoadProtectedDrives()
  246.      
  247.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  248.     
  249.     Dim strProtDrive, intCharPos
  250.      
  251.     ' ~~~ Get the existing set of restricted drives from dialog arguments
  252.     strProtDrive = DecToBinValue (window.DialogArguments)
  253.     
  254.     For intCharPos = 1 To 26
  255.          If Mid(strProtDrive,intCharPos,1) = "1"  Then
  256.              document.all("trL" & Chr(intCharPos + 64)).style.display = "none"
  257.              document.all("trR" & Chr(intCharPos + 64)).style.display = "block"
  258.          End If
  259.     Next
  260. End Sub
  261.  
  262. ' ***
  263. ' *** ------------------------------------------------------------------------------
  264. ' *** Name:            DriveClick(oDriveSelected)
  265. ' *** ------------------------------------------------------------------------------
  266. ' *** Purpose:        This subroutine is executed on click of a drive.
  267. ' *** ------------------------------------------------------------------------------
  268. ' ***
  269. Sub DriveClick(oDriveSelected)
  270.     
  271.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  272.     
  273.     Dim oDrive 
  274.     
  275.     ' ~~~ Select the clicked drive
  276.     For Each oDrive in ColDrives 
  277.         If oDrive.ClassName = "selectuser" Then
  278.             oDrive.ClassName = "unselectuser"
  279.         End If
  280.     Next
  281.     
  282.     document.all(oDriveSelected).classname = "selectuser"
  283.     
  284. End Sub
  285.  
  286. ' ***
  287. ' *** ------------------------------------------------------------------------------
  288. ' *** Name:            MoveRight()
  289. ' *** ------------------------------------------------------------------------------
  290. ' *** Purpose:        This subroutine is executed on Right arrow key press.
  291. ' *** ------------------------------------------------------------------------------
  292. ' ***
  293. Sub MoveRight
  294.     
  295.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  296.     
  297.     Dim bLeftEmpty, oDrive, LeftDrive, NextDrive, CurrDrive, bDown,LeftPrevDrive, LeftCurrDrive, bSelDrive 
  298.     
  299.     bLeftEmpty = True 
  300.     
  301.     For Each oDrive in ColDrives 
  302.         If Left(oDrive.id,3) = "lbL" Then
  303.             If oDrive.ClassName = "selectuser" Then
  304.                 document.all("trL" + Mid(oDrive.id,4)).style.display = "none"
  305.                 document.all("trR" + Mid(oDrive.id,4)).style.display = "block"
  306.                 Set LeftDrive = oDrive
  307.             End If
  308.         End If
  309.         If Left(oDrive.id,3) = "lbR" Then
  310.             If oDrive.classname = "selectuser" Then
  311.             Exit Sub
  312.             End If
  313.         End If
  314.     Next
  315.     
  316.     If Not IsEmpty(LeftDrive) Then
  317.         ' ~~~ Set the next drive to the moved drive as selected
  318.         For Each oDrive in ColDrives 
  319.             If Left(oDrive.id,3) = "lbL" Then
  320.                 If bSelDrive = True Then
  321.                     If(document.all("trL" + Mid(oDrive.id,4)).style.display <> "none") Then
  322.                         Set NextDrive = oDrive
  323.                         bDown = True
  324.                         exit For
  325.                     End If
  326.                 End If
  327.                 If oDrive.id = LeftDrive.id Then
  328.                     bSelDrive = True
  329.                     Set CurrDrive = oDrive
  330.                 End If    
  331.             End If
  332.         Next
  333.         If Not IsEmpty(NextDrive) Then
  334.                 NextDrive.ClassName = "selectuser"
  335.                 CurrDrive.ClassName = "unselectuser"
  336.                 NextDrive.ScrollInToView( False)
  337.         End If
  338.  
  339.         
  340.         If bDown = False Then
  341.             ' ~~~ Set the previous drive to the moved drive as selected
  342.             For Each oDrive in ColDrives 
  343.                 If Left(oDrive.id,3) = "lbL" Then
  344.                     If oDrive.id = LeftDrive.id Then
  345.                         Set LeftCurrDrive = oDrive
  346.                         Exit For
  347.                     Else
  348.                         If (document.all("trL" + Mid(oDrive.id,4)).style.display <> "none") Then
  349.                             Set LeftPrevDrive = oDrive
  350.                         End If
  351.                     End If
  352.                 End If
  353.             Next
  354.             If ( Not IsEmpty(LeftPrevDrive) ) Then
  355.                 LeftPrevDrive.ClassName = "selectuser"
  356.                 LeftCurrDrive.ClassName = "unselectuser"
  357.                 LeftCurrDrive.ScrollIntoView( False )
  358.             End If
  359.         End If    
  360.     End If
  361.         
  362.     ' ~~~ To select the drive the right pane
  363.     For Each oDrive in ColDrives 
  364.         If Left(oDrive.id,3) = "lbL" Then    
  365.             If (document.all("trL" + Mid(oDrive.id,4)).style.display <> "none") Then
  366.                 bLeftEmpty = False
  367.             End If
  368.         End If
  369.     Next
  370.     
  371.     ' ~~~ If no drives in left pane, move all drives to right pane
  372.     If bLeftEmpty = True Then
  373.         Call RestrictAll()
  374.     End If
  375.     
  376. End Sub
  377.  
  378. ' ***
  379. ' *** ------------------------------------------------------------------------------
  380. ' *** Name:            MoveLeft()
  381. ' *** ------------------------------------------------------------------------------
  382. ' *** Purpose:        This subroutine is executed on Left arrow key press.
  383. ' *** ------------------------------------------------------------------------------
  384. ' ***
  385. Sub MoveLeft
  386.     
  387.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  388.     
  389.     Dim bRightEmpty, oDrive, RightDrive, bDown, NextDrive, CurrDrive, LeftCurrDrive, LeftPrevDrive, bSelDrive  
  390.     
  391.     bRightEmpty = True
  392.     
  393.     For Each oDrive in ColDrives 
  394.         If Left(oDrive.id,3) = "lbR" Then
  395.             If oDrive.ClassName = "selectuser" Then
  396.                 document.all("trL" + Mid(oDrive.id,4)).style.display = "block"
  397.                 document.all("trR" + Mid(oDrive.id,4)).style.display = "none"
  398.                 Set RightDrive = oDrive
  399.             End If
  400.         End If
  401.         If Left(oDrive.id,3) = "lbL" Then
  402.             If oDrive.classname = "selectuser" Then
  403.                 Exit Sub
  404.             End If
  405.         End If
  406.     Next
  407.     
  408.     
  409.     If Not IsEmpty(RightDrive) Then
  410.         ' ~~~ Set the next drive as selected
  411.         For Each oDrive in ColDrives 
  412.             If Left(oDrive.id,3) = "lbR" Then
  413.                 If bSelDrive = True Then
  414.                     If (document.all("trR" + Mid(oDrive.id,4)).style.display <> "none") Then
  415.                         Set NextDrive = oDrive
  416.                         bDown = True
  417.                         exit For
  418.                     End If
  419.                 End If
  420.                 If oDrive.id = RightDrive.id Then
  421.                     bSelDrive = True
  422.                     Set CurrDrive = oDrive
  423.                 End If    
  424.             End If
  425.         Next
  426.         If Not IsEmpty(NextDrive) Then
  427.                 NextDrive.ClassName = "selectuser"
  428.                 CurrDrive.ClassName = "unselectuser"
  429.                 NextDrive.ScrollInToView( False)
  430.         End If
  431.     
  432.         If bDown = False Then
  433.             ' ~~~ Set the previous drive as selected
  434.             For Each oDrive in ColDrives 
  435.                 If Left(oDrive.id,3) = "lbR" Then
  436.                     If oDrive.id = RightDrive.id Then
  437.                         Set LeftCurrDrive = oDrive
  438.                         Exit For
  439.                     Else
  440.                         If (document.all("trR" + Mid(oDrive.id,4)).style.display <> "none" )Then
  441.                             Set LeftPrevDrive = oDrive
  442.                         End If
  443.                     End If
  444.                 End If
  445.             Next
  446.  
  447.             If ( Not IsEmpty(LeftPrevDrive) ) Then
  448.                 LeftPrevDrive.ClassName = "selectuser"
  449.                 LeftCurrDrive.ClassName = "unselectuser"
  450.                 LeftCurrDrive.ScrollIntoView( False )
  451.             End If
  452.         End If    
  453.     End If
  454.         
  455.     ' ~~~ To select the drive the right pane
  456.     For Each oDrive in ColDrives 
  457.         If Left(oDrive.id,3) = "lbR" Then    
  458.             If (document.all("trR" + Mid(oDrive.id,4)).style.display <> "none" )Then
  459.                 bRightEmpty = False
  460.             End If
  461.         End If
  462.     Next
  463.     
  464.     ' ~~~ If no drives in right pane, enable all drives in left pane
  465.     If bRightEmpty = True Then
  466.         Call ClearAll()
  467.     End If
  468.     
  469. End Sub
  470.  
  471. ' ***
  472. ' *** ------------------------------------------------------------------------------
  473. ' *** Name:            moveup()
  474. ' *** ------------------------------------------------------------------------------
  475. ' *** Purpose:        This subroutine is executed on Up Arrow key press
  476. ' *** ------------------------------------------------------------------------------
  477. ' ***
  478. Sub moveup
  479.     
  480.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  481.     
  482.     Dim oDrive, LeftCurrDrive, LeftPrevDrive, bLeft, RightCurrDrive, RightPrevDrive
  483.     
  484.     ' ~~~ Select the previous drive in left pane on down arrow key press
  485.     For Each oDrive in ColDrives 
  486.         If Left(oDrive.id,3) = "lbL" Then
  487.             If oDrive.ClassName = "selectuser" Then
  488.                 Set LeftCurrDrive = oDrive
  489.                 bLeft = True
  490.                 Exit For
  491.             Else
  492.                 If(document.all("trL" + Mid(oDrive.id,4)).style.display <> "none" )Then
  493.                     Set LeftPrevDrive = oDrive
  494.                 End If
  495.             End If
  496.         End If
  497.     Next
  498.     If ( (Not IsEmpty(LeftPrevDrive)) and bLeft) Then
  499.         LeftPrevDrive.ClassName = "selectuser"
  500.         LeftCurrDrive.ClassName = "unselectuser"
  501.         LeftCurrDrive.ScrollIntoView( False )
  502.     End If
  503.     
  504.     ' ~~~ Select the previous drive in right pane on down arrow key press
  505.     If Not(bLeft ) Then
  506.         For Each oDrive in ColDrives 
  507.             If Left(oDrive.id,3) = "lbR" Then
  508.                 If oDrive.ClassName = "selectuser" Then
  509.                     Set RightCurrDrive = oDrive
  510.                     Exit For
  511.                 Else
  512.                     If (document.all("trR" + Mid(oDrive.id,4)).style.display <> "none") Then
  513.                         Set RightPrevDrive = oDrive
  514.                         
  515.                     End If
  516.                 End If
  517.             End If
  518.         Next
  519.         If Not IsEmpty(RightPrevDrive) Then
  520.             RightPrevDrive.ClassName = "selectuser"
  521.             RightCurrDrive.ClassName = "unselectuser"
  522.             RightCurrDrive.ScrollIntoView( False )
  523.         End If
  524.     End If
  525. End Sub
  526.  
  527. ' ***
  528. ' *** ------------------------------------------------------------------------------
  529. ' *** Name:            movedown()
  530. ' *** ------------------------------------------------------------------------------
  531. ' *** Purpose:        This subroutine is for Down arrow key press
  532. ' *** ------------------------------------------------------------------------------
  533. ' ***
  534. Sub movedown
  535.     
  536.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  537.     
  538.     Dim oDrive, bSelDrive, bLeft, NextDrive, CurrDrive 
  539.     
  540.     bSelDrive = False
  541.     bLeft = False
  542.     
  543.     ' ~~~ Select the next drive in left pane on down arrow key press
  544.     For Each oDrive in ColDrives 
  545.         If Left(oDrive.id,3) = "lbL" Then
  546.             If bSelDrive = True Then
  547.                 If(document.all("trL" + Mid(oDrive.id,4)).style.display <> "none") Then
  548.                     Set NextDrive = oDrive
  549.                     bLeft = True
  550.                     exit For
  551.                 End If
  552.             End If
  553.             If oDrive.classname = "selectuser" Then
  554.                 bSelDrive = True
  555.                 Set CurrDrive = oDrive
  556.             End If    
  557.         End If
  558.     Next
  559.     
  560.     ' ~~~ Select the next drive in right pane on down arrow key press
  561.     If Not(bLeft ) Then
  562.         bSelDrive = False
  563.         For Each oDrive in ColDrives 
  564.             If Left(oDrive.id,3) = "lbR" Then
  565.                 If bSelDrive = True Then
  566.                     If (document.all("trR" + Mid(oDrive.id,4)).style.display <> "none")Then
  567.                         Set NextDrive = oDrive
  568.                         exit For
  569.                     End If
  570.                 End If
  571.                 If oDrive.classname = "selectuser" Then
  572.                     bSelDrive = True
  573.                     Set CurrDrive = oDrive
  574.                 End If    
  575.             End If
  576.         Next
  577.     End If
  578.     If Not IsEmpty(NextDrive) Then
  579.         NextDrive.ClassName = "selectuser"
  580.         CurrDrive.ClassName = "unselectuser"
  581.         NextDrive.ScrollInToView( False)
  582.     End If
  583. End Sub
  584.  
  585. ' ***
  586. ' *** ------------------------------------------------------------------------------
  587. ' *** Name:            RestrictAll()
  588. ' *** ------------------------------------------------------------------------------
  589. ' *** Purpose:        This subroutine is on click of the RestrictAll button.
  590. ' ***            This adds all the drives in the Restricted section.
  591. ' *** ------------------------------------------------------------------------------
  592. ' ***
  593. Sub RestrictAll
  594.     
  595.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  596.     
  597.     Dim intValue
  598.     
  599.     For intValue = 65 to 90
  600.         ' ~~~ Make all drives in right pane visible
  601.         document.all("trR" + chr(intValue) ).style.display = "block"
  602.         document.all("trL" + chr(intValue) ).style.display = "none"
  603.         
  604.         document.all("lbR" + chr(intValue)).classname = "unselectuser"
  605.         document.all("lbL" + chr(intValue)).classname = "unselectuser"
  606.     Next
  607.     
  608.     ' ~~~ Select the first drive in the right pane
  609.     document.all("trRA").style.display = "block"
  610.     document.all("lbRA").classname = "selectuser"
  611.     
  612. End Sub
  613.  
  614. ' ***
  615. ' *** ------------------------------------------------------------------------------
  616. ' *** Name:            ClearAll()
  617. ' *** ------------------------------------------------------------------------------
  618. ' *** Purpose:        This subroutine is on click of the ClearAll button.
  619. ' ***            This clears all the drives in the Restricted section.
  620. ' *** ------------------------------------------------------------------------------
  621. ' ***
  622. Sub ClearAll
  623.     
  624.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  625.     
  626.     Dim intValue
  627.     For intValue = 65 to 90
  628.         ' ~~~ Make all drives in left pane visible
  629.         document.all("trR" + chr(intValue) ).style.display = "none"
  630.         document.all("trL" + chr(intValue) ).style.display = "block"
  631.         document.all("lbR" + chr(intValue)).classname = "unselectuser"
  632.         document.all("lbL" + chr(intValue)).classname = "unselectuser"
  633.     Next
  634.     
  635.     ' ~~~ Select the first drive in left pane
  636.     document.all("trLA").style.display = "block"
  637.     document.all("lbLA").classname = "selectuser"
  638.     
  639. End Sub
  640.  
  641. ' ***
  642. ' *** ------------------------------------------------------------------------------
  643. ' *** Name:            CloseOK()
  644. ' *** ------------------------------------------------------------------------------
  645. ' *** Purpose:        This is executed on click of the "OK" button
  646. ' ***            
  647. ' *** ------------------------------------------------------------------------------
  648. ' ***
  649. Sub CloseOK
  650.     
  651.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  652.     
  653.     Dim strSelDrives, oDrive
  654.     For Each oDrive in ColDrives 
  655.         If Left(oDrive.id,3) = "lbR" Then
  656.             If document.all("trR" + Mid(oDrive.id,4)).style.display = "none" Then    
  657.                 strSelDrives = strSelDrives & 0
  658.             End If                
  659.             If document.all("trR" + Mid(oDrive.id,4)).style.display = "block" Then    
  660.                 strSelDrives = strSelDrives & 1
  661.             End If
  662.  
  663.         End If
  664.     Next
  665.         
  666.     strSelDrives = strReverse(strSelDrives)
  667.     
  668.     ' ~~~ Call the function to get the decimal value and return it
  669.     window.returnValue = BinToDecValue(strSelDrives)
  670.     
  671.     window.close
  672. End Sub
  673.  
  674. ' ***
  675. ' *** ------------------------------------------------------------------------------
  676. ' *** Name:            TabPress()
  677. ' *** ------------------------------------------------------------------------------
  678. ' *** Purpose:        This is executed on TAB Key Navigation            
  679. ' *** ------------------------------------------------------------------------------
  680. ' ***
  681. Sub TabPress
  682.     
  683.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  684.     
  685.     Dim oDrive
  686.     
  687.     If ( document.activeelement.id = "tRight" ) Then
  688.         ' ~~~ To select the first drive in the left pane
  689.         For Each oDrive in ColDrives 
  690.             If Left(oDrive.id,3) = "lbR" Then
  691.                 oDrive.classname = "unselectuser"
  692.             End If
  693.         Next
  694.         For Each oDrive in ColDrives 
  695.             If Left(oDrive.id,3) = "lbL" Then
  696.                 oDrive.classname = "unselectuser"
  697.             End If
  698.         Next
  699.         For Each oDrive in ColDrives 
  700.             If Left(oDrive.id,3) = "lbL" Then
  701.                 If (document.all("trL" + Mid(oDrive.id,4)).style.display <> "none" )Then
  702.                     oDrive.classname = "selectuser"
  703.                     oDrive.ScrollIntoView( False )
  704.                     Exit For
  705.                 End If
  706.             End If
  707.         Next
  708.                 
  709.     ElseIf ( document.activeelement.id = "btnClearAll"  )Then
  710.         ' ~~~ To select the first drive in the Right pane
  711.         For Each oDrive in ColDrives 
  712.             If Left(oDrive.id,3) = "lbL" Then
  713.                 oDrive.classname = "unselectuser"
  714.             End If
  715.         Next
  716.         For Each oDrive in ColDrives 
  717.             If Left(oDrive.id,3) = "lbR" Then
  718.                 oDrive.classname = "unselectuser"
  719.             End If
  720.         Next
  721.         For Each oDrive in ColDrives 
  722.             If Left(oDrive.id,3) = "lbR" Then
  723.                 If (document.all("trR" + Mid(oDrive.id,4)).style.display <> "none" )Then
  724.                     oDrive.classname = "selectuser"
  725.                     oDrive.ScrollIntoView( False )
  726.                     Exit For
  727.                 End If
  728.             End If
  729.         Next
  730.     End If
  731.     
  732. End Sub
  733.  
  734. ' ***
  735. ' *** ------------------------------------------------------------------------------
  736. ' *** Name:            ShiftTabPress()
  737. ' *** ------------------------------------------------------------------------------
  738. ' *** Purpose:        This is executed on the release of the TAB key with the
  739. ' ***            SHIFT Key combination.
  740. ' *** ------------------------------------------------------------------------------
  741. ' ***
  742. Sub ShiftTabPress
  743.     
  744.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  745.     
  746.     Dim oDrive
  747.         
  748.     If ( strDivFocus = "tLeft") Then
  749.         ' ~~~ To select the first drive in the left pane
  750.         For Each oDrive in ColDrives 
  751.             If Left(oDrive.id,3) = "lbR" Then
  752.                 oDrive.classname = "unselectuser"
  753.             End If
  754.         Next
  755.         For Each oDrive in ColDrives 
  756.             If Left(oDrive.id,3) = "lbL" Then
  757.                 oDrive.classname = "unselectuser"
  758.             End If
  759.         Next
  760.         For Each oDrive in ColDrives 
  761.             If Left(oDrive.id,3) = "lbL" Then
  762.                 If (document.all("trL" + Mid(oDrive.id,4)).style.display <> "none" )Then
  763.                     oDrive.classname = "selectuser"
  764.                     oDrive.ScrollIntoView( False )
  765.                     Exit For
  766.                 End If
  767.             End If
  768.         Next
  769.  
  770.         ' ~~~ Set the string that holds tab focus to null
  771.         strDivFocus = ""
  772.  
  773.  
  774.     ElseIf ( strDivFocus = "tRight")Then
  775.         ' ~~~ To select the first drive in the Right pane
  776.         For Each oDrive in ColDrives 
  777.             If Left(oDrive.id,3) = "lbL" Then
  778.                 oDrive.classname = "unselectuser"
  779.             End If
  780.         Next
  781.         For Each oDrive in ColDrives 
  782.             If Left(oDrive.id,3) = "lbR" Then
  783.                 oDrive.classname = "unselectuser"
  784.             End If
  785.         Next
  786.         For Each oDrive in ColDrives 
  787.             If Left(oDrive.id,3) = "lbR" Then
  788.                 If (document.all("trR" + Mid(oDrive.id,4)).style.display <> "none" )Then
  789.                     oDrive.classname = "selectuser"
  790.                     oDrive.ScrollIntoView( False )
  791.                     Exit For
  792.                 End If
  793.             End If
  794.         Next
  795.  
  796.         ' ~~~ Set the string that holds tab focus to null
  797.         strDivFocus = ""
  798.     End If
  799. End Sub
  800.  
  801. ' ***
  802. ' *** ------------------------------------------------------------------------------
  803. ' *** Name:            divLeftfocus()
  804. ' *** ------------------------------------------------------------------------------
  805. ' *** Purpose:        This is executed when the focus is on Left DIV section
  806. ' *** ------------------------------------------------------------------------------
  807. ' ***
  808. Sub divLeftfocus
  809.     
  810.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  811.     
  812.     ' ~~~ Set the string that holds the current focus
  813.     strDivFocus = "tLeft"
  814. End Sub
  815.  
  816. ' ***
  817. ' *** ------------------------------------------------------------------------------
  818. ' *** Name:            divRightfocus()
  819. ' *** ------------------------------------------------------------------------------
  820. ' *** Purpose:        This is executed when the focus is on Right DIV section
  821. ' *** ------------------------------------------------------------------------------
  822. ' ***
  823. Sub divRightfocus
  824.     
  825.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  826.     
  827.     ' ~~~ Set the string that holds the current focus
  828.     strDivFocus = "tRight"
  829. End Sub
  830.  
  831. ' ***
  832. ' *** ------------------------------------------------------------------------------
  833. ' *** Name:            BinToDecValue(strValue)
  834. ' *** ------------------------------------------------------------------------------
  835. ' *** Purpose:        This is executed to return the selected drives as a 
  836. ' ***            decimal value
  837. ' *** ------------------------------------------------------------------------------
  838. ' ***
  839. Function BinToDecValue(strValue)
  840.     
  841.     If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  842.     
  843.     Dim intLength ' ~~~ Integer that stores the length of the input number
  844.     Dim dblDecimalNumber:dblDecimalNumber=0 ' ~~~ Double that stores the decimal number
  845.     Dim strCharFromHex ' ~~~ Character from the Hex number
  846.     Dim intCharIndex ' ~~~ Integer that stores the index of the character
  847.     Dim intPower ' ~~~ Integer that stores the power to which 16 is to be raised
  848.     Dim strNumber 
  849.     
  850.     strNumber = strValue
  851.     
  852.     ' ~~~ Get the length of the Hexa decimal number given
  853.     intLength = Len(strNumber)
  854.     
  855.     intCharIndex = intLength
  856.     
  857.     ' ~~~ Loop till the intLength becomes 0
  858.     While intCharIndex <> 0 
  859.     
  860.         ' ~~~ Extract the first character from the string
  861.         strCharFromHex = Mid(strNumber,intCharIndex,1)
  862.         
  863.         ' ~~~ Get the power
  864.         intPower = intLength - intCharIndex
  865.         
  866.         dblDecimalNumber = dblDecimalNumber + (2^intPower) * CInt(strCharFromHex)
  867.             
  868.         intCharIndex = intCharIndex - 1
  869.     Wend
  870.                 
  871. ' ~~~ Return the decimal value
  872. BinToDecValue = dblDecimalNumber
  873.  
  874. End Function
  875.  
  876. ' ***
  877. ' *** ------------------------------------------------------------------------------
  878. ' *** Name:            DecToBinValue(intDecValue)
  879. ' *** ------------------------------------------------------------------------------
  880. ' *** Purpose:        This is executed to get the protected drives from the 
  881. ' ***            decimal value
  882. ' *** ------------------------------------------------------------------------------
  883. ' ***
  884. Function DecToBinValue(intDecValue)
  885.  
  886. If NOT DEBUG Then On Error Resume Next Else On Error Goto 0
  887.  
  888. Dim strBin, intValue
  889.  
  890. Select Case intDecValue
  891.     ' ~~~ If no drives protected
  892.     Case "0"
  893.         For intValue = 1 to 26 
  894.             strBin = strBin & 0  
  895.         Next
  896.         
  897.         ' ~~~ Return the value
  898.         DecToBinValue = strBin
  899.         Exit Function
  900.     ' ~~~ If only A: is protected
  901.     Case "1" 
  902.         strBin = 1
  903.         For intValue = 2 to 26 
  904.             strBin = strBin & 0  
  905.         Next
  906.         
  907.         ' ~~~ Return the value
  908.         DecToBinValue = strBin
  909.         Exit Function
  910. End Select
  911.  
  912. Select Case intDecValue
  913.     ' ~~~ If no drives protected
  914.     Case ""
  915.         For intValue = 1 to 26 
  916.             strBin = strBin & 0  
  917.         Next
  918.         
  919.         ' ~~~ Return the value
  920.         DecToBinValue = strBin
  921.         Exit Function
  922. End Select 
  923.  
  924. ' ~~~ Convert the decimal value into binary
  925. While intDecValue > 1 
  926.     strBin = strBin & CStr(intDecValue Mod 2)
  927.     intDecValue = int(intDecValue/2)
  928. Wend
  929.  
  930. strBin = strBin & CStr(intDecValue )
  931. strBin = CStr(strBin)
  932.  
  933. ' ~~~ Pad the other bits with 0
  934. If Len(strBin) < 26 Then
  935.     For intValue = Len(strBin)+1 To 26
  936.         strBin = strBin & 0
  937.     Next
  938. End If
  939.  
  940. ' ~~~ Return the value
  941. DecToBinValue = strBin
  942.  
  943. End Function
  944.  
  945. ' ***
  946. ' *** ------------------------------------------------------------------------------
  947. ' *** Name:            OnDoubleclick()
  948. ' *** ------------------------------------------------------------------------------
  949. ' *** Purpose:        The drive double clicked is added to the restricted list
  950. ' ***            or unrestricted list.
  951. ' *** ------------------------------------------------------------------------------
  952. ' ***
  953.  
  954. Sub OnDoubleclick()
  955.     ' ~~~ If the selected drive is in leftside move it to right else move it to left
  956.     If mid(window.event.srcelement.id,3,1) = "L" Then
  957.         MoveRight()
  958.     Else
  959.         MoveLeft()
  960.     End If
  961. End sub