Allow prefilling instance URL from parameter
This commit is contained in:
parent
1e37b3ae21
commit
ee1089ef65
1 changed files with 7 additions and 5 deletions
|
@ -1,7 +1,4 @@
|
|||
var remembered = window.localStorage.getItem('mastodon_instance');
|
||||
if (remembered != null) {
|
||||
document.getElementById('instance').value = remembered;
|
||||
}
|
||||
var prefillInstance = window.localStorage.getItem('mastodon_instance');
|
||||
|
||||
var paramPairs = window.location.search.substr(1).split('&');
|
||||
var paramPairsLength = paramPairs.length;
|
||||
|
@ -10,12 +7,17 @@ for (var i = 0; i < paramPairsLength; i++) {
|
|||
var paramPair = paramPairs[i].split('=');
|
||||
if (paramPair[0] === 'text') {
|
||||
document.getElementById('text').value = decodeURIComponent(paramPair[1]);
|
||||
break;
|
||||
} else if (paramPair[0] === 'instance') {
|
||||
prefillInstance = decodeURIComponent(paramPair[1]);
|
||||
}
|
||||
}
|
||||
delete i
|
||||
delete paramPair
|
||||
|
||||
if (prefillInstance != null) {
|
||||
document.getElementById('instance').value = prefillInstance;
|
||||
}
|
||||
|
||||
document
|
||||
.getElementById('form')
|
||||
.addEventListener('submit', function (e) {
|
||||
|
|
Reference in a new issue