summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorccd0 <admin@containerchan.org>2013-11-10 19:09:12 -0800
committerccd0 <admin@containerchan.org>2013-11-10 19:09:12 -0800
commit9c335764c4ba4aa056cb708390c74ad8b195f193 (patch)
tree646c73fc0badca05865ce149322bbd47b086e595
parentbcdedcb28a7d353a78491c203e1ee7ce7e14aace (diff)
loop controls on main page
-rw-r--r--expandvideo.js29
-rw-r--r--playersettings.js3
2 files changed, 29 insertions, 3 deletions
diff --git a/expandvideo.js b/expandvideo.js
index 260ff17d..b79b52ce 100644
--- a/expandvideo.js
+++ b/expandvideo.js
@@ -3,6 +3,9 @@ function setupVideo(thumb, url) {
var videoContainer, videoHide;
var expanded = false;
var hovering = false;
+ var loop = true;
+ var loopControls = [document.createElement("span"), document.createElement("span")];
+ var fileInfo = thumb.parentNode.querySelector(".fileinfo");
function unexpand() {
if (expanded) {
@@ -25,7 +28,7 @@ function setupVideo(thumb, url) {
if (video == null) {
video = document.createElement("video");
video.src = url;
- video.loop = true;
+ video.loop = loop;
video.innerText = "Your browser does not support HTML5 video.";
video.addEventListener("click", function(e) {
if (e.shiftKey) {
@@ -104,6 +107,30 @@ function setupVideo(thumb, url) {
}, false);
thumb.addEventListener("mouseout", unhover, false);
+
+ function setupLoopControl(i) {
+ loopControls[i].addEventListener("click", function(e) {
+ loop = (i != 0);
+ thumb.href = thumb.href.replace(/([\?&])loop=\d+/, "$1loop=" + i);
+ if (video != null) {
+ video.loop = loop;
+ if (loop && video.currentTime >= video.duration) {
+ video.currentTime = 0;
+ }
+ }
+ loopControls[i].style.fontWeight = "bold";
+ loopControls[1-i].style.fontWeight = "inherit";
+ }, false);
+ }
+
+ loopControls[0].textContent = "[play once]";
+ loopControls[1].textContent = "[loop]";
+ loopControls[1].style.fontWeight = "bold";
+ for (var i = 0; i < 2; i++) {
+ setupLoopControl(i);
+ fileInfo.appendChild(document.createTextNode(" "));
+ fileInfo.appendChild(loopControls[i]);
+ }
}
if (window.addEventListener) window.addEventListener("load", function(e) {
diff --git a/playersettings.js b/playersettings.js
index 8c508fd7..66a023a0 100644
--- a/playersettings.js
+++ b/playersettings.js
@@ -7,10 +7,9 @@ if (window.addEventListener) window.addEventListener("load", function(e) {
function setupLoopLink(i) {
loopLinks[i].addEventListener("click", function(e) {
video.loop = (i != 0);
- if (i == 1 && video.currentTime >= video.duration) {
+ if (i != 0 && video.currentTime >= video.duration) {
video.currentTime = 0;
}
- video.play();
loopLinks[i].style.fontWeight = "bold";
loopLinks[1-i].style.fontWeight = "inherit";
e.preventDefault();