diff --git a/README.md b/README.md index 53cba460..2039b318 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ 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'; diff --git a/defaults.js b/defaults.js new file mode 100644 index 00000000..71dade12 --- /dev/null +++ b/defaults.js @@ -0,0 +1,14 @@ +// 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 8d6124b3..26979bea 100644 --- a/expandvideo.js +++ b/expandvideo.js @@ -106,12 +106,7 @@ function setupVideo(thumb, url) { thumb.onmouseout = unhover; } -window.onload = function() { - settingsPanel.style.position = "absolute"; - settingsPanel.style.top = "1em"; - settingsPanel.style.right = "1em"; - document.body.insertBefore(settingsPanel, document.body.firstChild); - +if (window.addEventListener) window.addEventListener("load", function(e) { var thumbs = document.querySelectorAll("a.file"); for (var i = 0; i < thumbs.length; i++) { if (/\.webm$/.test(thumbs[i].pathname)) { @@ -124,4 +119,4 @@ window.onload = function() { } } } -}; +}, false); diff --git a/player.php b/player.php index ecfaf953..150a1087 100644 --- a/player.php +++ b/player.php @@ -3,7 +3,8 @@