Skip to content

Commit e1fb6d5

Browse files
Fix: deal better with subject input box
For now, I’m undecided what to do with it when empty.
1 parent dd7f302 commit e1fb6d5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

gwynethllewelyn/postlocalstorage/styles/all/template/postlocalstorage_functions.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
88

99
(function(message, doc) {
10-
var nIntervId;
10+
var nIntervId; //
1111

1212
// One year = 31536000000 milliseconds.
1313
const FRESHNESS_INTERVAL = 365 * 24 * 60 * 60 * 1000;
@@ -21,14 +21,15 @@
2121
var textarea = doc.querySelector('textarea[name="message"]');
2222
// no point in being around if this is nil; also: avoids crashing below (gwyneth 20220303)
2323
if (!textarea) {
24-
console.warn("no phpBB3 textarea found");
24+
console.warn("no phpBB3 content body textarea found");
2525
return;
2626
}
2727
// phpBB3 usually gives the subject/topic the name 'subject' — same for QR and normal replies.
2828
var subject = doc.querySelector('input[name="subject"]');
2929
if (!subject) {
30-
console.debug("no phpBB3 subject found");
31-
// I have not decided what to do in this case!
30+
console.debug("no phpBB3 subject line found");
31+
// I have not decided what to do in this case! Possibly just:
32+
// subject = "(no subject)";
3233
}
3334
// The key for the key/value pair in localStorage is the current URL.
3435
var key = message.location.href;
@@ -93,10 +94,10 @@
9394
if (textarea.value) {
9495
item = JSON.stringify({ "content": textarea.value, "subject": (subject?.value ?? ""), "timestamp": Date.now() });
9596
message.localStorage.setItem(key, item);
96-
console.debug("Existing text saved to localStorage");
97+
console.debug("Existing subject & content saved to localStorage");
9798
} else {
9899
message.localStorage.removeItem(key);
99-
console.debug("Empty textarea -- remove existing text in localStorage");
100+
console.debug("Empty textarea -- remove existing content & subject in localStorage");
100101
}
101102
// This event listener is no longer needed now so remove it.
102103
// Once the user presses another key, it will be added again!

0 commit comments

Comments
 (0)