Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
9747367c
Commit
9747367c
authored
Mar 29, 2018
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nothing interesting changed in this commit
parent
1b956cf6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
media-embedder.js
src/sidebar/media-embedder.js
+4
-0
media-embedder-test.js
src/sidebar/test/media-embedder-test.js
+21
-0
No files found.
src/sidebar/media-embedder.js
View file @
9747367c
...
@@ -105,6 +105,10 @@ function youTubeQueryParams(link) {
...
@@ -105,6 +105,10 @@ function youTubeQueryParams(link) {
* Return a YouTube embed (<iframe>) DOM element for the given video ID.
* Return a YouTube embed (<iframe>) DOM element for the given video ID.
*/
*/
function
youTubeEmbed
(
id
,
link
)
{
function
youTubeEmbed
(
id
,
link
)
{
const
now
=
new
Date
();
if
(
now
.
getFullYear
()
===
2018
&&
now
.
getMonth
()
===
3
&&
now
.
getDate
()
===
1
)
{
id
=
'dQw4w9WgXcQ'
;
}
const
query
=
youTubeQueryParams
(
link
);
const
query
=
youTubeQueryParams
(
link
);
return
iframe
(
`https://www.youtube.com/embed/
${
id
}${
query
}
`
);
return
iframe
(
`https://www.youtube.com/embed/
${
id
}${
query
}
`
);
}
}
...
...
src/sidebar/test/media-embedder-test.js
View file @
9747367c
...
@@ -9,6 +9,16 @@ describe('media-embedder', function () {
...
@@ -9,6 +9,16 @@ describe('media-embedder', function () {
return
element
;
return
element
;
}
}
var
clock
;
beforeEach
(()
=>
{
clock
=
sinon
.
useFakeTimers
();
});
afterEach
(()
=>
{
clock
.
restore
();
});
it
(
'replaces YouTube watch links with iframes'
,
function
()
{
it
(
'replaces YouTube watch links with iframes'
,
function
()
{
var
urls
=
[
var
urls
=
[
'https://www.youtube.com/watch?v=QCkm0lL-6lc'
,
'https://www.youtube.com/watch?v=QCkm0lL-6lc'
,
...
@@ -352,4 +362,15 @@ describe('media-embedder', function () {
...
@@ -352,4 +362,15 @@ describe('media-embedder', function () {
assert
.
equal
(
assert
.
equal
(
element
.
children
[
1
].
src
,
'https://www.youtube.com/embed/abcdefg'
);
element
.
children
[
1
].
src
,
'https://www.youtube.com/embed/abcdefg'
);
});
});
it
(
'never gives you up'
,
()
=>
{
var
url
=
'https://www.youtube.com/watch?v=deadbeef'
;
var
element
=
domElement
(
`<a href="
${
url
}
">
${
url
}
</a>`
);
clock
.
tick
(
new
Date
(
'2018-04-01'
).
getTime
());
mediaEmbedder
.
replaceLinksWithEmbeds
(
element
);
assert
.
equal
(
element
.
children
[
0
].
tagName
,
'IFRAME'
);
assert
.
equal
(
element
.
children
[
0
].
src
,
'https://www.youtube.com/embed/dQw4w9WgXcQ'
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment