Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

634 lines
44 KiB

  1. ��<HTML>
  2. <!-- Copyright (c) Microsoft Corporation. All rights reserved.-->
  3. <HEAD>
  4. <TITLE>Tasks Page</TITLE>
  5. <SCRIPT LANGUAGE="VBScript">
  6. <!--
  7. Option Explicit
  8. 'Windows constants for key codes
  9. Public Const RightArrow = 39
  10. Public Const LeftArrow = 37
  11. Public Const EnterKey = 13
  12. Public Const EscapeKey = 27
  13. Public Const TabKey = 9
  14. 'special code for new alerts
  15. Public Const NewAlertKey = 135
  16. 'color constants
  17. Public Const BLACK = "#000000"
  18. Public Const WHITE = "#FFFFFF"
  19. 'Three dimentional array holding alert captions, descriptions and long descs
  20. Dim TasksArray()
  21. 'Number of localui tasks
  22. Dim NumberOfTasks
  23. 'Number of localui tasks
  24. Dim NumberOfPages
  25. 'Index of the alert with the focus
  26. Dim intCurrentTask
  27. 'Current page that is on display
  28. Dim intCurrentPage
  29. 'Timer for idle timeout
  30. Dim iIdleTimeOut
  31. 'Timer for idle timeout
  32. Dim iFlashIconTimeOut
  33. '"Page" text to diplay
  34. Dim strPageText
  35. '"View Alerts" text to diplay
  36. Dim strViewAlertsText
  37. '----------------------------------------------------------------------------
  38. ' Function: Window_OnLoad
  39. ' Description: Initialization routine for the page
  40. ' Input Variables: None
  41. ' Output Variables: None
  42. ' Return Values: None
  43. ' Global Variables: AlertsArray,NumberOfAlerts,bAlertViewMode,bOnlyOnePage
  44. '----------------------------------------------------------------------------
  45. Sub Window_OnLoad()
  46. 'Localization manager object
  47. Dim objLocMgr
  48. 'Replacement strings
  49. Dim varReplacementStrings
  50. 'Resource ID for "page" text
  51. Const PAGEINFO_PAGE_TEXT = "&H40020013"
  52. 'Resource ID for "View Alerts" text
  53. Const ALERTS_VIEWALERTS_TEXT = "&H40020015"
  54. On Error Resume Next
  55. Err.Clear
  56. 'Create the localization manager
  57. Set objLocMgr = CreateObject("ServerAppliance.LocalizationManager")
  58. If Err.number = 0 Then
  59. 'Get the strings
  60. strPageText = objLocMgr.GetString("salocaluimsg.dll",PAGEINFO_PAGE_TEXT,varReplacementStrings)
  61. strViewAlertsText = objLocMgr.GetString("salocaluimsg.dll",ALERTS_VIEWALERTS_TEXT,varReplacementStrings)
  62. Set objLocMgr = Nothing
  63. End If
  64. Err.Clear
  65. 'set the text for alerts link
  66. SaAlertsLink.innerText = strViewAlertsText
  67. 'Get the current local ui alerts
  68. GetLocalUITasks
  69. intCurrentPage = CInt(CurrentPage.value)
  70. intCurrentTask = CInt(CurrentTask.value)
  71. ServeLocalUITasks
  72. iIdleTimeOut = window.SetTimeOut("IdleHandler()",300000)
  73. On Error Resume Next
  74. Err.Clear
  75. 'set the key codes for the page
  76. Dim objKeypad
  77. Set objKeypad = CreateObject("Ldm.SAKeypadController")
  78. If Err.number = 0 Then
  79. objKeypad.Setkey 0,TabKey,TRUE
  80. objKeypad.Setkey 1,TabKey,FALSE
  81. objKeypad.Setkey 2,LeftArrow,FALSE
  82. objKeypad.Setkey 3,RightArrow,FALSE
  83. objKeypad.Setkey 4,EscapeKey,FALSE
  84. objKeypad.Setkey 5,EnterKey,FALSE
  85. Set objKeypad = Nothing
  86. End If
  87. Dim bNewAlerts
  88. bNewAlerts = AreThereLocalUIAlerts
  89. 'display or hide the link
  90. HideOrDisplayAlertsLink(bNewAlerts)
  91. End Sub
  92. '----------------------------------------------------------------------------
  93. ' Function: IdleHandler
  94. ' Description: Goes back to main page when timeout expires
  95. ' Input Variables: None
  96. ' Output Variables: None
  97. ' Return Values: None
  98. ' Global Variables: None
  99. '----------------------------------------------------------------------------
  100. Sub IdleHandler()
  101. window.history.go(-1)
  102. End Sub
  103. '----------------------------------------------------------------------------
  104. ' Function: ServeLocalUITasks
  105. ' Description: Format the alerts and display them
  106. ' Input Variables: None
  107. ' Output Variables: None
  108. ' Return Values: None
  109. ' Global Variables: TasksArray,NumberOfTasks,NumberOfPages
  110. '----------------------------------------------------------------------------
  111. Sub ServeLocalUITasks
  112. Dim NumberOfTasksBefore
  113. Dim RemainingTasks
  114. NumberOfTasksBefore = (intCurrentPage-1) * 4
  115. RemainingTasks = NumberOfTasks - NumberOfTasksBefore
  116. 'Clear all of the tasks
  117. SaTask1.style.display = "none"
  118. SaTask2.style.display = "none"
  119. SaTask3.style.display = "none"
  120. SaTask4.style.display = "none"
  121. If RemainingTasks > 0 Then
  122. SaTask1.innerText = TasksArray(NumberOfTasksBefore,0)
  123. SaTask1.href = TasksArray(NumberOfTasksBefore,1)
  124. SaTask1.style.display = ""
  125. End If
  126. NumberOfTasksBefore = NumberOfTasksBefore + 1
  127. If RemainingTasks > 1 Then
  128. SaTask2.innerText = TasksArray(NumberOfTasksBefore,0)
  129. SaTask2.href = TasksArray(NumberOfTasksBefore,1)
  130. SaTask2.style.display = ""
  131. End If
  132. NumberOfTasksBefore = NumberOfTasksBefore + 1
  133. If RemainingTasks > 2 Then
  134. SaTask3.innerText = TasksArray(NumberOfTasksBefore,0)
  135. SaTask3.href = TasksArray(NumberOfTasksBefore,1)
  136. SaTask3.style.display = ""
  137. End If
  138. NumberOfTasksBefore = NumberOfTasksBefore + 1
  139. If RemainingTasks > 3 Then
  140. SaTask4.innerText = TasksArray(NumberOfTasksBefore,0)
  141. SaTask4.href = TasksArray(NumberOfTasksBefore,1)
  142. SaTask4.style.display = ""
  143. End If
  144. If NumberOfPages > 1 Then
  145. SaPageInfo.innertext = strPageText&" "&intCurrentPage&"/"&NumberOfPages
  146. End If
  147. 'Set the focus on the current task
  148. If intCurrentTask = 1 Then
  149. SaTask1.focus
  150. ElseIf intCurrentTask = 2 Then
  151. SaTask2.focus
  152. ElseIf intCurrentTask = 3 Then
  153. SaTask3.focus
  154. ElseIf intCurrentTask = 4 Then
  155. SaTask4.focus
  156. End If
  157. End Sub
  158. '----------------------------------------------------------------------------
  159. ' Function: GetLocalUITasks
  160. ' Description: Get the local ui tasks from element manager
  161. ' Input Variables: None
  162. ' Output Variables: None
  163. ' Return Values: None
  164. ' Global Variables: TasksArray,NumberOfTasks
  165. '----------------------------------------------------------------------------
  166. Sub GetLocalUITasks()
  167. Dim objTaskElementCol
  168. Dim objTaskElement
  169. Dim objLocMgr
  170. Dim varReplacementStrings
  171. Dim objRetriever
  172. Dim intCaptionID
  173. Dim strURL
  174. Dim intMerit
  175. Dim intCount
  176. Dim strSourceDll
  177. On Error Resume Next
  178. Err.Clear
  179. 'Create elementmgr and get current alerts
  180. Set objRetriever = CreateObject("Elementmgr.ElementRetriever")
  181. If Err.Number = 0 Then
  182. Set objTaskElementCol = objRetriever.GetElements(1, "LocalUITask")
  183. If objTaskElementCol.Count=0 or Err.Number <> 0 Then
  184. Err.Clear
  185. NumberOfTasks = 0
  186. Else
  187. ReDim TasksArray(objTaskElementCol.Count-1,2)
  188. 'create localization manager to get task strings
  189. Set objLocMgr = CreateObject("ServerAppliance.LocalizationManager")
  190. If (Err.Number <> 0) Then
  191. Err.Clear
  192. NumberOfTasks = 0
  193. Else
  194. intCount = 0
  195. For Each objTaskElement in objTaskElementCol
  196. strSourceDll = objTaskElement.GetProperty("Source")
  197. intCaptionID = "&H" & objTaskElement.GetProperty("CaptionRID")
  198. strURL = objTaskElement.GetProperty("URL")
  199. intMerit = CInt(objTaskElement.GetProperty("Merit"))
  200. TasksArray(intCount,0) = objLocMgr.GetString(strSourceDll, intCaptionID, varReplacementStrings)
  201. TasksArray(intCount,1) = strURL
  202. TasksArray(intCount,2) = intMerit
  203. intCount = intCount + 1
  204. Next
  205. NumberOfTasks = intCount
  206. NumberOfPages = (NumberOfTasks-1)\4 + 1
  207. End If
  208. End If
  209. End If
  210. SortTasksArray
  211. Set objLocMgr = Nothing
  212. Set objTaskElement = Nothing
  213. Set objTaskElementCol = Nothing
  214. Set objRetriever = Nothing
  215. End Sub
  216. '----------------------------------------------------------------------------
  217. ' Function: SortTasksArray
  218. ' Description: Sorts tasks array by merit values
  219. ' Input Variables: None
  220. ' Output Variables: None
  221. ' Return Values: None
  222. ' Global Variables: TasksArray,NumberOfTasks
  223. '----------------------------------------------------------------------------
  224. Sub SortTasksArray()
  225. Dim i
  226. Dim j
  227. Dim iSmallest
  228. Dim strCaption
  229. Dim strURL
  230. Dim intMerit
  231. 'for each item in the array
  232. For i = 0 To NumberOfTasks-2
  233. iSmallest = i
  234. 'find the index of the item with the smallest merit
  235. For j = i To NumberOfTasks-1
  236. If TasksArray(j,2) < TasksArray(iSmallest,2) Then
  237. iSmallest = j
  238. End If
  239. Next
  240. 'swap the smallest item with the current item
  241. strCaption = TasksArray(i,0)
  242. strURL = TasksArray(i,1)
  243. intMerit = TasksArray(i,2)
  244. TasksArray(i,0) = TasksArray(iSmallest,0)
  245. TasksArray(i,1) = TasksArray(iSmallest,1)
  246. TasksArray(i,2) = TasksArray(iSmallest,2)
  247. TasksArray(iSmallest,0) = strCaption
  248. TasksArray(iSmallest,1) = strURL
  249. TasksArray(iSmallest,2) = intMerit
  250. Next
  251. End Sub
  252. '----------------------------------------------------------------------------
  253. ' Function: KeyDown
  254. ' Description: Changes pages in response to right and left arrows
  255. ' in multiple task page mode
  256. ' Input Variables: None
  257. ' Output Variables: None
  258. ' Return Values: None
  259. ' Global Variables: None
  260. '----------------------------------------------------------------------------
  261. Sub KeyDown()
  262. If window.event.keycode = NewAlertKey Then
  263. Dim bNewAlerts
  264. bNewAlerts = AreThereLocalUIAlerts
  265. 'display or hide the link
  266. HideOrDisplayAlertsLink(bNewAlerts)
  267. Exit Sub
  268. End If
  269. 'clear the timeout and restart it
  270. window.clearTimeOut(iIdleTimeOut)
  271. iIdleTimeOut = window.SetTimeOut("IdleHandler()",300000)
  272. 'If escape key is hit, go back to alerts page
  273. If window.event.keycode = EscapeKey Then
  274. window.history.back
  275. End If
  276. 'if there are tasks and they don't fit one page
  277. If NumberOfPages > 1 Then
  278. 'right arrow
  279. If window.event.keycode = RightArrow Then
  280. intCurrentPage = intCurrentPage + 1
  281. If intCurrentPage = NumberOfPages + 1 Then
  282. intCurrentPage = 1
  283. End If
  284. intCurrentTask = 1
  285. ServeLocalUITasks
  286. CurrentTask.value = CStr(intCurrentTask)
  287. CurrentPage.value = CStr(intCurrentPage)
  288. End If
  289. 'left arrow
  290. If window.event.keycode = LeftArrow Then
  291. intCurrentPage = intCurrentPage -1
  292. If intCurrentPage = 0 Then
  293. intCurrentPage = NumberOfPages
  294. End If
  295. intCurrentTask = 1
  296. ServeLocalUITasks
  297. CurrentTask.value = CStr(intCurrentTask)
  298. CurrentPage.value = CStr(intCurrentPage)
  299. End If
  300. End If
  301. End Sub
  302. '----------------------------------------------------------------------------
  303. ' Function: InvertSelection
  304. ' Description: Inverts the focus element's background and foreground
  305. ' Input Variables: intIndex, index of the focus element, -1 for alerts link
  306. ' Output Variables: None
  307. ' Return Values: None
  308. ' Global Variables: None
  309. '----------------------------------------------------------------------------
  310. Sub InvertSelection(intIndex)
  311. CurrentTask.value = CStr(intIndex)
  312. 'Invert the background and foreground for the focus element
  313. If intIndex = 1 Then
  314. SaTask1.style.backgroundColor = BLACK
  315. SaTask1.style.color = WHITE
  316. ElseIf intIndex = 2 Then
  317. SaTask2.style.backgroundColor = BLACK
  318. SaTask2.style.color = WHITE
  319. ElseIf intIndex = 3 Then
  320. SaTask3.style.backgroundColor = BLACK
  321. SaTask3.style.color = WHITE
  322. ElseIf intIndex = 4 Then
  323. SaTask4.style.backgroundColor = BLACK
  324. SaTask4.style.color = WHITE
  325. ElseIf intIndex = -1 Then
  326. SaAlertsLink.style.backgroundColor = BLACK
  327. SaAlertsLink.style.color = WHITE
  328. End If
  329. End Sub
  330. '----------------------------------------------------------------------------
  331. ' Function: InvertToNormal
  332. ' Description: Inverts element that loses focus to normal
  333. ' Input Variables: intIndex, index of the element loosing the focus, -1 for alerts link
  334. ' Output Variables: None
  335. ' Return Values: None
  336. ' Global Variables: None
  337. '----------------------------------------------------------------------------
  338. Sub InvertToNormal(intIndex)
  339. 'Invert the background and color for the element loosing the focus
  340. If intIndex = 1 Then
  341. SaTask1.style.backgroundColor = ""
  342. SaTask1.style.color = BLACK
  343. ElseIf intIndex = 2 Then
  344. SaTask2.style.backgroundColor = ""
  345. SaTask2.style.color = BLACK
  346. ElseIf intIndex = 3 Then
  347. SaTask3.style.backgroundColor = ""
  348. SaTask3.style.color = BLACK
  349. ElseIf intIndex = 4 Then
  350. SaTask4.style.backgroundColor = ""
  351. SaTask4.style.color = BLACK
  352. ElseIf intIndex = -1 Then
  353. SaAlertsLink.style.backgroundColor = ""
  354. SaAlertsLink.style.color = BLACK
  355. End If
  356. End Sub
  357. '----------------------------------------------------------------------------
  358. ' Function: HideOrDisplayAlertsLink
  359. ' Description: Displays or hides the link to alerts
  360. ' Input Variables: true, display the link
  361. ' false, hide the link
  362. ' Output Variables: None
  363. ' Return Values: None
  364. ' Global Variables: None
  365. '----------------------------------------------------------------------------
  366. Sub HideOrDisplayAlertsLink(bDisplay)
  367. 'clear the current timeout
  368. window.clearTimeOut(iFlashIconTimeOut)
  369. If bDisplay = true Then
  370. 'reposition the page info
  371. SaPageInfo.style.top = 39
  372. 'display the link and flashing icon
  373. SaAlertsLink.style.display = ""
  374. SaAlertsIcon.style.display = ""
  375. 'start the timer
  376. iFlashIconTimeOut = window.SetTimeOut("FlashAlertsIcon(1)",500)
  377. Else
  378. 'reposition the page info
  379. SaPageInfo.style.top = 52
  380. 'hide the link and flashing icon
  381. SaAlertsLink.style.display = "none"
  382. SaAlertsIcon.style.display = "none"
  383. End If
  384. End Sub
  385. '----------------------------------------------------------------------------
  386. ' Function: AreThereLocalUIAlerts
  387. ' Description: Check if there are existing localui alerts
  388. ' Input Variables: None
  389. ' Output Variables: None
  390. ' Return Values: true, false
  391. ' Global Variables: None
  392. '----------------------------------------------------------------------------
  393. Function AreThereLocalUIAlerts()
  394. Dim objElement
  395. Dim objElementCol
  396. Dim objAlertElementCol
  397. Dim objAlertElement
  398. Dim strElementID
  399. Dim strAlertLog
  400. Dim objRetriever
  401. On Error Resume Next
  402. AreThereLocalUIAlerts = false
  403. Err.Clear
  404. 'Create elementmgr and get current alerts
  405. Set objRetriever = CreateObject("Elementmgr.ElementRetriever")
  406. If Err.Number = 0 Then
  407. Set objElementCol = objRetriever.GetElements(1, "SA_Alerts")
  408. If objElementCol.Count=0 or Err.Number <> 0 Then
  409. Err.Clear
  410. AreThereLocalUIAlerts = false
  411. Else
  412. 'get alert definitions
  413. Set objAlertElementCol = objRetriever.GetElements(1,"LocalUIAlertDefinitions")
  414. If (Err.Number <> 0) Then
  415. Err.Clear
  416. AreThereLocalUIAlerts = false
  417. Else
  418. For Each objElement in objElementCol
  419. strAlertLog = objElement.GetProperty("AlertLog")
  420. strElementID = "LocalUIAlertDefinitions" & strAlertLog & Hex(objElement.GetProperty("AlertID"))
  421. Err.Clear
  422. Set objAlertElement = objAlertElementCol.Item(strElementID)
  423. If Err <> 0 Then
  424. Set objAlertElement = Nothing
  425. Else
  426. AreThereLocalUIAlerts = true
  427. Exit For
  428. End If
  429. Next
  430. End If
  431. End If
  432. End If
  433. Set objElement = Nothing
  434. Set objElementCol = Nothing
  435. Set objAlertElement = Nothing
  436. Set objAlertElementCol = Nothing
  437. Set objRetriever = Nothing
  438. End Function
  439. '----------------------------------------------------------------------------
  440. ' Function: FlashAlertsIcon
  441. ' Description: Flash the alert icon
  442. ' Input Variables: iIndex, current status of icon
  443. ' 0, invisible 1, visible
  444. ' Output Variables: None
  445. ' Return Values: None
  446. ' Global Variables: None
  447. '----------------------------------------------------------------------------
  448. Sub FlashAlertsIcon(iIndex)
  449. If iIndex = 1 Then
  450. SaAlertsIcon.style.display = "none"
  451. iFlashIconTimeOut = window.SetTimeOut("FlashAlertsIcon(0)",500)
  452. Else
  453. iFlashIconTimeOut = window.SetTimeOut("FlashAlertsIcon(1)",500)
  454. SaAlertsIcon.style.display = ""
  455. End If
  456. End Sub
  457. '----------------------------------------------------------------------------
  458. ' Function: GotoAlertsPage
  459. ' Description: Goes back to alerts page
  460. ' Input Variables: None
  461. ' Output Variables: None
  462. ' Return Values: None
  463. ' Global Variables: None
  464. '----------------------------------------------------------------------------
  465. Sub GotoAlertsPage()
  466. window.event.returnValue = false
  467. window.history.back
  468. End Sub
  469. -->
  470. </SCRIPT>
  471. </HEAD>
  472. <BODY RIGHTMARGIN=0 LEFTMARGIN=0>
  473. <A STYLE="position:absolute; top:0; left:0; font-size:10; font-family=arial;"
  474. ID="SaTask1" OnFocus="InvertSelection(1)" HIDEFOCUS=true onkeydown="KeyDown"
  475. OnBlur="InvertToNormal(1)">
  476. </A>
  477. <A STYLE="position:absolute; top:13; left:0; font-size:10; font-family=arial;"
  478. ID="SaTask2" OnFocus="InvertSelection(2)" HIDEFOCUS=true onkeydown="KeyDown"
  479. OnBlur="InvertToNormal(2)">
  480. </A>
  481. <A STYLE="position:absolute; top:26; left:0; font-size:10; font-family=arial;"
  482. ID="SaTask3" OnFocus="InvertSelection(3)" HIDEFOCUS=true onkeydown="KeyDown"
  483. OnBlur="InvertToNormal(3)">
  484. </A>
  485. <A STYLE="position:absolute; top:39; left:0; font-size:10; font-family=arial;"
  486. ID="SaTask4" OnFocus="InvertSelection(4)" HIDEFOCUS=true onkeydown="KeyDown"
  487. OnBlur="InvertToNormal(4)">
  488. </A>
  489. <A ID="SaPageInfo" STYLE="position:absolute; top:52; right:0; font-size:10;
  490. font-family=arial;">
  491. </A>
  492. <A STYLE="position:absolute; top:52; right:14; font-size:10; font-family=arial; display:none;"
  493. ID="SaAlertsLink" href="localui_main.htm" onkeydown="KeyDown" OnBlur="InvertToNormal(-1)"
  494. OnFocus="InvertSelection(-1)" OnClick="GotoAlertsPage()" HIDEFOCUS=true>
  495. </A>
  496. <IMG STYLE="position:absolute; bottom:0; right:0; display:none;"
  497. ID="SaAlertsIcon" SRC="localui_saalertsicon.bmp" BORDER=0>
  498. <INPUT TYPE=HIDDEN Name="CurrentPage" value="1">
  499. <INPUT TYPE=HIDDEN Name="CurrentTask" value="1">
  500. </BODY>
  501. </HTML>