let sermon_rss = "/playlist.php?pl=PLGtPNoN_ZSqA5_cgwhRXRmPaQdlcXzU05"; let choir_rss = "/playlist.php?pl=PLGtPNoN_ZSqARVNWA9vUiONpmgRhKgxfX"; let shots_rss = "/playlist.php?pl=PLGtPNoN_ZSqDnTRj1ImhyEAyNTA2cEz58"; $(document).ready(function(){ $("button.scard").off("click"); $("button.short").off("click"); $("button.scard").on("click", function(ev){ let video_id = $(this).data("vid"); openVideo(video_id, false); }); $("button.short").on("click", function(ev){ let video_id = $(this).data("vid"); openVideo(video_id, true); }); $.ajax({ url: sermon_rss, // 호출할 XML 파일 주소 type: 'GET', dataType: 'json', success: function(json) { $.each(json, function(index, value) { // console.log(value); if (index == 0){ $("div.sermon__grid > button.scard").data("vid", value.video_id); $("div.sermon__grid > button div.scard__thumb img").attr("src", value.thumbnail).attr("alt", value.sermon_title); $("div.sermon__grid > button div.scard__body > p.scard__ttl").html(value.sermon_title); $("div.sermon__grid > button div.scard__body > p.scard__meta").html(value.sermon_date+" · "+value.preacher); } else if (index >= 1 && index <= 4){ $("div.sermon__grid > div.sermon__list > button.scard").eq(index -1).data("vid", value.video_id); $("div.sermon__grid > div.sermon__list > button div.scard__thumb img").eq(index -1).attr("src", value.thumbnail).attr("alt", value.sermon_title); $("div.sermon__grid > div.sermon__list > button div.scard__body > p.scard__ttl").eq(index -1).html(value.sermon_title); $("div.sermon__grid > div.sermon__list > button div.scard__body > p.scard__meta").eq(index -1).html(value.sermon_date+" · "+value.preacher); } }); }, error: function(xhr, status, error) { console.error("데이터를 불러오지 못했습니다.", error); } }); $.ajax({ url: choir_rss, // 호출할 XML 파일 주소 type: 'GET', dataType: 'json', success: function(json) { $.each(json, function(index, value) { // console.log(value); if (index >= 0 && index <= 4){ $("div.choir__grid > button.scard").eq(index).data("vid", value.video_id); $("div.choir__grid > button div.scard__thumb img").eq(index).attr("src", value.thumbnail).attr("alt", value.sermon_title); $("div.choir__grid > button div.scard__body > p.scard__ttl").eq(index).html(value.sermon_title); $("div.choir__grid > button div.scard__body > p.scard__meta").eq(index).html(value.sermon_date+" · "+value.preacher); } }); }, error: function(xhr, status, error) { console.error("데이터를 불러오지 못했습니다.", error); } }); $.ajax({ url: shots_rss, // 호출할 XML 파일 주소 type: 'GET', dataType: 'json', success: function(json) { $.each(json, function(index, value) { // console.log(value); if (index >= 0 && index <= 5){ $("div.shorts__rail > button.short").eq(index).data("vid", value.video_id); $("div.shorts__rail > button.short div.short__thumb > img").eq(index).attr("src", value.thumbnail).attr("alt", value.sermon_title); $("div.shorts__rail > button.short div.short__thumb > span.short__ttl").eq(index).html(value.sermon_title); } }); }, error: function(xhr, status, error) { console.error("데이터를 불러오지 못했습니다.", error); } }); });