goto.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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', (800 - (scrolled * .2)) + 'px');
  14. $('#act3').css('top', (300 - (scrolled * .1)) + 'px');
  15. $('#act4').css('top', (0 + (scrolled * .1)) + 'px');
  16. $('#act5').css('top', (800 - (scrolled * .2)) + 'px');
  17. }
  18. }
  19. // 手機課程大綱輪播
  20. $("#card-box").slick({
  21. arrows: false,
  22. slidesToShow: 1,
  23. centerMode: true,
  24. infinite: false,
  25. dots: true,
  26. });
  27. // 手機課程大綱彈跳視窗
  28. // 視窗一
  29. $(".box-img01").click(function () {
  30. $(".mobile01-1").fadeIn();
  31. $(".mobile-box1").fadeIn();
  32. $(".card-box-1").slick({
  33. arrows: false,
  34. slidesToShow: 1,
  35. centerMode: true,
  36. infinite: false,
  37. });
  38. });
  39. $(".close").click(function () {
  40. $(".mobile-box1").fadeOut();
  41. $(".mobile01-1").fadeOut();
  42. });
  43. // 視窗二
  44. $(".mobile01-2").fadeOut(0);
  45. $(".mobile-box2").fadeOut(0);
  46. $(".box-img02").click(function () {
  47. $(".mobile01-2").fadeIn();
  48. $(".mobile-box2").fadeIn();
  49. $(".card-box-2").slick({
  50. arrows: false,
  51. slidesToShow: 1,
  52. centerMode: true,
  53. infinite: false,
  54. });
  55. });
  56. $(".close").click(function () {
  57. $(".mobile-box2").fadeOut();
  58. $(".mobile01-2").fadeOut();
  59. });
  60. // 視窗三
  61. $(".mobile01-3").fadeOut(0);
  62. $(".mobile-box3").fadeOut(0);
  63. $(".box-img03").click(function () {
  64. $(".mobile01-3").fadeIn();
  65. $(".mobile-box3").fadeIn();
  66. $(".card-box-3").slick({
  67. arrows: false,
  68. slidesToShow: 1,
  69. centerMode: true,
  70. infinite: false,
  71. });
  72. });
  73. $(".close").click(function () {
  74. $(".mobile-box3").fadeOut();
  75. $(".mobile01-3").fadeOut();
  76. });
  77. // 手機課程日程輪播
  78. $("#card-box2").slick({
  79. arrows: false,
  80. slidesToShow: 1,
  81. centerMode: true,
  82. infinite: false,
  83. dots: true,
  84. });
  85. // 手機選單彈跳視窗
  86. $("#menu-box2").hide();
  87. $("#menu-box").hide();
  88. $("#menu-btn1").click(function () {
  89. $("#menu-box").slideToggle("slow");
  90. $("#menu-box2").slideToggle("slow");
  91. });
  92. $(".link").click(function () {
  93. $("#menu-box").slideUp("slow", function () {
  94. $("#menu-box2").slideUp("slow");
  95. // Animation complete.
  96. });
  97. });
  98. $("*").each(function (index, element) {
  99. // 此元素被點選後執行
  100. $(this).click(function (e) {
  101. // 取得被點選元素的屬性:data-gt-target
  102. var target = $(this).attr("data-gt-target");
  103. var duration = $(this).attr("data-gt-duration");
  104. var offset = $(this).attr("data-gt-offset");
  105. // JS 語法:判斷式
  106. // if (條件) {程式區塊}
  107. // 當條件成立,會執行程式區塊
  108. // 如果 目標有資料 才會執行 { } 內的程式
  109. // 避免出現 undefine (未定義 - 不存在的資料)
  110. if (target) {
  111. //console.log("目標:" + target);
  112. //console.log("時間:" + duration);
  113. //console.log("位移:" + offset);
  114. // 上方位置 = 目標區塊.位移().上方位置
  115. var top = $(target).offset().top;
  116. //console.log("要前往元素的上方位置:" + top);
  117. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  118. // parseInt() 將文字轉為數字
  119. $("html").stop().animate({
  120. scrollTop: top - offset
  121. }, parseInt(duration));
  122. }
  123. });
  124. });
  125. // 避免動畫與使用者滾輪衝突
  126. // html 在滾動滾輪時 停止 html 所有效果
  127. $("html").on("mousewheel", function () {
  128. $("html").stop();
  129. });
  130. // gotop下滑效果
  131. $(".arrow").hide();
  132. $(window).scroll(function () {
  133. var y = window.scrollY;
  134. if (y > 10) {
  135. $(".arrow").show();
  136. } else {
  137. $(".arrow").hide();
  138. }
  139. });
  140. $.fn.serializeObject = function () {
  141. var o = {};
  142. var a = this.serializeArray();
  143. // o["id"] = 0;
  144. // o["time_stamp"] = "";
  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:8003/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. $(function () {
  197. $(".box1").hover(
  198. function () {
  199. $("#title1").html('課程1手機拍片');
  200. $("#title1-1").html('知名媒體網站電視台店長');
  201. },
  202. function () {
  203. $("#title1").html('課程1');
  204. $("#title1-1").html('手機拍片');
  205. })
  206. });
  207. $(function () {
  208. $(".box2").hover(
  209. function () {
  210. $("#title2").html('課程2社群營造');
  211. $("#title2-1").html('資深數位廣告投手');
  212. },
  213. function () {
  214. $("#title2").html('課程2');
  215. $("#title2-1").html('社群營造');
  216. })
  217. });
  218. $(function () {
  219. $(".box3").hover(
  220. function () {
  221. $("#title3").html('課程3文案撰寫');
  222. $("#title3-1").html('資深新聞媒體工作者');
  223. },
  224. function () {
  225. $("#title3").html('課程3');
  226. $("#title3-1").html('文案撰寫');
  227. })
  228. });
  229. // 電腦版彈跳視窗
  230. $("#Course-box01").fadeOut(0);
  231. $(".Course-box01").fadeOut(0);
  232. $("#Course-box02").fadeOut(0);
  233. $(".Course-box01").fadeOut(0);
  234. $("#Course-box03").fadeOut(0);
  235. $(".Course-box01").fadeOut(0);
  236. // 電腦版視窗一
  237. $(".box1").click(function () {
  238. $("#Course-box01").fadeIn();
  239. $(".Course-box01").fadeIn();
  240. });
  241. $(".close").click(function () {
  242. $("#Course-box01").fadeOut();
  243. $(".Course-box01").fadeOut();
  244. });
  245. // 電腦版視窗二
  246. $(".box2").click(function () {
  247. $("#Course-box02").fadeIn();
  248. $(".Course-box01").fadeIn();
  249. });
  250. $(".close").click(function () {
  251. $("#Course-box02").fadeOut();
  252. $(".Course-box01").fadeOut();
  253. });
  254. // 電腦版視窗三
  255. $(".box3").click(function () {
  256. $("#Course-box03").fadeIn();
  257. $(".Course-box01").fadeIn();
  258. });
  259. $(".close").click(function () {
  260. $("#Course-box03").fadeOut();
  261. $(".Course-box01").fadeOut();
  262. });
  263. (function () {
  264. const second = 1000,
  265. minute = second * 60,
  266. hour = minute * 60,
  267. day = hour * 24;
  268. let birthday = "July 21, 2021 00:00:00",
  269. countDown = new Date(birthday).getTime(),
  270. x = setInterval(function() {
  271. let now = new Date().getTime(),
  272. distance = countDown - now;
  273. document.getElementById("days").innerText = Math.floor(distance / (day)),
  274. document.getElementById("hours").innerText = Math.floor((distance % (day)) / (hour)),
  275. document.getElementById("minutes").innerText = Math.floor((distance % (hour)) / (minute)),
  276. document.getElementById("seconds").innerText = Math.floor((distance % (minute)) / second);
  277. //do something later when date is reached
  278. if (distance < 0) {
  279. let headline = document.getElementById("headline"),
  280. countdown = document.getElementById("countdown"),
  281. content = document.getElementById("content");
  282. headline.innerText = "It's my birthday!";
  283. countdown.style.display = "none";
  284. content.style.display = "block";
  285. clearInterval(x);
  286. }
  287. //seconds
  288. }, 0)
  289. }());