]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - plugins/playvideos/youtube_playlist.js
1 var run_playideos
= (function () {
2 var e
, n
, t
, o
, r
, i
= [].indexOf
|| function (e
) {
3 for (var n
= 0, t
= this.length
; n
< t
; n
++) {
4 if (n
in this && this[n
] === e
) return n
15 "background-color": "black",
43 r
= document
.createElement("script");
45 o
= document
.getElementsByTagName("head")[0];
47 r
.onload
= r
.onreadystatechange = function () {
49 e
= !this.readyState
|| (i
= this.readyState
) === "loaded" || i
=== "complete";
53 r
.onload
= r
.onreadystatechange
= null;
54 return o
.removeChild(r
)
57 return o
.appendChild(r
)
60 var t
, o
, r
, a
, u
, l
, d
, c
, f
, p
, s
, y
, h
, g
, v
, m
, w
;
61 e
.getScript("//www.youtube.com/iframe_api");
63 w
= new RegExp("https?://(www.)?youtube.com/");
64 e('a[href^="http"]').each(function () {
66 if (!e(this).attr("href").match(w
)) {
69 n
= this.href
.replace(/^.*v=/, "").replace(/\&.*$/, "");
70 if (i
.call(d
, n
) < 0) {
74 console
.log("video ids", d
);
77 g
= "playlist_player";
79 console
.log("Playing", c
, d
[c
]);
80 return y
.loadVideoById(d
[c
])
97 e("#shadow, #player_box").remove();
98 return e(document
).unbind("keyup.player")
100 e(document
).bind("keyup.player", function (e
) {
101 if (e
.keyCode
=== 27) {
104 if (e
.keyCode
=== 39) {
107 if (e
.keyCode
=== 37) {
124 href: "javascript:;",
130 href: "javascript:;",
135 r
.append(o
).append(a
).append(t
);
136 e("body").append(u
).append(r
);
138 console
.log("player ready");
139 return e
.target
.playVideo()
144 2: "invalid video id",
145 5: "video not supported in html5",
146 100: "video removed or private",
147 101: "video not embedable",
148 150: "video not embedable"
150 t
= n
[e
.data
] || "unknown error";
151 console
.log("Error", t
);
159 if (e
.data
=== YT
.PlayerState
.ENDED
) {
163 return window
.onYouTubeIframeAPIReady = function () {
164 return y
= new YT
.Player(g
, {
177 if (typeof jQuery
!== "undefined" && jQuery
!== null && jQuery
.fn
&& jQuery
.fn
.jquery
) {
178 r
= jQuery
.fn
.jquery
.split(".");
179 if (r
.length
=== 3 && parseInt(r
[1]) > 3) {
180 console
.log("using in page jquery version", jQuery
.fn
.jquery
);
186 t("plugins/playvideos/jquery-1.11.2.min.js", function () {
187 return e(jQuery
.noConflict(true))
192 var input
= document
.querySelector('#playvideos');
193 input
.addEventListener('click', function()