goto.js 8.8 KB

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