From 4fcb43330f79a2399b45e54481c96f2fe5554093 Mon Sep 17 00:00:00 2001 From: Joshua Merrell Date: Sun, 28 Jan 2018 15:01:59 -0800 Subject: [PATCH] Add webm support and update jQuery --- html/javascript/gochan.js | 177 +++++++++--------- html/javascript/jquery-1.10.2.min.js | 6 - html/javascript/jquery-3.3.1.min.js | 2 + src/manage.go | 66 ++++--- src/posting.go | 260 ++++++++++++++++++++------- src/server.go | 17 +- src/template.go | 25 ++- src/types.go | 13 ++ src/util.go | 13 +- templates/banpage.html | 2 +- templates/front.html | 2 +- templates/img_boardpage.html | 10 +- templates/img_threadpage.html | 15 +- templates/manage_header.html | 2 +- vagrant/bootstrap.sh | 4 +- 15 files changed, 395 insertions(+), 219 deletions(-) delete mode 100644 html/javascript/jquery-1.10.2.min.js create mode 100644 html/javascript/jquery-3.3.1.min.js diff --git a/html/javascript/gochan.js b/html/javascript/gochan.js index 16a47c32..5a39c71c 100644 --- a/html/javascript/gochan.js +++ b/html/javascript/gochan.js @@ -42,15 +42,89 @@ function preparePostPreviews(is_inline) { if($(this).next().attr("class") != "inlinepostprev") { $(".postprev").remove(); $(this).after($("div#"+this.innerHTML.replace(">>","")).clone().attr({"class":"inlinepostprev","id":"i"+$(this).parent().attr("id")+"-"+($(this).parent().find("div#i"+$(this).parent().attr("id")).length+1)})); - console.debug("honk"); preparePostPreviews(true); } else { $(this).next().remove(); - } + } }); } } +function getUploadPostID(upload, container) { + // if container, upload is div.upload-container + // otherwise it's img or video + var jqu = container? $jq(upload) : $jq(upload).parent(); + if(insideOP(jqu)) return jqu.siblings().eq(4).text(); + else return jqu.siblings().eq(3).text(); +} + +function insideOP(elem) { + return $jq(elem).parents("div.op-post").length > 0; +} + +function prepareThumbnails() { + // set thumbnails to expand when clicked + $jq("a.upload-container").click(function(e) { + var a = $jq(this); + var thumb = a.find("img.thumbnail"); + var video; + var thumbURL; + if(thumb.attr("alt") == undefined) thumbURL = thumb.attr("src"); + else thumbURL = thumb.attr("alt"); + var thumb_width = thumb.attr("width"); + var thumb_height = thumb.attr("height"); + var file_info_elem = a.prevAll(".file-info:first"); + var uploadURL = file_info_elem.children("a:first")[0].href; + + if(thumb.attr("src") == thumbURL) { + // Expanding thumbnail + if(uploadURL.indexOf(".webm") > 0) { + // Upload is a video + thumb.hide(); + video = $jq("