Segitseg kellene egy javascript atalakitasaba,adott egy script ami kereses alapjan bekeri a youtube videokat nagyon jol mukodik de en szeretnem ezt ugy hasznalni hogy a kereso mezot elhagyom es az alltalam megadott kulcsszo alapjan jelenjenek meg a videok.Ez a kod
PHP kód:
<form id="search-term" method="" onsubmit="return false;">
<input id="query" type="text" >
<input type="submit" class="icon" value="" onsubmit="return false;">
</form><br/>
<div id="now_video" style="width:560px"></div>
<div id="search-results" style="width:<?php echo $wth; ?>;"></div><script type='text/javascript'>
//var listoplyryn;
function getRequest(searchTerm) {
url = 'https://www.googleapis.com/youtube/v3/search';
var params = {
maxResults: '<?php echo $youtubenum; ?>',
part: 'snippet',
key: '<?php echo $youtubekey; ?>',
q: 'sajat kulcsszo'
};
$.getJSON(url, params, function (searchTerm) {
showResults(searchTerm);
});
}
//function getmevideo(myvideo) {
// document.getElementById("now_video").innerHTML = '<iframe width="560" height="315" src="https://www.youtube.com/embed/' + myvideo + '?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>'+ listoplyryn;
// window.location.hash = "search-term";
//}
var listoplyryn;
function showResults(results) {
var html = "";
var entries = results.items;
listoplyryn = ',';
$.each(entries, function (index, value) {
//alert(JSON.stringify(value));
var title = value.snippet.title;
var thumbnail = value.snippet.thumbnails.medium.url;
var descript = value.snippet.description;
if(typeof value.id.playlistId !== 'undefined') {
var resulturl = thumbnail.split("/");
listoplyryn += ',' + resulturl[4];
html += '<div style="width: 300px; height: 450px; margin:10px; float: left;"><div class="card" id="whatsup" style="width: 300px; height: auto;" onclick="getmevideo(\'' + resulturl[4] +'\');"><img class="card-img-top" src="' + thumbnail +'" alt="Card image cap"><div class="card-block"><h4 class="card-title" style="margin-top:10px;">'+ title.substring(0, 60) +' ...</h4><p class="card-text" style="font-size:14px;">'+ descript.substring(0, 120) +' ... </p></div></div></div>';
}
if(typeof value.id.videoId !== 'undefined') {
listoplyryn += ',' + value.id.videoId;
html += '<div style="width: 300px; height: 450px; margin:10px; float: left;"><div class="card" id="whatsup" style="width: 300px; height: auto;" onclick="getmevideo(\'' + value.id.videoId +'\');"><img class="card-img-top" src="' + thumbnail +'" alt="Card image cap"><div class="card-block"><h4 class="card-title" style="margin-top:10px;">'+ title.substring(0, 60) +' ...</h4><p class="card-text" style="font-size:14px;">'+ descript.substring(0, 120) +' ... </p></div></div></div>';
}
if(typeof value.id.channelId !== 'undefined') {
html += '<div style="width: 300px; height: 450px; margin:10px; float: left;"><div class="card" style="width: 300px; height: auto;"><img class="card-img-top" src="' + thumbnail +'" alt="Card image cap">';
html += '<div class="card-block"><h4 class="card-title" style="margin-top:10px;">'+ title.substring(0, 60) +' ...</h4><p class="card-text" style="font-size:14px;">'+ descript.substring(0, 120) +' ... </p>';
html += '<a href="https://www.youtube.com/channel/' + value.id.channelId + '" class="btn btn-primary" target="_blank">Go to video...</a></div></div></div>';
}
});
$('#search-results').html(html);
}
jQuery(function() {
jQuery( "#query" ).autocomplete({
source: function( request, response ) {
var searchTerm = $('#query').val();
getRequest(searchTerm);
//console.log(request.term);
$('#search-term').on('click', function (event) {
event.preventDefault();
var searchTerm = $('#query').val();
getRequest(searchTerm);
});
var sqValue = [];
}
});
});
window.onload = getRequest(searchTerm);
function getmevideo(myvideo) {
document.getElementById("now_video").innerHTML = '<iframe width="560" height="315" src="https://www.youtube.com/embed/' + myvideo + '?playlist=' + listoplyryn + '&cc_load_policy=0&iv_load_policy=3&showinfo=0&modestbranding=1&fs=1&loop=1&hl=en_US&autoplay=1" frameborder="0" allowfullscreen></iframe>';
window.location.hash = "search-term";
}
</script>
a videok betoltodnek ahogy elkezdek gepelni valamit a keresomezobe de en azt szeretnem ha nincs keresomezo es automatikusan betoltodnenek a videok
Könyvjelzők