AI Image Video

by gokulmaha

HTML

<script src="https://unpkg.com/compromise"></script>

<textarea id="txtArea"></textarea>
</br>
Image<input type="text" id="search"/> <span id="count"></span>
Video<input type="text" id="searchVideo"/> <span id="videocount"></span>

<div id="Imageview">
 </div>
 <div id="Videoview">
 </div>

CSS

img,video{
  max-width:400px;
    float: left;

}

.vid-cont{
  padding:10px;
  float: left;
}

JavaScript

$("#search").on('change', function() {
  $.ajax({
    type: "GET",
    url: "https://api.pexels.com/v1/search?query="+$(this).val(),
    dataType: 'json',
    headers: {
      "Authorization": "vk7yrdtjdxkyHys6pdRRZh7evOdEaV0ECnsqgjurwgezjCSvrKPmtDye"
    },
    success: function(d) {
 			$("#Imageview").empty()
      $("#count").text(d.photos.length)
      $.each(d.photos, function(i, v) {
        $("#Imageview").append("<img src=" + v.src.portrait + "/>")

      })
    }
  });
})

$("#searchVideo").on('change', function() {
  $.ajax({
    type: "GET",
    url: "https://api.pexels.com/v1/videos/search?query="+$(this).val()+"&orientation=portrait",
    dataType: 'json',
    headers: {
      "Authorization": "vk7yrdtjdxkyHys6pdRRZh7evOdEaV0ECnsqgjurwgezjCSvrKPmtDye"
    },
    success: function(d) {
  	  console.log(d)
 			$("#Videoview").empty()
      $("#videocount").text(d.videos.length)
      $.each(d.videos, function(i, v) {
      
       	  console.log(v.video_files[0].link )
if(v.duration < 20){
 $("#Videoview").append('<div class="vid-cont"><video controls <source src="'+v.video_files[0].link+'" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support the video tag.</video></div>')
}
       

      })
    }
  });
})
$("#txtArea").on('change', function() {
	var doc = nlp($("#txtArea").val()).compute('penn')
  console.log(doc.json()[0].terms)
  var adj = doc.json()[0].terms.filter(function(v){
    return v.tags.indexOf("Adjective") > -1
	})

if(adj.length == 0){
adj = doc.json()[0].terms.filter(function(v){
    return v.tags.indexOf("Verb") > -1 && v.text.length > 3
	})
}
console.log(adj)

	$("#search").val(adj[0].text).trigger('change');
	$("#searchVideo").val(adj[0].text).trigger('change');
})

function downloadResource(url, filename) {

  // Current blob size limit is around 500MB for browsers
  if (!filename) filename = url.split('\\').pop().split('/').pop();
  fetch(url, {
      headers: new Headers({
        'Origin':...