Skip to content

Commit 5b6eb62

Browse files
authored
Update postlocalstorage_functions.js
Workaround to delete local storage at PM's because expiry-time=0. It must be fixed. Minor other cosmetic changes
1 parent a0e017b commit 5b6eb62

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

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

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@
5454
// Firefox seems to have an odd bug which affects clicking backspace in quick succession.
5555
// Kudos to @gvp9000 and for the fix below. (gwyneth 20240414)
5656
// @see https://www.phpbb.com/customise/db/extension/postlocalstorage/support/topic/246616?p=877489#p877489
57-
58-
59-
// POSTING
60-
//possible key formats
61-
//./phpBB3/posting.php?mode=edit&&p=xxxxx#preview#preview#preview#preview .......
62-
//./phpBB3/posting.php?mode=quote&p=xxxxx#preview#preview#preview#preview .......
63-
//./phpBB3/posting.php?mode=reply&t=yyyyy#preview#preview#preview#preview .......
64-
//Remove all "#preview" strings at the end
57+
58+
// POSTING
59+
//possible key formats
60+
//./phpBB3/posting.php?mode=edit&&p=xxxxx#preview#preview#preview#preview .......
61+
//./phpBB3/posting.php?mode=quote&p=xxxxx#preview#preview#preview#preview .......
62+
//./phpBB3/posting.php?mode=reply&t=yyyyy#preview#preview#preview#preview .......
63+
//Remove all "#preview" strings at the end
6564
if (key.includes("posting.php?mode=")) {
6665
if (key.endsWith("#preview")) {
6766
var count_hash = key.split("#").length - 1;
@@ -70,31 +69,30 @@
7069
}
7170
}
7271
}
73-
74-
// PM'ing
75-
//possible key formats
76-
77-
//1 case
78-
//./phpBB3/ucp.php?i=pm&mode=compose
79-
//nothing to do here
80-
81-
//2 case
82-
//./phpBB3/ucp.php?i=ucp_pm&mode=compose returns
83-
//./phpBB3/ucp.php?i=pm&mode=compose
72+
// PM'ing
73+
//possible key formats
74+
75+
//1 case
76+
//./phpBB3/ucp.php?i=pm&mode=compose
77+
//nothing to do here
78+
79+
//2 case
80+
//./phpBB3/ucp.php?i=ucp_pm&mode=compose returns
81+
//./phpBB3/ucp.php?i=pm&mode=compose
8482
if (key.includes("ucp.php?i=ucp_pm&mode=compose")) {
8583
key = key.split("?")[0].concat("?i=pm&mode=compose");
8684
}
8785

88-
//3 case
89-
//./phpBB3/ucp.php?i=pm&mode=compose&action=post&sid=sssssssssssssssssssssssssss returns
90-
//./phpBB3/ucp.php?i=pm&mode=compose
86+
//3 case
87+
//./phpBB3/ucp.php?i=pm&mode=compose&action=post&sid=sssssssssssssssssssssssssss returns
88+
//./phpBB3/ucp.php?i=pm&mode=compose
9189
if (key.includes("ucp.php?i=pm&mode=compose&action=post")) {
9290
key = key.split("?")[0].concat("?i=pm&mode=compose");
9391
}
9492

95-
//4 case ./phpBB3/ucp.php?i=pm&mode=compose&action=reply&f=xxx&p=yyy
96-
//5 case ./phpBB3/ucp.php?i=pm&mode=compose&action=forward&f=xxx&p=yyy
97-
//6 case ./phpBB3/ucp.php?i=pm&mode=compose&action=quote&f=xxx&p=yyy
93+
//4 case ./phpBB3/ucp.php?i=pm&mode=compose&action=reply&f=xxx&p=yyy
94+
//5 case ./phpBB3/ucp.php?i=pm&mode=compose&action=forward&f=xxx&p=yyy
95+
//6 case ./phpBB3/ucp.php?i=pm&mode=compose&action=quote&f=xxx&p=yyy
9896
if (key.includes("ucp.php?i=pm&mode=compose&action=reply&f=") || key.includes("ucp.php?i=pm&mode=compose&action=forward&f=") || key.includes("ucp.php?i=pm&mode=compose&action=quote&f=")) {
9997
var fpos = key.indexOf("&f="),
10098
ppos = key.indexOf("&p=");
@@ -103,15 +101,15 @@
103101
}
104102
}
105103

106-
//7 case
107-
//./phpBB3/ucp.php?i=pm&mode=compose&action=reply&sid=sssssssssssssssssssssssssss&p=yyy returns
108-
//./phpBB3/ucp.php?i=pm&mode=compose&action=reply&p=yyy
109-
//8th case
110-
//./phpBB3/ucp.php?i=pm&mode=compose&action=forward&sid=sssssssssssssssssssssssssss&p=yyy returns
111-
//./phpBB3/ucp.php?i=pm&mode=compose&action=forward&p=yyy
112-
//9th case
113-
//./phpBB3/ucp.php?i=pm&mode=compose&action=quote&sid=sssssssssssssssssssssssssss&p=yyy returns
114-
//./phpBB3/ucp.php?i=pm&mode=compose&action=quote&p=yyy
104+
//7 case
105+
//./phpBB3/ucp.php?i=pm&mode=compose&action=reply&sid=sssssssssssssssssssssssssss&p=yyy returns
106+
//./phpBB3/ucp.php?i=pm&mode=compose&action=reply&p=yyy
107+
//8th case
108+
//./phpBB3/ucp.php?i=pm&mode=compose&action=forward&sid=sssssssssssssssssssssssssss&p=yyy returns
109+
//./phpBB3/ucp.php?i=pm&mode=compose&action=forward&p=yyy
110+
//9th case
111+
//./phpBB3/ucp.php?i=pm&mode=compose&action=quote&sid=sssssssssssssssssssssssssss&p=yyy returns
112+
//./phpBB3/ucp.php?i=pm&mode=compose&action=quote&p=yyy
115113
if (key.includes("ucp.php?i=pm&mode=compose&action=reply&sid=") || key.includes("ucp.php?i=pm&mode=compose&action=forward&sid=") || key.includes("ucp.php?i=pm&mode=compose&action=quote&sid=")) {
116114
var sipos = key.indexOf("&sid="),
117115
pipos = key.indexOf("&p=");
@@ -243,9 +241,13 @@
243241
const expiry_time = parseInt(document.getElementById('expiry-time').innerText.trim(), 10);
244242
const dateNow = Math.floor(Date.now() / 1000); // we get milliseconds, so we need to convert to seconds.
245243
console.debug("Date.now() in seconds is " + dateNow + " and expiry_time is " + expiry_time);
246-
if (dateNow > expiry_time) {
244+
245+
//the if statement for deleting local storage in PM'ing, because expiry_time = 0, it must be fixed
246+
if (!key.includes("ucp.php")) {
247+
if (dateNow > expiry_time) {
247248
// We won't clear anything if the session already expired, so return.
248249
return;
250+
}
249251
}
250252

251253
// Now remove the local storage on `Submit` — it'll get saved to the database as a post/PM,

0 commit comments

Comments
 (0)