index-js.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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. } else {
  153. $("#ahome").attr("href","http://dropin.5mode-foss.eu");
  154. $("#agithub").css("display","inline");
  155. $("#afeedback").css("display","inline");
  156. $("#asupport").css("display","inline");
  157. $("#pwd2").css("display","none");
  158. //$("#sidebar").css("display","inline");
  159. $("#burger-menu").css("display","none");
  160. //$("#contentbar").css("width","75%");
  161. $("#logo-hl").css("display","inline");
  162. }
  163. hideBurgerMenu();
  164. //window.scroll(0, 0);
  165. //$(document.body).css("overflow-y", "hidden");
  166. }
  167. function setFooterPos() {
  168. //if (document.getElementById("footerCont")) {
  169. //if ($("#Password").val() === "") {
  170. // tollerance = 48;
  171. //} else {
  172. tollerance = 15;
  173. //}
  174. if (window.innerWidth<450) {
  175. $(".no-sm").css("display", "none");
  176. } else {
  177. $(".no-sm").css("display", "inline");
  178. }
  179. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  180. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance ) + "px");
  181. //}
  182. }
  183. function showEncodedPassword() {
  184. if ($("#Password").val() === "") {
  185. $("#Password").addClass("emptyfield");
  186. return;
  187. }
  188. if ($("#Salt").val() === "") {
  189. $("#Salt").addClass("emptyfield");
  190. return;
  191. }
  192. passw = encryptSha2( $("#Password").val() + $("#Salt").val());
  193. msg = "Please set your hash in the config file with this value:";
  194. alert(msg + "\n\n" + passw);
  195. }
  196. //$("input#files").on("change", function(e) {
  197. //
  198. // if (!document.getElementById("files").files) {
  199. // $("#del-attach").css("display", "none");
  200. // } else {
  201. // $("#del-attach").css("display", "inline");
  202. // }
  203. //frmDI.submit();
  204. //});
  205. $("div.dragover").on("dragover", function(e) {
  206. e.stopPropagation();
  207. e.preventDefault();
  208. e.originalEvent.dataTransfer.dropEffect = "copy";
  209. return false;
  210. });
  211. $("div.dragover").on("drop", function(e) {
  212. e.stopPropagation();
  213. e.preventDefault();
  214. // Get the current Upload form obejct..
  215. var form = document.getElementById("frmDI");
  216. // Create a FormData object including the actual form data..
  217. var fd = new FormData(form);
  218. // Get the array of files dropped..
  219. var dt = e.originalEvent.dataTransfer;
  220. var files = dt.files;
  221. var count = files.length;
  222. //alert("File Count: " + count + "\n");
  223. if (count !== 0) {
  224. for (var i = 0; i < count; i++) {
  225. //alert(" File " + i + ":\n(" + (typeof files[i]) + ") : <" + files[i] + " > " +
  226. // files[i].name + " " + files[i].size + " " + files[i].type + "\n");
  227. if (files[i].size > <?PHP echo(APP_FILE_MAX_SIZE); ?>) {
  228. alert("ERROR: file size (" + files[i].size +") exceeds app limit: <?PHP echo(APP_FILE_MAX_SIZE); ?>");
  229. return;
  230. }
  231. fd.append("filesdd[]", files[i]);
  232. }
  233. // Submit of the FormData..
  234. $.ajax("/", {
  235. method: "POST",
  236. processData: false,
  237. contentType: false,
  238. data: fd//,
  239. //success: function (data) {
  240. // $("body").html(data);
  241. //}
  242. });
  243. setTimeout("reload()", 2000);
  244. } else {
  245. ttext = e.originalEvent.dataTransfer.getData('text/plain');
  246. //re = new RegExp(/(https?:\/\/)([\da-z\.-]+)\.([a-z\.]{2,8})(\/?.+)?$/gum);
  247. //matches = mytext.matchAll(re);
  248. //matches = mytext;
  249. //alert(ttext);
  250. if (ttext!=="") {
  251. //fd.append("f", ffriends);
  252. document.getElementById("t").value = ttext;
  253. //alert(document.getElementById("f").value);
  254. document.getElementById("frmDI").submit();
  255. } else {
  256. //alert("ale!");
  257. }
  258. }
  259. return false;
  260. });
  261. $("input#files").on("change", function(e) {
  262. frmDI.submit();
  263. });
  264. function reload() {
  265. document.getElementById("frmDI").submit();
  266. }
  267. function openEx(ex) {
  268. <?PHP if (DISPLAY_SHOW_HEADER): ?>
  269. $("#fullExerpt").html($("#hheader"+ex).html() + $("#eexerpt"+ex).html());
  270. <?PHP else: ?>
  271. $("#fullExerpt").html($("#eexerpt"+ex).html());
  272. <?PHP endif; ?>
  273. $("#modalButtonNew").click();
  274. }
  275. //function clearUpload() {
  276. // $("#upload-cont").html("<input id='files' name='files[]' type='file' accept='.gif,.png,.jpg,.jpeg' style='visibility: hidden;' multiple>");
  277. // $("#del-attach").css("display", "none");
  278. //}
  279. $("#Password").on("keydown", function(e){
  280. $("#Password").removeClass("emptyfield");
  281. });
  282. $("#Salt").on("keydown", function(e){
  283. $("#Salt").removeClass("emptyfield");
  284. });
  285. window.addEventListener("load", function() {
  286. if ($("#frmDI").css("display")==="none") {
  287. setTimeout("setContentPos()", 5200);
  288. //setTimeout("setFooterPos()", 5300);
  289. } else {
  290. setTimeout("setContentPos()", 1000);
  291. //setTimeout("setFooterPos()", 2000);
  292. }
  293. }, true);
  294. window.addEventListener("resize", function() {
  295. if ($("#frmDI").css("display")==="none") {
  296. setTimeout("setContentPos()", 5200);
  297. //setTimeout("setFooterPos()", 5300);
  298. } else {
  299. setTimeout("setContentPos()", 1000);
  300. //setTimeout("setFooterPos()", 2000);
  301. }
  302. }, true);