goto.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. $("*").each(function (index, element) {
  2. // 此元素被點選後執行
  3. $(this).click(function (e) {
  4. // 取得被點選元素的屬性:data-gt-target
  5. var target = $(this).attr("data-gt-target");
  6. var duration = $(this).attr("data-gt-duration");
  7. var offset = $(this).attr("data-gt-offset");
  8. // JS 語法:判斷式
  9. // if (條件) {程式區塊}
  10. // 當條件成立,會執行程式區塊
  11. // 如果 目標有資料 才會執行 { } 內的程式
  12. // 避免出現 undefine (未定義 - 不存在的資料)
  13. if (target) {
  14. //console.log("目標:" + target);
  15. //console.log("時間:" + duration);
  16. //console.log("位移:" + offset);
  17. // 上方位置 = 目標區塊.位移().上方位置
  18. var top = $(target).offset().top;
  19. //console.log("要前往元素的上方位置:" + top);
  20. // 網頁元素.停止().動畫({ 上方捲動:指定元素 - 位移},持續時間)
  21. // parseInt() 將文字轉為數字
  22. $("html").stop().animate({
  23. scrollTop: top - offset
  24. }, parseInt(duration));
  25. }
  26. });
  27. });
  28. // 避免動畫與使用者滾輪衝突
  29. // html 在滾動滾輪時 停止 html 所有效果
  30. $("html").on("mousewheel", function () {
  31. $("html").stop();
  32. });
  33. // gotop下滑效果
  34. $(".arrow").hide();
  35. $(window).scroll(function () {
  36. var y = window.scrollY;
  37. if (y > 500) {
  38. $(".arrow").show();
  39. } else {
  40. $(".arrow").hide();
  41. }
  42. });
  43. console.log(28);
  44. // $('.nav-item2').click(function(){
  45. // $(this).toggleClass('after-nav')
  46. // })
  47. function funcTest2() {
  48. $.ajax({
  49. method: "GET",
  50. url: "designer4.json",
  51. dataType: "json",
  52. })
  53. .done(function (msg) {
  54. var desBanner = '';
  55. var MobBanner = '';
  56. var bodyBannerDes = '';
  57. console.log(msg);
  58. var res = msg.length;
  59. console.log(res);
  60. const limit = res;
  61. var arrIndex = Math.floor(Math.random() * msg.length);
  62. console.log(arrIndex);
  63. console.log(msg[arrIndex].Designerimg);
  64. desBanner += ' \
  65. <div class="banner-des row vertical align-items-end px-0 mx-0">\
  66. <div class="banner-0 col-0 order-1 col-lg-5 order-1 pe-0">\
  67. <img class="img-fluid" src="./img/banner/bannertitle.png" alt="">\
  68. </div>\
  69. <div class="banner-1 col-5 order-3 col-lg-5 order-2 text-white text-end py-3">\
  70. <a style="text-decoration: none;color:#fff;" href="./about/index.html?id='+ msg[arrIndex].id + '"><div class="banner1-1" style="font-weight: 900;">'+ msg[arrIndex].WorkName + '</div>\
  71. <p><span class="fs-5">'+ msg[arrIndex].DesignerName + '</span>設計師</p>\
  72. </a>\
  73. </div>\
  74. <div class="banner-2 col-7 order-2 col-lg-2 order-3 px-0 mx-0">\
  75. <a href="./about/index.html?id='+ msg[arrIndex].id + '"><img class="img-fluid" src="'+ msg[arrIndex].Designerimg + '" alt=""></a>\
  76. </div>\
  77. </div>';
  78. MobBanner += ' \
  79. <div class="banner-m row vertical align-items-end px-0 mx-0">\
  80. <div class="bannerm-0 col-12 my-5 px-0">\
  81. <img class="img-fluid" src="./img/banner/banner-mobile.png" alt="">\
  82. </div>\
  83. <div class="bannerm-2 col-7 order-2 col-lg-2 order-3 px-0 mx-0">\
  84. <a href="./about/index.html?id='+ msg[arrIndex].id + '"><img class="img-fluid" src="' + msg[arrIndex].Designerimg + '" alt=""></a>\
  85. </div>\
  86. <div class="bannerm-1 col-5 order-3 col-lg-5 order-2 text-white text-start py-3">\
  87. <a style="text-decoration: none;color:#fff;" href="./about/index.html?id='+ msg[arrIndex].id + '">\
  88. <div class="banner1-1" style="font-weight: 900;">'+ msg[arrIndex].WorkName + '</div>\
  89. <p><span class="fs-5">'+ msg[arrIndex].DesignerName + '</span>設計師</p>\
  90. </a>\
  91. </div>\
  92. </div > ';
  93. bodyBannerDes += ' \
  94. <img class="banner-img img-fluid" id="img_id" src="'+ msg[arrIndex].workimg[0].img + '" alt="">\
  95. ';
  96. $('.banner-des').html(desBanner);
  97. $('.banner-m').html(MobBanner);
  98. $('#bannerdes-img').html(bodyBannerDes);
  99. // var test = msg[0].newstext1;
  100. // $('#jsontest').append(test);
  101. });
  102. }
  103. window.onload = funcTest2();
  104. window.setInterval("funcTest2()",1000*8);
  105. // 點選該設計師,導至其對應id的參數網址
  106. $('#278').click(function () {
  107. console.log(1);
  108. window.location.href = `./about/index.html?id=278`;
  109. });
  110. $('#507').click(function () {
  111. console.log(2);
  112. window.location.href = `./about/index.html?id=507`;
  113. });
  114. $('#423').click(function () {
  115. console.log(3);
  116. window.location.href = `./about/index.html?id=423`;
  117. });
  118. $('#594').click(function () {
  119. console.log(4);
  120. window.location.href = `./about/index.html?id=594`;
  121. });
  122. $('#364').click(function () {
  123. console.log(5);
  124. window.location.href = `./about/index.html?id=364`;
  125. });
  126. $('#500').click(function () {
  127. console.log(6);
  128. window.location.href = `./about/index.html?id=500`;
  129. });
  130. $('#651').click(function () {
  131. console.log(7);
  132. window.location.href = `./about/index.html?id=651`;
  133. });
  134. $('#347').click(function () {
  135. console.log(8);
  136. window.location.href = `./about/index.html?id=347`;
  137. });
  138. $('#363').click(function () {
  139. console.log(9);
  140. window.location.href = `./about/index.html?id=363`;
  141. });
  142. $('#555').click(function () {
  143. console.log(10);
  144. window.location.href = `./about/index.html?id=555`;
  145. });
  146. $('#79').click(function () {
  147. console.log(11);
  148. window.location.href = `./about/index.html?id=79`;
  149. });
  150. $('#158').click(function () {
  151. console.log(12);
  152. window.location.href = `./about/index.html?id=158`;
  153. });
  154. $('#301').click(function () {
  155. console.log(13);
  156. window.location.href = `./about/index.html?id=301`;
  157. });
  158. $('#402').click(function () {
  159. console.log(14);
  160. window.location.href = `./about/index.html?id=402`;
  161. });
  162. $('#131').click(function () {
  163. console.log(15);
  164. window.location.href = `./about/index.html?id=131`;
  165. });
  166. $('#28').click(function () {
  167. console.log(16);
  168. window.location.href = `./about/index.html?id=28`;
  169. });
  170. $('#65').click(function () {
  171. console.log(17);
  172. window.location.href = `./about/index.html?id=65`;
  173. });
  174. $('#672').click(function () {
  175. console.log(9);
  176. window.location.href = `./about/index.html?id=672`;
  177. });
  178. $('#438').click(function () {
  179. console.log(9);
  180. window.location.href = `./about/index.html?id=438`;
  181. });
  182. $('#291').click(function () {
  183. console.log(9);
  184. window.location.href = `./about/index.html?id=291`;
  185. });
  186. $('#465').click(function () {
  187. console.log(9);
  188. window.location.href = `./about/index.html?id=465`;
  189. });
  190. $('#436').click(function () {
  191. console.log(9);
  192. window.location.href = `./about/index.html?id=436`;
  193. });
  194. $('#279').click(function () {
  195. console.log(9);
  196. window.location.href = `./about/index.html?id=279`;
  197. });
  198. $('#418').click(function () {
  199. console.log(9);
  200. window.location.href = `./about/index.html?id=418`;
  201. });
  202. $('#385').click(function () {
  203. console.log(9);
  204. window.location.href = `./about/index.html?id=385`;
  205. });
  206. $('#688').click(function () {
  207. console.log(9);
  208. window.location.href = `./about/index.html?id=688`;
  209. });
  210. $('#474').click(function () {
  211. console.log(9);
  212. window.location.href = `./about/index.html?id=474`;
  213. });
  214. $('#505').click(function () {
  215. console.log(9);
  216. window.location.href = `./about/index.html?id=505`;
  217. });
  218. $('#712').click(function () {
  219. console.log(9);
  220. window.location.href = `./about/index.html?id=712`;
  221. });
  222. $('#680').click(function () {
  223. console.log(9);
  224. window.location.href = `./about/index.html?id=680`;
  225. });
  226. $('#705').click(function () {
  227. console.log(9);
  228. window.location.href = `./about/index.html?id=705`;
  229. });
  230. $('#23').click(function () {
  231. console.log(9);
  232. window.location.href = `./about/index.html?id=23`;
  233. });
  234. $('#33').click(function () {
  235. console.log(9);
  236. window.location.href = `./about/index.html?id=33`;
  237. });
  238. $('#491').click(function () {
  239. console.log(9);
  240. window.location.href = `./about/index.html?id=491`;
  241. });
  242. function funcTest() {
  243. $("div.sec01-designer div").sort(function () {
  244. return Math.random() * 10 > 5 ? 1 : -1;
  245. }).each(function () {
  246. var $t = $(this),
  247. color = $t.attr("");
  248. $t.css({ backgroundColor: color }).appendTo($t.parent());
  249. });
  250. }
  251. window.setInterval("funcTest()",1000*10);
  252. window.onload = funcTest();