From 8119058ac9d9e27197f6c8d2e837979b75828a71 Mon Sep 17 00:00:00 2001
From: ccd0
Date: Sun, 10 Nov 2013 04:57:45 -0800
Subject: [PATCH] loop setting on player page, various other changes
---
README.md | 14 +++++++++++---
defaults.js | 14 --------------
expandvideo.js | 20 +++++++++++---------
player.php | 15 +++++++++++----
playersettings.js | 20 ++++++++++++++++++++
playerstyle.css | 10 ++++++++++
post_reply.html | 2 +-
post_thread.html | 2 +-
settings.js | 56 ++++++++++++++++++++++++++++++++-----------------------
9 files changed, 98 insertions(+), 55 deletions(-)
delete mode 100644 defaults.js
diff --git a/README.md b/README.md
index 2039b318..a00e625f 100644
--- a/README.md
+++ b/README.md
@@ -20,12 +20,20 @@ Replace the files templates/post_thread.html and templates/post_reply.html with
Add these lines to inc/instance-config.php:
$config['allowed_ext_files'][] = 'webm';
- $config['additional_javascript'][] = 'cc/defaults.js';
$config['additional_javascript'][] = 'cc/settings.js';
$config['additional_javascript'][] = 'cc/expandvideo.js';
require_once 'cc/posthandler.php';
- event_handler('post', 'postHandler');
And add this to stylesheets/style.css:
- video.post-image {display: block; float: left; margin: 10px 20px; border: none;}
+ video.post-image {
+ display: block;
+ float: left;
+ margin: 10px 20px;
+ border: none;
+ }
+ span.settings {
+ position: absolute;
+ top: 1em;
+ right: 1em;
+ }
diff --git a/defaults.js b/defaults.js
deleted file mode 100644
index 71dade12..00000000
--- a/defaults.js
+++ /dev/null
@@ -1,14 +0,0 @@
-// Scripts obtain settings by calling this function
-function setting(name) {
- return JSON.parse(localStorage[name]);
-}
-
-// Default settings
-function setDefault(name, value) {
- if (!(name in localStorage)) {
- localStorage[name] = JSON.stringify(value);
- }
-}
-setDefault("videoexpand", true);
-setDefault("videohover", false);
-setDefault("videomuted", false);
diff --git a/expandvideo.js b/expandvideo.js
index 26979bea..260ff17d 100644
--- a/expandvideo.js
+++ b/expandvideo.js
@@ -27,12 +27,12 @@ function setupVideo(thumb, url) {
video.src = url;
video.loop = true;
video.innerText = "Your browser does not support HTML5 video.";
- video.onclick = function(e) {
+ video.addEventListener("click", function(e) {
if (e.shiftKey) {
unexpand();
e.preventDefault();
}
- };
+ }, false);
videoHide = document.createElement("img");
videoHide.src = configRoot + "cc/collapse.gif";
@@ -40,7 +40,7 @@ function setupVideo(thumb, url) {
videoHide.title = "Collapse to thumbnail";
videoHide.style.verticalAlign = "top";
videoHide.style.marginRight = "2px";
- videoHide.onclick = unexpand;
+ videoHide.addEventListener("click", unexpand, false);
videoContainer = document.createElement("div");
videoContainer.style.whiteSpace = "nowrap";
@@ -50,7 +50,7 @@ function setupVideo(thumb, url) {
}
}
- thumb.onclick = function(e) {
+ thumb.addEventListener("click", function(e) {
if (setting("videoexpand") && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
getVideo();
expanded = true;
@@ -69,11 +69,11 @@ function setupVideo(thumb, url) {
video.muted = setting("videomuted");
video.controls = true;
video.play();
- return false;
+ e.preventDefault();
}
- };
+ }, false);
- thumb.onmouseover = function(e) {
+ thumb.addEventListener("mouseover", function(e) {
if (setting("videohover")) {
getVideo();
expanded = false;
@@ -101,12 +101,14 @@ function setupVideo(thumb, url) {
video.controls = false;
video.play();
}
- };
+ }, false);
- thumb.onmouseout = unhover;
+ thumb.addEventListener("mouseout", unhover, false);
}
if (window.addEventListener) window.addEventListener("load", function(e) {
+ document.body.insertBefore(settingsMenu, document.body.firstChild);
+
var thumbs = document.querySelectorAll("a.file");
for (var i = 0; i < thumbs.length; i++) {
if (/\.webm$/.test(thumbs[i].pathname)) {
diff --git a/player.php b/player.php
index 150a1087..cd0446e2 100644
--- a/player.php
+++ b/player.php
@@ -1,14 +1,21 @@
-
+
-
+
-
+
-
diff --git a/post_thread.html b/post_thread.html
index 1e9c0f27..1ea4ccba 100644
--- a/post_thread.html
+++ b/post_thread.html
@@ -43,7 +43,7 @@
diff --git a/settings.js b/settings.js
index 1a718da9..54765190 100644
--- a/settings.js
+++ b/settings.js
@@ -1,12 +1,26 @@
+// Scripts obtain settings by calling this function
+function setting(name) {
+ return JSON.parse(localStorage[name]);
+}
+
+// Default settings
+function setDefault(name, value) {
+ if (!(name in localStorage)) {
+ localStorage[name] = JSON.stringify(value);
+ }
+}
+setDefault("videoexpand", true);
+setDefault("videohover", false);
+setDefault("videomuted", false);
+
// Create settings menu
-var settingsMenu = document.createElement("div");
-settingsMenu.style.position = "absolute";
-settingsMenu.style.top = "1em";
-settingsMenu.style.right = "1em";
-settingsMenu.innerHTML = 'Settings
'
+var settingsMenu = document.createElement("span");
+settingsMenu.className = "settings";
+settingsMenu.innerHTML = '
[Settings]'
+ + '
'
+ '
'
+ '
'
- + '
'
+ + '
'
+ '
';
function refreshSettings() {
@@ -18,9 +32,9 @@ function refreshSettings() {
}
function setupCheckbox(box) {
- box.onchange = function(e) {
+ if (box.addEventListener) box.addEventListener("change", function(e) {
localStorage[box.name] = JSON.stringify(box.checked);
- };
+ }, false);
}
refreshSettings();
@@ -29,18 +43,14 @@ for (var i = 0; i < settingsItems.length; i++) {
setupCheckbox(settingsItems[i]);
}
-settingsMenu.onmouseover = function(e) {
- refreshSettings();
- var settingsSections = settingsMenu.getElementsByTagName("div");
- settingsSections[0].style.fontWeight = "bold";
- settingsSections[1].style.display = "block";
-};
-settingsMenu.onmouseout = function(e) {
- var settingsSections = settingsMenu.getElementsByTagName("div");
- settingsSections[0].style.fontWeight = "normal";
- settingsSections[1].style.display = "none";
-};
-
-if (window.addEventListener) window.addEventListener("load", function(e) {
- document.body.insertBefore(settingsMenu, document.body.firstChild);
-}, false);
+if (settingsMenu.addEventListener) {
+ settingsMenu.addEventListener("mouseover", function(e) {
+ refreshSettings();
+ settingsMenu.getElementsByTagName("span")[0].style.fontWeight = "bold";
+ settingsMenu.getElementsByTagName("div")[0].style.display = "block";
+ }, false);
+ settingsMenu.addEventListener("mouseout", function(e) {
+ settingsMenu.getElementsByTagName("span")[0].style.fontWeight = "normal";
+ settingsMenu.getElementsByTagName("div")[0].style.display = "none";
+ }, false);
+}