mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-15 18:12:47 +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);
|