index.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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. //$(document.body).css("background","#a38873");
  134. $(document.body).css("background","url('/SW_res/sw_bgm1.jpg') fixed");
  135. $(document.body).css("background-size","100 100");
  136. $(document.body).css("background-position","30% 0%");
  137. $("#ahome").attr("href","/");
  138. $("#agithub").css("display","none");
  139. $("#afeedback").css("display","none");
  140. $("#asupport").css("display","none");
  141. $("#pwd2").css("display","inline");
  142. //$("#sidebar").css("display","none");
  143. $("#burger-menu").css("display","none");
  144. //$("#content-bar").css("width","100%");
  145. $("#logo-hl").css("display","none");
  146. $(".td-data-date").hide();
  147. $(".td-data-time").hide();
  148. } else {
  149. $(document.body).css("background","url('/SW_res/sw_bg1.jpg') fixed");
  150. $(document.body).css("background-size","cover");
  151. $(document.body).css("background-position","left top");
  152. $("#ahome").attr("href","http://starworth.5mode-foss.eu");
  153. $("#agithub").css("display","inline");
  154. $("#afeedback").css("display","inline");
  155. $("#asupport").css("display","inline");
  156. $("#pwd2").css("display","none");
  157. //$("#sidebar").css("display","inline");
  158. $("#burger-menu").css("display","none");
  159. //$("#content-bar").css("width","75%");
  160. $("#logo-hl").css("display","inline");
  161. $(".td-data-date").show();
  162. $(".td-data-time").show();
  163. }
  164. //table-event
  165. if (window.innerWidth<1250) {
  166. $(".table-event").css("margin-left","2%");
  167. $(".table-event").css("width","98%");
  168. $(".table-event").css("min-width","500px");
  169. } else {
  170. $(".table-event").css("margin-left","33%");
  171. $(".table-event").css("width","62%");
  172. $(".table-event").css("min-width","900px");
  173. $(".table-event").css("max-width","900px");
  174. }
  175. hideBurgerMenu();
  176. }
  177. function setFooterPos2() {
  178. if (document.getElementById("footerCont")) {
  179. tollerance = 16;
  180. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance) + "px");
  181. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance) + "px");
  182. }
  183. }
  184. function showEncodedPassword() {
  185. if ($("#Password").val() === "") {
  186. $("#Password").addClass("emptyfield");
  187. return;
  188. }
  189. if ($("#Salt").val() === "") {
  190. $("#Salt").addClass("emptyfield");
  191. return;
  192. }
  193. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  194. msg = "Please set your hash in the config file with this value:";
  195. alert(msg + "\n\n" + passw);
  196. }
  197. $("input#files").on("change", function(e) {
  198. if (!document.getElementById("files").files) {
  199. $("#del-attach").css("display", "none");
  200. } else {
  201. $("#del-attach").css("display", "inline");
  202. }
  203. //frmHC.submit();
  204. });
  205. function clearUpload() {
  206. $("#upload-cont").html("<input id='files' name='files[]' type='file' accept='.gif,.png,.jpg,.jpeg' style='visibility: hidden;' multiple>");
  207. $("#del-attach").css("display", "none");
  208. }
  209. $("#Password").on("keydown", function(e){
  210. $("#Password").removeClass("emptyfield");
  211. });
  212. $("#Salt").on("keydown", function(e){
  213. $("#Salt").removeClass("emptyfield");
  214. });
  215. window.addEventListener("load", function() {
  216. if ($("#frmHC").css("display")==="none") {
  217. setTimeout("setContentPos()", 5200);
  218. setTimeout("setFooterPos2()", 500);
  219. } else {
  220. setTimeout("setContentPos()", 1000);
  221. setTimeout("setFooterPos2()", 500);
  222. }
  223. }, true);
  224. window.addEventListener("resize", function() {
  225. if ($("#frmHC").css("display")==="none") {
  226. setTimeout("setContentPos()", 5200);
  227. setTimeout("setFooterPos2()", 500);
  228. } else {
  229. setTimeout("setContentPos()", 1000);
  230. setTimeout("setFooterPos2()", 500);
  231. }
  232. }, true);