View file javascript/main.js

File size: 0.99Kb
$(document).ready(function() 
{
  $('a').click(function() {
    var title = $(this).attr('title');
    var url = $(this).attr('href');
    var searchObject = $(this).attr('id');
    
    objectYoutube = /you-/i
    
    if (searchObject.match(objectYoutube)) {
      
      function explode(d, s, l) {
        var out=[], tmp, pos;
        if (l) {
          tmp = s;
          pos = s.indexOf(d)
          while(l-1 && pos>=0) {
            out.push(tmp.substr(0, pos));
            tmp = tmp.substr(pos+d.length);
            l--;
            pos = tmp.indexOf(d);
          }
          out.push(tmp);
        }
        else
        out = s.split(d);
        return out;
      }
      var code = explode('v=', url, '11');
      
      document.getElementById("you-" + url + "-play").innerHTML = '<iframe width="320" height="240" src="//www.youtube.com/embed/' + code['1'] + '?feature=player_detailpage" frameborder="0" allowfullscreen></iframe>';
      return false;
    }
  });
});