espdefault.js 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. /*-----------------------------------------------------------------------
  17. Default ESP Script Functions
  18. **-----------------------------------------------------------------------*/
  19. /*-----------------------------------------------------------------------
  20. To be included in any ESP page that needs to prevent F5 from refreshing and
  21. resetting back to the home frameset.
  22. **-----------------------------------------------------------------------*/
  23. var isFF=/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)?1:0;
  24. var isChrome=/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)?1:0;
  25. function nof5() {
  26. if (parent.window.frames && parent.window.frames[0]) {
  27. //parent.window.frames[0].focus();
  28. for (var i_tem = 0; i_tem < parent.window.frames.length; i_tem++) {
  29. if (parent.window.frames[i_tem] == window) {
  30. if (isFF)
  31. parent.window.frames[i_tem].onkeypress = new Function("e", "if(e.keyCode==116){parent.window.frames[" + i_tem + "].location.replace(parent.window.frames[" + i_tem + "].location);e.preventDefault();e.stopPropagation();}")
  32. else
  33. parent.window.frames[i_tem].document.onkeydown = new Function("var e=parent.window.frames[" + i_tem + "].event; if(e.keyCode==116){parent.window.frames[" + i_tem + "].location.replace(parent.window.frames[" + i_tem + "].location);e.keyCode=0;return false;};");
  34. }
  35. }
  36. }
  37. setF5ForFrames();
  38. }
  39. function getAFrame(name) {
  40. var aFrame = null;
  41. if (parent.window.frames && parent.window.frames[0]) {
  42. for (var i_tem = 0; i_tem < parent.window.frames.length; i_tem++) {
  43. if (parent.window.frames[i_tem].name == name)
  44. aFrame = parent.window.frames[i_tem];
  45. }
  46. }
  47. return aFrame;
  48. }
  49. function setF5ForFrames() {
  50. var headerFrame = getAFrame('header');
  51. if (headerFrame) {
  52. if (isFF)
  53. headerFrame.onkeypress = new Function("e", "if(e.keyCode==116){getAFrame('main').location.replace(getAFrame('main').location);e.preventDefault();e.stopPropagation();}")
  54. else
  55. headerFrame.document.onkeydown = new Function("var e=getAFrame('header').event; if(e.keyCode==116){getAFrame('main').location.replace(getAFrame('main').location);e.keyCode=0;return false;};");
  56. }
  57. var navFrame = getAFrame('nav');
  58. if (navFrame) {
  59. if (isFF)
  60. navFrame.onkeypress = new Function("e", "if(e.keyCode==116){getAFrame('main').location.replace(getAFrame('main').location);e.preventDefault();e.stopPropagation();}")
  61. else
  62. navFrame.document.onkeydown = new Function("var e=getAFrame('nav').event; if(e.keyCode==116){getAFrame('main').location.replace(getAFrame('main').location);e.keyCode=0;return false;};");
  63. }
  64. }
  65. function setReloadFunction(TargetFunction) {
  66. var LocalReloadFunction = (TargetFunction.indexOf('(') > -1 ? TargetFunction : TargetFunction + '()');
  67. if (parent.window.frames && parent.window.frames[0]) {
  68. //parent.window.frames[0].focus();
  69. for (var i_tem = 0; i_tem < parent.window.frames.length; i_tem++) {
  70. if (parent.window.frames[i_tem] == window) {
  71. if (isFF)
  72. parent.window.frames[i_tem].onkeypress = new Function("e", "if(e.keyCode==116){" + LocalReloadFunction + ";e.preventDefault();e.stopPropagation();}")
  73. else
  74. parent.window.frames[i_tem].document.onkeydown = new Function("var e=parent.window.frames[" + i_tem + "].event; if(e.keyCode==116){e.keyCode=0;" + LocalReloadFunction + ";return false;};");
  75. }
  76. }
  77. }
  78. }
  79. function go(url) {
  80. document.location.href = url;
  81. }