Skip to content

Commit

Permalink
fix type error
Browse files Browse the repository at this point in the history
  • Loading branch information
956237586 committed Oct 5, 2024
1 parent 0a2e8c3 commit ec77bcc
Showing 1 changed file with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,24 @@ object OnScreenMessenger : LafListener {
}

private val reload = (document.createElement("div") as HTMLDivElement).apply {
if(text.contains("Reason: Bad handshake token")){
innerHTML = """
<p>If you wish, you can reconnect with token:
<input id='customToken' type='text'/>
<a href='' onclick='
let token = document.getElementById("customToken").value;
let searchParams = new URLSearchParams(location.search);
searchParams.set("token", token);
let url = `${'$'}{location.protocol}//${'$'}{location.host}${'$'}{location.pathname}?${'$'}{searchParams.toString()}`;
console.log("reconnect with token", token);
location.href = url;
return false;
'>Submit</a></p>
""".trimIndent()
} else {
innerHTML = "<p>If you wish, you can try to <a onclick='location.reload();' href=''>reconnect</a>.</p>"
}
innerHTML = "<p>If you wish, you can try to <a onclick='location.reload();' href=''>reconnect</a>.</p>"
div.appendChild(this)
}

private val reloadWithToken = (document.createElement("div") as HTMLDivElement).apply {
innerHTML = """
<p>If you wish, you can reconnect with token:
<input id='customToken' type='text'/>
<a href='' onclick='
let token = document.getElementById("customToken").value;
let searchParams = new URLSearchParams(location.search);
searchParams.set("token", token);
let url = `${'$'}{location.protocol}//${'$'}{location.host}${'$'}{location.pathname}?${'$'}{searchParams.toString()}`;
console.log("reconnect with token", token);
location.href = url;
return false;
'>Submit</a></p>
""".trimIndent()
div.appendChild(this)
}

Expand All @@ -92,8 +93,11 @@ object OnScreenMessenger : LafListener {

header.title = title
text.innerText = content

reload.style.display = canReload.toDisplayType()
var reloadDiv = reload
if (content.contains("Reason: Bad handshake token")) {
reloadDiv = reloadWithToken
}
reloadDiv.style.display = canReload.toDisplayType()

if (div.parentElement == null) {
document.body!!.appendChild(div)
Expand Down

0 comments on commit ec77bcc

Please sign in to comment.