Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions webrepl.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
});
term.open(document.getElementById("term"));
show_https_warning();
populate_recent_url();
};
window.addEventListener('resize', function() {
var size = calculate_size(self);
Expand All @@ -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();
Expand Down Expand Up @@ -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;
});
Expand Down