index.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /**
  2. * Copyright 2021, 2024 5 Mode
  3. *
  4. * This file is part of StarWorth.
  5. *
  6. * StarWorth 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. * StarWorth 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 StarWorth. If not, see <https://www.gnu.org/licenses/>.
  18. *
  19. * index.js
  20. *
  21. * StarWorth JS file for Home
  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. $("#content-bar").css("width","100%");
  79. $("#sidebar").show("slow");
  80. }
  81. bSideBarVisible = true;
  82. }
  83. function closeSideBar() {
  84. $("#sidebar").hide();
  85. $("#content-bar").css("width","100%");
  86. bSideBarVisible = false;
  87. }
  88. $("#call-sidebar").on("mouseover", function() {
  89. showSideBar();
  90. });
  91. function closeSplash() {
  92. $("#hideSplash").val("1");
  93. $("#splash").hide();
  94. }
  95. function refresh() {
  96. $("#CommandLine").val("refreshbrd");
  97. frmHC.submit();
  98. }
  99. function delSign(sign) {
  100. $("#CommandLine").val("del '" + sign + "'");
  101. frmHC.submit();
  102. }
  103. function confSign(sign) {
  104. $("#CommandLine").val("conf '" + sign + "'");
  105. frmHC.submit();
  106. }
  107. function setStar(sign) {
  108. $("#CommandLine").val("set '" + sign + "'");
  109. frmHC.submit();
  110. }
  111. function sendSign() {
  112. var val = "";
  113. val = $("#date").val().trim();
  114. if (val=="" || val.length<4) {
  115. $("#date").addClass("emptyfield");
  116. return;
  117. }
  118. val = $("#desc").val().trim();
  119. if (val=="" || val.length<4) {
  120. $("#desc").addClass("emptyfield");
  121. return;
  122. }
  123. $("#CommandLine").val("sign");
  124. frmHC.submit();
  125. }
  126. $("#send").on("click",function() {
  127. $("#date").removeClass("emptyfield");
  128. $("#desc").removeClass("emptyfield");
  129. sendSign();
  130. });
  131. function setContentPos() {
  132. if (window.innerWidth<650) {
  133. $("#ahome").attr("href","/");
  134. $("#agithub").css("display","none");
  135. $("#afeedback").css("display","none");
  136. $("#asupport").css("display","none");
  137. $("#pwd2").css("display","inline");
  138. //$("#sidebar").css("display","none");
  139. $("#burger-menu").css("display","inline");
  140. //$("#contentbar").css("width","100%");
  141. $("#logo-hl").css("display","none");
  142. } else {
  143. $("#ahome").attr("href","http://starworth.5mode-foss.eu");
  144. $("#agithub").css("display","inline");
  145. $("#afeedback").css("display","inline");
  146. $("#asupport").css("display","inline");
  147. $("#pwd2").css("display","none");
  148. //$("#sidebar").css("display","inline");
  149. $("#burger-menu").css("display","none");
  150. //$("#contentbar").css("width","75%");
  151. $("#logo-hl").css("display","inline");
  152. }
  153. //table-event
  154. if (window.innerWidth<1250) {
  155. $(".table-event").css("margin-left","2%");
  156. $(".table-event").css("width","98%");
  157. $(".table-event").css("min-width","700px");
  158. } else {
  159. $(".table-event").css("margin-left","33%");
  160. $(".table-event").css("width","62%");
  161. $(".table-event").css("min-width","900px");
  162. $(".table-event").css("max-width","900px");
  163. }
  164. hideBurgerMenu();
  165. }
  166. function setFooterPos2() {
  167. if (document.getElementById("footerCont")) {
  168. tollerance = 16;
  169. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance) + "px");
  170. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance) + "px");
  171. }
  172. }
  173. function showEncodedPassword() {
  174. if ($("#Password").val() === "") {
  175. $("#Password").addClass("emptyfield");
  176. return;
  177. }
  178. if ($("#Salt").val() === "") {
  179. $("#Salt").addClass("emptyfield");
  180. return;
  181. }
  182. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  183. msg = "Please set your hash in the config file with this value:";
  184. alert(msg + "\n\n" + passw);
  185. }
  186. $("input#files").on("change", function(e) {
  187. if (!document.getElementById("files").files) {
  188. $("#del-attach").css("display", "none");
  189. } else {
  190. $("#del-attach").css("display", "inline");
  191. }
  192. //frmHC.submit();
  193. });
  194. function clearUpload() {
  195. $("#upload-cont").html("<input id='files' name='files[]' type='file' accept='.gif,.png,.jpg,.jpeg' style='visibility: hidden;' multiple>");
  196. $("#del-attach").css("display", "none");
  197. }
  198. $("#Password").on("keydown", function(e){
  199. $("#Password").removeClass("emptyfield");
  200. });
  201. $("#Salt").on("keydown", function(e){
  202. $("#Salt").removeClass("emptyfield");
  203. });
  204. window.addEventListener("load", function() {
  205. if ($("#frmHC").css("display")==="none") {
  206. setTimeout("setContentPos()", 5200);
  207. setTimeout("setFooterPos2()", 500);
  208. } else {
  209. setTimeout("setContentPos()", 1000);
  210. setTimeout("setFooterPos2()", 500);
  211. }
  212. }, true);
  213. window.addEventListener("resize", function() {
  214. if ($("#frmHC").css("display")==="none") {
  215. setTimeout("setContentPos()", 5200);
  216. setTimeout("setFooterPos2()", 500);
  217. } else {
  218. setTimeout("setContentPos()", 1000);
  219. setTimeout("setFooterPos2()", 500);
  220. }
  221. }, true);