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.

403 lines
10 KiB

  1. // ==============================================================
  2. // Microsoft Server Appliance
  3. // Page-level JavaScript functions
  4. //
  5. // Copyright (c) 1999 - 2000 Microsoft Corporation. All rights reserved.
  6. // ==============================================================
  7. <!-- Copyright (c) 1999 - 2000 Microsoft Corporation. All rights reserved-->
  8. //-------------------------------------------------------------------------
  9. //
  10. // Function : SetNavBar
  11. //
  12. // Synopsis : Set tab location
  13. //
  14. // Arguments: TabNum(IN) - tab to set focus on
  15. //
  16. // Returns : None
  17. //
  18. //-------------------------------------------------------------------------
  19. function SetNavBar(TabNum) {
  20. if (window.parent.navbar.intCurrentTab != null) {
  21. if (window.parent.navbar.intCurrentTab != TabNum) {
  22. window.parent.navbar.location = "../navbar.asp?Tab=" + TabNum;
  23. }
  24. }
  25. else
  26. window.setTimeout('SetNavBar(' + TabNum + ');',50);
  27. }
  28. //-------------------------------------------------------------------------
  29. //
  30. // Function : GetCurrentTabURL
  31. //
  32. // Synopsis : Get the URL of the currently active tab
  33. //
  34. // Arguments: None
  35. //
  36. // Returns : None
  37. //
  38. //-------------------------------------------------------------------------
  39. function GetCurrentTabURL() {
  40. var strReturnURL;
  41. var strStart;
  42. var strEnd;
  43. var intTab;
  44. strReturnURL = document.location.search;
  45. strStart = strReturnURL.indexOf("Tab=");
  46. if (strStart != -1)
  47. {
  48. strEnd = strReturnURL.indexOf("&", strStart+4);
  49. if (strEnd != -1)
  50. {
  51. intTab = strReturnURL.substring(strStart+4, strEnd);
  52. }
  53. else
  54. {
  55. intTab = strReturnURL.substring(strStart+4, strReturnURL.length);
  56. }
  57. }
  58. if (intTab==null)
  59. {
  60. intTab=0;
  61. }
  62. return GetTabURL(intTab);
  63. }
  64. function ClickCurrentTab() {
  65. var intTab = window.parent.navbar.intCurrentTab;
  66. window.parent.navbar.ClickTab(intTab);
  67. }
  68. function SetFrameSet(PageURL) {
  69. if (window.parent == window) {
  70. window.parent.location = "../default.htm?Page=" + PageURL;
  71. }
  72. }
  73. function SetupMainPage(TabNum) {
  74. SetFrameSet(window.location.pathname);
  75. if (window.parent.navbar != null) {
  76. if (window.parent.navbar.intCurrentTab != null) {
  77. if (window.parent.navbar.intCurrentTab.value != TabNum)
  78. window.parent.navbar.location = "navbar.asp?Tab=" + TabNum;
  79. }
  80. else {
  81. top.main.navbar.location = "navbar.asp?Tab=" + TabNum;
  82. }
  83. }
  84. else
  85. window.parent.navbar = "navbar.asp";
  86. }
  87. function SetupAreaPage(TabNum) {
  88. if (window.parent == window) {
  89. window.parent.location = "../default.htm?Page=" + window.location.pathname;
  90. }
  91. if (window.parent.navbar != null)
  92. SetNavBar(TabNum);
  93. else
  94. window.parent.navbar = "navbar.asp";
  95. }
  96. function SetTargetURL(TargetURL) {
  97. // indicates the URL being navigated to,
  98. // uses a static variable in the hidden frame.
  99. if (top.hidden != null)
  100. top.hidden.Hidden.MainURL = TargetURL;
  101. }
  102. function GetTargetURL() {
  103. // returns the URL being navigated to,
  104. // or the current URL, depending on the timing
  105. // of the call.
  106. if (top.hidden != null)
  107. return top.hidden.Hidden.MainURL;
  108. else
  109. return '';
  110. }
  111. //-------------------------------------------------------------------------
  112. //
  113. // Function : OpenPage
  114. //
  115. // Synopsis : Open a specified URL and set its return URL
  116. //
  117. // Arguments: TaskURL(IN) - URL to open
  118. // ReturnURL(IN) - URL to mark as return URL for the TaskURL
  119. //
  120. // Returns : None
  121. //
  122. //-------------------------------------------------------------------------
  123. function OpenPage(TaskURL, ReturnURL)
  124. {
  125. // function: OpenPage
  126. // Builds a URL, adding a ReturnURL and a random
  127. // number(R), and sets the current window to open it.
  128. var strURL;
  129. var strCurrentURL;
  130. var strQueryString;
  131. var intReturnURLIndex;
  132. strURL = TaskURL;
  133. if (TaskURL.indexOf('?') != -1)
  134. {
  135. strURL += "&";
  136. }
  137. else
  138. {
  139. strURL += "?";
  140. }
  141. if (TaskURL.indexOf('ReturnURL') == -1)
  142. {
  143. if (ReturnURL == null)
  144. {
  145. strQueryString = window.location.search;
  146. i = strQueryString.indexOf('&R=');
  147. if (i != -1) {
  148. strQueryString=strQueryString.substring(0, i);
  149. }
  150. else
  151. {
  152. i = strQueryString.indexOf('?R=');
  153. if (i != -1) {
  154. strQueryString=strQueryString.substring(0, i);
  155. }
  156. }
  157. intReturnURLIndex = strQueryString.indexOf('ReturnURL');
  158. if (intReturnURLIndex != -1)
  159. {
  160. strQueryString = strQueryString.substring(0, intReturnURLIndex);
  161. }
  162. strCurrentURL = window.location.pathname + strQueryString;
  163. }
  164. else
  165. {
  166. strCurrentURL = ReturnURL;
  167. }
  168. strURL += "ReturnURL=";
  169. if (strCurrentURL.indexOf('/', 1) != -1 && strCurrentURL.substr('..',0,2) == -1)
  170. {
  171. strURL += "..";
  172. }
  173. strURL += strCurrentURL;
  174. }
  175. strURL += "&R=" + Math.random();
  176. strURL = "http://" + GetServerName() + "/" + strURL;
  177. top.location.href = strURL;
  178. return strURL;
  179. }
  180. //-------------------------------------------------------------------------
  181. //
  182. // Function : StartTask
  183. //
  184. // Synopsis : Open a specified URL as a task page and set its return URL
  185. //
  186. // Arguments: TaskURL(IN) - URL to open
  187. // ReturnURL(IN) - URL to mark as return URL for the TaskURL
  188. //
  189. // Returns : None
  190. //
  191. //-------------------------------------------------------------------------
  192. function StartTask(TaskURL, ReturnURL)
  193. {
  194. var strURL;
  195. var strCurrentURL = "";
  196. var strQueryString;
  197. var strFrameset;
  198. var i;
  199. var intReturnURLIndex;
  200. strURL = TaskURL;
  201. if (TaskURL.indexOf('ReturnURL') == -1)
  202. {
  203. if (ReturnURL == null)
  204. {
  205. strQueryString = window.location.search;
  206. i = strQueryString.indexOf('&R=');
  207. if (i != -1) {
  208. strQueryString=strQueryString.substring(0, i);
  209. }
  210. else
  211. {
  212. i = strQueryString.indexOf('?R=');
  213. if (i != -1) {
  214. strQueryString=strQueryString.substring(0, i);
  215. }
  216. }
  217. intReturnURLIndex = strQueryString.indexOf('ReturnURL');
  218. if (intReturnURLIndex != -1)
  219. {
  220. strQueryString = strQueryString.substring(0, i);
  221. }
  222. strCurrentURL = window.location.pathname + strQueryString;
  223. strCurrentURL = window.location.pathname;
  224. strCurrentURL += strQueryString;
  225. }
  226. else
  227. {
  228. strCurrentURL = ReturnURL;
  229. }
  230. }
  231. if (strCurrentURL != "")
  232. {
  233. if (TaskURL.indexOf('ReturnURL') == -1)
  234. {
  235. if (TaskURL.indexOf('?') != -1)
  236. {
  237. strURL += "&";
  238. }
  239. else
  240. {
  241. strURL += "?";
  242. }
  243. strURL += "ReturnURL=";
  244. if (strCurrentURL.indexOf('/', 1) != -1 && strCurrentURL.substr('..',0,2) == -1)
  245. {
  246. strURL += "..";
  247. }
  248. else
  249. {
  250. }
  251. strURL += strCurrentURL;
  252. }
  253. }
  254. strURL = 'http://' + GetServerName() + '/' + strURL;
  255. top.location.href = strURL;
  256. return strURL;
  257. }
  258. //-------------------------------------------------------------------------
  259. //
  260. // Function : GetServerName
  261. //
  262. // Synopsis : Return server name as specified in browser address bar
  263. //
  264. // Arguments: None
  265. //
  266. // Returns : server name object
  267. //
  268. //-------------------------------------------------------------------------
  269. function GetServerName() {
  270. return window.location.host;
  271. }
  272. //-------------------------------------------------------------------------
  273. //
  274. // Function : IsIE
  275. //
  276. // Synopsis : Is browser IE
  277. //
  278. // Arguments: None
  279. //
  280. // Returns : true/false
  281. //
  282. //-------------------------------------------------------------------------
  283. function IsIE() {
  284. if (navigator.userAgent.indexOf('IE')>-1)
  285. return true;
  286. else
  287. return false;
  288. }
  289. //-------------------------------------------------------------------------
  290. //
  291. // Function : IsAllSpaces
  292. //
  293. // Synopsis : is a string made up only of spaces
  294. //
  295. // Arguments: In(IN) - string to test
  296. //
  297. // Returns : true/false
  298. //
  299. //-------------------------------------------------------------------------
  300. function IsAllSpaces(In) {
  301. var strTest = In;
  302. var i;
  303. for(i=0;i<strTest.length;i++) {
  304. if(strTest.charAt(i) != " ")
  305. return false;
  306. }
  307. return true;
  308. }
  309. //-------------------------------------------------------------------------
  310. //
  311. // Function : Trim
  312. //
  313. // Synopsis : remove all spaces from a string
  314. //
  315. // Arguments: str(IN) - string to modify
  316. //
  317. // Returns : modified string
  318. //
  319. //-------------------------------------------------------------------------
  320. function Trim(str) {
  321. var res="", i, ch;
  322. for (i=0; i < str.length; i++) {
  323. ch = str.charAt(i);
  324. if (ch != ' '){
  325. res = res + ch;
  326. }
  327. }
  328. return res;
  329. }
  330. //-------------------------------------------------------------------------
  331. //
  332. // Function : LaunchHelp
  333. //
  334. // Synopsis : launch help file
  335. //
  336. // Arguments: None
  337. //
  338. // Returns : None
  339. //
  340. //-------------------------------------------------------------------------
  341. function LaunchHelp() {
  342. alert("See the Microsoft Server Appliance Kit SDK for instructions on adding a custom help file to your Windows(R) Powered server appliance.");
  343. }
  344. //-------------------------------------------------------------------------
  345. //
  346. // Function : BlurLayer
  347. //
  348. // Synopsis : hide layer
  349. //
  350. // Arguments: None
  351. //
  352. // Returns : None
  353. //
  354. //-------------------------------------------------------------------------
  355. function BlurLayer()
  356. {
  357. document.menu.visibility = "hide";
  358. }