home.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. //tollerance = 22;
  49. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  50. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance + 6) + "px");
  51. }
  52. }
  53. function delImg(id, path) {
  54. if (confirm("Do you really want to delete that picture?")) {
  55. $("#CommandLine").val("del " + path);
  56. frmHC.submit();
  57. }
  58. }
  59. function changeVisibility(id, path) {
  60. if ($("#lock-" + id).attr("src") === "/res/private.png") {
  61. $("#CommandLine").val("publicify " + path);
  62. } else {
  63. $("#CommandLine").val("privatify " + path);
  64. }
  65. frmHC.submit();
  66. }
  67. function makeNewFolder() {
  68. var newFolderName = prompt("How to name the new folder?");
  69. if (newFolderName != null) {
  70. $("#CommandLine").val("makedir " + newFolderName);
  71. frmHC.submit();
  72. }
  73. }
  74. function openLink(href, target) {
  75. window.open(href, target);
  76. }
  77. function changePath(newPath) {
  78. $("#pwd").val(newPath);
  79. frmHC.submit();
  80. }
  81. function showEncodedPassword() {
  82. if ($("#Password").val() === "") {
  83. $("#Password").addClass("emptyfield");
  84. return;
  85. }
  86. if ($("#Salt").val() === "") {
  87. $("#Salt").addClass("emptyfield");
  88. return;
  89. }
  90. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  91. msg = "Please set your hash in the config file with this value:";
  92. alert(msg + "\n\n" + passw);
  93. }
  94. function upload() {
  95. $("input#files").click();
  96. }
  97. $("input#files").on("change", function(e) {
  98. frmHC.submit();
  99. });
  100. $("#Password").on("keydown", function(e){
  101. $("#Password").removeClass("emptyfield");
  102. });
  103. $("#Salt").on("keydown", function(e){
  104. $("#Salt").removeClass("emptyfield");
  105. });
  106. window.addEventListener("load", function() {
  107. setTimeout("setFooterPos()", 3000);
  108. //document.getElementById("CommandLine").focus();
  109. }, true);
  110. window.addEventListener("resize", function() {
  111. setTimeout("setFooterPos()", 3000);
  112. }, true);