common.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* $Id: common.js 3171 2007-08-06 20:52:00Z warion $ */
  2. var actionInProgress = false;
  3. var varRefresh;
  4. function initRefresh(refresh) {
  5. varRefresh = refresh;
  6. setTimeout("updateRefresh();", 1000);
  7. }
  8. function updateRefresh() {
  9. varRefresh--;
  10. if (varRefresh >= 0) {
  11. document.getElementById("span_refresh").innerHTML = String(varRefresh);
  12. setTimeout("updateRefresh();", 1000);
  13. }
  14. }
  15. function bulkCheck(thisIn) {
  16. ajax_updateState = 0;
  17. var form = thisIn.form, i = 0;
  18. for(i = 0; i < form.length; i++) {
  19. if (form[i].type == 'checkbox' && form[i].name != 'bulkBox' && form[i].disabled == false) {
  20. form[i].checked = thisIn.checked;
  21. }
  22. }
  23. }
  24. function showTransfer(name_file) {
  25. if (actionInProgress)
  26. return;
  27. window.open(name_file,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=400">')
  28. }
  29. function openServerMonitor() {
  30. if (actionInProgress)
  31. return;
  32. window.open('index.php?iid=servermon','_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=470,height=220')
  33. }
  34. function actionClick(showlabel,labeltext) {
  35. if (actionInProgress) {
  36. actionRequestError();
  37. return false;
  38. }
  39. actionRequest(showlabel,labeltext);
  40. return true;
  41. }
  42. function actionConfirm(question,labeltext) {
  43. if (actionInProgress) {
  44. actionRequestError();
  45. return false;
  46. } else {
  47. var confirmResult = confirm(question);
  48. if (confirmResult)
  49. actionRequest(true,labeltext);
  50. return confirmResult;
  51. }
  52. }
  53. function actionSubmit(labeltext) {
  54. if (actionInProgress) {
  55. actionRequestError();
  56. return false;
  57. }
  58. actionRequest(true,labeltext);
  59. return true;
  60. }
  61. function actionRequest(showlabel,labeltext) {
  62. actionInProgress = true;
  63. ajax_updateState = 0;
  64. if(window.ajax_unload) ajax_unload();
  65. if (showlabel) {
  66. var label = document.getElementById("action_in_progress");
  67. var gray_layer = document.getElementById("grey_out");
  68. if (label != null) {
  69. if(labeltext != null)
  70. {
  71. var label_span = document.getElementById("progress_label");
  72. if(label_span != null)
  73. label_span.innerHTML = labeltext;
  74. }
  75. if(gray_layer != null)
  76. {
  77. if(gray_layer.className == 'hidden')
  78. gray_layer.className = 'active';
  79. }
  80. if(label.className == 'hidden')
  81. {
  82. //only if using style.visibility (not style.display!!) we can center the div exactly
  83. label.className = 'active';
  84. center_div("action_in_progress",document.getElementById("action_in_progress").offsetWidth,document.getElementById("action_in_progress").offsetHeight);
  85. }
  86. else
  87. label.style.display = 'block';
  88. }
  89. }
  90. }
  91. function actionRequestError() {
  92. alert("Another Request in progress...");
  93. }
  94. function flux_clientWidth() {
  95. return flux_filterResults (
  96. window.innerWidth ? window.innerWidth : 0,
  97. document.documentElement ? document.documentElement.clientWidth : 0,
  98. document.body ? document.body.clientWidth : 0
  99. );
  100. }
  101. function flux_clientHeight() {
  102. return flux_filterResults (
  103. window.innerHeight ? window.innerHeight : 0,
  104. document.documentElement ? document.documentElement.clientHeight : 0,
  105. document.body ? document.body.clientHeight : 0
  106. );
  107. }
  108. function flux_scrollLeft() {
  109. return flux_filterResults (
  110. window.pageXOffset ? window.pageXOffset : 0,
  111. document.documentElement ? document.documentElement.scrollLeft : 0,
  112. document.body ? document.body.scrollLeft : 0
  113. );
  114. }
  115. function flux_scrollTop() {
  116. return flux_filterResults (
  117. window.pageYOffset ? window.pageYOffset : 0,
  118. document.documentElement ? document.documentElement.scrollTop : 0,
  119. document.body ? document.body.scrollTop : 0
  120. );
  121. }
  122. function flux_filterResults(n_win, n_docel, n_body) {
  123. var n_result = n_win ? n_win : 0;
  124. if (n_docel && (!n_result || (n_result > n_docel)))
  125. n_result = n_docel;
  126. return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
  127. }
  128. function center_div(name,w,h){
  129. var div = document.getElementById(name);
  130. if(div == null)
  131. return;
  132. // If using IE hack, nothing to do here (centering is done in CSS).
  133. if (div.currentStyle && div.currentStyle.position == 'absolute')
  134. return;
  135. div.style.position = "fixed";
  136. div.style.top = (( flux_clientHeight()/2 ) - ( h/2 )) + 'px';
  137. div.style.left = (( flux_clientWidth()/2 ) - ( w/2 )) + 'px';
  138. }
  139. String.prototype.Trim = function ()
  140. {
  141. return (this.replace(/\s+$/,"").replace(/^\s+/,""));
  142. };