From f308493a4a6b791024fa4259cb7e28e9e68543ed Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Mon, 20 Nov 2017 18:49:29 +0000
Subject: [PATCH] Add title to delete button

---
 build/index.php              | 13 ++++++++++---
 module_index.json            |  2 +-
 modules/feature-comments.php |  2 +-
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/build/index.php b/build/index.php
index 5ceaf3f..93e2631 100644
--- a/build/index.php
+++ b/build/index.php
@@ -2853,8 +2853,15 @@ function delete_comment(&$comment_data, $target_id)
 	
 	for($i = 0; $i < $comment_count; $i++) {
 		if($comment_data[$i]->id == $target_id) {
-			unset($comment_data[$i]->username);
-			$comment_data[$i]->message = "_[Deleted]_";
+			if(count($comment_data[$i]->replies) == 0) {
+				unset($comment_data[$i]);
+				// Reindex the comment list before returning
+				$comment_data = array_values($comment_data);
+			}
+			else {
+				unset($comment_data[$i]->username);
+				$comment_data[$i]->message = "_[Deleted]_";
+			}
 			return true;
 		}
 		if(count($comment_data[$i]->replies) > 0 &&
@@ -2932,7 +2939,7 @@ function render_comments($comments_data, $depth = 0)
 		$result .= "\t<p class='comment-footer'>";
 		$result .= "\t\t<span class='comment-footer-item'><button class='reply-button'>Reply</button></span>\n";
 		if($env->user == $comment->username || $env->is_admin)
-			$result .= "<span class='comment-footer-item'><a href='?action=comment-delete&page=" . rawurlencode($env->page) . "&delete_id=" . rawurlencode($comment->id) . "' class='delete-button'>Delete</a></span>\n";
+			$result .= "<span class='comment-footer-item'><a href='?action=comment-delete&page=" . rawurlencode($env->page) . "&delete_id=" . rawurlencode($comment->id) . "' class='delete-button' title='Permanently delete this comment'>Delete</a></span>\n";
 		$result .= "\t\t<span class='comment-footer-item'><a class='permalink-button' href='#comment-$comment->id' title='Permalink to this comment'>&#x1f517;</a></span>\n";
 		$result .= "\t\t<span class='comment-footer-item'><time datetime='" . date("c", strtotime($comment->timestamp)) . "' title='The time this comment was posted'>$settings->comment_time_icon " . date("l jS \of F Y \a\\t h:ia T", strtotime($comment->timestamp)) . "</time></span>\n";
 		$result .= "\t</p>\n";
diff --git a/module_index.json b/module_index.json
index ee0ebfc..6e039d9 100755
--- a/module_index.json
+++ b/module_index.json
@@ -59,7 +59,7 @@
         "author": "Starbeamrainbowlabs",
         "description": "Adds threaded comments to the bottom of every page.",
         "id": "feature-comments",
-        "lastupdate": 1511092595,
+        "lastupdate": 1511096059,
         "optional": false
     },
     {
diff --git a/modules/feature-comments.php b/modules/feature-comments.php
index c0b6e8e..5902db4 100644
--- a/modules/feature-comments.php
+++ b/modules/feature-comments.php
@@ -424,7 +424,7 @@ function render_comments($comments_data, $depth = 0)
 		$result .= "\t<p class='comment-footer'>";
 		$result .= "\t\t<span class='comment-footer-item'><button class='reply-button'>Reply</button></span>\n";
 		if($env->user == $comment->username || $env->is_admin)
-			$result .= "<span class='comment-footer-item'><a href='?action=comment-delete&page=" . rawurlencode($env->page) . "&delete_id=" . rawurlencode($comment->id) . "' class='delete-button'>Delete</a></span>\n";
+			$result .= "<span class='comment-footer-item'><a href='?action=comment-delete&page=" . rawurlencode($env->page) . "&delete_id=" . rawurlencode($comment->id) . "' class='delete-button' title='Permanently delete this comment'>Delete</a></span>\n";
 		$result .= "\t\t<span class='comment-footer-item'><a class='permalink-button' href='#comment-$comment->id' title='Permalink to this comment'>&#x1f517;</a></span>\n";
 		$result .= "\t\t<span class='comment-footer-item'><time datetime='" . date("c", strtotime($comment->timestamp)) . "' title='The time this comment was posted'>$settings->comment_time_icon " . date("l jS \of F Y \a\\t h:ia T", strtotime($comment->timestamp)) . "</time></span>\n";
 		$result .= "\t</p>\n";
