index.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /**
  2. * Copyright 2021, 2024 5 Mode
  3. *
  4. * This file is part of Homomm.
  5. *
  6. * Homomm 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. * Homomm 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 Homomm. 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. var bBurgerMenuVisible = false;
  27. var bSideBarVisible = false;
  28. $(document).ready(function() {
  29. $("#Password").on("keydown",function(e){
  30. key = e.which;
  31. //alert(key);
  32. $("#chatHint").val("");
  33. if (key===13) {
  34. e.preventDefault();
  35. frmHC.submit();
  36. } else {
  37. $("#Password2").val($(this).val());
  38. //e.preventDefault();
  39. }
  40. });
  41. $("#Password2").on("keydown",function(e){
  42. key = e.which;
  43. //alert(key);
  44. $("#chatHint").val("");
  45. if (key===13) {
  46. e.preventDefault();
  47. $("#Password").val("");
  48. frmHC.submit();
  49. } else {
  50. //e.preventDefault();
  51. }
  52. });
  53. $("#MessageLine").on("keydown",function(e){
  54. key = e.which;
  55. //alert(key);
  56. if (key===13) {
  57. //e.preventDefault();
  58. //sendMessage()
  59. } else {
  60. //e.preventDefault();
  61. }
  62. });
  63. });
  64. $("#burger-menu").on("click",function(){
  65. if (!bBurgerMenuVisible) {
  66. $(".friend-header").css("display", "table");
  67. } else {
  68. $(".friend-header").css("display", "none");
  69. }
  70. bBurgerMenuVisible=!bBurgerMenuVisible;
  71. });
  72. function hideBurgerMenu() {
  73. $(".friend-header").css("display", "none");
  74. bBurgerMenuVisible=false;
  75. }
  76. function showSideBar() {
  77. if (!bSideBarVisible) {
  78. $("#contentbar").css("width","100%");
  79. $("#sidebar").show("slow");
  80. }
  81. bSideBarVisible = true;
  82. }
  83. function closeSideBar() {
  84. $("#sidebar").hide();
  85. $("#contentbar").css("width","100%");
  86. bSideBarVisible = false;
  87. }
  88. $("#call-sidebar").on("mouseover", function() {
  89. //alert("hello");
  90. showSideBar();
  91. });
  92. function closeSplash() {
  93. $("#hideSplash").val("1");
  94. $("#splash").hide();
  95. }
  96. function refresh() {
  97. $("#CommandLine").val("refreshbrd");
  98. frmHC.submit();
  99. }
  100. function delSign(sign) {
  101. $("#CommandLine").val("del '" + sign + "'");
  102. frmHC.submit();
  103. }
  104. function confSign(sign) {
  105. $("#CommandLine").val("conf '" + sign + "'");
  106. frmHC.submit();
  107. }
  108. function sendSign() {
  109. $("#CommandLine").val("sign");
  110. frmHC.submit();
  111. }
  112. $("#send").on("click",function(){
  113. sendSign();
  114. });
  115. function deletePic(pic) {
  116. $("#CommandLine").val("delpic " + pic);
  117. frmHC.submit();
  118. }
  119. function deleteMsg(msg) {
  120. $("#CommandLine").val("delmsg " + msg);
  121. frmHC.submit();
  122. }
  123. function openPic(pic) {
  124. $("#CommandLine").val("openpic " + pic);
  125. frmHC.submit();
  126. }
  127. function setContentPos() {
  128. if (window.innerWidth<650) {
  129. $("#ahome").attr("href","/");
  130. $("#agithub").css("display","none");
  131. $("#afeedback").css("display","none");
  132. $("#asupport").css("display","none");
  133. $("#pwd2").css("display","inline");
  134. //$("#sidebar").css("display","none");
  135. $("#burger-menu").css("display","inline");
  136. //$("#contentbar").css("width","100%");
  137. $("#logo-hmm").css("display","none");
  138. } else {
  139. $("#ahome").attr("href","http://homomm.org");
  140. $("#agithub").css("display","inline");
  141. $("#afeedback").css("display","inline");
  142. $("#asupport").css("display","inline");
  143. $("#pwd2").css("display","none");
  144. //$("#sidebar").css("display","inline");
  145. $("#burger-menu").css("display","none");
  146. //$("#contentbar").css("width","75%");
  147. $("#logo-hmm").css("display","inline");
  148. }
  149. hideBurgerMenu();
  150. //window.scroll(0, 0);
  151. //$(document.body).css("overflow-y", "hidden");
  152. }
  153. function setFooterPos() {
  154. //if (document.getElementById("footerCont")) {
  155. //if ($("#Password").val() === "") {
  156. // tollerance = 48;
  157. //} else {
  158. tollerance = 15;
  159. //}
  160. if (window.innerWidth<450) {
  161. $(".no-sm").css("display", "none");
  162. } else {
  163. $(".no-sm").css("display", "inline");
  164. }
  165. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  166. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance ) + "px");
  167. //}
  168. }
  169. function showEncodedPassword() {
  170. if ($("#Password").val() === "") {
  171. $("#Password").addClass("emptyfield");
  172. return;
  173. }
  174. if ($("#Salt").val() === "") {
  175. $("#Salt").addClass("emptyfield");
  176. return;
  177. }
  178. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  179. msg = "Please set your hash in the config file with this value:";
  180. alert(msg + "\n\n" + passw);
  181. }
  182. $("input#files").on("change", function(e) {
  183. if (!document.getElementById("files").files) {
  184. $("#del-attach").css("display", "none");
  185. } else {
  186. $("#del-attach").css("display", "inline");
  187. }
  188. //frmHC.submit();
  189. });
  190. function clearUpload() {
  191. $("#upload-cont").html("<input id='files' name='files[]' type='file' accept='.gif,.png,.jpg,.jpeg' style='visibility: hidden;' multiple>");
  192. $("#del-attach").css("display", "none");
  193. }
  194. $("#Password").on("keydown", function(e){
  195. $("#Password").removeClass("emptyfield");
  196. });
  197. $("#Salt").on("keydown", function(e){
  198. $("#Salt").removeClass("emptyfield");
  199. });
  200. window.addEventListener("load", function() {
  201. if ($("#frmHC").css("display")==="none") {
  202. setTimeout("setContentPos()", 5200);
  203. //setTimeout("setFooterPos()", 5300);
  204. } else {
  205. setTimeout("setContentPos()", 1000);
  206. //setTimeout("setFooterPos()", 2000);
  207. }
  208. }, true);
  209. window.addEventListener("resize", function() {
  210. if ($("#frmHC").css("display")==="none") {
  211. setTimeout("setContentPos()", 5200);
  212. //setTimeout("setFooterPos()", 5300);
  213. } else {
  214. setTimeout("setContentPos()", 1000);
  215. //setTimeout("setFooterPos()", 2000);
  216. }
  217. }, true);