From e75fd4d8fe3ffd6d364e67070578e798bda2df28 Mon Sep 17 00:00:00 2001 From: Anonish Date: Fri, 6 Feb 2015 20:42:13 -0600 Subject: [PATCH 01/11] Update quick-reply.js apparently 600 was still not allowing QR to load on portrait mode. 400 seems to work fine --- js/quick-reply.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/quick-reply.js b/js/quick-reply.js index 48d7864e..c5738eec 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -115,7 +115,7 @@ #quick-reply td.recaptcha-response {\ padding: 0 0 1px 0;\ }\ - @media screen and (max-width: 600px) {\ + @media screen and (max-width: 400px) {\ #quick-reply {\ display: none !important;\ }\ @@ -369,7 +369,7 @@ $(window).ready(function() { if (settings.get('hide_at_top', true)) { $(window).scroll(function() { - if ($(this).width() <= 600) + if ($(this).width() <= 400) return; if ($(this).scrollTop() < $origPostForm.offset().top + $origPostForm.height() - 100) $postForm.fadeOut(100); @@ -391,7 +391,7 @@ }; $(window).on('cite', function(e, id, with_link) { - if ($(this).width() <= 600) + if ($(this).width() <= 400) return; show_quick_reply(); if (with_link) { @@ -446,7 +446,7 @@ $('.quick-reply-btn').hide(); $(window).scroll(function() { - if ($(this).width() <= 600) + if ($(this).width() <= 400) return; if ($(this).scrollTop() < $('form[name="post"]:first').offset().top + $('form[name="post"]:first').height() - 100) $('.quick-reply-btn').fadeOut(100); From 1df89e2a87bc7997c6929a9df4c138f1316f9d08 Mon Sep 17 00:00:00 2001 From: Anonish Date: Sun, 8 Feb 2015 01:04:41 -0600 Subject: [PATCH 02/11] changes to expand-video.js --- js/expand-video.js | 85 +++++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 27 deletions(-) diff --git a/js/expand-video.js b/js/expand-video.js index 6d04b858..aa56ca64 100644 --- a/js/expand-video.js +++ b/js/expand-video.js @@ -21,6 +21,7 @@ function setupVideo(thumb, url) { function unexpand() { if (expanded) { expanded = false; + hovering = false; if (video.pause) video.pause(); videoContainer.style.display = "none"; thumb.style.display = "inline"; @@ -34,8 +35,7 @@ function setupVideo(thumb, url) { hovering = false; if (video.pause) video.pause(); videoContainer.style.display = "none"; - video.style.maxWidth = "inherit"; - video.style.maxHeight = "inherit"; + video.style.display = "none"; } } @@ -56,6 +56,7 @@ function setupVideo(thumb, url) { videoHide.addEventListener("click", unexpand, false); videoContainer = document.createElement("div"); + videoContainer.id = "#expandedVideo"; videoContainer.style.paddingLeft = "15px"; videoContainer.style.display = "none"; videoContainer.appendChild(videoHide); @@ -113,6 +114,7 @@ function setupVideo(thumb, url) { 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); @@ -124,34 +126,64 @@ function setupVideo(thumb, url) { // Hovering over thumbnail displays video thumb.addEventListener("mouseover", function(e) { - if (setting("videohover")) { - getVideo(); - expanded = false; - hovering = true; + 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; + var pageURL = window.location.href; + var jsonURL = pageURL.replace(/\.html$/, ".json"); + var vidName = video.src.split('/').pop().split(".").shift(); + + $.getJSON(jsonURL, function (result) { + $.each(result.posts, function(){ + if (vidName==this.tim) { - 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"; + var vidX = e.clientX; + var vidY = e.clientY; + var vidWidth = this.w; + var vidHeight = this.h; + var vidAspect = vidHeight / vidWidth; + var windowWidth = $(window).width(); + var windowHeight = $(window).height(); + var totalWidth = windowWidth - vidX; + var totalHeight = totalWidth*vidAspect; + var maxWidth = totalWidth - 20; + if (maxWidth < 250) { maxWidth = 250; } + var maxHeight = maxWidth * vidAspect; + var vidTop = vidY; + var vidBottom; - video.style.display = "inline"; - videoHide.style.display = "none"; - videoContainer.style.display = "inline"; - videoContainer.style.position = "fixed"; + if (vidWidth > windowWidth) { + video.style.maxWidth = maxWidth+"px"; + video.style.maxHeight = maxHeight+"px"; + vidBottom = vidTop + maxHeight; + } else { + video.style.maxWidth = vidWidth+"px"; + video.style.maxHeight = vidHeight+"px"; + vidBottom = vidTop + vidHeight; + } - video.muted = (setting("videovolume") == 0); - video.volume = setting("videovolume"); - video.controls = false; - video.play(); + if (vidBottom > windowHeight) { vidTop -= vidBottom-windowHeight; } + + videoContainer.style.position = "fixed"; + videoContainer.style.display = "block"; + + videoHide.style.display = "none"; + + video.style.left = vidX+"px"; + video.style.top = vidTop+"px"; + video.style.pointerEvents = "none"; + video.style.display = "block"; + video.style.position = "fixed"; + video.muted = (setting("videovolume") == 0); + video.volume = setting("videovolume"); + video.controls = false; + video.play(); + + } + }); + }); } }, false); @@ -241,4 +273,3 @@ onready(function(){ observer.observe(document.body, {childList: true, subtree: true}); } }); - From d2faa943b0a1ecec8856b7b526f463482e9ff733 Mon Sep 17 00:00:00 2001 From: Anonish Date: Sun, 8 Feb 2015 16:36:52 -0600 Subject: [PATCH 03/11] hover video fixes On index pages, restore original behavior (temp fix) On thread pages, fixed multiple file posts so all posts hover - still need to fix width for multiple posts as the ones on the right side of the page extend beyond the page (on original method they become tiny) - fix catalog long term i am thinking of just redoing the whole hover file (unless someone else does first). --- js/expand-video.js | 72 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/js/expand-video.js b/js/expand-video.js index aa56ca64..538e018a 100644 --- a/js/expand-video.js +++ b/js/expand-video.js @@ -130,15 +130,67 @@ function setupVideo(thumb, url) { getVideo(); expanded = false; hovering = true; - - var pageURL = window.location.href; - var jsonURL = pageURL.replace(/\.html$/, ".json"); - var vidName = video.src.split('/').pop().split(".").shift(); - $.getJSON(jsonURL, function (result) { - $.each(result.posts, function(){ - if (vidName==this.tim) { + var vidName = video.src.split('/').pop().split(".").shift(); + var isMod = (window.location.pathname.split("/")[1]=="mod.php"); + var thisBoard = isMod?window.location.href.split("/")[4]:window.location.pathname.split("/")[1]; + var pageType = window.active_page; + var pageURL = isMod?window.location.href:window.location.pathname; + var jsonURL; + + var thisThread; + var thisPost; + + if (pageType==="thread") { + jsonURL = pageURL.replace(/\.html$/, ".json"); + } else + if (pageType==="index"){ + var thisPage = isMod?window.location.href.split("/")[5].split(".")[0]:window.location.pathname.split("/")[2].split(".")[0]; + if (thisPage=="index") { thisPage="0"; } else { thisPage-=1;} + jsonURL = pageURL.replace(/[a-z0-9]+.html$/, thisPage+".json"); + } + + $.getJSON(jsonURL, function (thread) { + $this = thread; + if(typeof thread.threads != "undefined" && thread.threads != null && thread.threads.length > 0){ + console.log("index page"); + 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(); + } + else { + $.each($this.posts, function(){ + var tim = this.tim; + var fileNum = vidName.split('-').pop(); + if(typeof this.extra_files != "undefined" && this.extra_files != null && this.extra_files.length > 0){ + console.log("extra file exists"); + $.each(this.extra_files, function() { + if (vidName==this.tim){ + tim = this.tim; + } + }); + } + console.log("tim = "+tim); + if (vidName==tim) { var vidX = e.clientX; var vidY = e.clientY; var vidWidth = this.w; @@ -153,7 +205,7 @@ function setupVideo(thumb, url) { var maxHeight = maxWidth * vidAspect; var vidTop = vidY; var vidBottom; - + if (vidWidth > windowWidth) { video.style.maxWidth = maxWidth+"px"; video.style.maxHeight = maxHeight+"px"; @@ -181,8 +233,8 @@ function setupVideo(thumb, url) { video.controls = false; video.play(); - } - }); + } + }); } //else*/ }); } }, false); From 02708219d3aea65bffe40f6bc893e08dda1290ec Mon Sep 17 00:00:00 2001 From: Anonish Date: Sun, 8 Feb 2015 18:39:01 -0600 Subject: [PATCH 04/11] hover video fixes - fixes width on thread pages when opening video at bottom - works better on index pages, but still need to get actual width of video --- js/expand-video.js | 174 +++++++++++++++++++++++++++------------------ 1 file changed, 103 insertions(+), 71 deletions(-) diff --git a/js/expand-video.js b/js/expand-video.js index 538e018a..0e9ddcbb 100644 --- a/js/expand-video.js +++ b/js/expand-video.js @@ -149,28 +149,54 @@ function setupVideo(thumb, url) { if (thisPage=="index") { thisPage="0"; } else { thisPage-=1;} jsonURL = pageURL.replace(/[a-z0-9]+.html$/, thisPage+".json"); } - + $.getJSON(jsonURL, function (thread) { $this = thread; if(typeof thread.threads != "undefined" && thread.threads != null && thread.threads.length > 0){ - console.log("index page"); - 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"; + + var vidX = e.clientX; + var vidY = e.clientY; + var windowWidth = $(window).width(); + var windowHeight = $(window).height(); + var vidWidth = windowWidth - vidX; + var vidHeight = windowHeight - vidY; + var vidAspect = vidHeight / vidWidth; + + var totalWidth = windowWidth - vidX; + var totalHeight = totalWidth*vidAspect; + var maxWidth = totalWidth - 20; + if (maxWidth < 250) { maxWidth = 250; } + var maxHeight = maxWidth * vidAspect; + var vidTop = vidY; + var vidBottom; + var vidRight; + + if (vidWidth > windowWidth) { + video.style.maxWidth = maxWidth+"px"; + video.style.maxHeight = maxHeight+"px"; + vidBottom = vidTop + maxHeight; + vidRight = vidX+maxWidth - 20; + } else { + video.style.maxWidth = vidWidth+"px"; + video.style.maxHeight = vidHeight+"px"; + vidBottom = vidTop + vidHeight; + vidRight = vidX+vidWidth - 20; + } + + if (vidBottom > windowHeight) { vidTop -= vidBottom-windowHeight; } videoContainer.style.position = "fixed"; + videoContainer.style.display = "block"; + videoHide.style.display = "none"; + if (vidRight > windowWidth) { + video.style.left = vidX-(vidRight-windowWidth)+"px"; + } + else { + video.style.left = vidX+"px"; + } + video.style.top = vidTop+"px"; + video.style.pointerEvents = "none"; + video.style.display = "block"; + video.style.position = "fixed"; video.muted = (setting("videovolume") == 0); video.volume = setting("videovolume"); video.controls = false; @@ -178,63 +204,69 @@ function setupVideo(thumb, url) { } else { - $.each($this.posts, function(){ - var tim = this.tim; - var fileNum = vidName.split('-').pop(); - if(typeof this.extra_files != "undefined" && this.extra_files != null && this.extra_files.length > 0){ - console.log("extra file exists"); - $.each(this.extra_files, function() { - if (vidName==this.tim){ - tim = this.tim; - } - }); - } - console.log("tim = "+tim); - if (vidName==tim) { - var vidX = e.clientX; - var vidY = e.clientY; - var vidWidth = this.w; - var vidHeight = this.h; - var vidAspect = vidHeight / vidWidth; - var windowWidth = $(window).width(); - var windowHeight = $(window).height(); - var totalWidth = windowWidth - vidX; - var totalHeight = totalWidth*vidAspect; - var maxWidth = totalWidth - 20; - if (maxWidth < 250) { maxWidth = 250; } - var maxHeight = maxWidth * vidAspect; - var vidTop = vidY; - var vidBottom; - - if (vidWidth > windowWidth) { - video.style.maxWidth = maxWidth+"px"; - video.style.maxHeight = maxHeight+"px"; - vidBottom = vidTop + maxHeight; - } else { - video.style.maxWidth = vidWidth+"px"; - video.style.maxHeight = vidHeight+"px"; - vidBottom = vidTop + vidHeight; + $.each($this.posts, function(){ + var tim = this.tim; + var fileNum = vidName.split('-').pop(); + if(typeof this.extra_files != "undefined" && this.extra_files != null && this.extra_files.length > 0){ + $.each(this.extra_files, function() { + if (vidName==this.tim){ + tim = this.tim; + } + }); } + if (vidName==tim) { + var vidX = e.clientX; + var vidY = e.clientY; + var vidWidth = this.w; + var vidHeight = this.h; + var vidAspect = vidHeight / vidWidth; + var windowWidth = $(window).width(); + var windowHeight = $(window).height(); + var totalWidth = windowWidth - vidX; + var totalHeight = totalWidth*vidAspect; + var maxWidth = totalWidth - 20; + if (maxWidth < 250) { maxWidth = 250; } + var maxHeight = maxWidth * vidAspect; + var vidTop = vidY; + var vidBottom; + var vidRight; + if (vidWidth > windowWidth) { + video.style.maxWidth = maxWidth+"px"; + video.style.maxHeight = maxHeight+"px"; + vidBottom = vidTop + maxHeight; + vidRight = maxWidth+vidX; + } else { + video.style.maxWidth = vidWidth+"px"; + video.style.maxHeight = vidHeight+"px"; + vidBottom = vidTop + vidHeight; + vidRight = vidWidth+vidX; + } + if (vidBottom > windowHeight) { + vidTop -= vidBottom-windowHeight; + } - if (vidBottom > windowHeight) { vidTop -= vidBottom-windowHeight; } - - videoContainer.style.position = "fixed"; - videoContainer.style.display = "block"; + videoContainer.style.position = "fixed"; + videoContainer.style.display = "block"; - videoHide.style.display = "none"; + videoHide.style.display = "none"; - video.style.left = vidX+"px"; - video.style.top = vidTop+"px"; - video.style.pointerEvents = "none"; - video.style.display = "block"; - video.style.position = "fixed"; - video.muted = (setting("videovolume") == 0); - video.volume = setting("videovolume"); - video.controls = false; - video.play(); - - } - }); } //else*/ + if (vidRight > windowWidth) { + video.style.left = vidX-(vidRight-windowWidth)+"px"; + } + else { + video.style.left = vidX+"px"; + } + video.style.top = vidTop+"px"; + video.style.pointerEvents = "none"; + video.style.display = "block"; + video.style.position = "fixed"; + video.muted = (setting("videovolume") == 0); + video.volume = setting("videovolume"); + video.controls = false; + video.play(); + } + }); + } //else*/ }); } }, false); From 78cc03c2041b31590be90a952e1b43ff2d2ae4b4 Mon Sep 17 00:00:00 2001 From: anonish Date: Sun, 8 Feb 2015 21:36:33 -0600 Subject: [PATCH 05/11] Updating expand-video.js --- inc/template.php | 3 +- js/expand-video.js | 171 +++++++++++++++++++++++++++++++++++++-------- 2 files changed, 145 insertions(+), 29 deletions(-) diff --git a/inc/template.php b/inc/template.php index b0d7bfb2..2049b004 100644 --- a/inc/template.php +++ b/inc/template.php @@ -22,7 +22,8 @@ function load_twig() { $loader = new Twig_Loader_Filesystem($config['dir']['template']); $loader->setPaths($config['dir']['template']); $twig = new Twig_Environment($loader, array( - 'autoescape' => false, + 'autoescape' => false, + 'auto_reload' => true, 'cache' => is_writable('templates') || (is_dir('templates/cache') && is_writable('templates/cache')) ? "{$config['dir']['template']}/cache" : false, 'debug' => $config['debug'] diff --git a/js/expand-video.js b/js/expand-video.js index 6d04b858..56fc3654 100644 --- a/js/expand-video.js +++ b/js/expand-video.js @@ -21,6 +21,7 @@ function setupVideo(thumb, url) { function unexpand() { if (expanded) { expanded = false; + hovering = false; if (video.pause) video.pause(); videoContainer.style.display = "none"; thumb.style.display = "inline"; @@ -34,8 +35,7 @@ function setupVideo(thumb, url) { hovering = false; if (video.pause) video.pause(); videoContainer.style.display = "none"; - video.style.maxWidth = "inherit"; - video.style.maxHeight = "inherit"; + video.style.display = "none"; } } @@ -56,6 +56,7 @@ function setupVideo(thumb, url) { videoHide.addEventListener("click", unexpand, false); videoContainer = document.createElement("div"); + videoContainer.id = "#expandedVideo"; videoContainer.style.paddingLeft = "15px"; videoContainer.style.display = "none"; videoContainer.appendChild(videoHide); @@ -113,6 +114,7 @@ function setupVideo(thumb, url) { 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); @@ -124,34 +126,148 @@ function setupVideo(thumb, url) { // Hovering over thumbnail displays video thumb.addEventListener("mouseover", function(e) { - if (setting("videohover")) { - getVideo(); - expanded = false; - hovering = true; + if (setting("videohover")) { + getVideo(); + expanded = false; + hovering = true; + + var vidName = video.src.split('/').pop().split(".").shift(); + var isMod = (window.location.pathname.split("/")[1]=="mod.php"); + var thisBoard = isMod?window.location.href.split("/")[4]:window.location.pathname.split("/")[1]; + var pageType = window.active_page; + var pageURL = isMod?window.location.href:window.location.pathname; + var jsonURL; + + var thisThread; + var thisPost; + + if (pageType==="thread") { + jsonURL = pageURL.replace(/\.html$/, ".json"); + } else + if (pageType==="index"){ + var thisPage = isMod?window.location.href.split("/")[5].split(".")[0]:window.location.pathname.split("/")[2].split(".")[0]; + if (thisPage=="index") { thisPage="0"; } else { thisPage-=1;} + jsonURL = pageURL.replace(/[a-z0-9]+.html$/, thisPage+".json"); + } - var docRight = document.documentElement.getBoundingClientRect().right; - var thumbRight = thumb.querySelector("img, video").getBoundingClientRect().right; - var maxWidth = docRight - thumbRight - 20; - if (maxWidth < 250) maxWidth = 250; + $.getJSON(jsonURL, function (thread) { + $this = thread; + if(typeof thread.threads != "undefined" && thread.threads != null && thread.threads.length > 0){ - 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"; + var vidX = e.clientX; + var vidY = e.clientY; + var windowWidth = $(window).width(); + var windowHeight = $(window).height(); + var vidWidth = windowWidth - vidX; + var vidHeight = windowHeight - vidY; + var vidAspect = vidHeight / vidWidth; - video.style.display = "inline"; - videoHide.style.display = "none"; - videoContainer.style.display = "inline"; - videoContainer.style.position = "fixed"; + var totalWidth = windowWidth - vidX; + var totalHeight = totalWidth*vidAspect; + var maxWidth = totalWidth - 20; + if (maxWidth < 250) { maxWidth = 250; } + var maxHeight = maxWidth * vidAspect; + var vidTop = vidY; + var vidBottom; + var vidRight; - video.muted = (setting("videovolume") == 0); - video.volume = setting("videovolume"); - video.controls = false; - video.play(); + if (vidWidth > windowWidth) { + video.style.maxWidth = maxWidth+"px"; + video.style.maxHeight = maxHeight+"px"; + vidBottom = vidTop + maxHeight; + vidRight = vidX+maxWidth - 20; + } else { + video.style.maxWidth = vidWidth+"px"; + video.style.maxHeight = vidHeight+"px"; + vidBottom = vidTop + vidHeight; + vidRight = vidX+vidWidth - 20; + } + + if (vidBottom > windowHeight) { vidTop -= vidBottom-windowHeight; } + videoContainer.style.position = "fixed"; + videoContainer.style.display = "block"; + videoHide.style.display = "none"; + if (vidRight > windowWidth) { + video.style.left = vidX-(vidRight-windowWidth)+"px"; + } + else { + video.style.left = vidX+"px"; + } + video.style.top = vidTop+"px"; + video.style.pointerEvents = "none"; + video.style.display = "block"; + video.style.position = "fixed"; + video.muted = (setting("videovolume") == 0); + video.volume = setting("videovolume"); + video.controls = false; + video.play(); + } + else { + + $.each($this.posts, function(){ + var tim = this.tim; + var fileNum = vidName.split('-').pop(); + if(typeof this.extra_files != "undefined" && this.extra_files != null && this.extra_files.length > 0){ + $.each(this.extra_files, function() { + if (vidName==this.tim){ + tim = this.tim; + } + }); + } + if (vidName==tim) { + var vidX = e.clientX; + var vidY = e.clientY; + var vidWidth = this.w; + var vidHeight = this.h; + var vidAspect = vidHeight / vidWidth; + var windowWidth = $(window).width(); + var windowHeight = $(window).height(); + var totalWidth = windowWidth - vidX; + var totalHeight = totalWidth*vidAspect; + var maxWidth = totalWidth - 20; + if (maxWidth < 250) { maxWidth = 250; } + var maxHeight = maxWidth * vidAspect; + var vidTop = vidY; + var vidBottom; + var vidRight; + if (vidWidth > windowWidth) { + video.style.maxWidth = maxWidth+"px"; + video.style.maxHeight = maxHeight+"px"; + vidBottom = vidTop + maxHeight; + vidRight = maxWidth+vidX; + } else { + video.style.maxWidth = vidWidth+"px"; + video.style.maxHeight = vidHeight+"px"; + vidBottom = vidTop + vidHeight; + vidRight = vidWidth+vidX; + } + if (vidBottom > windowHeight) { + vidTop -= vidBottom-windowHeight; + } + + videoContainer.style.position = "fixed"; + videoContainer.style.display = "block"; + + videoHide.style.display = "none"; + + if (vidRight > windowWidth) { + video.style.left = vidX-(vidRight-windowWidth)+"px"; + } + else { + video.style.left = vidX+"px"; + } + video.style.top = vidTop+"px"; + video.style.pointerEvents = "none"; + video.style.display = "block"; + video.style.position = "fixed"; + video.muted = (setting("videovolume") == 0); + video.volume = setting("videovolume"); + video.controls = false; + video.play(); + } + }); + } //else*/ + }); } }, false); @@ -240,5 +356,4 @@ onready(function(){ }); observer.observe(document.body, {childList: true, subtree: true}); } -}); - +}); \ No newline at end of file From afd79689f3fe230528c0e190a86d113d825a6945 Mon Sep 17 00:00:00 2001 From: anonish Date: Sun, 8 Feb 2015 21:48:23 -0600 Subject: [PATCH 06/11] Cleanup for expand-video.js --- js/expand-video.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/js/expand-video.js b/js/expand-video.js index f268d550..0e9ddcbb 100644 --- a/js/expand-video.js +++ b/js/expand-video.js @@ -356,8 +356,4 @@ onready(function(){ }); observer.observe(document.body, {childList: true, subtree: true}); } -<<<<<<< HEAD }); -======= -}); ->>>>>>> 02708219d3aea65bffe40f6bc893e08dda1290ec From b6151bee514d0aa336bfff8ad0011b9a65821c8d Mon Sep 17 00:00:00 2001 From: anonish Date: Sun, 8 Feb 2015 21:53:36 -0600 Subject: [PATCH 07/11] testing --- js/expand-video.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/expand-video.js b/js/expand-video.js index 0e9ddcbb..57612e14 100644 --- a/js/expand-video.js +++ b/js/expand-video.js @@ -137,7 +137,7 @@ function setupVideo(thumb, url) { var pageType = window.active_page; var pageURL = isMod?window.location.href:window.location.pathname; var jsonURL; - + console.log("vidName = "+vidName); var thisThread; var thisPost; From d69e0e6fccc592492e49cdea412034e42da611c7 Mon Sep 17 00:00:00 2001 From: anonish Date: Sun, 8 Feb 2015 22:14:17 -0600 Subject: [PATCH 08/11] test 2 --- js/expand-video.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/expand-video.js b/js/expand-video.js index 57612e14..2f1e8713 100644 --- a/js/expand-video.js +++ b/js/expand-video.js @@ -137,9 +137,9 @@ function setupVideo(thumb, url) { var pageType = window.active_page; var pageURL = isMod?window.location.href:window.location.pathname; var jsonURL; - console.log("vidName = "+vidName); var thisThread; var thisPost; + console.log("vidName = "+vidName); if (pageType==="thread") { jsonURL = pageURL.replace(/\.html$/, ".json"); From 6dd547e1bfddf994b23aecb39ededb2f437d9ea4 Mon Sep 17 00:00:00 2001 From: anonish Date: Sat, 21 Feb 2015 00:47:07 -0600 Subject: [PATCH 09/11] revert changes to template.php --- inc/template.php | 1 - 1 file changed, 1 deletion(-) diff --git a/inc/template.php b/inc/template.php index 2049b004..416b6ecf 100644 --- a/inc/template.php +++ b/inc/template.php @@ -23,7 +23,6 @@ function load_twig() { $loader->setPaths($config['dir']['template']); $twig = new Twig_Environment($loader, array( 'autoescape' => false, - 'auto_reload' => true, 'cache' => is_writable('templates') || (is_dir('templates/cache') && is_writable('templates/cache')) ? "{$config['dir']['template']}/cache" : false, 'debug' => $config['debug'] From 9c7cfc56d03734786add1ff578d9cba9d4f7849a Mon Sep 17 00:00:00 2001 From: Bui Date: Fri, 27 Feb 2015 23:34:16 +0900 Subject: [PATCH 10/11] actually check if images are disabled fixes #410 --- inc/config.php | 5 ++++- inc/instance-config.php | 1 - post.php | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/inc/config.php b/inc/config.php index 1531d807..b2ce8bf4 100644 --- a/inc/config.php +++ b/inc/config.php @@ -561,6 +561,9 @@ // When true, users are instead presented a selectbox for email. Contains, blank, noko and sage. $config['field_email_selectbox'] = &$config['field_disable_name']; + // Prevent users from uploading files. + $config['disable_images'] = false; + // When true, the sage won't be displayed $config['hide_sage'] = false; @@ -1117,7 +1120,7 @@ $config['error']['mime_exploit'] = _('MIME type detection XSS exploit (IE) detected; post discarded.'); $config['error']['invalid_embed'] = _('Couldn\'t make sense of the URL of the video you tried to embed.'); $config['error']['captcha'] = _('You seem to have mistyped the verification.'); - + $config['error']['images_disabled'] = _('Uploading files is disabled on this board.'); // Moderator errors $config['error']['toomanyunban'] = _('You are only allowed to unban %s users at a time. You tried to unban %u users.'); diff --git a/inc/instance-config.php b/inc/instance-config.php index 732eade1..20f2c757 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -57,7 +57,6 @@ $config['show_ratio'] = true; //$config['allow_upload_by_url'] = true; $config['max_filesize'] = 1024 * 1024 * 8; // 8MB - $config['disable_images'] = false; $config['spoiler_images'] = true; $config['image_reject_repost'] = true; $config['allowed_ext_files'][] = 'webm'; diff --git a/post.php b/post.php index b303f536..86b7de61 100644 --- a/post.php +++ b/post.php @@ -406,6 +406,10 @@ elseif (isset($_POST['post'])) { error('Sorry. Tor users can\'t upload files.'); if ($tor && !$config['tor_posting']) error('Sorry. The owner of this board has decided not to allow Tor posters for some reason...'); + + if ($post['has_file'] && $config['disable_images']) { + error($config['error']['images_disabled']); + } if (!($post['has_file'] || isset($post['embed'])) || (($post['op'] && $config['force_body_op']) || (!$post['op'] && $config['force_body']))) { // http://stackoverflow.com/a/4167053 From 331b471bea7f95d2ab0f06c32de7932fd74f41eb Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Fri, 6 Mar 2015 16:15:49 +0800 Subject: [PATCH 11/11] post-filter.js catalog support Removes hidden threads from catalog page Shift click on catalog to hide thread Improved word matching for simple comment and subject filter. --- js/catalog.js | 20 ------ js/post-filter.js | 160 ++++++++++++++++++++++++---------------------- 2 files changed, 83 insertions(+), 97 deletions(-) diff --git a/js/catalog.js b/js/catalog.js index 38382096..d9388638 100644 --- a/js/catalog.js +++ b/js/catalog.js @@ -6,26 +6,6 @@ if (active_page == 'catalog') $(function(){ localStorage.catalog = JSON.stringify(catalog); } - if (localStorage.hiddenthreads) { - var hidden_data = JSON.parse(localStorage.hiddenthreads); - - if (hidden_data[board_name] && !$.isEmptyObject(hidden_data[board_name])) { - $.each(hidden_data[board_name], function(k, v) { - $('a[href$="/'+k+'.html"]').parents('.mix').remove(); - }); - } - } else { - hidden_data = {}; - } - - $(document).on('click', '.mix', function(e) { - if (e.shiftKey) { - hidden_data[board_name][$(this).data('id')] = Math.round(Date.now() / 1000); - $(this).remove(); - localStorage.hiddenthreads = JSON.stringify(hidden_data); - } - }); - $("#sort_by").change(function(){ var value = this.value; $('#Grid').mixItUp('sort', value); diff --git a/js/post-filter.js b/js/post-filter.js index 9ec28262..28e02f78 100644 --- a/js/post-filter.js +++ b/js/post-filter.js @@ -1,4 +1,4 @@ -if (active_page === 'thread' || active_page === 'index') { +if (active_page === 'thread' || active_page === 'index' || active_page === 'catalog') { $(document).ready(function () { 'use strict'; // returns blacklist object from storage @@ -408,13 +408,13 @@ if (active_page === 'thread' || active_page === 'index') { if (!forcedAnon && hasTrip) trip = $post.find('.trip').text(); if (hasSub) - subject = ' '+ $post.find('.subject').text() +' '; + subject = $post.find('.subject').text(); array = $post.find('.body').contents().filter(function () {if ($(this).text() !== '') return true;}).toArray(); array = $.map(array, function (ele) { return $(ele).text(); }); - comment = ' '+ array.join(' ') +' '; + comment = array.join(' '); for (i = 0, length = list.generalFilter.length; i < length; i++) { @@ -430,7 +430,7 @@ if (active_page === 'thread' || active_page === 'index') { } break; case 'trip': - if (!forcedAnon && pattern.test(trip)) { + if (!forcedAnon && hasTrip && pattern.test(trip)) { $post.data('hiddenByTrip', true); hide(post); } @@ -463,13 +463,15 @@ if (active_page === 'thread' || active_page === 'index') { } break; case 'sub': - if (hasSub && subject.indexOf(' '+ rule.value +' ') != -1) { + pattern = new RegExp('\\b'+ rule.value+ '\\b'); + if (hasSub && pattern.test(subject)) { $post.data('hiddenBySubject', true); hide(post); } break; case 'com': - if (comment.indexOf(' '+ rule.value +' ') != -1) { + pattern = new RegExp('\\b'+ rule.value+ '\\b'); + if (pattern.test(comment)) { $post.data('hiddenByComment', true); hide(post); } @@ -502,43 +504,63 @@ if (active_page === 'thread' || active_page === 'index') { function filterPage(pageData) { var list = getList(); - // empty the local and no-reply list - pageData.localList = []; - pageData.noReplyList = []; + if (active_page != 'catalog') { - $('.thread').each(function () { - var $thread = $(this); - // disregard the hidden threads constructed by post-hover.js - if ($thread.css('display') == 'none') + // empty the local and no-reply list + pageData.localList = []; + pageData.noReplyList = []; + + $('.thread').each(function () { + var $thread = $(this); + // disregard the hidden threads constructed by post-hover.js + if ($thread.css('display') == 'none') + return; + + var threadId = $thread.attr('id').replace('thread_', ''); + var op = $thread.children('.op')[0]; + var i, array; // temp variables + + // add posts to localList and noReplyList + if (typeof list.postFilter[pageData.boardId] != 'undefined' && typeof list.postFilter[pageData.boardId][threadId] != 'undefined') { + array = list.postFilter[pageData.boardId][threadId]; + for (i=0; i'); $row.append( - ''+ typeName[obj.type] +'', - ''+ val +'', - $('').append( - $('').html('X') - .addClass('del-btn') - .attr('href', '#') - .data('type', obj.type) - .data('val', obj.value) - .data('useRegex', obj.regex) - ) - ); + ''+ typeName[obj.type] +'', + ''+ val +'', + $('').append( + $('').html('X') + .addClass('del-btn') + .attr('href', '#') + .data('type', obj.type) + .data('val', obj.value) + .data('useRegex', obj.regex) + ) + ); $ele.append($row); } } @@ -754,33 +776,6 @@ if (active_page === 'thread' || active_page === 'index') { }); } - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Migrate from previous version of post filter - * Remember to remove next time anyone touches this file - */ - (function () { - var list = getList(); - if (typeof list.nameFilter != 'undefined') { - var filter = list.nameFilter; - list.generalFilter = []; - - for (var i = 0; i < filter.length; i++) { - var obj = filter[i]; - for (var key in obj) { - list.generalFilter.push({ - type: key, - value: obj[key], - regex: false - }); - } - } - - delete list.nameFilter; - localStorage.postFilter = JSON.stringify(list); - } - })(); - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - var pageData = { boardId: board_name, // get the id from the global variable localList: [], // all the blacklisted post IDs or UIDs that apply to the current page @@ -812,6 +807,17 @@ if (active_page === 'thread' || active_page === 'index') { filterPage(pageData); }); + // shift+click on catalog to hide thread + if (active_page == 'catalog') { + $(document).on('click', '.mix', function(e) { + if (e.shiftKey) { + var threadId = $(this).data('id'); + var postId = threadId; + blacklist.add.post(pageData.boardId, threadId, postId, false); + } + }); + } + // clear out the old threads purge(); }