76 lines
2.2 KiB
Plaintext
76 lines
2.2 KiB
Plaintext
% title 'UNIX.dog Services';
|
|
% layout 'default';
|
|
<section>
|
|
<h2>XMPP and Matrix Bridge Helper</h2>
|
|
<p id="result">
|
|
</p>
|
|
<noscript>Since JS is disabled, this form will send the addresses to
|
|
the UNIX.dog server to convert.</noscript>
|
|
<form id="bridging" method="post">
|
|
<div>
|
|
<label for="bridge_service">Bridge:</label>
|
|
<select name="bridge" id="bridge_service">
|
|
<option value="unix.dog">UNIX.dog</option>
|
|
<option value="aria-net">ARIA-net</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<select name="type" id="bridge_type">
|
|
<option value="muc">XMPP MUC:</option>
|
|
<option value="room">Matrix Room:</option>
|
|
<option value="jid">XMPP User:</option>
|
|
<option value="user">Matrix User:</option>
|
|
</select>
|
|
<input type="text" id="handle" name="handle" required />
|
|
</div>
|
|
<div>
|
|
<input type="submit"/>
|
|
</div>
|
|
</form>
|
|
</section>
|
|
<script>
|
|
const conversion = {
|
|
"unix.dog": {
|
|
"muc": jid => (s => `#_xmpp_${s[0]}_${s[1]}:unix.dog`)(jid.split("@")),
|
|
"room": rm => `${rm.replace(":","#")}@matrix.unix.dog`,
|
|
"jid": jid => `@_xmpp_${jid.replace("@", "=40")}:unix.dog`,
|
|
"user": u => `${u.slice(1).replace(":","_")}@matrix.unix.dog`
|
|
},
|
|
"aria-net": {
|
|
"muc": jid => (s => `#_bifrost_${s[0]}_${s[1]}:aria-net.org`)(jid.split("@")),
|
|
"room": rm => `${rm.replace(":","#")}@aria-net.org`,
|
|
"jid": jid => `@_bifrost_${jid.replace("@", "=40")}:aria-net.org`,
|
|
"user": u => `${u.slice(1).replace(":", "_")}@aria-net.org`
|
|
},
|
|
};
|
|
|
|
const urlify = {
|
|
"room": jid => `xmpp:${encodeURI(jid)}?join`,
|
|
"muc": room => `https://matrix.to/#/%23${encodeURI(room.slice(1))}`,
|
|
"user": jid => `xmpp:${encodeURI(jid)}?roster`,
|
|
"jid": u => `https://matrix.to/#/${encodeURI(u)}`,
|
|
};
|
|
|
|
const form = document.getElementById("bridging");
|
|
const output = document.getElementById("result");
|
|
|
|
form.addEventListener("submit", e => {
|
|
e.preventDefault();
|
|
|
|
const formData = new FormData(form);
|
|
|
|
let service = formData.get("bridge");
|
|
let type = formData.get("type");
|
|
let handle = formData.get("handle");
|
|
|
|
let bridged = conversion[service][type](handle);
|
|
output.textContent = `Use address `
|
|
|
|
let link = document.createElement("a");
|
|
link.href = urlify[type](bridged);
|
|
link.textContent = bridged;
|
|
|
|
output.appendChild(link);
|
|
});
|
|
</script>
|