From 4559c242366fd9bdb2d5c6c18107eb6af71090c0 Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Fri, 22 Aug 2014 23:10:10 -0700 Subject: [PATCH] Add one-click post quoting (closes #13) --- inc/functions.php | 4 ++-- inc/html.php | 13 ++++++++++--- js/tinyib.js | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 js/tinyib.js diff --git a/inc/functions.php b/inc/functions.php index 33ec6fc..39613b5 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -181,8 +181,8 @@ function writePage($filename, $contents) { } function fixLinksInRes($html) { - $search = array(' href="css/', ' href="src/', ' href="thumb/', ' href="res/', ' href="imgboard.php', ' href="favicon.ico', 'src="thumb/', ' action="imgboard.php'); - $replace = array(' href="../css/', ' href="../src/', ' href="../thumb/', ' href="../res/', ' href="../imgboard.php', ' href="../favicon.ico', 'src="../thumb/', ' action="../imgboard.php'); + $search = array(' href="css/', ' src="js/', ' href="src/', ' href="thumb/', ' href="res/', ' href="imgboard.php', ' href="favicon.ico', 'src="thumb/', ' action="imgboard.php'); + $replace = array(' href="../css/', ' src="../js/', ' href="../src/', ' href="../thumb/', ' href="../res/', ' href="../imgboard.php', ' href="../favicon.ico', 'src="../thumb/', ' action="../imgboard.php'); return str_replace($search, $replace, $html); } diff --git a/inc/html.php b/inc/html.php index 9f0c422..8b2bad9 100644 --- a/inc/html.php +++ b/inc/html.php @@ -16,6 +16,7 @@ EOF; + @@ -71,7 +72,13 @@ function supportedFileTypes() { function buildPost($post, $res) { $return = ""; $threadid = ($post['parent'] == TINYIB_NEWTHREAD) ? $post['id'] : $post['parent']; - $postlink = ($res == TINYIB_RESPAGE) ? ($threadid . '.html#' . $post['id']) : ('res/' . $threadid . '.html#' . $post['id']); + + if ($res == TINYIB_RESPAGE) { + $reflink = "No.{$post['id']}"; + } else { + $reflink = "No.{$post['id']}"; + } + if (!isset($post["omitted"])) { $post["omitted"] = 0; } @@ -110,7 +117,7 @@ EOF; ${post["nameblock"]} - No.${post["id"]} + $reflink EOF; @@ -281,7 +288,7 @@ EOF; Message - + $file_input_html diff --git a/js/tinyib.js b/js/tinyib.js new file mode 100644 index 0000000..bc70d02 --- /dev/null +++ b/js/tinyib.js @@ -0,0 +1,20 @@ +function quotePost(postID){ + var message_element = document.getElementById("message"); + if (message_element){ + message_element.focus(); + message_element.value += '>>' + postID + "\n"; + } + + return false; +} + +document.addEventListener('DOMContentLoaded', function() { + if(window.location.hash){ + if(window.location.hash.match(/^#q[0-9]+$/i) !== null){ + var quotePostID = window.location.hash.match(/^#q[0-9]+$/i)[0].substr(2); + if (quotePostID != ''){ + quotePost(quotePostID); + } + } + } +});