-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sumner Evans <[email protected]>
- Loading branch information
1 parent
15656a6
commit 48a54e9
Showing
4 changed files
with
96 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,88 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Matrix Link to Useful Text</title> | ||
<style> | ||
input, textarea, button { | ||
width: 700px; | ||
font-size: 1.5em; | ||
} | ||
textarea { | ||
height: 150px; | ||
} | ||
#error-text { | ||
color: red; | ||
} | ||
</style> | ||
<script defer data-domain="nevarro.space" src="https://plausible.io/js/script.js"></script> | ||
</head> | ||
<body> | ||
<p> | ||
<input id="permalink-input" type="text" placeholder="enter your matrix.to permalink here"/> | ||
</p> | ||
<p id="error-text"> | ||
</p> | ||
<p> | ||
<textarea id="useful-text" onclick="this.select()" readonly></textarea> | ||
</p> | ||
<p> | ||
<button id="copy-button" disabled>Copy</button> | ||
</p> | ||
<p> | ||
<a href="https://github.com/sumnerevans/nevarro.space">Source Code</a> | ||
</p> | ||
|
||
<script> | ||
const permalinkInput = document.getElementById("permalink-input"); | ||
const errorText = document.getElementById("error-text"); | ||
const usefulText = document.getElementById("useful-text"); | ||
const copyButton = document.getElementById("copy-button"); | ||
<head> | ||
<title>Matrix Link to Useful Text</title> | ||
<style> | ||
input, | ||
textarea, | ||
button { | ||
width: 700px; | ||
font-size: 1.5em; | ||
} | ||
|
||
const getInfo = (permalink) => { | ||
const match = permalink.match(/^https?:\/\/matrix.to\/#\/(!.*)\/(\$.*?)(?:\?.*)?$/); | ||
if (!match) return null; | ||
return { | ||
roomID: match[1], | ||
eventID: match[2], | ||
}; | ||
}; | ||
textarea { | ||
height: 150px; | ||
} | ||
|
||
const copy = () => { | ||
usefulText.select(); | ||
document.execCommand("copy"); | ||
}; | ||
#error-text { | ||
color: red; | ||
} | ||
</style> | ||
<script defer data-domain="nevarro.space" src="https://plausible.io/js/script.js"></script> | ||
</head> | ||
|
||
const updateInfo = () => { | ||
const info = getInfo(permalinkInput.value); | ||
if (info) { | ||
errorText.innerHTML = ""; | ||
usefulText.innerHTML = `Room ID: ${info.roomID}\nEvent ID: ${info.eventID}`; | ||
copyButton.disabled = false; | ||
} else { | ||
errorText.innerHTML = "Invalid matrix.to link"; | ||
copyButton.disabled = true; | ||
} | ||
return info != null; | ||
}; | ||
<body> | ||
<p> | ||
<input id="permalink-input" type="text" placeholder="enter your matrix.to permalink here" /> | ||
</p> | ||
<p id="error-text"> | ||
</p> | ||
<p> | ||
<textarea id="useful-text" onclick="this.select()" readonly></textarea> | ||
</p> | ||
<p> | ||
<button id="copy-button" disabled>Copy</button> | ||
</p> | ||
<p> | ||
<a href="https://github.com/sumnerevans/nevarro.space">Source Code</a> | ||
</p> | ||
|
||
permalinkInput.addEventListener("input", updateInfo); | ||
<script> | ||
const permalinkInput = document.getElementById("permalink-input"); | ||
const errorText = document.getElementById("error-text"); | ||
const usefulText = document.getElementById("useful-text"); | ||
const copyButton = document.getElementById("copy-button"); | ||
|
||
permalinkInput.addEventListener("keyup", (e) => { | ||
if (e.key === "Enter" || e.keyCode === 13) { | ||
copy(); | ||
} | ||
}); | ||
const getInfo = (permalink) => { | ||
const match = permalink.match(/^https?:\/\/matrix.to\/#\/(!.*)\/(\$.*?)(?:\?.*)?$/); | ||
if (!match) return null; | ||
return { | ||
roomID: match[1], | ||
eventID: match[2], | ||
}; | ||
}; | ||
|
||
copyButton.addEventListener("click", copy); | ||
const copy = () => { | ||
usefulText.select(); | ||
document.execCommand("copy"); | ||
}; | ||
|
||
const updateInfo = () => { | ||
const info = getInfo(permalinkInput.value); | ||
if (info) { | ||
errorText.innerHTML = ""; | ||
usefulText.innerHTML = `Room ID: ${info.roomID}\nEvent ID: ${info.eventID}`; | ||
copyButton.disabled = false; | ||
} else { | ||
errorText.innerHTML = "Invalid matrix.to link"; | ||
copyButton.disabled = true; | ||
} | ||
return info != null; | ||
}; | ||
|
||
permalinkInput.addEventListener("input", updateInfo); | ||
|
||
permalinkInput.addEventListener("keyup", (e) => { | ||
if (e.key === "Enter" || e.keyCode === 13) { | ||
copy(); | ||
} | ||
}); | ||
|
||
copyButton.addEventListener("click", copy); | ||
|
||
permalinkInput.focus(); | ||
</script> | ||
</body> | ||
|
||
permalinkInput.focus(); | ||
</script> | ||
</body> | ||
</html> |