| 1 |
window._EPYTWIZ_ = window._EPYTWIZ_ || {}; |
| 2 |
(function ($) |
| 3 |
{ |
| 4 |
|
| 5 |
$.fn.followTo = function (pos, startTop) |
| 6 |
{ |
| 7 |
var $this = this, |
| 8 |
$window = $(window); |
| 9 |
|
| 10 |
$window.on('scroll', function (e) |
| 11 |
{ |
| 12 |
if ($window.scrollTop() > pos) |
| 13 |
{ |
| 14 |
$this.css({ |
| 15 |
position: 'absolute', |
| 16 |
top: pos |
| 17 |
}); |
| 18 |
} |
| 19 |
else |
| 20 |
{ |
| 21 |
$this.css({ |
| 22 |
position: 'fixed', |
| 23 |
top: startTop |
| 24 |
}); |
| 25 |
} |
| 26 |
}); |
| 27 |
}; |
| 28 |
|
| 29 |
window._EPYTWIZ_.getUrlParameter = function (name) |
| 30 |
{ |
| 31 |
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); |
| 32 |
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); |
| 33 |
var results = regex.exec(window.location.search); |
| 34 |
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); |
| 35 |
}; |
| 36 |
|
| 37 |
window._EPYTWIZ_.selectText = window._EPYTWIZ_.selectText || function (ele) |
| 38 |
{ |
| 39 |
if (document.selection) |
| 40 |
{ |
| 41 |
var range = document.body.createTextRange(); |
| 42 |
range.moveToElementText(ele); |
| 43 |
range.select(); |
| 44 |
} |
| 45 |
else if (window.getSelection) |
| 46 |
{ |
| 47 |
var selection = window.getSelection(); |
| 48 |
var range = document.createRange(); |
| 49 |
range.selectNode(ele); |
| 50 |
selection.removeAllRanges(); |
| 51 |
selection.addRange(range); |
| 52 |
} |
| 53 |
}; |
| 54 |
|
| 55 |
|
| 56 |
window._EPYTWIZ_.loadmovieplain = window._EPYTWIZ_.loadmovieplain || function (vid) |
| 57 |
{ |
| 58 |
var codetemplate = '<iframe allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" width="600" height="368" src="//www.youtube.com/embed/~ytid?autoplay=1" frameborder="0" allowfullscreen ></iframe>'; |
| 59 |
codetemplate = codetemplate.replace(/~ytid/g, vid); |
| 60 |
$("#watch" + vid).html(codetemplate); |
| 61 |
$('#closeme' + vid).css('display', 'inline'); |
| 62 |
$("#moviecontainer" + vid).css('display', 'block'); |
| 63 |
if (document.getElementById('scrollwatch' + vid)) |
| 64 |
{ |
| 65 |
setTimeout(function () |
| 66 |
{ |
| 67 |
$('html, body').animate({ |
| 68 |
scrollTop: $('#scrollwatch' + vid).offset().top - 50 |
| 69 |
}, 250, function () |
| 70 |
{ |
| 71 |
}); |
| 72 |
|
| 73 |
}, 800); |
| 74 |
} |
| 75 |
}; |
| 76 |
|
| 77 |
|
| 78 |
window._EPYTWIZ_.closeme = window._EPYTWIZ_.closeme || function (vid) |
| 79 |
{ |
| 80 |
$("#moviecontainer" + vid).css('display', 'none'); |
| 81 |
$("#watch" + vid).html(""); |
| 82 |
}; |
| 83 |
|
| 84 |
$(document).ready(function () |
| 85 |
{ |
| 86 |
$('.wiz-accordion').accordion({ |
| 87 |
header: "> h3", |
| 88 |
collapsible: true, |
| 89 |
active: false, |
| 90 |
icons: { |
| 91 |
header: "ui-icon-circle-arrow-e", |
| 92 |
activeHeader: "ui-icon-circle-arrow-s" |
| 93 |
}, |
| 94 |
heightStyle: "content", |
| 95 |
autoHeight: false |
| 96 |
}).find('h3.header-go').on('click', function () |
| 97 |
{ |
| 98 |
window.open($(this).find('a').attr('href'), '_blank'); |
| 99 |
return false; |
| 100 |
}); |
| 101 |
|
| 102 |
$('.playlist-tabs').tabs(); |
| 103 |
$('.livestream-tabs').tabs(); |
| 104 |
|
| 105 |
if (window._EPYTWIZ_.acc_expand) |
| 106 |
{ |
| 107 |
$('.wiz-accordion #' + window._EPYTWIZ_.acc_expand).trigger('click'); |
| 108 |
} |
| 109 |
|
| 110 |
$('form.wizform').each(function () |
| 111 |
{ |
| 112 |
var $thisForm = $(this); |
| 113 |
var pasteTimeout; |
| 114 |
$thisForm.find('.txturlpastecustom').on('paste change', function () |
| 115 |
{ |
| 116 |
var $thisTxtUrl = $(this); |
| 117 |
clearTimeout(pasteTimeout); |
| 118 |
pasteTimeout = setTimeout(function () |
| 119 |
{ |
| 120 |
var thepaste = $.trim($thisTxtUrl.val()); |
| 121 |
var badpaste = /<.*/i; |
| 122 |
if (badpaste.test(thepaste)) |
| 123 |
{ |
| 124 |
var reg = new RegExp('(?:https?://)?(?:www\\.)?(?:youtu\\.be/|youtube\\.com(?:/embed/|/shorts/|/v/|/watch\\?v=))([\\w-]{10,12})', 'ig'); |
| 125 |
//get matches found for the regular expression |
| 126 |
var matches = reg.exec(thepaste); |
| 127 |
//check if we have found a match for a YouTube video |
| 128 |
//will support legacy code, shortened urls and |
| 129 |
if (matches) |
| 130 |
{ |
| 131 |
var ytid = matches[1]; |
| 132 |
$thisTxtUrl.val('https://www.youtube.com/watch?v=' + ytid); |
| 133 |
} |
| 134 |
else |
| 135 |
{ |
| 136 |
$thisTxtUrl.val('https://www.youtube.com/watch?v='); |
| 137 |
} |
| 138 |
$thisForm.find('.badpaste').show(); |
| 139 |
|
| 140 |
} |
| 141 |
else |
| 142 |
{ |
| 143 |
$thisForm.find('.badpaste').hide(); |
| 144 |
} |
| 145 |
|
| 146 |
}, 100); |
| 147 |
}); |
| 148 |
$thisForm.on('submit', function() { |
| 149 |
clearTimeout(pasteTimeout); |
| 150 |
}); |
| 151 |
}); |
| 152 |
|
| 153 |
var $epyt_wiz_wrap = $('#epyt_wiz_wrap'); |
| 154 |
|
| 155 |
$epyt_wiz_wrap.on('click', '.copycode', function () |
| 156 |
{ |
| 157 |
window._EPYTWIZ_.selectText(this); |
| 158 |
}); |
| 159 |
|
| 160 |
$epyt_wiz_wrap.on('click', '.inserttopost', function () |
| 161 |
{ |
| 162 |
var targetdomain = window.location.toString().split("/")[0] + "//" + window.location.toString().split("/")[2]; |
| 163 |
var embedline = $(this).attr("rel"); |
| 164 |
var gbclientId = window._EPYTWIZ_.getUrlParameter('clientId'); |
| 165 |
parent.postMessage("youtubeembedplus|" + embedline + (gbclientId ? '|clientId=' + gbclientId : ''), targetdomain); |
| 166 |
}); |
| 167 |
|
| 168 |
$epyt_wiz_wrap.on('click', '.resultdiv .load-movie', function () |
| 169 |
{ |
| 170 |
window._EPYTWIZ_.loadmovieplain($(this).closest('.resultdiv').data('vid')); |
| 171 |
return false; |
| 172 |
}); |
| 173 |
|
| 174 |
$epyt_wiz_wrap.on('click', '.moviecontainer a.closeme', function () |
| 175 |
{ |
| 176 |
window._EPYTWIZ_.closeme($(this).data('vid')); |
| 177 |
}); |
| 178 |
|
| 179 |
$epyt_wiz_wrap.on('paste change input propertychange', '#txtUrlChannel', function () |
| 180 |
{ |
| 181 |
if ($(this).val().indexOf('/c/') > 0) |
| 182 |
{ |
| 183 |
$('.error-channel-format').addClass('orange bold'); |
| 184 |
$(this).val(''); |
| 185 |
} |
| 186 |
else |
| 187 |
{ |
| 188 |
$('.error-channel-format').removeClass('orange bold'); |
| 189 |
} |
| 190 |
}); |
| 191 |
|
| 192 |
}); |
| 193 |
})(jQuery); |