2
0

topic.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. Inno Setup
  3. Copyright (C) 1997-2025 Jordan Russell
  4. Portions by Martijn Laan
  5. For conditions of distribution and use, see LICENSE.TXT.
  6. JavaScript code used by topic_*.htm
  7. */
  8. window.onload = topic_loaded;
  9. var redirectBox = null;
  10. var topicRedirectURL;
  11. function get_viewport_element()
  12. {
  13. // On IE 6 in Standards mode & Firefox 1.5, properties like
  14. // scrollTop and clientHeight are set on document.documentElement.
  15. // On IE 5, they're on document.body; the ones on documentElement
  16. // are zero.
  17. if (document.documentElement.clientHeight) {
  18. return document.documentElement;
  19. } else {
  20. return document.body;
  21. }
  22. }
  23. function create_redirect_box()
  24. {
  25. redirectBox = document.createElement("div");
  26. redirectBox.id = "redirectbox";
  27. redirectBox.innerHTML = "Loading contents...";
  28. redirectBox.style.visibility = "hidden";
  29. document.body.appendChild(redirectBox);
  30. var viewport = get_viewport_element();
  31. redirectBox.style.left = Math.max(0, Math.floor(viewport.scrollLeft + (viewport.clientWidth - redirectBox.offsetWidth) / 2)) + "px";
  32. redirectBox.style.top = Math.max(0, Math.floor(viewport.scrollTop + (viewport.clientHeight - redirectBox.offsetHeight) / 2)) + "px";
  33. redirectBox.style.visibility = "";
  34. }
  35. function topic_loaded()
  36. {
  37. var matches;
  38. if (window == window.top &&
  39. (window.location.protocol == "http:" || window.location.protocol == "https:") &&
  40. (window.location.hostname == "jrsoftware.org" || window.location.hostname == "www.jrsoftware.org") &&
  41. (matches = window.location.pathname.match(/^(\/.+\/)topic_([a-z0-9_\-]+)\.htm$/)) &&
  42. window.location.hash != "#noredir") {
  43. topicRedirectURL = matches[1] + "index.php?topic=" + matches[2];
  44. if ((matches = window.location.hash.match(/^#([a-zA-Z0-9_\-.]+)$/))) {
  45. topicRedirectURL += "&anchor=" + matches[1];
  46. }
  47. create_redirect_box();
  48. window.setTimeout(topic_redirect, 1500);
  49. }
  50. // Inform parent frame (index.htm) that the topic changed
  51. if (window.parent) {
  52. if ((matches = window.location.pathname.match(/\/topic_([a-z0-9_\-]+)\.htm$/))) {
  53. window.parent.postMessage("ishelp_topic_loaded:" + matches[1], "*");
  54. }
  55. }
  56. }
  57. function topic_redirect()
  58. {
  59. document.body.removeChild(redirectBox);
  60. redirectBox = null;
  61. window.location.href = topicRedirectURL;
  62. }