goto.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. var random = Math.floor(Math.random() * $('.youtube').length);
  2. $('.youtube').hide().eq(random).show();
  3. // sec03排名table輪播
  4. $('#sec03-slider').slick({
  5. arrows: false,
  6. slidesToShow: 1,
  7. slidesToScroll: 1,
  8. infinite: true,
  9. });
  10. $('#sec03-slider-next').click(function () {
  11. $('#sec03-slider').slick('slickNext')
  12. });
  13. // sec05 熱門作品 手機輪播
  14. $('#sec05-moblie-slider').slick({
  15. arrows: false,
  16. slidesToShow: 1,
  17. slidesToScroll: 1,
  18. infinite: true,
  19. });
  20. $('#sec05-slider-next').click(function () {
  21. $('#sec05-moblie-slider').slick('slickNext')
  22. });
  23. // sec05桌機輪播
  24. $('#sec05-destop-slider').slick({
  25. arrows: true,
  26. slidesToShow: 3,
  27. slidesToScroll: 3,
  28. infinite: true,
  29. });
  30. // sec06桌機輪波
  31. // $('#sec06-container').slick({
  32. // arrows: true,
  33. // slidesToShow: 4,
  34. // slidesToScroll: 3,
  35. // infinite:true,
  36. // });
  37. // $('#sec06-2-slider').slick({
  38. // arrows: true,
  39. // slidesToShow: 3,
  40. // slidesToScroll: 3,
  41. // infinite:true,
  42. // vertical:true,
  43. // });
  44. $(function () {
  45. $('#sec06-container').slick({
  46. slidesToShow: 4,
  47. slidesToScroll: 3,
  48. infinite: true,
  49. arrows: true,
  50. responsive: [
  51. {
  52. breakpoint: 600, // RWD在1024寬度時切換顯示數量
  53. settings: {
  54. arrows: false,
  55. slidesToShow: 1, //一次顯示3個
  56. slidesToScroll: 1,//切換下一頁時移動3個
  57. infinite: true,
  58. }
  59. }, {
  60. breakpoint: 600,// RWD在600寬度時切換顯示數量
  61. settings: {
  62. arrows: false,
  63. slidesToShow: 1,//一次顯示2個
  64. slidesToScroll: 1,//切換下一頁時移動2個
  65. infinite: true,
  66. }
  67. },
  68. ]
  69. });
  70. })
  71. // sec04 洞察報告 手機輪播
  72. $('#sec04-moblie-container').slick({
  73. arrows: false,
  74. slidesToShow: 1,
  75. slidesToScroll: 1,
  76. infinite: true,
  77. // centerMode: true,
  78. });
  79. // $('#sec04-slider-next').click(function () {
  80. // $('#sec04-moblie-container').slick('slickNext')
  81. // });
  82. // 手機板menu彈跳視窗
  83. $("#menu-box2").hide();
  84. $("#menu-box").hide();
  85. $(".link").click(function () {
  86. $("#menu-box").fadeOut("slow", function () {
  87. $("#menu-box2").fadeOut("slow");
  88. // Animation complete.
  89. });
  90. });
  91. $("#menu-btn1").click(function () {
  92. $("#menu-box").fadeIn();
  93. $("#menu-box2").fadeIn();
  94. });
  95. $(".close").click(function () {
  96. $("#menu-box").fadeOut();
  97. $("#menu-box2").fadeOut();
  98. });
  99. $("*").each(function (index, element) {
  100. // 此元素被點選後執行
  101. $(this).click(function (e) {
  102. // 取得被點選元素的屬性:data-gt-target
  103. var target = $(this).attr("data-gt-target");
  104. var duration = $(this).attr("data-gt-duration");
  105. var offset = $(this).attr("data-gt-offset");
  106. // JS 語法:判斷式
  107. // if (條件) {程式區塊}
  108. // 當條件成立,會執行程式區塊
  109. // 如果 目標有資料 才會執行 { } 內的程式
  110. // 避免出現 undefine (未定義 - 不存在的資料)
  111. if (target) {
  112. //console.log("目標:" + target);
  113. //console.log("時間:" + duration);
  114. //console.log("位移:" + offset);
  115. // 上方位置 = 目標區塊.位移().上方位置
  116. var top = $(target).offset().top;
  117. //console.log("要前往元素的上方位置:" + top);
  118. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  119. // parseInt() 將文字轉為數字
  120. $("html").stop().animate({
  121. scrollTop: top - offset
  122. }, parseInt(duration));
  123. }
  124. });
  125. });
  126. // 避免動畫與使用者滾輪衝突
  127. // html 在滾動滾輪時 停止 html 所有效果
  128. $("html").on("mousewheel", function () {
  129. $("html").stop();
  130. });
  131. $(".sec03-table-title").addClass("contant-toggle");
  132. $("#sec03-slider").on('beforeChange', function (event, slick, currentSlide, nextSlide) {
  133. console.log('beforeChangeEvent: currenSlide=' + currentSlide + ', nextSlide= ' + nextSlide);
  134. if (nextSlide == 1) {
  135. $(".sec03-table-title").removeClass("contant-toggle");
  136. $(".sec03-table-title2").addClass("contant-toggle");
  137. }
  138. else if (nextSlide == 0) {
  139. $(".sec03-table-title2").removeClass("contant-toggle");
  140. $(".sec03-table-title").addClass("contant-toggle");
  141. }
  142. });
  143. // 電腦版email
  144. $.fn.serializeObject = function () {
  145. var o = {};
  146. var a = this.serializeArray();
  147. // o["id"] = 0;
  148. // o["time_stamp"] = "";
  149. $.each(a, function () {
  150. if (o[this.name]) {
  151. if (!o[this.name].push) {
  152. o[this.name] = [o[this.name]];
  153. }
  154. o[this.name].push(this.value || '');
  155. } else {
  156. o[this.name] = this.value || '';
  157. }
  158. });
  159. return o;
  160. };
  161. $(".contact-form-destop").submit(function (e) {
  162. /* var formRef = $('#form1').serializeArray();
  163. var jsonString = JSON.stringify(formRef);*/
  164. var jsonInfo = $('.contact-form-destop').serializeObject();
  165. var jsonString = JSON.stringify(jsonInfo);
  166. console.log(jsonString),
  167. $.ajax({
  168. type: 'POST',
  169. url: 'https://nftboard.info:8001/add_sub',
  170. data: jsonString,
  171. dataType: 'json',
  172. success: function (data) {
  173. console.log('送出成功: ' + data);
  174. alert("訂閱成功");
  175. // if (data == 0) {
  176. // alert("送出成功");
  177. // } else if (data == 1) {
  178. // alert("此email已填過表單");
  179. // } else if (data == 2) {
  180. // alert("此phone已填過表單");
  181. // } else if (data == 3) {
  182. // alert("此email、phone已填過表單");
  183. // }
  184. // location.reload();
  185. },
  186. beforeSend: function () {
  187. console.log('beforeSend');
  188. },
  189. complete: function () {
  190. console.log('complete');
  191. },
  192. error: function (jqXHR, textStatus, errorThrown) {
  193. console.log(JSON.stringify(jqXHR));
  194. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  195. console.log('送出失敗: ' + jqXHR.responseText);
  196. }
  197. });
  198. return false;
  199. });
  200. // 手機板 email
  201. $.fn.serializeObject = function () {
  202. var o = {};
  203. var a = this.serializeArray();
  204. $.each(a, function () {
  205. if (o[this.name]) {
  206. if (!o[this.name].push) {
  207. o[this.name] = [o[this.name]];
  208. }
  209. o[this.name].push(this.value || '');
  210. } else {
  211. o[this.name] = this.value || '';
  212. }
  213. });
  214. return o;
  215. };
  216. $(".contact-form-mobile").submit(function (e) {
  217. /* var formRef = $('#form1').serializeArray();
  218. var jsonString = JSON.stringify(formRef);*/
  219. var jsonInfo = $('.contact-form-mobile').serializeObject();
  220. var jsonString = JSON.stringify(jsonInfo);
  221. console.log(jsonString),
  222. $.ajax({
  223. type: 'POST',
  224. url: 'https://nftboard.info:8001/add_sub',
  225. data: jsonString,
  226. dataType: 'json',
  227. success: function (data) {
  228. console.log('送出成功: ' + data);
  229. alert("訂閱成功");
  230. // if (data == 0) {
  231. // alert("送出成功");
  232. // } else if (data == 1) {
  233. // alert("此email已填過表單");
  234. // } else if (data == 2) {
  235. // alert("此phone已填過表單");
  236. // } else if (data == 3) {
  237. // alert("此email、phone已填過表單");
  238. // }
  239. location.reload();
  240. },
  241. beforeSend: function () {
  242. console.log('beforeSend');
  243. },
  244. complete: function () {
  245. console.log('complete');
  246. },
  247. error: function (jqXHR, textStatus, errorThrown) {
  248. console.log(JSON.stringify(jqXHR));
  249. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  250. console.log('送出失敗: ' + jqXHR.responseText);
  251. }
  252. });
  253. return false;
  254. });
  255. $(function() {
  256. $("#sec05-moblie").swipe( { fingers:'all', swipeLeft:swipe1, swipeRight:swipe2} );
  257. function swipe1(event, direction, distance, duration, fingerCount) {
  258. $('#sec05-moblie-slider').slick('slickNext')//向左滑動你要執行的動作
  259. }
  260. function swipe2(event, direction, distance, duration, fingerCount) {
  261. $('#sec05-moblie-slider').slick('slickPrev') //向右滑動你要執行的動作
  262. }
  263. });
  264. $(function() {
  265. $(".sec05-button").swipe( { fingers:'all', swipeLeft:swipe1, swipeRight:swipe2} );
  266. function swipe1(event, direction, distance, duration, fingerCount) {
  267. $('#sec05-moblie-slider').slick('slickNext')//向左滑動你要執行的動作
  268. }
  269. function swipe2(event, direction, distance, duration, fingerCount) {
  270. $('#sec05-moblie-slider').slick('slickPrev') //向右滑動你要執行的動作
  271. }
  272. });
  273. $(function() {
  274. $("#sec06").swipe( { fingers:'all', swipeLeft:swipe1, swipeRight:swipe2} );
  275. function swipe1(event, direction, distance, duration, fingerCount) {
  276. $('#sec06-container').slick('slickNext')//向左滑動你要執行的動作
  277. }
  278. function swipe2(event, direction, distance, duration, fingerCount) {
  279. $('#sec06-container').slick('slickPrev') //向右滑動你要執行的動作
  280. }
  281. });
  282. $(function() {
  283. $("#sec04-moblie").swipe( { fingers:'all', swipeLeft:swipe1, swipeRight:swipe2} );
  284. function swipe1(event, direction, distance, duration, fingerCount) {
  285. $('#sec04-moblie-container').slick('slickNext')//向左滑動你要執行的動作
  286. }
  287. function swipe2(event, direction, distance, duration, fingerCount) {
  288. $('#sec04-moblie-container').slick('slickPrev') //向右滑動你要執行的動作
  289. }
  290. });