common.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) 2016, 2024, 5 Mode
  3. * All rights reserved.
  4. *
  5. * This file is part of Avatar Free.
  6. *
  7. * Avatar Free 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. * Avatar Free 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 Avatar Free. If not, see <https://www.gnu.org/licenses/>.
  19. * config.inc
  20. *
  21. * Avatar Free common javascript code.
  22. *
  23. * @author Daniele Bonini <my25mb@aol.com>
  24. * @copyrights (c) 2021, 2024, 5 Mode
  25. */
  26. function closeMe(tthis) {
  27. $(tthis).parent().hide();
  28. }
  29. /**
  30. * Encrypt the given string
  31. *
  32. * @param {string} string - The string to encrypt
  33. * @returns {string} the encrypted string
  34. */
  35. function encryptSha2(string) {
  36. var jsSHAo = new jsSHA("SHA-256", "TEXT", 1);
  37. jsSHAo.update(string);
  38. return jsSHAo.getHash("HEX");
  39. }
  40. function rnd(min, max) {
  41. min = Math.ceil(min);
  42. max = Math.floor(max);
  43. return Math.floor(Math.random() * (max - min +1)) + min;
  44. }
  45. /**
  46. * Open a link from any event handler
  47. *
  48. * @param {string} href the link to open
  49. * @param {string} target the frame target
  50. * @returns {none}
  51. */
  52. function openLink(href, target) {
  53. window.open(href, target);
  54. }