diff --git a/webrepl.html b/webrepl.html
index 297d97e..ad66344 100644
--- a/webrepl.html
+++ b/webrepl.html
@@ -111,6 +111,7 @@
});
term.open(document.getElementById("term"));
show_https_warning();
+ populate_recent_url();
};
window.addEventListener('resize', function() {
var size = calculate_size(self);
@@ -132,6 +133,28 @@
}
}
+// Test if localStorage is available. via https://stackoverflow.com/questions/16427636
+function lsTest(){
+ var test = 'test';
+ try {
+ localStorage.setItem(test, test);
+ localStorage.removeItem(test);
+ return true;
+ } catch(e) {
+ return false;
+ }
+}
+
+function populate_recent_url() {
+ if (lsTest() === true) {
+ var recent_url = localStorage.getItem('recent_url');
+ if (recent_url) {
+ var input = document.getElementById('url');
+ input.value = recent_url;
+ }
+ }
+}
+
function button_click() {
if (connected) {
ws.close();
@@ -165,6 +188,11 @@
ws.send(data);
});
+ // Record url for future use
+ if (lsTest() === true) {
+ localStorage.setItem('recent_url', url);
+ }
+
term.on('title', function(title) {
document.title = title;
});