<div id="player" ></div>
<script type="text/javascript">
// vid = "X2gcLUZ7qnw%3Flist%3D"; x4GcbYqpESQ
var player; function onYouTubeIframeAPIReady()
{ player = new YT.Player('player',{ videoId:'X2gcLUZ7qnw',
playerVars: { autoplay: 1, html5: 1, theme: "light", modesbranding: 0,
color: "white", iv_load_policy: 3, showinfo: 0, controls: 2, 'wmode':'opaque', 'list' : ''}, }); }
var tag = document.createElement('script');tag.src = "//www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
document.getElementById('getJSON').addEventListener('click', getJSON);document.getElementById('postData');
function getJSON(){fetch('p2.json').then((res) => { return res.json() }).then((data) => { let result = ' ';
data.forEach((user) => {result += `
<ul >
<li>
<span id="_index_1_${user.num}" onclick="load()"> ${user.id} </span>
<img align=left src="">
${user.body}</li><li>
<a href="#${user.num}" id="_index_2_${user.num}" > ${user.title}</a></li>
</ul>
`;
document.getElementById('result').innerHTML = result;
});}) };
[
{
"userId": 1,
"id": 1,
"ris": "a7DIP8u3BAM","com": "-aShrBgwOzJo",
"num": "UC3wf1pcRkwV-NvUpBfHovPw",
"title": "LIFE | Новости",
"body": "Бывают трансляции."
},
{
"userId": 1,
"id": 2,
"ris": "Bs5olPCc94w","com": "-af8gHJIIm3c",
"num": "UCSPd93is2UQsd_jZ6yHBfqQ",
"title": "ПостНаука. Спросить. ",
"body": "Популярная наука."
},
{
"userId": 1,
"id": 3,
"ris": "-0-nRfYvyvY","com": "-ozIaPTmocNg",
"num": "UCBR8-60-B28hp2BmDPdntcQ",
"title": "НТВ.",
"body": " Прямой эфир. Трансляция."
},
{
"userId": 1,
"id": 4,
"ris": "7zCt63Ghg3A","com": "-WG2w_PTtoS0",
"num": "UCKonxxVHzDl55V7a9n_Nlgg",
"title": "Новости на 1",
"body": "Трансляция."
},
{
"userId": 1,
"id": 5,
"ris": "WIMgNJSIyAo","com": "-1C2sit92qoI",
"num": "UCFU30dGHNhZ-hkh0R10LhLw",
"title": "Россия тудей",
"body": "На русском."
},
{
"userId": 1,
"id": 6,
"ris": "5NdDPcu1rz8","com": "-Kctadlnnczo",
"num": "UCpwvZwUam-URkxB7g4USKpg",
"title": "RussiaToday",
"body": "На английском."
},
{
"userId": 1,
"id": 7,
"ris": "mlBvC324vQg","com": "-QtSXu5yl9KE",
"num": "UCVPYbobPRzz0SjinWekjUBw",
"title": "Анатолий Шарий",
"body": "Новости Украины."
},
{
"userId": 1,
"id": 8,
"ris": "5ybChx8YIbg","com": "-LnrKwmlxGxM",
"num": "UCXoAjrdHFa2hEL3Ug8REC1w",
"title": "DW Russian",
"body": "Новости Германии по России."
},
{
"userId": 1,
"id": 9,
"ris": "ZCMMkRj-hrw","com": "-dL2jeHlm2Ok",
"num": "UCBR8-60-B28hp2BmDPdntcQ",
"title": "YouTube Spotlight",
"body": "агрегатор каналов"
},
{
"userId": 1,
"id": 10,
"ris": "_2CAWn_kDB8","com": "-OblrqunS_Q4",
"num": "UCY14-R0pMrQzLne7lbTqRvA",
"title": "Vevo UK",
"body": "Музыка."
},
{
"userId": 1,
"id": 11,
"ris": "au0eYRpL_t0","com": "-TS7z3VJPozU",
"num": "UCWAK-dRtTEjnQnD96L6UMsQ",
"title": "РБК",
"body": "Бизнес."
}
]
var i = 0;(function(history){ var pushState = history.pushState;
history.pushState = function(state) { if (typeof history.onpushstate == "function")
{history.onpushstate({state: state});}
return pushState.apply(history, arguments); }})(window.history);
window.onpopstate = history.onpushstate = function(e){ i++; test=JSON.stringify(e.state);
<nav>
<ul><li tabindex="1"><a class="box" data-page="page1_index_1_UCY14-R0pMrQzLne7lbTqRvA"> VEVO UK</a></li></ul></nav>
var myArticle = document.querySelector('article'); var myLinks = document.querySelectorAll('nav ul a'); for(var i = 0; i <= myLinks.length - 1; i++) {
myLinks[i].onclick = function(e) {e.preventDefault();var linkData = e.currentTarget.getAttribute('data-page'); getData(linkData); } };
function getData(pageId) {
lo2 = pageId.substr(5); lo1 = pageId.substr(0,5);
var myRequest = new Request(lo1+ '.php', {method: 'POST',headers: { "Content-Type":"application/x-www-form-urlencoded" },
body: 'foo={"name":"'+lo2+'","time":"'+lo2+'","name2":"'+lo1+' "} '}); fetch(myRequest).then(function(response) { return response.text() })
.then(function(text) { myArticle.innerHTML = text;
}); };