get_input.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*##############################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################## */
  16. // Get input using window
  17. var gInputWnd;
  18. var gWndObjInterval;
  19. var gWndObj = new Object;
  20. gWndObj.value = '';
  21. gWndObj.eventhandler = '';
  22. function gWndObjMaintainFocus()
  23. {
  24. try {
  25. if (gInputWnd.closed) {
  26. window.clearInterval(gWndObjInterval);
  27. eval(gWndObj.eventhandler);
  28. return;
  29. }
  30. gInputWnd.focus();
  31. }
  32. catch (everything) { }
  33. }
  34. function gWndObjRemoveWatch()
  35. {
  36. gWndObj.value = '';
  37. gWndObj.eventhandler = '';
  38. }
  39. function gWndObjShow(Title,BodyText,EventHandler)
  40. {
  41. gWndObjRemoveWatch();
  42. gWndObj.eventhandler = EventHandler;
  43. var args='width=600,height=405,left=200,top=200,toolbar=0,';
  44. args+='location=0,status=0,menubar=0,scrollbars=0,resizable=0';
  45. gInputWnd=window.open("","",args);
  46. gInputWnd.document.open();
  47. var html = '<html><head><title>' + Title + '</title>'
  48. + '<script language="JavaScript">\n'
  49. + 'function CloseForm(Response) {\n'
  50. +' window.opener.gWndObj.value = Response; \n'
  51. + 'window.close(); \n'
  52. +'} \n'
  53. + 'function onClose(ok) { var val = ""; if (ok) { var ctrl = document.getElementById("textarea1"); val = ctrl.value; } CloseForm(val); return true; }\n'
  54. + 'function onFocus() { document.getElementById("textarea1").focus(); }\n'
  55. + 'function onLoad() { onFocus(); document.onfocusin=onFocus; }\n'
  56. + '</script' + '>\n'
  57. + '</head>\n'
  58. // this cause IE textarea readonly
  59. //+ '<body onblur="window.focus();">\n'
  60. + '<body onload="onLoad()" onunload="onClose(0)">\n'
  61. + '<form> <table border="0" width="95%" align="center" cellspacing="0" cellpadding="2">\n'
  62. + '<tr><td align="left">' + BodyText + '</td></tr>'
  63. + '<tr><td align="left"><br/></td></tr>'
  64. +'<tr><td align="center"> <textarea id="textarea1" rows="18" cols="65"></textarea></td></tr>'
  65. //+'<tr><td> <textarea id="textarea1" style="width:100%; overflow:visible" rows="18"></textarea></td></tr>'
  66. + '<tr><td align="center"> <input type="submit" value="Submit" onclick="onClose(1)"/> <input type="submit" value="Cancel" onclick="onClose(0)"/></td></tr>'
  67. + '</table></form>'
  68. + '</body></html>';
  69. gInputWnd.document.write(html);
  70. gInputWnd.document.close();
  71. gInputWnd.focus();
  72. gWndObjInterval = window.setInterval("gWndObjMaintainFocus()",5);
  73. }
  74. function showGetInputWnd(BodyText,EventHandler)
  75. {
  76. gWndObjShow("Dialog",BodyText,EventHandler);
  77. }