index.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /**
  2. * Copyright 2021, 2024 5 Mode
  3. *
  4. * This file is part of Actitude.
  5. *
  6. * Actitude 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. * Actitude 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 Actitude. 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. var val = "";
  110. val = $("#name").val().trim();
  111. if (val=="" || val.length<3) {
  112. $("#name").addClass("emptyfield");
  113. return;
  114. }
  115. val = $("#place").val().trim();
  116. if (val=="" || val.length<3) {
  117. $("#place").addClass("emptyfield");
  118. return;
  119. }
  120. $("#CommandLine").val("sign");
  121. frmHC.submit();
  122. }
  123. $("#send").on("click",function() {
  124. $("#name").removeClass("emptyfield");
  125. $("#name").removeClass("emptyfield");
  126. sendSign();
  127. });
  128. function setContentPos() {
  129. if (window.innerWidth<650) {
  130. $("#ahome").attr("href","/");
  131. $("#agithub").css("display","none");
  132. $("#afeedback").css("display","none");
  133. $("#asupport").css("display","none");
  134. $("#pwd2").css("display","inline");
  135. //$("#sidebar").css("display","none");
  136. $("#burger-menu").css("display","inline");
  137. //$("#contentbar").css("width","100%");
  138. $("#logo-hmm").css("display","none");
  139. } else {
  140. $("#ahome").attr("href","http://actitude.5mode.com");
  141. $("#agithub").css("display","inline");
  142. $("#afeedback").css("display","inline");
  143. $("#asupport").css("display","inline");
  144. $("#pwd2").css("display","none");
  145. //$("#sidebar").css("display","inline");
  146. $("#burger-menu").css("display","none");
  147. //$("#contentbar").css("width","75%");
  148. $("#logo-hmm").css("display","inline");
  149. }
  150. hideBurgerMenu();
  151. //window.scroll(0, 0);
  152. //$(document.body).css("overflow-y", "hidden");
  153. }
  154. function setFooterPos() {
  155. //if (document.getElementById("footerCont")) {
  156. //if ($("#Password").val() === "") {
  157. // tollerance = 48;
  158. //} else {
  159. tollerance = 15;
  160. //}
  161. if (window.innerWidth<450) {
  162. $(".no-sm").css("display", "none");
  163. } else {
  164. $(".no-sm").css("display", "inline");
  165. }
  166. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  167. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance ) + "px");
  168. //}
  169. }
  170. function showEncodedPassword() {
  171. if ($("#Password").val() === "") {
  172. $("#Password").addClass("emptyfield");
  173. return;
  174. }
  175. if ($("#Salt").val() === "") {
  176. $("#Salt").addClass("emptyfield");
  177. return;
  178. }
  179. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  180. msg = "Please set your hash in the config file with this value:";
  181. alert(msg + "\n\n" + passw);
  182. }
  183. $("input#files").on("change", function(e) {
  184. if (!document.getElementById("files").files) {
  185. $("#del-attach").css("display", "none");
  186. } else {
  187. $("#del-attach").css("display", "inline");
  188. }
  189. //frmHC.submit();
  190. });
  191. function clearUpload() {
  192. $("#upload-cont").html("<input id='files' name='files[]' type='file' accept='.gif,.png,.jpg,.jpeg' style='visibility: hidden;' multiple>");
  193. $("#del-attach").css("display", "none");
  194. }
  195. $("#Password").on("keydown", function(e){
  196. $("#Password").removeClass("emptyfield");
  197. });
  198. $("#Salt").on("keydown", function(e){
  199. $("#Salt").removeClass("emptyfield");
  200. });
  201. window.addEventListener("load", function() {
  202. if ($("#frmHC").css("display")==="none") {
  203. setTimeout("setContentPos()", 5200);
  204. //setTimeout("setFooterPos()", 5300);
  205. } else {
  206. setTimeout("setContentPos()", 1000);
  207. //setTimeout("setFooterPos()", 2000);
  208. }
  209. }, true);
  210. window.addEventListener("resize", function() {
  211. if ($("#frmHC").css("display")==="none") {
  212. setTimeout("setContentPos()", 5200);
  213. //setTimeout("setFooterPos()", 5300);
  214. } else {
  215. setTimeout("setContentPos()", 1000);
  216. //setTimeout("setFooterPos()", 2000);
  217. }
  218. }, true);