vtubers.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. const data = [
  2. {
  3. "id": "0",
  4. "name": "凡笙弦語",
  5. "intro": "台灣新人Vtuber鹹魚翻身後依然是條鹹魚以歌唱與歌曲創作為主!",
  6. "img": "https://i.imgur.com/1Oahh38.jpg",
  7. "style": ["可愛"],
  8. "tags": ["#FS鹹魚", "#魚塭", "#TWVtuber" ],
  9. "contact": "",
  10. "follow": [
  11. {
  12. "channel": "facebook",
  13. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  14. "img": "https://i.imgur.com/HtfL33q.png"
  15. },
  16. {
  17. "channel": "Youtube",
  18. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  19. "img": "https://i.imgur.com/c4VdjRJ.png"
  20. },
  21. {
  22. "channel": "twitter",
  23. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  24. "img": "https://i.imgur.com/4VKBo9w.png"
  25. },
  26. {
  27. "channel": "IG",
  28. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  29. "img": "https://i.imgur.com/MAObTJv.png"
  30. },
  31. {
  32. "channel": "youtube",
  33. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  34. "img": "https://i.imgur.com/c4VdjRJ.png"
  35. },
  36. {
  37. "channel": "website",
  38. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  39. "img": "https://i.imgur.com/8nmvSdj.png"
  40. },
  41. {
  42. "channel": "twitch",
  43. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  44. "img": "https://i.imgur.com/FjIaiz9.png"
  45. },
  46. ],
  47. "mp4": null
  48. },
  49. {
  50. "id": "1",
  51. "name": "小烏龜-Yui",
  52. "intro": "lorem",
  53. "img": "https://i.imgur.com/iHtiCpP.jpg",
  54. "style": ["可愛"],
  55. "tags": ["#小烏龜yui"],
  56. "contact": "",
  57. "follow": [
  58. {
  59. "channel": "facebook",
  60. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  61. "img": "https://i.imgur.com/HtfL33q.png"
  62. },
  63. {
  64. "channel": "Youtube",
  65. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  66. "img": "https://i.imgur.com/c4VdjRJ.png"
  67. },
  68. {
  69. "channel": "twitter",
  70. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  71. "img": "https://i.imgur.com/4VKBo9w.png"
  72. },
  73. {
  74. "channel": "IG",
  75. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  76. "img": "https://i.imgur.com/MAObTJv.png"
  77. },
  78. {
  79. "channel": "youtube",
  80. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  81. "img": "https://i.imgur.com/c4VdjRJ.png"
  82. },
  83. {
  84. "channel": "website",
  85. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  86. "img": "https://i.imgur.com/8nmvSdj.png"
  87. },
  88. {
  89. "channel": "twitch",
  90. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  91. "img": "https://i.imgur.com/FjIaiz9.png"
  92. },
  93. ],
  94. "mp4": null
  95. },
  96. {
  97. "id": "2",
  98. "name": "柚餓幽窮",
  99. "intro": "lorem",
  100. "img": "https://i.imgur.com/g00i7Ji.jpg",
  101. "style": ["奶兇"],
  102. "tags": [],
  103. "contact": "",
  104. "follow": [
  105. {
  106. "channel": "facebook",
  107. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  108. "img": "https://i.imgur.com/HtfL33q.png"
  109. },
  110. {
  111. "channel": "Youtube",
  112. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  113. "img": "https://i.imgur.com/c4VdjRJ.png"
  114. },
  115. {
  116. "channel": "twitter",
  117. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  118. "img": "https://i.imgur.com/4VKBo9w.png"
  119. },
  120. {
  121. "channel": "IG",
  122. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  123. "img": "https://i.imgur.com/MAObTJv.png"
  124. },
  125. {
  126. "channel": "youtube",
  127. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  128. "img": "https://i.imgur.com/c4VdjRJ.png"
  129. },
  130. {
  131. "channel": "website",
  132. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  133. "img": "https://i.imgur.com/8nmvSdj.png"
  134. },
  135. {
  136. "channel": "twitch",
  137. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  138. "img": "https://i.imgur.com/FjIaiz9.png"
  139. },
  140. ],
  141. "mp4": null
  142. },
  143. {
  144. "id": "3",
  145. "name": "花御いしき",
  146. "intro": "lorem",
  147. "img": "https://i.imgur.com/e0Nl0FW.png",
  148. "style": ["溫柔可愛", "人格分裂", "配音系"],
  149. "tags": ["#擴散希望", "#男vtuber", " #虛擬youtuber", "#新人VTuber"],
  150. "contact": "",
  151. "follow": [
  152. {
  153. "channel": "facebook",
  154. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  155. "img": "https://i.imgur.com/HtfL33q.png"
  156. },
  157. {
  158. "channel": "Youtube",
  159. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  160. "img": "https://i.imgur.com/c4VdjRJ.png"
  161. },
  162. {
  163. "channel": "twitter",
  164. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  165. "img": "https://i.imgur.com/4VKBo9w.png"
  166. },
  167. {
  168. "channel": "IG",
  169. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  170. "img": "https://i.imgur.com/MAObTJv.png"
  171. },
  172. {
  173. "channel": "youtube",
  174. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  175. "img": "https://i.imgur.com/c4VdjRJ.png"
  176. },
  177. {
  178. "channel": "website",
  179. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  180. "img": "https://i.imgur.com/8nmvSdj.png"
  181. },
  182. {
  183. "channel": "twitch",
  184. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  185. "img": "https://i.imgur.com/FjIaiz9.png"
  186. },
  187. ],
  188. "mp4": "https://www.mboxdrive.com/%E8%81%B2%E9%9F%B3%E7%9B%92%E5%AD%901%20-%20ishiki%20hanao.mp4"
  189. },
  190. {
  191. "id": "4",
  192. "name": "Ikusen(小千)",
  193. "intro": "lorem",
  194. "img": "https://i.imgur.com/GXHDTcd.png",
  195. "style": ["御姊"],
  196. "tags": ["#台V", "#いくせん", "#VTuber ", "#TWvtuber"],
  197. "contact": "",
  198. "follow": [
  199. {
  200. "channel": "facebook",
  201. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  202. "img": "https://i.imgur.com/HtfL33q.png"
  203. },
  204. {
  205. "channel": "Youtube",
  206. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  207. "img": "https://i.imgur.com/c4VdjRJ.png"
  208. },
  209. {
  210. "channel": "twitter",
  211. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  212. "img": "https://i.imgur.com/4VKBo9w.png"
  213. },
  214. {
  215. "channel": "IG",
  216. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  217. "img": "https://i.imgur.com/MAObTJv.png"
  218. },
  219. {
  220. "channel": "youtube",
  221. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  222. "img": "https://i.imgur.com/c4VdjRJ.png"
  223. },
  224. {
  225. "channel": "website",
  226. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  227. "img": "https://i.imgur.com/8nmvSdj.png"
  228. },
  229. {
  230. "channel": "twitch",
  231. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  232. "img": "https://i.imgur.com/FjIaiz9.png"
  233. },
  234. ],
  235. "mp4": null
  236. },
  237. {
  238. "id": "5",
  239. "name": "迷途小喵",
  240. "intro": "lorem",
  241. "img": "https://i.imgur.com/YnSPyv7.jpg",
  242. "style": ["御姊", "多聲線"],
  243. "tags": ["#台V", "#いくせん", "#VTuber ", "#TWvtuber"],
  244. "contact": "",
  245. "follow": [
  246. {
  247. "channel": "facebook",
  248. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  249. "img": "https://i.imgur.com/HtfL33q.png"
  250. },
  251. {
  252. "channel": "Youtube",
  253. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  254. "img": "https://i.imgur.com/c4VdjRJ.png"
  255. },
  256. {
  257. "channel": "twitter",
  258. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  259. "img": "https://i.imgur.com/4VKBo9w.png"
  260. },
  261. {
  262. "channel": "IG",
  263. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  264. "img": "https://i.imgur.com/MAObTJv.png"
  265. },
  266. {
  267. "channel": "youtube",
  268. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  269. "img": "https://i.imgur.com/c4VdjRJ.png"
  270. },
  271. {
  272. "channel": "website",
  273. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  274. "img": "https://i.imgur.com/8nmvSdj.png"
  275. },
  276. {
  277. "channel": "twitch",
  278. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  279. "img": "https://i.imgur.com/FjIaiz9.png"
  280. },
  281. ],
  282. "mp4": null
  283. },
  284. {
  285. "id": "6",
  286. "name": "天晴Haruru🐧",
  287. "intro": "lorem",
  288. "img": "https://i.imgur.com/9autFIy.jpg",
  289. "style": ["奶兇"],
  290. "tags": ["#天晴Haruru", "#VTuber", "#新人VTuber", "#TWvtuber", "#企鵝"],
  291. "contact": "",
  292. "follow": [
  293. {
  294. "channel": "facebook",
  295. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  296. "img": "https://i.imgur.com/HtfL33q.png"
  297. },
  298. {
  299. "channel": "Youtube",
  300. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  301. "img": "https://i.imgur.com/c4VdjRJ.png"
  302. },
  303. {
  304. "channel": "twitter",
  305. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  306. "img": "https://i.imgur.com/4VKBo9w.png"
  307. },
  308. {
  309. "channel": "IG",
  310. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  311. "img": "https://i.imgur.com/MAObTJv.png"
  312. },
  313. {
  314. "channel": "youtube",
  315. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  316. "img": "https://i.imgur.com/c4VdjRJ.png"
  317. },
  318. {
  319. "channel": "website",
  320. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  321. "img": "https://i.imgur.com/8nmvSdj.png"
  322. },
  323. {
  324. "channel": "twitch",
  325. "link": 'https://www.facebook.com/groups/590614894737063/?hoisted_section_header_type=recently_seen&multi_permalinks=1253077595157453',
  326. "img": "https://i.imgur.com/FjIaiz9.png"
  327. },
  328. ],
  329. "mp4": null
  330. },
  331. ];
  332. function getVtuber() {
  333. if(window.location.pathname.match('vtuber')) {
  334. console.log('vtuber list');
  335. let result = [...data];
  336. console.log(result);
  337. let str = '';
  338. for(let i = 0; i < result.length; i++){
  339. let style = '';
  340. for(let j = 0; j < result[i].style.length; j++){
  341. style += `<span class="vt-style">${result[i].style[j]}</span>`;
  342. console.log(result[i].style.length);
  343. }
  344. str += `<div class="col-6 col-sm-4 col-md-3">
  345. <div class="card" style="width: 100%;">
  346. <div class="vt-ribbon"><p>Vtuber</p></div>
  347. <div class="card-img-fr" style="background-image:url(${result[i].img})"></div>
  348. <div class="card-body">
  349. <h5 class="card-title">${result[i].name}</h5>
  350. ${style}
  351. <button class="card-link" data-toggle="modal" data-target="#more1Modal" data-id="${result[i].id}" >查看更多></button>
  352. </div>
  353. </div>
  354. </div>`;
  355. }
  356. $('.vt-list .vt-content').html(str);
  357. $('.vt-content .card-link').click(function(){
  358. const music = document.querySelector('.modal-body-sample audio');
  359. const progressBar = document.querySelector('#progress-bar');
  360. const progressZone = document.querySelector('.music-progress');
  361. let selected = result.filter(item =>
  362. item.id == $(this).data('id')
  363. )[0];
  364. console.log(selected);
  365. $('#more1Modal .modal-title').text(selected.name);
  366. $('#more1Modal .modal-imgfr').css('background-image', `url(${selected.img})`);
  367. $('#more1Modal p').text(selected.intro);
  368. let str = '';
  369. for(let i = 0; i < selected.follow.length; i++){
  370. str += `<a href="${selected.follow[i].link}"><img src="${selected.follow[i].img}" alt="${selected.follow[i].channel}" width="32px" height="32px"></a>`
  371. }
  372. $('#more1Modal .footer-socials').html(str);
  373. if(selected.mp4 == null) {
  374. $('.modal-body-sample').css('display', 'none');
  375. } else {
  376. $('.modal-body-sample audio').attr('src', selected.mp4);
  377. }
  378. let hashtagStr = "";
  379. for(let i = 0; i < selected.tags.length; i++){
  380. hashtagStr+= `<span class="hashtag-pill">${selected.tags[i]}</span>`;
  381. };
  382. $('#more1Modal .modal-hashtag').html(hashtagStr);
  383. let isPlaying = false;
  384. $('.modal-body-toggleplay').click(function(){
  385. //isPlaying? pauseMusic(music) : playMusic(music)
  386. if(isPlaying) {
  387. music.pause();
  388. $('.modal-body-toggleplay').attr("src", "https://i.imgur.com/gYst9TQ.png");
  389. isPlaying = false;
  390. } else {
  391. music.play();
  392. $('.modal-body-toggleplay').attr("src", "https://i.imgur.com/f5PWQUb.png");
  393. isPlaying = true;
  394. }
  395. console.log(isPlaying);
  396. });
  397. $('[data-dismiss="modal"]').click(function() {
  398. music.pause();
  399. $('.modal-body-toggleplay').attr("src", "https://i.imgur.com/gYst9TQ.png");
  400. isPlaying = false;
  401. });
  402. music.addEventListener('timeupdate', updateProgress);
  403. progressZone.addEventListener('click', setProgress);
  404. })
  405. }
  406. }
  407. getVtuber();
  408. const updateProgress = (e) => {
  409. const music = document.querySelector('.modal-body-sample audio');
  410. const progressBar = document.querySelector('#progress-bar');
  411. const progressZone = document.querySelector('.music-progress');
  412. const {
  413. duration,
  414. currentTime
  415. } = e.srcElement;
  416. const progressPercent = (currentTime / duration) * 100
  417. progressBar.style.width = `${progressPercent}%`
  418. if(progressPercent == 100) {
  419. music.pause();
  420. $('.modal-body-toggleplay').attr("src", "https://i.imgur.com/gYst9TQ.png");
  421. isPlaying = false;
  422. console.log('test');
  423. }
  424. }
  425. function setProgress(e) {
  426. const music = document.querySelector('.modal-body-sample audio');
  427. const width = this.clientWidth;
  428. const setPoint = e.offsetX;
  429. const duration = music.duration;
  430. music.currentTime = (setPoint / width) * duration;
  431. }