User:KurwaAntics/common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 8: Line 8:
     } else {
     } else {
         var url = $(this).attr('href');
         var url = $(this).attr('href');
         var id = url.substring(url.indexOf(".be/") + 4, url.indexOf("?"));
         var id = url.substring(url.indexOf(".be/") + 4, url.indexOf("?") - 1);
 
         $('body').prepend('<div class="greyout"><span class="close-modal">✕</span></div><div class="mymodal" style="width: 800px; height: 450px;"><iframe style="width:100%; height:100%" src="http://www.youtube.com/embed/' + id + '?autoplay=1"></iframe></div>');
if(your_string.indexOf('?') === -1)
{
  var cond = "&" + url.substring(url.indexOf("?") + 1);
}
       
         $('body').prepend('<div class="greyout"><span class="close-modal">✕</span></div><div class="mymodal" style="width: 800px; height: 450px;"><iframe style="width:100%; height:100%" src="http://www.youtube.com/embed/' + id + '?autoplay=1' + cond + '"></iframe></div>');
         $('.close-modal').on('click', function() {
         $('.close-modal').on('click', function() {
             $(".greyout, .mymodal").remove();
             $(".greyout, .mymodal").remove();
Line 22: Line 16:
     }
     }
});
});


$('a[href*="youtube.com/watch"]').on('click', function(){
$('a[href*="youtube.com/watch"]').on('click', function(){
Line 28: Line 23:
     } else {
     } else {
         var url = $(this).attr('href');
         var url = $(this).attr('href');
         var id = url.substring(url.indexOf("v=") + 2, url.indexOf("&"));
         var id = url.substring(url.indexOf("v=") + 2, url.indexOf("&") - 1);
if(your_string.indexOf('&') === -1)
         $('body').prepend('<div class="greyout"><span class="close-modal">✕</span></div><div class="mymodal" style="width: 800px; height: 450px;"><iframe style="width:100%; height:100%" src="http://www.youtube.com/embed/' + id + '?autoplay=1"></iframe></div>');
{
  var cond = url.substring(url.indexOf("&"));
}
       
         $('body').prepend('<div class="greyout"><span class="close-modal">✕</span></div><div class="mymodal" style="width: 800px; height: 450px;"><iframe style="width:100%; height:100%" src="http://www.youtube.com/embed/' + id + '?autoplay=1' + cond + '"></iframe></div>');
         $('.close-modal').on('click', function() {
         $('.close-modal').on('click', function() {
             $(".greyout, .mymodal").remove();
             $(".greyout, .mymodal").remove();
323

edits