index-js.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <?PHP
  2. /**
  3. * Copyright 2021, 2024 5 Mode
  4. *
  5. * This file is part of Homolog.
  6. *
  7. * Homolog is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Homolog is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with Homolog. If not, see <https://www.gnu.org/licenses/>.
  19. *
  20. * index.js
  21. *
  22. * JS file for Home page
  23. *
  24. * @author Daniele Bonini <my25mb@aol.com>
  25. * @copyrights (c) 2021, 2024, the Open Gallery's contributors
  26. */
  27. require "../init.inc";
  28. header("Content-Type: text/javascript");
  29. ?>
  30. var bBurgerMenuVisible = false;
  31. var bSideBarVisible = false;
  32. $(document).ready(function() {
  33. $("#txtSearch").on("keyup",function(e){
  34. key = e.which;
  35. if (key===13) {
  36. e.preventDefault();
  37. frmDI.submit();
  38. } else {
  39. //e.preventDefault();
  40. }
  41. });
  42. $("#Password").on("keydown",function(e){
  43. key = e.which;
  44. //alert(key);
  45. $("#chatHint").val("");
  46. if (key===13) {
  47. e.preventDefault();
  48. frmDI.submit();
  49. } else {
  50. $("#Password2").val($(this).val());
  51. //e.preventDefault();
  52. }
  53. });
  54. $("#Password2").on("keydown",function(e){
  55. key = e.which;
  56. //alert(key);
  57. $("#chatHint").val("");
  58. if (key===13) {
  59. e.preventDefault();
  60. $("#Password").val("");
  61. frmDI.submit();
  62. } else {
  63. //e.preventDefault();
  64. }
  65. });
  66. $("#MessageLine").on("keydown",function(e){
  67. key = e.which;
  68. //alert(key);
  69. if (key===13) {
  70. //e.preventDefault();
  71. //sendMessage()
  72. } else {
  73. //e.preventDefault();
  74. }
  75. });
  76. });
  77. $("#burger-menu").on("click",function(){
  78. if (!bBurgerMenuVisible) {
  79. $(".friend-header").css("display", "table");
  80. } else {
  81. $(".friend-header").css("display", "none");
  82. }
  83. bBurgerMenuVisible=!bBurgerMenuVisible;
  84. });
  85. function hideBurgerMenu() {
  86. $(".friend-header").css("display", "none");
  87. bBurgerMenuVisible=false;
  88. }
  89. function showSideBar() {
  90. if (!bSideBarVisible) {
  91. $("#content-bar").css("width","100%");
  92. $("#sidebar").show("slow");
  93. }
  94. bSideBarVisible = true;
  95. }
  96. function closeSideBar() {
  97. $("#sidebar").hide();
  98. $("#content-bar").css("width","100%");
  99. bSideBarVisible = false;
  100. }
  101. $("#call-sidebar").on("mouseover", function() {
  102. //alert("hello");
  103. showSideBar();
  104. });
  105. function closeSplash() {
  106. $("#hideSplash").val("1");
  107. $("#splash").hide();
  108. }
  109. function refresh() {
  110. $("#CommandLine").val("refreshbrd");
  111. frmDI.submit();
  112. }
  113. function delSign(sign) {
  114. $("#CommandLine").val("del '" + sign + "'");
  115. frmDI.submit();
  116. }
  117. function confSign(sign) {
  118. $("#CommandLine").val("conf '" + sign + "'");
  119. frmDI.submit();
  120. }
  121. function sendSign() {
  122. var val = "";
  123. val = $("#date").val().trim();
  124. if (val=="" || val.length<4) {
  125. $("#date").addClass("emptyfield");
  126. return;
  127. }
  128. val = $("#desc").val().trim();
  129. if (val=="" || val.length<4) {
  130. $("#desc").addClass("emptyfield");
  131. return;
  132. }
  133. $("#CommandLine").val("sign");
  134. frmDI.submit();
  135. }
  136. $("#send").on("click",function() {
  137. $("#date").removeClass("emptyfield");
  138. $("#desc").removeClass("emptyfield");
  139. sendSign();
  140. });
  141. function setContentPos() {
  142. if (window.innerWidth<650) {
  143. //$("#ahome").attr("href","/");
  144. $("#agithub").css("display","none");
  145. $("#afeedback").css("display","none");
  146. $("#asupport").css("display","none");
  147. $("#pwd2").css("display","inline");
  148. //$("#sidebar").css("display","none");
  149. $("#burger-menu").css("display","inline");
  150. //$("#contentbar").css("width","100%");
  151. $("#logo-hl").css("display","none");
  152. $("#template-img").hide();
  153. $(".dragover").css("min-width", "450px");
  154. } else {
  155. //$("#ahome").attr("href","http://dropinsound.5mode-foss.eu");
  156. $("#agithub").css("display","inline");
  157. $("#afeedback").css("display","inline");
  158. $("#asupport").css("display","inline");
  159. $("#pwd2").css("display","none");
  160. //$("#sidebar").css("display","inline");
  161. $("#burger-menu").css("display","none");
  162. //$("#contentbar").css("width","75%");
  163. $("#logo-hl").css("display","inline");
  164. $("#template-img").show();
  165. $(".dragover").css("min-width", "630px");
  166. }
  167. hideBurgerMenu();
  168. //window.scroll(0, 0);
  169. //$(document.body).css("overflow-y", "hidden");
  170. }
  171. function setFooterPos() {
  172. //if (document.getElementById("footerCont")) {
  173. //if ($("#Password").val() === "") {
  174. // tollerance = 48;
  175. //} else {
  176. tollerance = 15;
  177. //}
  178. if (window.innerWidth<450) {
  179. $(".no-sm").css("display", "none");
  180. } else {
  181. $(".no-sm").css("display", "inline");
  182. }
  183. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  184. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance ) + "px");
  185. //}
  186. }
  187. function showEncodedPassword() {
  188. if ($("#Password").val() === "") {
  189. $("#Password").addClass("emptyfield");
  190. return;
  191. }
  192. if ($("#Salt").val() === "") {
  193. $("#Salt").addClass("emptyfield");
  194. return;
  195. }
  196. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  197. msg = "Please set your hash in the config file with this value:";
  198. alert(msg + "\n\n" + passw);
  199. }
  200. //$("input#files").on("change", function(e) {
  201. //
  202. // if (!document.getElementById("files").files) {
  203. // $("#del-attach").css("display", "none");
  204. // } else {
  205. // $("#del-attach").css("display", "inline");
  206. // }
  207. //frmDI.submit();
  208. //});
  209. $("div.dragover").on("dragover", function(e) {
  210. e.stopPropagation();
  211. e.preventDefault();
  212. e.originalEvent.dataTransfer.dropEffect = "copy";
  213. return false;
  214. });
  215. $("div.dragover").on("drop", function(e) {
  216. e.stopPropagation();
  217. e.preventDefault();
  218. // Get the current Upload form obejct..
  219. var form = document.getElementById("frmDI");
  220. // Create a FormData object including the actual form data..
  221. var fd = new FormData(form);
  222. // Get the array of files dropped..
  223. var dt = e.originalEvent.dataTransfer;
  224. var files = dt.files;
  225. var count = files.length;
  226. //alert("File Count: " + count + "\n");
  227. if (count !== 0) {
  228. for (var i = 0; i < count; i++) {
  229. //alert(" File " + i + ":\n(" + (typeof files[i]) + ") : <" + files[i] + " > " +
  230. // files[i].name + " " + files[i].size + " " + files[i].type + "\n");
  231. if (files[i].size > <?PHP echo(APP_FILE_MAX_SIZE); ?>) {
  232. alert("ERROR: file size (" + files[i].size +") exceeds app limit: <?PHP echo(APP_FILE_MAX_SIZE); ?>");
  233. return;
  234. }
  235. fd.append("filesdd[]", files[i]);
  236. }
  237. // Submit of the FormData..
  238. $.ajax("/", {
  239. method: "POST",
  240. processData: false,
  241. contentType: false,
  242. data: fd//,
  243. //success: function (data) {
  244. // $("body").html(data);
  245. //}
  246. });
  247. setTimeout("reload()", 2000);
  248. } else {
  249. ttext = e.originalEvent.dataTransfer.getData('text/plain');
  250. //re = new RegExp(/(https?:\/\/)([\da-z\.-]+)\.([a-z\.]{2,8})(\/?.+)?$/gum);
  251. //matches = mytext.matchAll(re);
  252. //matches = mytext;
  253. //alert(ttext);
  254. if (ttext!=="") {
  255. //fd.append("f", ffriends);
  256. document.getElementById("t").value = ttext;
  257. //alert(document.getElementById("f").value);
  258. document.getElementById("frmDI").submit();
  259. } else {
  260. //alert("ale!");
  261. }
  262. }
  263. return false;
  264. });
  265. $("input#files").on("change", function(e) {
  266. frmDI.submit();
  267. });
  268. function reload() {
  269. document.getElementById("frmDI").submit();
  270. }
  271. function openEx(ex) {
  272. <?PHP if (DISPLAY_SHOW_HEADER): ?>
  273. $("#fullExerpt").html($("#hheader"+ex).html() + $("#eexerpt"+ex).html());
  274. <?PHP else: ?>
  275. $("#fullExerpt").html($("#eexerpt"+ex).html());
  276. <?PHP endif; ?>
  277. $("#modalButtonNew").click();
  278. }
  279. //function clearUpload() {
  280. // $("#upload-cont").html("<input id='files' name='files[]' type='file' accept='.gif,.png,.jpg,.jpeg' style='visibility: hidden;' multiple>");
  281. // $("#del-attach").css("display", "none");
  282. //}
  283. $("#Password").on("keydown", function(e){
  284. $("#Password").removeClass("emptyfield");
  285. });
  286. $("#Salt").on("keydown", function(e){
  287. $("#Salt").removeClass("emptyfield");
  288. });
  289. window.addEventListener("load", function() {
  290. if ($("#frmDI").css("display")==="none") {
  291. setTimeout("setContentPos()", 5200);
  292. setTimeout("setFooterPos()", 300);
  293. } else {
  294. setTimeout("setContentPos()", 300);
  295. setTimeout("setFooterPos()", 300);
  296. }
  297. }, true);
  298. window.addEventListener("resize", function() {
  299. if ($("#frmDI").css("display")==="none") {
  300. setTimeout("setContentPos()", 5200);
  301. setTimeout("setFooterPos()", 300);
  302. } else {
  303. setTimeout("setContentPos()", 300);
  304. setTimeout("setFooterPos()", 300);
  305. }
  306. }, true);