HC.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. function startApp() {
  31. if (document.getElementById("HCsplash")) {
  32. $("#HCsplash").hide();
  33. $("#frmHC").show();
  34. }
  35. }
  36. /**
  37. * Encrypt the given string
  38. *
  39. * @param {string} string - The string to encrypt
  40. * @returns {string} the encrypted string
  41. */
  42. function encryptSha2(string) {
  43. var jsSHAo = new jsSHA("SHA-256", "TEXT", 1);
  44. jsSHAo.update(string);
  45. return jsSHAo.getHash("HEX");
  46. }
  47. function setFooterPos() {
  48. if (document.getElementById("footerCont")) {
  49. tollerance = 25;
  50. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  51. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance ) + "px");
  52. }
  53. }
  54. function showEncodedPassword() {
  55. if ($("#Password").val() === "") {
  56. $("#Password").addClass("emptyfield");
  57. return;
  58. }
  59. if ($("#Salt").val() === "") {
  60. $("#Salt").addClass("emptyfield");
  61. return;
  62. }
  63. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  64. msg = "Please set your password in the config file with this value:";
  65. alert(msg + "\n\n" + passw);
  66. }
  67. function upload() {
  68. $("input#files").click();
  69. }
  70. $("input#files").on("change", function(e) {
  71. frmHC.submit();
  72. });
  73. $("#Password").on("keydown", function(e){
  74. $("#Password").removeClass("emptyfield");
  75. });
  76. $("#Salt").on("keydown", function(e){
  77. $("#Salt").removeClass("emptyfield");
  78. });
  79. window.addEventListener("load", function() {
  80. setTimeout("setFooterPos()", 3000);
  81. $(".footer").css("width", parseInt(window.innerWidth)+"px");
  82. $("#footerCont").css("width", parseInt(window.innerWidth)+"px");
  83. setTimeout("startApp()", 5000);
  84. document.getElementById("CommandLine").focus();
  85. }, true);
  86. window.addEventListener("resize", function() {
  87. setTimeout("setFooterPos()", 3000);
  88. $(".footer").css("width", parseInt(window.innerWidth)+"px");
  89. $("#footerCont").css("width", parseInt(window.innerWidth)+"px");
  90. }, true);