From 56eaf863f2593920161d5588c9ca63fe8e9312ce Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 27 Mar 2014 13:10:53 +0100 Subject: SECURITY: fix XSS vulnerability --- js/attention-bar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/attention-bar.js b/js/attention-bar.js index a84cadff..40073081 100644 --- a/js/attention-bar.js +++ b/js/attention-bar.js @@ -2,7 +2,7 @@ $(document).ready(function(){ $("#attention_bar").click(function(eO){ $("#attention_bar").css("display","none"); $("#attention_bar_form").css("display","block"); }); $.get(configRoot + "attentionbar.txt", function(data) { - $("#attention_bar").text(data); - $("#attention_bar_input").val(data); + $("#attention_bar").html(data); + $("#attention_bar_input").val($("#attention_bar").text()); }); }); -- cgit v1.3 From 647c59f8209e3a82adb3e54f4c211fc67f1e1fd6 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 6 Apr 2014 21:27:41 +0200 Subject: move webm js into a better place --- containerchan/expandvideo.js | 235 ------------------------------------------- containerchan/settings.js | 81 --------------- js/expand-video.js | 235 +++++++++++++++++++++++++++++++++++++++++++ js/webm-settings.js | 81 +++++++++++++++ 4 files changed, 316 insertions(+), 316 deletions(-) delete mode 100644 containerchan/expandvideo.js delete mode 100644 containerchan/settings.js create mode 100644 js/expand-video.js create mode 100644 js/webm-settings.js (limited to 'js') diff --git a/containerchan/expandvideo.js b/containerchan/expandvideo.js deleted file mode 100644 index 27438427..00000000 --- a/containerchan/expandvideo.js +++ /dev/null @@ -1,235 +0,0 @@ -/* This file is dedicated to the public domain; you may do as you wish with it. */ -/* Note: This code expects the global variable configRoot to be set. */ - -function setupVideo(thumb, url) { - var video = null; - 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"); - var mouseDown = false; - - function unexpand() { - if (expanded) { - expanded = false; - if (video.pause) video.pause(); - videoContainer.style.display = "none"; - thumb.style.display = "inline"; - video.style.maxWidth = "inherit"; - video.style.maxHeight = "inherit"; - } - } - - function unhover() { - if (hovering) { - hovering = false; - if (video.pause) video.pause(); - videoContainer.style.display = "none"; - video.style.maxWidth = "inherit"; - video.style.maxHeight = "inherit"; - } - } - - // Create video element if does not exist yet - function getVideo() { - if (video == null) { - video = document.createElement("video"); - video.src = url; - video.loop = loop; - video.innerText = "Your browser does not support HTML5 video."; - - videoHide = document.createElement("img"); - videoHide.src = configRoot + "cc/collapse.gif"; - videoHide.alt = "[ - ]"; - videoHide.title = "Collapse video"; - videoHide.style.marginLeft = "-15px"; - videoHide.style.cssFloat = "left"; - videoHide.addEventListener("click", unexpand, false); - - videoContainer = document.createElement("div"); - videoContainer.style.paddingLeft = "15px"; - videoContainer.style.display = "none"; - videoContainer.appendChild(videoHide); - videoContainer.appendChild(video); - thumb.parentNode.insertBefore(videoContainer, thumb.nextSibling); - - // Dragging to the left collapses the video - video.addEventListener("mousedown", function(e) { - if (e.button == 0) mouseDown = true; - }, false); - video.addEventListener("mouseup", function(e) { - if (e.button == 0) mouseDown = false; - }, false); - video.addEventListener("mouseenter", function(e) { - mouseDown = false; - }, false); - video.addEventListener("mouseout", function(e) { - if (mouseDown && e.clientX - video.getBoundingClientRect().left <= 0) { - unexpand(); - } - mouseDown = false; - }, false); - } - } - - // Clicking on thumbnail expands video - thumb.addEventListener("click", function(e) { - if (setting("videoexpand") && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) { - getVideo(); - expanded = true; - hovering = false; - - video.style.position = "static"; - video.style.pointerEvents = "inherit"; - video.style.display = "inline"; - videoHide.style.display = "inline"; - videoContainer.style.display = "block"; - videoContainer.style.position = "static"; - thumb.style.display = "none"; - - video.muted = (setting("videovolume") == 0); - video.volume = setting("videovolume"); - video.controls = true; - if (video.readyState == 0) { - video.addEventListener("loadedmetadata", expand2, false); - } else { - setTimeout(expand2, 0); - } - video.play(); - e.preventDefault(); - } - }, false); - - function expand2() { - video.style.maxWidth = "100%"; - video.style.maxHeight = window.innerHeight + "px"; - var bottom = video.getBoundingClientRect().bottom; - if (bottom > window.innerHeight) { - window.scrollBy(0, bottom - window.innerHeight); - } - // work around Firefox volume control bug - video.volume = Math.max(setting("videovolume") - 0.001, 0); - video.volume = setting("videovolume"); - } - - // Hovering over thumbnail displays video - thumb.addEventListener("mouseover", function(e) { - if (setting("videohover")) { - getVideo(); - expanded = false; - hovering = true; - - var docRight = document.documentElement.getBoundingClientRect().right; - var thumbRight = thumb.querySelector("img, video").getBoundingClientRect().right; - var maxWidth = docRight - thumbRight - 20; - if (maxWidth < 250) maxWidth = 250; - - video.style.position = "fixed"; - video.style.right = "0px"; - video.style.top = "0px"; - var docRight = document.documentElement.getBoundingClientRect().right; - var thumbRight = thumb.querySelector("img, video").getBoundingClientRect().right; - video.style.maxWidth = maxWidth + "px"; - video.style.maxHeight = "100%"; - video.style.pointerEvents = "none"; - - video.style.display = "inline"; - videoHide.style.display = "none"; - videoContainer.style.display = "inline"; - videoContainer.style.position = "fixed"; - - video.muted = (setting("videovolume") == 0); - video.volume = setting("videovolume"); - video.controls = false; - video.play(); - } - }, false); - - thumb.addEventListener("mouseout", unhover, false); - - // Scroll wheel on thumbnail adjusts default volume - thumb.addEventListener("wheel", function(e) { - if (setting("videohover")) { - var volume = setting("videovolume"); - if (e.deltaY > 0) volume -= 0.1; - if (e.deltaY < 0) volume += 0.1; - if (volume < 0) volume = 0; - if (volume > 1) volume = 1; - if (video != null) { - video.muted = (volume == 0); - video.volume = volume; - } - changeSetting("videovolume", volume); - e.preventDefault(); - } - }, false); - - // [play once] vs [loop] controls - 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); - loopControls[i].style.whiteSpace = "nowrap"; - fileInfo.appendChild(document.createTextNode(" ")); - fileInfo.appendChild(loopControls[i]); - } -} - -function setupVideosIn(element) { - var thumbs = element.querySelectorAll("a.file"); - for (var i = 0; i < thumbs.length; i++) { - if (/\.webm$/.test(thumbs[i].pathname)) { - setupVideo(thumbs[i], thumbs[i].href); - } else { - var m = thumbs[i].search.match(/\bv=([^&]*)/); - if (m != null) { - var url = decodeURIComponent(m[1]); - if (/\.webm$/.test(url)) setupVideo(thumbs[i], url); - } - } - } -} - -if (window.addEventListener) window.addEventListener("load", function(e) { - // Insert menu from settings.js - if (typeof settingsMenu != "undefined") document.body.insertBefore(settingsMenu, document.body.firstChild); - - // Setup Javascript events for videos in document now - setupVideosIn(document); - - // Setup Javascript events for videos added by updater - if (window.MutationObserver) { - var observer = new MutationObserver(function(mutations) { - for (var i = 0; i < mutations.length; i++) { - var additions = mutations[i].addedNodes; - if (additions == null) continue; - for (var j = 0; j < additions.length; j++) { - var node = additions[j]; - if (node.nodeType == 1) { - setupVideosIn(node); - } - } - } - }); - observer.observe(document.body, {childList: true, subtree: true}); - } -}, false); - diff --git a/containerchan/settings.js b/containerchan/settings.js deleted file mode 100644 index 279ea1c1..00000000 --- a/containerchan/settings.js +++ /dev/null @@ -1,81 +0,0 @@ -/* This file is dedicated to the public domain; you may do as you wish with it. */ - -// Default settings -var defaultSettings = { - "videoexpand": true, - "videohover": false, - "videovolume": 1.0 -}; - -// Non-persistent settings for when localStorage is absent/disabled -var tempSettings = {}; - -// Scripts obtain settings by calling this function -function setting(name) { - if (localStorage) { - if (localStorage[name] === undefined) return defaultSettings[name]; - return JSON.parse(localStorage[name]); - } else { - if (tempSettings[name] === undefined) return defaultSettings[name]; - return tempSettings[name]; - } -} - -// Settings should be changed with this function -function changeSetting(name, value) { - if (localStorage) { - localStorage[name] = JSON.stringify(value); - } else { - tempSettings[name] = value; - } -} - -// Create settings menu -var settingsMenu = document.createElement("span"); -settingsMenu.className = "settings"; -settingsMenu.innerHTML = '[Settings]' - + '
' - + '
' - + '
' - + '
' - + '
'; - -function refreshSettings() { - var settingsItems = settingsMenu.getElementsByTagName("input"); - for (var i = 0; i < settingsItems.length; i++) { - var control = settingsItems[i]; - if (control.type == "checkbox") { - control.checked = setting(control.name); - } else if (control.type == "range") { - control.value = setting(control.name); - } - } -} - -function setupControl(control) { - if (control.addEventListener) control.addEventListener("change", function(e) { - if (control.type == "checkbox") { - changeSetting(control.name, control.checked); - } else if (control.type == "range") { - changeSetting(control.name, control.value); - } - }, false); -} - -refreshSettings(); -var settingsItems = settingsMenu.getElementsByTagName("input"); -for (var i = 0; i < settingsItems.length; i++) { - setupControl(settingsItems[i]); -} - -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); -} diff --git a/js/expand-video.js b/js/expand-video.js new file mode 100644 index 00000000..27438427 --- /dev/null +++ b/js/expand-video.js @@ -0,0 +1,235 @@ +/* This file is dedicated to the public domain; you may do as you wish with it. */ +/* Note: This code expects the global variable configRoot to be set. */ + +function setupVideo(thumb, url) { + var video = null; + 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"); + var mouseDown = false; + + function unexpand() { + if (expanded) { + expanded = false; + if (video.pause) video.pause(); + videoContainer.style.display = "none"; + thumb.style.display = "inline"; + video.style.maxWidth = "inherit"; + video.style.maxHeight = "inherit"; + } + } + + function unhover() { + if (hovering) { + hovering = false; + if (video.pause) video.pause(); + videoContainer.style.display = "none"; + video.style.maxWidth = "inherit"; + video.style.maxHeight = "inherit"; + } + } + + // Create video element if does not exist yet + function getVideo() { + if (video == null) { + video = document.createElement("video"); + video.src = url; + video.loop = loop; + video.innerText = "Your browser does not support HTML5 video."; + + videoHide = document.createElement("img"); + videoHide.src = configRoot + "cc/collapse.gif"; + videoHide.alt = "[ - ]"; + videoHide.title = "Collapse video"; + videoHide.style.marginLeft = "-15px"; + videoHide.style.cssFloat = "left"; + videoHide.addEventListener("click", unexpand, false); + + videoContainer = document.createElement("div"); + videoContainer.style.paddingLeft = "15px"; + videoContainer.style.display = "none"; + videoContainer.appendChild(videoHide); + videoContainer.appendChild(video); + thumb.parentNode.insertBefore(videoContainer, thumb.nextSibling); + + // Dragging to the left collapses the video + video.addEventListener("mousedown", function(e) { + if (e.button == 0) mouseDown = true; + }, false); + video.addEventListener("mouseup", function(e) { + if (e.button == 0) mouseDown = false; + }, false); + video.addEventListener("mouseenter", function(e) { + mouseDown = false; + }, false); + video.addEventListener("mouseout", function(e) { + if (mouseDown && e.clientX - video.getBoundingClientRect().left <= 0) { + unexpand(); + } + mouseDown = false; + }, false); + } + } + + // Clicking on thumbnail expands video + thumb.addEventListener("click", function(e) { + if (setting("videoexpand") && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) { + getVideo(); + expanded = true; + hovering = false; + + video.style.position = "static"; + video.style.pointerEvents = "inherit"; + video.style.display = "inline"; + videoHide.style.display = "inline"; + videoContainer.style.display = "block"; + videoContainer.style.position = "static"; + thumb.style.display = "none"; + + video.muted = (setting("videovolume") == 0); + video.volume = setting("videovolume"); + video.controls = true; + if (video.readyState == 0) { + video.addEventListener("loadedmetadata", expand2, false); + } else { + setTimeout(expand2, 0); + } + video.play(); + e.preventDefault(); + } + }, false); + + function expand2() { + video.style.maxWidth = "100%"; + video.style.maxHeight = window.innerHeight + "px"; + var bottom = video.getBoundingClientRect().bottom; + if (bottom > window.innerHeight) { + window.scrollBy(0, bottom - window.innerHeight); + } + // work around Firefox volume control bug + video.volume = Math.max(setting("videovolume") - 0.001, 0); + video.volume = setting("videovolume"); + } + + // Hovering over thumbnail displays video + thumb.addEventListener("mouseover", function(e) { + if (setting("videohover")) { + getVideo(); + expanded = false; + hovering = true; + + var docRight = document.documentElement.getBoundingClientRect().right; + var thumbRight = thumb.querySelector("img, video").getBoundingClientRect().right; + var maxWidth = docRight - thumbRight - 20; + if (maxWidth < 250) maxWidth = 250; + + video.style.position = "fixed"; + video.style.right = "0px"; + video.style.top = "0px"; + var docRight = document.documentElement.getBoundingClientRect().right; + var thumbRight = thumb.querySelector("img, video").getBoundingClientRect().right; + video.style.maxWidth = maxWidth + "px"; + video.style.maxHeight = "100%"; + video.style.pointerEvents = "none"; + + video.style.display = "inline"; + videoHide.style.display = "none"; + videoContainer.style.display = "inline"; + videoContainer.style.position = "fixed"; + + video.muted = (setting("videovolume") == 0); + video.volume = setting("videovolume"); + video.controls = false; + video.play(); + } + }, false); + + thumb.addEventListener("mouseout", unhover, false); + + // Scroll wheel on thumbnail adjusts default volume + thumb.addEventListener("wheel", function(e) { + if (setting("videohover")) { + var volume = setting("videovolume"); + if (e.deltaY > 0) volume -= 0.1; + if (e.deltaY < 0) volume += 0.1; + if (volume < 0) volume = 0; + if (volume > 1) volume = 1; + if (video != null) { + video.muted = (volume == 0); + video.volume = volume; + } + changeSetting("videovolume", volume); + e.preventDefault(); + } + }, false); + + // [play once] vs [loop] controls + 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); + loopControls[i].style.whiteSpace = "nowrap"; + fileInfo.appendChild(document.createTextNode(" ")); + fileInfo.appendChild(loopControls[i]); + } +} + +function setupVideosIn(element) { + var thumbs = element.querySelectorAll("a.file"); + for (var i = 0; i < thumbs.length; i++) { + if (/\.webm$/.test(thumbs[i].pathname)) { + setupVideo(thumbs[i], thumbs[i].href); + } else { + var m = thumbs[i].search.match(/\bv=([^&]*)/); + if (m != null) { + var url = decodeURIComponent(m[1]); + if (/\.webm$/.test(url)) setupVideo(thumbs[i], url); + } + } + } +} + +if (window.addEventListener) window.addEventListener("load", function(e) { + // Insert menu from settings.js + if (typeof settingsMenu != "undefined") document.body.insertBefore(settingsMenu, document.body.firstChild); + + // Setup Javascript events for videos in document now + setupVideosIn(document); + + // Setup Javascript events for videos added by updater + if (window.MutationObserver) { + var observer = new MutationObserver(function(mutations) { + for (var i = 0; i < mutations.length; i++) { + var additions = mutations[i].addedNodes; + if (additions == null) continue; + for (var j = 0; j < additions.length; j++) { + var node = additions[j]; + if (node.nodeType == 1) { + setupVideosIn(node); + } + } + } + }); + observer.observe(document.body, {childList: true, subtree: true}); + } +}, false); + diff --git a/js/webm-settings.js b/js/webm-settings.js new file mode 100644 index 00000000..f67e42d6 --- /dev/null +++ b/js/webm-settings.js @@ -0,0 +1,81 @@ +/* This file is dedicated to the public domain; you may do as you wish with it. */ + +// Default settings +var defaultSettings = { + "videoexpand": true, + "videohover": false, + "videovolume": 1.0 +}; + +// Non-persistent settings for when localStorage is absent/disabled +var tempSettings = {}; + +// Scripts obtain settings by calling this function +function setting(name) { + if (localStorage) { + if (localStorage[name] === undefined) return defaultSettings[name]; + return JSON.parse(localStorage[name]); + } else { + if (tempSettings[name] === undefined) return defaultSettings[name]; + return tempSettings[name]; + } +} + +// Settings should be changed with this function +function changeSetting(name, value) { + if (localStorage) { + localStorage[name] = JSON.stringify(value); + } else { + tempSettings[name] = value; + } +} + +// Create settings menu +var settingsMenu = document.createElement("span"); +settingsMenu.className = "settings"; +settingsMenu.innerHTML = '[WebM Settings]' + + '
' + + '
' + + '
' + + '
' + + '
'; + +function refreshSettings() { + var settingsItems = settingsMenu.getElementsByTagName("input"); + for (var i = 0; i < settingsItems.length; i++) { + var control = settingsItems[i]; + if (control.type == "checkbox") { + control.checked = setting(control.name); + } else if (control.type == "range") { + control.value = setting(control.name); + } + } +} + +function setupControl(control) { + if (control.addEventListener) control.addEventListener("change", function(e) { + if (control.type == "checkbox") { + changeSetting(control.name, control.checked); + } else if (control.type == "range") { + changeSetting(control.name, control.value); + } + }, false); +} + +refreshSettings(); +var settingsItems = settingsMenu.getElementsByTagName("input"); +for (var i = 0; i < settingsItems.length; i++) { + setupControl(settingsItems[i]); +} + +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); +} -- cgit v1.3 From 97792ff38732274e906071e72902db3b83df9f61 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 6 Apr 2014 21:39:33 +0200 Subject: more work on containerchan --- containerchan/collapse.gif | Bin 67 -> 0 bytes containerchan/playersettings.js | 28 ---------------------------- containerchan/playerstyle.css | 39 --------------------------------------- js/expand-video.js | 2 +- js/webm/playersettings.js | 28 ++++++++++++++++++++++++++++ static/collapse.gif | Bin 0 -> 67 bytes stylesheets/webm/playerstyle.css | 39 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 68 insertions(+), 68 deletions(-) delete mode 100644 containerchan/collapse.gif delete mode 100644 containerchan/playersettings.js delete mode 100644 containerchan/playerstyle.css create mode 100644 js/webm/playersettings.js create mode 100644 static/collapse.gif create mode 100644 stylesheets/webm/playerstyle.css (limited to 'js') diff --git a/containerchan/collapse.gif b/containerchan/collapse.gif deleted file mode 100644 index cda6b337..00000000 Binary files a/containerchan/collapse.gif and /dev/null differ diff --git a/containerchan/playersettings.js b/containerchan/playersettings.js deleted file mode 100644 index 861d27c2..00000000 --- a/containerchan/playersettings.js +++ /dev/null @@ -1,28 +0,0 @@ -/* This file is dedicated to the public domain; you may do as you wish with it. */ -if (window.addEventListener) window.addEventListener("load", function(e) { - document.getElementById("playerheader").appendChild(settingsMenu); - - var video = document.getElementsByTagName("video")[0]; - - var loopLinks = [document.getElementById("loop0"), document.getElementById("loop1")]; - function setupLoopLink(i) { - loopLinks[i].addEventListener("click", function(e) { - if (!e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) { - video.loop = (i != 0); - if (i != 0 && video.currentTime >= video.duration) { - video.currentTime = 0; - } - loopLinks[i].style.fontWeight = "bold"; - loopLinks[1-i].style.fontWeight = "inherit"; - e.preventDefault(); - } - }, false); - } - for (var i = 0; i < 2; i++) { - setupLoopLink(i); - } - - video.muted = (setting("videovolume") == 0); - video.volume = setting("videovolume"); - video.play(); -}, false); diff --git a/containerchan/playerstyle.css b/containerchan/playerstyle.css deleted file mode 100644 index b78b67ef..00000000 --- a/containerchan/playerstyle.css +++ /dev/null @@ -1,39 +0,0 @@ -/* This file is dedicated to the public domain; you may do as you wish with it. */ -body { - background: black; - color: white; - margin: 0px; -} -#playerheader { - position: absolute; - left: 0px; - right: 0px; - top: 0px; - height: 24px; - padding: 0px 4px; - text-align: right; - font-size: 16px; -} -#playerheader a { - color: white; - text-decoration: none; -} -span.settings div { - background: black; - z-index: 1; - padding-right: 4px; -} -#playercontent { - position: absolute; - left: 0px; - right: 0px; - top: 24px; - bottom: 0px; -} -video { - display: block; - margin-left: auto; - margin-right: auto; - max-width: 100%; - max-height: 100%; -} diff --git a/js/expand-video.js b/js/expand-video.js index 27438427..96427667 100644 --- a/js/expand-video.js +++ b/js/expand-video.js @@ -41,7 +41,7 @@ function setupVideo(thumb, url) { video.innerText = "Your browser does not support HTML5 video."; videoHide = document.createElement("img"); - videoHide.src = configRoot + "cc/collapse.gif"; + videoHide.src = configRoot + "static/collapse.gif"; videoHide.alt = "[ - ]"; videoHide.title = "Collapse video"; videoHide.style.marginLeft = "-15px"; diff --git a/js/webm/playersettings.js b/js/webm/playersettings.js new file mode 100644 index 00000000..861d27c2 --- /dev/null +++ b/js/webm/playersettings.js @@ -0,0 +1,28 @@ +/* This file is dedicated to the public domain; you may do as you wish with it. */ +if (window.addEventListener) window.addEventListener("load", function(e) { + document.getElementById("playerheader").appendChild(settingsMenu); + + var video = document.getElementsByTagName("video")[0]; + + var loopLinks = [document.getElementById("loop0"), document.getElementById("loop1")]; + function setupLoopLink(i) { + loopLinks[i].addEventListener("click", function(e) { + if (!e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) { + video.loop = (i != 0); + if (i != 0 && video.currentTime >= video.duration) { + video.currentTime = 0; + } + loopLinks[i].style.fontWeight = "bold"; + loopLinks[1-i].style.fontWeight = "inherit"; + e.preventDefault(); + } + }, false); + } + for (var i = 0; i < 2; i++) { + setupLoopLink(i); + } + + video.muted = (setting("videovolume") == 0); + video.volume = setting("videovolume"); + video.play(); +}, false); diff --git a/static/collapse.gif b/static/collapse.gif new file mode 100644 index 00000000..cda6b337 Binary files /dev/null and b/static/collapse.gif differ diff --git a/stylesheets/webm/playerstyle.css b/stylesheets/webm/playerstyle.css new file mode 100644 index 00000000..b78b67ef --- /dev/null +++ b/stylesheets/webm/playerstyle.css @@ -0,0 +1,39 @@ +/* This file is dedicated to the public domain; you may do as you wish with it. */ +body { + background: black; + color: white; + margin: 0px; +} +#playerheader { + position: absolute; + left: 0px; + right: 0px; + top: 0px; + height: 24px; + padding: 0px 4px; + text-align: right; + font-size: 16px; +} +#playerheader a { + color: white; + text-decoration: none; +} +span.settings div { + background: black; + z-index: 1; + padding-right: 4px; +} +#playercontent { + position: absolute; + left: 0px; + right: 0px; + top: 24px; + bottom: 0px; +} +video { + display: block; + margin-left: auto; + margin-right: auto; + max-width: 100%; + max-height: 100%; +} -- cgit v1.3 From 5c38368e600d04f4d2055a97c0b57a6dea520bd5 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 6 Apr 2014 22:28:26 +0200 Subject: webm: more integration --- js/expand-video.js | 6 +++--- js/webm-settings.js | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'js') diff --git a/js/expand-video.js b/js/expand-video.js index 96427667..530b8cac 100644 --- a/js/expand-video.js +++ b/js/expand-video.js @@ -208,9 +208,9 @@ function setupVideosIn(element) { } } -if (window.addEventListener) window.addEventListener("load", function(e) { +onready(function(){ // Insert menu from settings.js - if (typeof settingsMenu != "undefined") document.body.insertBefore(settingsMenu, document.body.firstChild); + if (typeof settingsMenu != "undefined") document.body.insertBefore(settingsMenu, document.getElementsByTagName("hr")[0]); // Setup Javascript events for videos in document now setupVideosIn(document); @@ -231,5 +231,5 @@ if (window.addEventListener) window.addEventListener("load", function(e) { }); observer.observe(document.body, {childList: true, subtree: true}); } -}, false); +}); diff --git a/js/webm-settings.js b/js/webm-settings.js index f67e42d6..6b1ed45c 100644 --- a/js/webm-settings.js +++ b/js/webm-settings.js @@ -31,10 +31,12 @@ function changeSetting(name, value) { } // Create settings menu -var settingsMenu = document.createElement("span"); -settingsMenu.className = "settings"; -settingsMenu.innerHTML = '[WebM Settings]' - + '
' +var settingsMenu = document.createElement("div"); +settingsMenu.style.textAlign = "right"; +settingsMenu.style.background = "inherit"; + +settingsMenu.innerHTML = 'WebM Settings' + + '
' + '
' + '
' + '
' -- cgit v1.3 From 28033fe6f35558b017b52f2564e3a2149cdd0c51 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 6 Apr 2014 22:32:48 +0200 Subject: webm i18n --- js/expand-video.js | 10 +++++++--- js/webm-settings.js | 12 ++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'js') diff --git a/js/expand-video.js b/js/expand-video.js index 530b8cac..d2e35249 100644 --- a/js/expand-video.js +++ b/js/expand-video.js @@ -1,6 +1,10 @@ /* This file is dedicated to the public domain; you may do as you wish with it. */ /* Note: This code expects the global variable configRoot to be set. */ +if (typeof _ == 'undefined') { + var _ = function(a) { return a; }; +} + function setupVideo(thumb, url) { var video = null; var videoContainer, videoHide; @@ -38,7 +42,7 @@ function setupVideo(thumb, url) { video = document.createElement("video"); video.src = url; video.loop = loop; - video.innerText = "Your browser does not support HTML5 video."; + video.innerText = _("Your browser does not support HTML5 video."); videoHide = document.createElement("img"); videoHide.src = configRoot + "static/collapse.gif"; @@ -182,8 +186,8 @@ function setupVideo(thumb, url) { }, false); } - loopControls[0].textContent = "[play once]"; - loopControls[1].textContent = "[loop]"; + loopControls[0].textContent = _("[play once]"); + loopControls[1].textContent = _("[loop]"); loopControls[1].style.fontWeight = "bold"; for (var i = 0; i < 2; i++) { setupLoopControl(i); diff --git a/js/webm-settings.js b/js/webm-settings.js index 6b1ed45c..cecf36d0 100644 --- a/js/webm-settings.js +++ b/js/webm-settings.js @@ -1,5 +1,9 @@ /* This file is dedicated to the public domain; you may do as you wish with it. */ +if (typeof _ == 'undefined') { + var _ = function(a) { return a; }; +} + // Default settings var defaultSettings = { "videoexpand": true, @@ -35,11 +39,11 @@ var settingsMenu = document.createElement("div"); settingsMenu.style.textAlign = "right"; settingsMenu.style.background = "inherit"; -settingsMenu.innerHTML = 'WebM Settings' +settingsMenu.innerHTML = ''+_('WebM Settings')+'' + '
' - + '
' - + '
' - + '
' + + '
' + + '
' + + '
' + '
'; function refreshSettings() { -- cgit v1.3 From eb2e3e876068f27a7a8e05fd0860ad7555b78c11 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 15 Apr 2014 13:49:38 +0200 Subject: quick-reply: fix z-index when boardlist is locationed as fixed --- js/quick-reply.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js') diff --git a/js/quick-reply.js b/js/quick-reply.js index 65e8e0d8..93cab334 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -36,6 +36,7 @@ display: block;\ padding: 0 0 0 0;\ width: 300px;\ + z-index: 100;\ }\ #quick-reply table {\ border-collapse: collapse;\ -- cgit v1.3 From f2b32fe3bc9ac78c254b7af97ff5e4eb9cc861d0 Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 16 Apr 2014 11:52:42 +0200 Subject: expand-video.js: avoid double-initialize --- js/expand-video.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js') diff --git a/js/expand-video.js b/js/expand-video.js index d2e35249..84a9108f 100644 --- a/js/expand-video.js +++ b/js/expand-video.js @@ -6,6 +6,9 @@ if (typeof _ == 'undefined') { } function setupVideo(thumb, url) { + if (thumb.videoAlreadySetUp) return; + thumb.videoAlreadySetUp = true; + var video = null; var videoContainer, videoHide; var expanded = false; -- cgit v1.3 From c4317cdbf7b24a9745f2126646162d527bd50c7b Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 16 Apr 2014 13:51:18 +0200 Subject: hide-threads.js + containerchan integration --- js/hide-threads.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/hide-threads.js b/js/hide-threads.js index 750d06a2..8ed150a3 100644 --- a/js/hide-threads.js +++ b/js/hide-threads.js @@ -35,6 +35,8 @@ $(document).ready(function(){ } } } + + var fields_to_hide = 'div.post,div.video-container,video,img,p.fileinfo,a.hide-thread-link,br'; var do_hide_threads = function() { var id = $(this).children('p.intro').children('a.post_no:eq(1)').text(); @@ -52,7 +54,7 @@ $(document).ready(function(){ hidden_data[board][id] = Math.round(Date.now() / 1000); store_data(); - thread_container.find('div.post,div.video-container,img,p.fileinfo,a.hide-thread-link,br').hide(); + thread_container.find(fields_to_hide).hide(); var hidden_div = thread_container.find('div.post.op > p.intro').clone(); hidden_div.addClass('thread-hidden'); @@ -65,7 +67,7 @@ $(document).ready(function(){ .click(function() { delete hidden_data[board][id]; store_data(); - thread_container.find('div.post,div.video-container,img,p.fileinfo,a.hide-thread-link,br').show(); + thread_container.find(fields_to_hide).show(); $(this).remove(); hidden_div.remove(); }); -- cgit v1.3 From 0ebd6afc6a06282921fa5dbb04cf954f755be3d9 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 18 Apr 2014 21:04:47 +0200 Subject: fix hide-threads and post-hover/expand.js interaction --- js/hide-threads.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js') diff --git a/js/hide-threads.js b/js/hide-threads.js index 8ed150a3..b26feca3 100644 --- a/js/hide-threads.js +++ b/js/hide-threads.js @@ -68,6 +68,7 @@ $(document).ready(function(){ delete hidden_data[board][id]; store_data(); thread_container.find(fields_to_hide).show(); + thread_container.find(".hidden").hide(); $(this).remove(); hidden_div.remove(); }); -- cgit v1.3