Skip to content

Commit 207119c

Browse files
committed
JavaScript: added Visitor.id and prefixed session storage
1 parent bfdbf46 commit 207119c

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

admin/javascripts/admin.js.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ function solo_submit() {
169169
action: '<?php echo $route->action; ?>'
170170
}
171171
var Visitor = {
172+
id: <?php echo $visitor->id; ?>,
172173
token: '<?php echo authenticate(); ?>'
173174
}
174175
var Site = {
@@ -521,17 +522,19 @@ function solo_submit() {
521522

522523
// Remember unsaved text entered in the primary text input and textarea.
523524
if (!!sessionStorage) {
525+
var prefix = "user_" + Visitor.id;
526+
524527
$("#write_form .main_options input[type='text']").first(
525528
).val(function() {
526529
try {
527-
return sessionStorage.getItem("write_title");
530+
return sessionStorage.getItem(prefix + "_write_title");
528531
} catch(e) {
529532
console.log("Caught Exception: Window.sessionStorage.getItem()");
530533
return null;
531534
}
532535
}).on("change", function(e) {
533536
try {
534-
sessionStorage.setItem("write_title", $(this).val());
537+
sessionStorage.setItem(prefix + "_write_title", $(this).val());
535538
} catch(e) {
536539
console.log("Caught Exception: Window.sessionStorage.setItem()");
537540
}
@@ -540,23 +543,23 @@ function solo_submit() {
540543
$("#write_form .main_options textarea").first(
541544
).val(function(index, value) {
542545
try {
543-
return sessionStorage.getItem("write_body");
546+
return sessionStorage.getItem(prefix + "_write_body");
544547
} catch(e) {
545548
console.log("Caught Exception: Window.sessionStorage.getItem()");
546549
return null;
547550
}
548551
}).on("change", function(e) {
549552
try {
550-
sessionStorage.setItem("write_body", $(this).val());
553+
sessionStorage.setItem(prefix + "_write_body", $(this).val());
551554
} catch(e) {
552555
console.log("Caught Exception: Window.sessionStorage.setItem()");
553556
}
554557
});
555558

556559
$("#write_form").on("submit.sessionStorage", function(e) {
557560
try {
558-
sessionStorage.removeItem("write_title");
559-
sessionStorage.removeItem("write_body");
561+
sessionStorage.removeItem(prefix + "_write_title");
562+
sessionStorage.removeItem(prefix + "_write_body");
560563
} catch(e) {
561564
console.log("Caught Exception: Window.sessionStorage.removeItem()");
562565
}

includes/main.js.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
action: '<?php echo $route->action; ?>'
1717
}
1818
var Visitor = {
19+
id: <?php echo $visitor->id; ?>,
1920
token: '<?php echo authenticate(); ?>'
2021
}
2122
var Site = {

0 commit comments

Comments
 (0)