home.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /**
  2. * Copyright 2021, 2024 5 Mode
  3. *
  4. * This file is part of SnipSwap.
  5. *
  6. * SnipSwap 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. * SnipSwap 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 SnipSwap. If not, see <https://www.gnu.org/licenses/>.
  18. *
  19. * home.js
  20. *
  21. * JS file for Home page
  22. *
  23. * @author Daniele Bonini <my25mb@aol.com>
  24. * @copyrights (c) 2016, 2024, 5 Mode
  25. */
  26. /*
  27. * Boot up code
  28. */
  29. //var fetchDataIntervalId;
  30. /*
  31. * App starting proc
  32. *
  33. * @returns void
  34. */
  35. function startApp() {
  36. window.name = encryptSha2(rnd(0,99999999)+"");
  37. $(document.body).css("background","#FFFFFF");
  38. $("#HCsplash").css("display","none");
  39. $(".body-area").show();
  40. $(".header2").show();
  41. //fetchDataIntervalId = setInterval("_fetchData()", 2000);
  42. }
  43. /*
  44. * call to startApp
  45. *
  46. * @returns void
  47. */
  48. function _startApp() {
  49. setTimeout("startApp()", 1000);
  50. }
  51. window.addEventListener("load", function() {
  52. //Splash
  53. if (firstaccess===1) {
  54. $("#HCsplash").show();
  55. }
  56. }, true);
  57. window.addEventListener("load", function() {
  58. if (firstaccess===1) {
  59. $(document.body).css("background","#0d0d0d");
  60. $(".body-area").hide();
  61. // Fisnished the Intro load the app..
  62. setTimeout("_startApp()", 6000);
  63. } else {
  64. $("#HCsplash").hide();
  65. _startApp();
  66. }
  67. // A bit of preload..
  68. });
  69. window.addEventListener("resize", function() {
  70. //if ($("#cubeList").css("display")==="none") {
  71. // setTimeout("setFooterPos()", 9000);
  72. //} else {
  73. // setTimeout("setFooterPos()", 2000);
  74. //}
  75. });
  76. // -- End Boot up code
  77. /*
  78. * Display the current hash for the config file
  79. *
  80. * @returns void
  81. */
  82. function showEncodedPassword() {
  83. if ($("#Password").val() === "") {
  84. $("#Password").addClass("emptyfield");
  85. return;
  86. }
  87. passw = encryptSha2( $("#Password").val() );
  88. msg = "Please set your new pasword in the config file with this value:";
  89. alert(msg + "\n\n" + passw);
  90. }
  91. function initLinkTooltip() {
  92. $("div.link-div").each(function(){
  93. $(this).tooltip({
  94. position: {
  95. my: "left+20 top+76",
  96. at: "left top",
  97. collision: "none"
  98. }
  99. });
  100. });
  101. }
  102. function setContentPosHome() {
  103. bodyRect = document.body.getBoundingClientRect();
  104. bodyRect.width = window.innerWidth;
  105. $(".snip-code").css("height", parseInt((window.innerHeight * 30) / 100) + "px");
  106. mytop = parseInt(window.innerHeight - ($("#passworddisplay").height() + 60));
  107. $("#passworddisplay").css("top", mytop+"px");
  108. tollerance = 180;
  109. frmSearchRect = document.getElementById("frmSearch").getBoundingClientRect();
  110. catListRect = document.getElementById("catList").getBoundingClientRect();
  111. vertHeight = frmSearchRect.height + catListRect.height + tollerance;
  112. if (bodyRect.width < 500) {
  113. $(".header").css("height",vertHeight);
  114. $("#logo-div").css("margin-left","39%");
  115. $("#frmSearch").css("left","");
  116. $("#frmSearch").css("float","none");
  117. $("#frmSearch").css("clear","both");
  118. $("#frmSearch").css("margin","auto");
  119. $("#form-vert-bar").hide();
  120. $("#form-ori-sep1").show();
  121. $(".link-div").css("float", "none");
  122. $(".link-div").css("clear", "both");
  123. $(".link-div").css("margin", "auto");
  124. $(".link-div").css("padding-left", "10px");
  125. $(".link-div").css("padding-right", "10px");
  126. } else if (bodyRect.width < 950) {
  127. $(".header").css("height",vertHeight);
  128. $("#logo-div").css("margin-left","39%");
  129. $("#frmSearch").css("left","-5%");
  130. $("#frmSearch").css("float","none");
  131. $("#frmSearch").css("clear","both");
  132. $("#frmSearch").css("margin","auto");
  133. $("#form-vert-bar").hide();
  134. $("#form-ori-sep1").show();
  135. $(".link-div").css("float", "left");
  136. $(".link-div").css("clear", "");
  137. $(".link-div").css("margin", "");
  138. $(".link-div").css("padding-left", "10px");
  139. $(".link-div").css("padding-right", "10px");
  140. } else {
  141. $(".header").css("height","228px");
  142. $("#logo-div").css("margin-left","46%");
  143. $("#frmSearch").css("left","+25px");
  144. $("#frmSearch").css("float","left");
  145. $("#frmSearch").css("clear","none");
  146. $("#frmSearch").css("margin","");
  147. $("#form-vert-bar").show();
  148. $("#form-ori-sep1").hide();
  149. $(".link-div").css("float", "left");
  150. $(".link-div").css("clear", "");
  151. $(".link-div").css("margin", "");
  152. $(".link-div").css("padding-left", "10px");
  153. $(".link-div").css("padding-right", "10px");
  154. }
  155. }
  156. window.addEventListener("load", function() {
  157. setTimeout("initLinkTooltip()", 1500);
  158. setContentPosHome();
  159. }, true);
  160. window.addEventListener("resize", function() {
  161. setTimeout("setContentPosHome()", 2000);
  162. }, true);