goto.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. $(window).bind('scroll', function (e) {
  2. parallaxScroll();
  3. });
  4. function parallaxScroll() {
  5. var scrolled = $(window).scrollTop();
  6. // 困擾
  7. if(screen.width>1024){
  8. $('#circle2').css('top', (350 - (scrolled * .2)) + 'px');
  9. $('#circle3').css('top', (1000- (scrolled * .2)) + 'px');
  10. $('#circle1').css('top', (650 - (scrolled * .2)) + 'px');
  11. // 課程大綱
  12. // $('#act1').css('top', (30 + (scrolled * .1)) + 'px');
  13. $('#act2').css('top', (900 - (scrolled * .2)) + 'px');
  14. // $('#act3').css('top', (300 - (scrolled * .1)) + 'px');
  15. $('#act4').css('top', (0 + (scrolled * .1)) + 'px');
  16. $('#act5').css('top', (900 - (scrolled * .2)) + 'px');
  17. }else{
  18. }
  19. }
  20. // 手機課程大綱輪播
  21. $("#card-box").slick({
  22. arrows: false,
  23. slidesToShow: 1,
  24. centerMode: true,
  25. infinite: false,
  26. dots: true,
  27. });
  28. // 手機課程大綱彈跳視窗
  29. // 視窗一
  30. $(".box-img01").click(function () {
  31. $(".mobile01-1").fadeIn();
  32. $(".mobile-box1").fadeIn();
  33. $(".card-box-1").slick({
  34. arrows: false,
  35. slidesToShow: 1,
  36. centerMode: true,
  37. infinite: false,
  38. });
  39. });
  40. $(".close").click(function () {
  41. $(".mobile-box1").fadeOut();
  42. $(".mobile01-1").fadeOut();
  43. });
  44. // 視窗二
  45. $(".mobile01-2").fadeOut(0);
  46. $(".mobile-box2").fadeOut(0);
  47. $(".box-img02").click(function () {
  48. $(".mobile01-2").fadeIn();
  49. $(".mobile-box2").fadeIn();
  50. $(".card-box-2").slick({
  51. arrows: false,
  52. slidesToShow: 1,
  53. centerMode: true,
  54. infinite: false,
  55. });
  56. });
  57. $(".close").click(function () {
  58. $(".mobile-box2").fadeOut();
  59. $(".mobile01-2").fadeOut();
  60. });
  61. // 視窗三
  62. $(".mobile01-3").fadeOut(0);
  63. $(".mobile-box3").fadeOut(0);
  64. $(".box-img03").click(function () {
  65. $(".mobile01-3").fadeIn();
  66. $(".mobile-box3").fadeIn();
  67. $(".card-box-3").slick({
  68. arrows: false,
  69. slidesToShow: 1,
  70. centerMode: true,
  71. infinite: false,
  72. });
  73. });
  74. $(".close").click(function () {
  75. $(".mobile-box3").fadeOut();
  76. $(".mobile01-3").fadeOut();
  77. });
  78. // 手機課程日程輪播
  79. $("#card-box2").slick({
  80. arrows: false,
  81. slidesToShow: 1,
  82. centerMode: true,
  83. infinite: false,
  84. dots: true,
  85. });
  86. // 手機選單彈跳視窗
  87. $("#menu-box2").hide();
  88. $("#menu-box").hide();
  89. $("#menu-btn1").click(function () {
  90. $("#menu-box").slideToggle("slow");
  91. $("#menu-box2").slideToggle("slow");
  92. });
  93. $(".link").click(function () {
  94. $("#menu-box").slideUp("slow", function () {
  95. $("#menu-box2").slideUp("slow");
  96. // Animation complete.
  97. });
  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. // gotop下滑效果
  132. $(".arrow").hide();
  133. $(window).scroll(function () {
  134. var y = window.scrollY;
  135. if (y > 10) {
  136. $(".arrow").show();
  137. } else {
  138. $(".arrow").hide();
  139. }
  140. });
  141. // 電腦版表單
  142. $.fn.serializeObject = function () {
  143. var o = {};
  144. var a = this.serializeArray();
  145. $.each(a, function () {
  146. if (o[this.name]) {
  147. if (!o[this.name].push) {
  148. o[this.name] = [o[this.name]];
  149. }
  150. o[this.name].push(this.value || '');
  151. } else {
  152. o[this.name] = this.value || '';
  153. }
  154. });
  155. return o;
  156. };
  157. $(".contact-form").submit(function (e) {
  158. /* var formRef = $('#form1').serializeArray();
  159. var jsonString = JSON.stringify(formRef);*/
  160. var jsonInfo = $('.contact-form').serializeObject();
  161. var jsonString = JSON.stringify(jsonInfo);
  162. console.log(jsonString),
  163. $.ajax({
  164. type: 'POST',
  165. url: 'https://go.hhh.com.tw:8004/add_client_info',
  166. data: jsonString,
  167. dataType: 'json',
  168. success: function (data) {
  169. console.log('送出成功: ' + data);
  170. alert("送出成功");
  171. // if (data == 0) {
  172. // alert("送出成功");
  173. // } else if (data == 1) {
  174. // alert("此email已填過表單");
  175. // } else if (data == 2) {
  176. // alert("此phone已填過表單");
  177. // } else if (data == 3) {
  178. // alert("此email、phone已填過表單");
  179. // }
  180. location.reload();
  181. },
  182. beforeSend: function () {
  183. console.log('beforeSend');
  184. },
  185. complete: function () {
  186. console.log('complete');
  187. },
  188. error: function (jqXHR, textStatus, errorThrown) {
  189. console.log(JSON.stringify(jqXHR));
  190. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  191. console.log('送出失敗: ' + jqXHR.responseText);
  192. }
  193. });
  194. return false;
  195. });
  196. // 手機板表單
  197. $.fn.serializeObject = function () {
  198. var o = {};
  199. var a = this.serializeArray();
  200. $.each(a, function () {
  201. if (o[this.name]) {
  202. if (!o[this.name].push) {
  203. o[this.name] = [o[this.name]];
  204. }
  205. o[this.name].push(this.value || '');
  206. } else {
  207. o[this.name] = this.value || '';
  208. }
  209. });
  210. return o;
  211. };
  212. $(".contact-form2").submit(function (e) {
  213. /* var formRef = $('#form1').serializeArray();
  214. var jsonString = JSON.stringify(formRef);*/
  215. var jsonInfo = $('.contact-form2').serializeObject();
  216. var jsonString = JSON.stringify(jsonInfo);
  217. console.log(jsonString),
  218. $.ajax({
  219. type: 'POST',
  220. url: 'https://go.hhh.com.tw:8004/add_client_info',
  221. data: jsonString,
  222. dataType: 'json',
  223. success: function (data) {
  224. console.log('送出成功: ' + data);
  225. alert("送出成功");
  226. // if (data == 0) {
  227. // alert("送出成功");
  228. // } else if (data == 1) {
  229. // alert("此email已填過表單");
  230. // } else if (data == 2) {
  231. // alert("此phone已填過表單");
  232. // } else if (data == 3) {
  233. // alert("此email、phone已填過表單");
  234. // }
  235. location.reload();
  236. },
  237. beforeSend: function () {
  238. console.log('beforeSend');
  239. },
  240. complete: function () {
  241. console.log('complete');
  242. },
  243. error: function (jqXHR, textStatus, errorThrown) {
  244. console.log(JSON.stringify(jqXHR));
  245. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  246. console.log('送出失敗: ' + jqXHR.responseText);
  247. }
  248. });
  249. return false;
  250. });
  251. $(function () {
  252. $(".box1").hover(
  253. function () {
  254. $("#title1").html('課程1手機拍片');
  255. $("#title1-1").html('知名媒體網站電視台店長');
  256. },
  257. function () {
  258. $("#title1").html('課程1');
  259. $("#title1-1").html('手機拍片');
  260. })
  261. });
  262. $(function () {
  263. $(".box2").hover(
  264. function () {
  265. $("#title2").html('課程2社群營造');
  266. $("#title2-1").html('資深數位廣告投手');
  267. },
  268. function () {
  269. $("#title2").html('課程2');
  270. $("#title2-1").html('社群營造');
  271. })
  272. });
  273. $(function () {
  274. $(".box3").hover(
  275. function () {
  276. $("#title3").html('課程3文案撰寫');
  277. $("#title3-1").html('資深新聞媒體工作者');
  278. },
  279. function () {
  280. $("#title3").html('課程3');
  281. $("#title3-1").html('文案撰寫');
  282. })
  283. });
  284. // 電腦版彈跳視窗
  285. $("#Course-box01").fadeOut(0);
  286. $(".Course-box01").fadeOut(0);
  287. $("#Course-box02").fadeOut(0);
  288. $(".Course-box01").fadeOut(0);
  289. $("#Course-box03").fadeOut(0);
  290. $(".Course-box01").fadeOut(0);
  291. // 電腦版視窗一
  292. $(".box1").click(function () {
  293. $("#Course-box01").fadeIn();
  294. $(".Course-box01").fadeIn();
  295. });
  296. $(".close").click(function () {
  297. $("#Course-box01").fadeOut();
  298. $(".Course-box01").fadeOut();
  299. });
  300. // 電腦版視窗二
  301. $(".box2").click(function () {
  302. $("#Course-box02").fadeIn();
  303. $(".Course-box01").fadeIn();
  304. });
  305. $(".close").click(function () {
  306. $("#Course-box02").fadeOut();
  307. $(".Course-box01").fadeOut();
  308. });
  309. // 電腦版視窗三
  310. $(".box3").click(function () {
  311. $("#Course-box03").fadeIn();
  312. $(".Course-box01").fadeIn();
  313. });
  314. $(".close").click(function () {
  315. $("#Course-box03").fadeOut();
  316. $(".Course-box01").fadeOut();
  317. });
  318. (function () {
  319. const second = 1000,
  320. minute = second * 60,
  321. hour = minute * 60,
  322. day = hour * 24;
  323. let birthday = "July 21, 2021 00:00:00",
  324. countDown = new Date(birthday).getTime(),
  325. x = setInterval(function() {
  326. let now = new Date().getTime(),
  327. distance = countDown - now;
  328. document.getElementById("days").innerText = Math.floor(distance / (day)),
  329. document.getElementById("hours").innerText = Math.floor((distance % (day)) / (hour)),
  330. document.getElementById("minutes").innerText = Math.floor((distance % (hour)) / (minute)),
  331. document.getElementById("seconds").innerText = Math.floor((distance % (minute)) / second);
  332. //do something later when date is reached
  333. if (distance < 0) {
  334. let headline = document.getElementById("headline"),
  335. countdown = document.getElementById("countdown"),
  336. content = document.getElementById("content");
  337. headline.innerText = "It's my birthday!";
  338. countdown.style.display = "none";
  339. content.style.display = "block";
  340. clearInterval(x);
  341. }
  342. //seconds
  343. }, 0)
  344. }());