index.js 7.0 KB

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