common.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright (c) 2016, 2024, 5 Mode
  3. * All rights reserved.
  4. *
  5. * This file is part of LightOff.
  6. *
  7. * LightOff is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * LightOff is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with LightOff. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * Common javascript code.
  21. *
  22. * @author Daniele Bonini <my25mb@aol.com>
  23. * @copyrights (c) 2021, 2024, 5 Mode
  24. */
  25. function LIGHTOFFcloseMe(tthis) {
  26. $(tthis).parent().hide();
  27. }
  28. /**
  29. * Get the height of the whole document
  30. *
  31. * @param {none}
  32. * @returns {int} the document height
  33. */
  34. function LIGHTOFFgetDocHeight() {
  35. var D = document;
  36. return Math.max(
  37. D.body.scrollHeight, D.documentElement.scrollHeight,
  38. D.body.offsetHeight, D.documentElement.offsetHeight,
  39. D.body.clientHeight, D.documentElement.clientHeight
  40. );
  41. }
  42. function LIGHTOFFgetDocHeight2() {
  43. var D = document;
  44. var scrollMaxY;
  45. if (window.scrollMaxY) {
  46. scrollMaxY = window.scrollMaxY;
  47. } else {
  48. scrollMaxY = D.documentElement.scrollHeight;
  49. }
  50. var height = Math.max(
  51. D.body.scrollHeight, scrollMaxY,
  52. D.body.offsetHeight, D.documentElement.offsetHeight,
  53. D.body.clientHeight, D.documentElement.clientHeight
  54. );
  55. return height;
  56. }
  57. /**
  58. * Get the width of the whole document
  59. *
  60. * @param {none}
  61. * @returns {int} the document width
  62. */
  63. function LIGHTOFFgetDocWidth() {
  64. var D = document;
  65. return Math.max(
  66. D.body.scrollWidth, D.documentElement.scrollWidth,
  67. D.body.offsetWidth, D.documentElement.offsetWidth,
  68. D.body.clientWidth, D.documentElement.clientWidth
  69. );
  70. }
  71. function LIGHTOFFgetDocWidth2() {
  72. var D = document;
  73. var scrollMaxX;
  74. if (window.scrollMaxX) {
  75. scrollMaxX = window.scrollMaxX;
  76. } else {
  77. scrollMaxX = D.documentElement.scrollWidth;
  78. }
  79. return Math.max(
  80. D.body.scrollWidth, scrollMaxX,
  81. D.body.offsetWidth, D.documentElement.offsetWidth,
  82. D.body.clientWidth, D.documentElement.clientWidth
  83. );
  84. }
  85. function LIGHTOFFrnd(min, max) {
  86. min = Math.ceil(min);
  87. max = Math.floor(max);
  88. return Math.floor(Math.random() * (max - min +1)) + min;
  89. }