From f393fa88ea528a46f91b296d34763a4d6dca5747 Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Sun, 27 Aug 2017 16:48:36 +0100
Subject: [PATCH] Fix bugs on file upload page

---
 Changelog.md               | 1 +
 build/index.php            | 8 ++++----
 module_index.json          | 4 ++--
 modules/feature-upload.php | 8 ++++----
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/Changelog.md b/Changelog.md
index 828e15e..8e7a2ee 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -15,6 +15,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
  - Fixed paths when generating previews in certain environments
  - Fixed handling of pages and tags with single quotes in the name
  - Fixed weirdness on some pages rendered by the Pepperminty Wiki core
+ - Fixed a few minor usability issues on the upload file page.
 
 ### Changed
  - Make `invindex-rebuild` admin-only, but allow access if the POST param `secret` is set to your secret in `peppermint.json`
diff --git a/build/index.php b/build/index.php
index c4885d0..a2a0129 100644
--- a/build/index.php
+++ b/build/index.php
@@ -4262,7 +4262,7 @@ function stats_save($stats)
 
 register_module([
 	"name" => "Uploader",
-	"version" => "0.5.9",
+	"version" => "0.5.10",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File/' prefix.",
 	"id" => "feature-upload",
@@ -4338,10 +4338,10 @@ register_module([
 		<p>Select an image or file below, and then type a name for it in the box. This server currently supports uploads up to " . human_filesize(get_max_upload_size()) . " in size.</p>
 		<p>$settings->sitename currently supports uploading of the following file types: " . implode(", ", $settings->upload_allowed_file_types) . ".</p>
 		<form method='post' action='?action=upload' enctype='multipart/form-data'>
-			<label for='file'>Select a file to upload.</label>
+			<label for='file-upload-selector'>Select a file to upload.</label>
 			<input type='file' name='file' id='file-upload-selector' tabindex='1' />
 			<br />
-			<label for='name'>Name:</label>
+			<label for='file-upload-name'>Name:</label>
 			<input type='text' name='name' id='file-upload-name' tabindex='5'  />
 			<br />
 			<label for='description'>Description:</label>
@@ -4350,7 +4350,7 @@ register_module([
 			<input type='submit' value='Upload' tabindex='20' />
 		</form>
 		<script>
-			document.getElementById('file-upload-selector').addEventListener('change', function() {
+			document.getElementById('file-upload-selector').addEventListener('change', function(event) {
 				var newName = event.target.value.substring(event.target.value.lastIndexOf(\"\\\\\") + 1, event.target.value.lastIndexOf(\".\"));
 				console.log('Changing content of name box to:', newName);
 				document.getElementById('file-upload-name').value = newName;
diff --git a/module_index.json b/module_index.json
index bf7943e..03aba6b 100755
--- a/module_index.json
+++ b/module_index.json
@@ -118,11 +118,11 @@
     },
     {
         "name": "Uploader",
-        "version": "0.5.9",
+        "version": "0.5.10",
         "author": "Starbeamrainbowlabs",
         "description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File\/' prefix.",
         "id": "feature-upload",
-        "lastupdate": 1501320696,
+        "lastupdate": 1503848840,
         "optional": false
     },
     {
diff --git a/modules/feature-upload.php b/modules/feature-upload.php
index ef67fbb..efac79e 100644
--- a/modules/feature-upload.php
+++ b/modules/feature-upload.php
@@ -1,7 +1,7 @@
 <?php
 register_module([
 	"name" => "Uploader",
-	"version" => "0.5.9",
+	"version" => "0.5.10",
 	"author" => "Starbeamrainbowlabs",
 	"description" => "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File/' prefix.",
 	"id" => "feature-upload",
@@ -77,10 +77,10 @@ register_module([
 		<p>Select an image or file below, and then type a name for it in the box. This server currently supports uploads up to " . human_filesize(get_max_upload_size()) . " in size.</p>
 		<p>$settings->sitename currently supports uploading of the following file types: " . implode(", ", $settings->upload_allowed_file_types) . ".</p>
 		<form method='post' action='?action=upload' enctype='multipart/form-data'>
-			<label for='file'>Select a file to upload.</label>
+			<label for='file-upload-selector'>Select a file to upload.</label>
 			<input type='file' name='file' id='file-upload-selector' tabindex='1' />
 			<br />
-			<label for='name'>Name:</label>
+			<label for='file-upload-name'>Name:</label>
 			<input type='text' name='name' id='file-upload-name' tabindex='5'  />
 			<br />
 			<label for='description'>Description:</label>
@@ -89,7 +89,7 @@ register_module([
 			<input type='submit' value='Upload' tabindex='20' />
 		</form>
 		<script>
-			document.getElementById('file-upload-selector').addEventListener('change', function() {
+			document.getElementById('file-upload-selector').addEventListener('change', function(event) {
 				var newName = event.target.value.substring(event.target.value.lastIndexOf(\"\\\\\") + 1, event.target.value.lastIndexOf(\".\"));
 				console.log('Changing content of name box to:', newName);
 				document.getElementById('file-upload-name').value = newName;
