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.

153 lines
4.1 KiB

  1. //
  2. // Microsoft Server Appliance - Quotas Support Functions
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. //
  5. // to check for maximum allowed warning size for the given Units
  6. function checkSizeAndUnits( Size, Units)
  7. {
  8. // Units can be any one of "KB","MB","GB","TB","PB","EB" only.
  9. if (Units =="GB"){
  10. if (Size > 999999999) return false;
  11. }
  12. if (Units =="TB"){
  13. if (Size > 999999) return false;
  14. }
  15. if (Units =="PB"){
  16. if (Size > 999) return false;
  17. }
  18. if (Units =="EB"){
  19. if (Size > 6) return false;
  20. }
  21. return true;
  22. }
  23. // to allow only Number to display on key press
  24. function allownumbers( obj )
  25. {
  26. if(window.event.keyCode == 13)
  27. return true;
  28. if ( !( window.event.keyCode >=48 && window.event.keyCode <=57 )) //|| window.event.keyCode == 46 ) )
  29. {
  30. window.event.keyCode = 0;
  31. obj.focus();
  32. }
  33. }
  34. // to check whether Minimum of 1 KB is Allowed in Warning Limit Text Box.
  35. function validatedisklimit(objsize, limitunit)
  36. {
  37. if ( objsize.value < 1 && limitunit == "KB" )
  38. objsize.value = 1;
  39. }
  40. // Disable the text box and list if 1st radio checked
  41. function DisableWarnLevel(objThresholdSize,objThresholdUnits)
  42. {
  43. //var L_NOLIMIT_TEXT = "No Limit";
  44. ClearErr();
  45. // stmts to remove the select() and write "No Limit" if first radio checked
  46. if( isNaN(objThresholdSize.value) || objThresholdSize.value == "" )
  47. objThresholdSize.value = "1" ; // "No Limit"
  48. // disable the fields
  49. objThresholdSize.disabled = true;
  50. objThresholdUnits.disabled = true;
  51. }
  52. // Enable the text box and list if 2nd radio checked
  53. function EnableWarnDiskSpace(objThresholdSize, objThresholdUnits)
  54. {
  55. ClearErr();
  56. objThresholdSize.disabled = false;
  57. objThresholdUnits.disabled = false;
  58. if( isNaN(objThresholdSize.value ) )
  59. objThresholdSize.value = "1" ;
  60. selectFocus(objThresholdSize);
  61. }
  62. // Disable the text box and list if 1st radio checked
  63. function DisableLimitLevel(objLimitSize, objLimitSizeUnits)
  64. {
  65. //var L_NOLIMIT_TEXT = "";
  66. ClearErr();
  67. // stmts to remove the select() and write "No Limit" if first radio checked
  68. if( isNaN(objLimitSize.value) || objLimitSize.value == "" )
  69. objLimitSize.value = "1" ; // "No Limit"
  70. // disable the fields
  71. objLimitSize.disabled = true;
  72. objLimitSizeUnits.disabled = true;
  73. }
  74. // Disable the text box and list if 1st radio checked
  75. function DisableLimitLevelForAdmin(objLimitSize, objLimitSizeUnits)
  76. {
  77. //var L_NOLIMIT_TEXT = "";
  78. ClearErr();
  79. // stmts to remove the select() and write "No Limit" if first radio checked
  80. if( isNaN(objLimitSize.value) || objLimitSize.value == "" )
  81. objLimitSize.value = "No Limit";
  82. // disable the fields
  83. objLimitSize.disabled = true;
  84. objLimitSizeUnits.disabled = true;
  85. }
  86. // Enable the text box and list if 2nd radio checked
  87. function EnableLimitDiskSpace(objLimitSize, objLimitSizeUnits)
  88. {
  89. ClearErr();
  90. objLimitSize.disabled = false;
  91. objLimitSizeUnits.disabled = false;
  92. if( isNaN( objLimitSize.value ) )
  93. objLimitSize.value = "1" ;
  94. selectFocus(objLimitSize);
  95. }
  96. // to validate if the field is of numeric type
  97. function isSizeValidDataType(textValue)
  98. {
  99. if ( isNaN(textValue) || (parseFloat(textValue) <= 0) || textValue.length == 0 )
  100. {
  101. return false;
  102. }
  103. return true;
  104. }
  105. // to verify if the warning level is greater than Limit
  106. function isWarningMoreThanLimit(objLimit,objLimitUnits,objWarnLimit,objWarnUnits)
  107. {
  108. var nLimitInFloat = changeToFloat(objLimit.value, objLimitUnits.value);
  109. var nThresholdInFloat = changeToFloat(objWarnLimit.value, objWarnUnits.value);
  110. if(nThresholdInFloat >nLimitInFloat)
  111. {
  112. return true;
  113. }
  114. return false;
  115. }
  116. // to convert to float Value
  117. function changeToFloat(nLimit, strUnits)
  118. {
  119. var arrUnits = ["KB","MB","GB","TB","PB","EB"];
  120. var nSizeOfArr = arrUnits.length ;
  121. for(var i=0;i<nSizeOfArr;i++)
  122. {
  123. if(arrUnits[i] == strUnits)
  124. {
  125. var nFloatValue = parseFloat(nLimit *(Math.pow(2,((i+1)*10))));
  126. return nFloatValue;
  127. }
  128. }
  129. }