HC.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * Copyright 2021, 2024 5 Mode
  3. *
  4. * This file is part of Http Console.
  5. *
  6. * Http Console is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Http Console is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Http Console. If not, see <https://www.gnu.org/licenses/>.
  18. *
  19. * home.js
  20. *
  21. * JS file for Home page
  22. *
  23. * @author Daniele Bonini <my25mb@aol.com>
  24. * @copyrights (c) 2021, 2024, the Open Gallery's contributors
  25. */
  26. function closeSplash() {
  27. $("#hideSplash").val("1");
  28. $("#splash").hide();
  29. }
  30. /**
  31. * Encrypt the given string
  32. *
  33. * @param {string} string - The string to encrypt
  34. * @returns {string} the encrypted string
  35. */
  36. function encryptSha2(string) {
  37. var jsSHAo = new jsSHA("SHA-256", "TEXT", 1);
  38. jsSHAo.update(string);
  39. return jsSHAo.getHash("HEX");
  40. }
  41. function setFooterPos() {
  42. if (document.getElementById("footerCont")) {
  43. if ($("#Password").val() === "") {
  44. tollerance = 48;
  45. } else {
  46. tollerance = 15;
  47. }
  48. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  49. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance ) + "px");
  50. }
  51. }
  52. function showEncodedPassword() {
  53. if ($("#Password").val() === "") {
  54. $("#Password").addClass("emptyfield");
  55. return;
  56. }
  57. if ($("#Salt").val() === "") {
  58. $("#Salt").addClass("emptyfield");
  59. return;
  60. }
  61. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  62. msg = "Please set your hash in the config file with this value:";
  63. alert(msg + "\n\n" + passw);
  64. }
  65. function upload() {
  66. $("input#files").click();
  67. }
  68. $("input#files").on("change", function(e) {
  69. frmHC.submit();
  70. });
  71. $("#Password").on("keydown", function(e){
  72. $("#Password").removeClass("emptyfield");
  73. });
  74. $("#Salt").on("keydown", function(e){
  75. $("#Salt").removeClass("emptyfield");
  76. });
  77. window.addEventListener("load", function() {
  78. setTimeout("setFooterPos()", 3000);
  79. document.getElementById("CommandLine").focus();
  80. }, true);
  81. window.addEventListener("resize", function() {
  82. setTimeout("setFooterPos()", 3000);
  83. }, true);