]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - plugins/playvideos/youtube_playlist.js
1 /** @licstart The following is the entire license notice for the
2 * JavaScript code in this page.
4 * Copyright: (c) 2011-2015 Sébastien SAUVAGE <sebsauvage@sebsauvage.net>
5 * (c) 2011-2017 The Shaarli Community, see AUTHORS
7 * This software is provided 'as-is', without any express or implied warranty.
8 * In no event will the authors be held liable for any damages arising from
9 * the use of this software.
11 * Permission is granted to anyone to use this software for any purpose,
12 * including commercial applications, and to alter it and redistribute it
13 * freely, subject to the following restrictions:
15 * 1. The origin of this software must not be misrepresented; you must not
16 * claim that you wrote the original software. If you use this software
17 * in a product, an acknowledgment in the product documentation would
18 * be appreciated but is not required.
20 * 2. Altered source versions must be plainly marked as such, and must
21 * not be misrepresented as being the original software.
23 * 3. This notice may not be removed or altered from any source distribution.
25 * @licend The above is the entire license notice
26 * for the JavaScript code in this page.
29 var run_playideos
= (function () {
30 var e
, n
, t
, o
, r
, i
= [].indexOf
|| function (e
) {
31 for (var n
= 0, t
= this.length
; n
< t
; n
++) {
32 if (n
in this && this[n
] === e
) return n
36 if (!window
.console
) {
43 "background-color": "black",
71 r
= document
.createElement("script");
73 o
= document
.getElementsByTagName("head")[0];
75 r
.onload
= r
.onreadystatechange = function () {
77 e
= !this.readyState
|| (i
= this.readyState
) === "loaded" || i
=== "complete";
81 r
.onload
= r
.onreadystatechange
= null;
82 return o
.removeChild(r
)
85 return o
.appendChild(r
)
88 var t
, o
, r
, a
, u
, l
, d
, c
, f
, p
, s
, y
, h
, g
, v
, m
, w
;
89 e
.getScript("//www.youtube.com/iframe_api");
91 w
= new RegExp("https?://(www.)?youtube.com/");
92 e('a[href^="http"]').each(function () {
94 if (!e(this).attr("href").match(w
)) {
97 n
= this.href
.replace(/^.*v=/, "").replace(/\&.*$/, "");
98 if (i
.call(d
, n
) < 0) {
102 console
.log("video ids", d
);
105 g
= "playlist_player";
107 console
.log("Playing", c
, d
[c
]);
108 return y
.loadVideoById(d
[c
])
125 e("#shadow, #player_box").remove();
126 return e(document
).unbind("keyup.player")
128 e(document
).bind("keyup.player", function (e
) {
129 if (e
.keyCode
=== 27) {
132 if (e
.keyCode
=== 39) {
135 if (e
.keyCode
=== 37) {
152 href: "javascript:;",
158 href: "javascript:;",
163 r
.append(o
).append(a
).append(t
);
164 e("body").append(u
).append(r
);
166 console
.log("player ready");
167 return e
.target
.playVideo()
172 2: "invalid video id",
173 5: "video not supported in html5",
174 100: "video removed or private",
175 101: "video not embedable",
176 150: "video not embedable"
178 t
= n
[e
.data
] || "unknown error";
179 console
.log("Error", t
);
187 if (e
.data
=== YT
.PlayerState
.ENDED
) {
191 return window
.onYouTubeIframeAPIReady = function () {
192 return y
= new YT
.Player(g
, {
205 if (typeof jQuery
!== "undefined" && jQuery
!== null && jQuery
.fn
&& jQuery
.fn
.jquery
) {
206 r
= jQuery
.fn
.jquery
.split(".");
207 if (r
.length
=== 3 && parseInt(r
[1]) > 3) {
208 console
.log("using in page jquery version", jQuery
.fn
.jquery
);
214 t("plugins/playvideos/jquery-1.11.2.min.js", function () {
215 return e(jQuery
.noConflict(true))
220 var input
= document
.querySelector('#playvideos');
221 input
.addEventListener('click', function()