{"id":9,"date":"2023-07-18T10:20:21","date_gmt":"2023-07-18T10:20:21","guid":{"rendered":"https:\/\/youflix.digitalsolutionsldn.co.uk\/?page_id=9"},"modified":"2023-07-18T10:20:56","modified_gmt":"2023-07-18T10:20:56","slug":"9-2","status":"publish","type":"page","link":"https:\/\/youflix.digitalsolutionsldn.co.uk\/index.php\/9-2\/","title":{"rendered":""},"content":{"rendered":"<script>\/\/ Wait for page to load\r\ndocument.addEventListener('DOMContentLoaded', function(event) {\r\n\tready();\r\n})\r\n\r\nfunction ready() {\r\n\tlet url = 'https:\/\/api.sheety.co\/8e9ea8da6dbc0ca6b0fad95171da60a8\/youflix\/videos';\r\n\tfetch(url)\r\n\t.then((response) => response.json())\r\n\t.then(json => {\r\n\t\tlet videos = json.videos;\r\n\t\t\/\/ Parse out YouTube ID from the URL, as we'll use that to get the thumbnail\r\n\t\tvideos.forEach(video => {\r\n\t\t\tlet regex = \/watch\\?v=([\\w\\d-]*)\/;\r\n\t\t\tvideo.youtubeID = video.url.match(regex)[1];\r\n\t\t});\r\n\t\t\r\n\t\tlet featuredVideo = videos.find(video => {\r\n\t\t\treturn video.isFeatured;\r\n\t\t});\r\n\t\r\n\t\tlet groupedVideos = _.groupBy(json.videos, 'category');\r\n\t\tvar template = Handlebars.compile(document.getElementById(\"app-template\").innerHTML);\r\n\t\t\/\/ Render items into Handlebars template, and set the html of the container element\r\n\t\tdocument.getElementById('app').innerHTML = template({\r\n\t\t\tfeatured: featuredVideo,\r\n\t\t\tvideos: groupedVideos\r\n\t\t});\r\n\t});\r\n}\r\n<\/script>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Wait for page to load\ndocument.addEventListener('DOMContentLoaded', function(event) {\n\tready();\n})\n\nfunction ready() {\n\tlet url = 'https:\/\/api.sheety.co\/8e9ea8da6dbc0ca6b0fad95171da60a8\/youflix\/videos';\n\tfetch(url)\n\t.then((response) => response.json())\n\t.then(json => {\n\t\tlet videos = json.videos;\n\t\t\/\/ Parse out YouTube ID from the URL, as we'll use that to get the thumbnail\n\t\tvideos.forEach(video => {\n\t\t\tlet regex = \/watch\\?v=(&#091;\\w\\d-]*)\/;\n\t\t\tvideo.youtubeID = video.url.match(regex)&#091;1];\n\t\t});\n\t\t\n\t\tlet featuredVideo = videos.find(video => {\n\t\t\treturn video.isFeatured;\n\t\t});\n\t\n\t\tlet groupedVideos = _.groupBy(json.videos, 'category');\n\t\tvar template = Handlebars.compile(document.getElementById(\"app-template\").innerHTML);\n\t\t\/\/ Render items into Handlebars template, and set the html of the container element\n\t\tdocument.getElementById('app').innerHTML = template({\n\t\t\tfeatured: featuredVideo,\n\t\t\tvideos: groupedVideos\n\t\t});\n\t});\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/youflix.digitalsolutionsldn.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/9"}],"collection":[{"href":"https:\/\/youflix.digitalsolutionsldn.co.uk\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/youflix.digitalsolutionsldn.co.uk\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/youflix.digitalsolutionsldn.co.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/youflix.digitalsolutionsldn.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=9"}],"version-history":[{"count":2,"href":"https:\/\/youflix.digitalsolutionsldn.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/9\/revisions"}],"predecessor-version":[{"id":12,"href":"https:\/\/youflix.digitalsolutionsldn.co.uk\/index.php\/wp-json\/wp\/v2\/pages\/9\/revisions\/12"}],"wp:attachment":[{"href":"https:\/\/youflix.digitalsolutionsldn.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}