mirror of
https://github.com/urbit/shrub.git
synced 2024-12-29 23:23:52 +03:00
21 lines
595 B
JavaScript
21 lines
595 B
JavaScript
|
|
||
|
function storeOptions(e) {
|
||
|
e.preventDefault();
|
||
|
|
||
|
// clean up endpoint address and store it
|
||
|
let endpoint = document.querySelector("#endpoint").value
|
||
|
.replace(/^.*:\/\//, '') // strip protocol
|
||
|
.replace(/\/+$/, ''); // strip trailing slashes
|
||
|
setEndpoint(endpoint);
|
||
|
}
|
||
|
|
||
|
async function restoreOptions() {
|
||
|
|
||
|
const endpoint = await getEndpoint();
|
||
|
console.log('prefilling with', endpoint);
|
||
|
|
||
|
document.querySelector("#endpoint").value = endpoint;
|
||
|
}
|
||
|
|
||
|
document.addEventListener("DOMContentLoaded", restoreOptions);
|
||
|
document.querySelector("form").addEventListener("submit", storeOptions);
|