goto.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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. $.fn.serializeObject = function () {
  142. var o = {};
  143. var a = this.serializeArray();
  144. // o["id"] = 0;
  145. // o["time_stamp"] = "";
  146. $.each(a, function () {
  147. if (o[this.name]) {
  148. if (!o[this.name].push) {
  149. o[this.name] = [o[this.name]];
  150. }
  151. o[this.name].push(this.value || '');
  152. } else {
  153. o[this.name] = this.value || '';
  154. }
  155. });
  156. return o;
  157. };
  158. $(".contact-form").submit(function (e) {
  159. /* var formRef = $('#form1').serializeArray();
  160. var jsonString = JSON.stringify(formRef);*/
  161. var jsonInfo = $('.contact-form').serializeObject();
  162. var jsonString = JSON.stringify(jsonInfo);
  163. console.log(jsonString),
  164. $.ajax({
  165. type: 'POST',
  166. url: 'https://go.hhh.com.tw:8005/add_client_info',
  167. data: jsonString,
  168. dataType: 'json',
  169. success: function (data) {
  170. console.log('送出成功: ' + data);
  171. alert("送出成功");
  172. // if (data == 0) {
  173. // alert("送出成功");
  174. // } else if (data == 1) {
  175. // alert("此email已填過表單");
  176. // } else if (data == 2) {
  177. // alert("此phone已填過表單");
  178. // } else if (data == 3) {
  179. // alert("此email、phone已填過表單");
  180. // }
  181. location.reload();
  182. },
  183. beforeSend: function () {
  184. console.log('beforeSend');
  185. },
  186. complete: function () {
  187. console.log('complete');
  188. },
  189. error: function (jqXHR, textStatus, errorThrown) {
  190. console.log(JSON.stringify(jqXHR));
  191. console.log("AJAX errr: " + textStatus + ' : ' + errorThrown);
  192. console.log('送出失敗: ' + jqXHR.responseText);
  193. }
  194. });
  195. return false;
  196. });
  197. $(function () {
  198. $(".box1").hover(
  199. function () {
  200. $("#title1").html('課程1手機拍片');
  201. $("#title1-1").html('知名媒體網站電視台店長');
  202. },
  203. function () {
  204. $("#title1").html('課程1');
  205. $("#title1-1").html('手機拍片');
  206. })
  207. });
  208. $(function () {
  209. $(".box2").hover(
  210. function () {
  211. $("#title2").html('課程2社群營造');
  212. $("#title2-1").html('資深數位廣告投手');
  213. },
  214. function () {
  215. $("#title2").html('課程2');
  216. $("#title2-1").html('社群營造');
  217. })
  218. });
  219. $(function () {
  220. $(".box3").hover(
  221. function () {
  222. $("#title3").html('課程3文案撰寫');
  223. $("#title3-1").html('資深新聞媒體工作者');
  224. },
  225. function () {
  226. $("#title3").html('課程3');
  227. $("#title3-1").html('文案撰寫');
  228. })
  229. });
  230. // 電腦版彈跳視窗
  231. $("#Course-box01").fadeOut(0);
  232. $(".Course-box01").fadeOut(0);
  233. $("#Course-box02").fadeOut(0);
  234. $(".Course-box01").fadeOut(0);
  235. $("#Course-box03").fadeOut(0);
  236. $(".Course-box01").fadeOut(0);
  237. // 電腦版視窗一
  238. $(".box1").click(function () {
  239. $("#Course-box01").fadeIn();
  240. $(".Course-box01").fadeIn();
  241. });
  242. $(".close").click(function () {
  243. $("#Course-box01").fadeOut();
  244. $(".Course-box01").fadeOut();
  245. });
  246. // 電腦版視窗二
  247. $(".box2").click(function () {
  248. $("#Course-box02").fadeIn();
  249. $(".Course-box01").fadeIn();
  250. });
  251. $(".close").click(function () {
  252. $("#Course-box02").fadeOut();
  253. $(".Course-box01").fadeOut();
  254. });
  255. // 電腦版視窗三
  256. $(".box3").click(function () {
  257. $("#Course-box03").fadeIn();
  258. $(".Course-box01").fadeIn();
  259. });
  260. $(".close").click(function () {
  261. $("#Course-box03").fadeOut();
  262. $(".Course-box01").fadeOut();
  263. });
  264. (function () {
  265. const second = 1000,
  266. minute = second * 60,
  267. hour = minute * 60,
  268. day = hour * 24;
  269. let birthday = "July 21, 2021 00:00:00",
  270. countDown = new Date(birthday).getTime(),
  271. x = setInterval(function() {
  272. let now = new Date().getTime(),
  273. distance = countDown - now;
  274. document.getElementById("days").innerText = Math.floor(distance / (day)),
  275. document.getElementById("hours").innerText = Math.floor((distance % (day)) / (hour)),
  276. document.getElementById("minutes").innerText = Math.floor((distance % (hour)) / (minute)),
  277. document.getElementById("seconds").innerText = Math.floor((distance % (minute)) / second);
  278. //do something later when date is reached
  279. if (distance < 0) {
  280. let headline = document.getElementById("headline"),
  281. countdown = document.getElementById("countdown"),
  282. content = document.getElementById("content");
  283. headline.innerText = "It's my birthday!";
  284. countdown.style.display = "none";
  285. content.style.display = "block";
  286. clearInterval(x);
  287. }
  288. //seconds
  289. }, 0)
  290. }());