This commit is contained in:
LibreHacker 2021-01-10 20:13:40 +03:00
parent b99ebf2c10
commit b86b6bcac4
3 changed files with 27 additions and 15 deletions

View file

@ -52,12 +52,16 @@
}
// TODO: proper error checking / display / Creation of invitations
if (jid.search("@") <= 0) return {jid: jid, name: jid};
if (jid.search("@") <= 0) return {jid:jid, jid_encoded:jid, name: jid};
var name = jid.split("@")[0];
name = name.charAt(0).toUpperCase() + name.slice(1);
return {jid: jid, name: name};
var jid_parts = jid.split("?");
jid_parts[0] = encodeURIComponent(jid_parts[0]) // URL-encode the JID only
var jid_encoded = jid_parts.join("?");
return {jid: jid, jid_encoded: jid_encoded, name: name};
}
function translate_ui() {
@ -68,18 +72,23 @@
document.getElementById(id).innerHTML = i18n.text(key_prefix + id, display_data);
});
// and agnostic
['clients', 'recommend', 'checkfulllist', 'xmppis', 'create', 'createhide'].forEach(function(id) {
['clients', 'recommend', 'checkfulllist', 'xmppis'].forEach(function(id) {
document.getElementById(id).innerHTML = i18n.text(id, display_data);
});
}
function rehash() {
display_data = load_hash();
document.getElementById('button').href = "xmpp:" + display_data.jid;
document.getElementById('button').href = "xmpp:" + display_data.jid_encoded;
document.getElementById('url_in').value = "xmpp:" + display_data.jid;
translate_ui();
}
function createQR() {
display_data = load_hash();
new QRCode(document.getElementById("qrcode"), "xmpp:" + display_data.jid);
}
function load_done() {
if (initialized) return;
initialized = true;
@ -96,13 +105,15 @@
load_clients("json/clients_Android.json")
}
else if (navigator.userAgent.indexOf("Linux") >= 0) {
load_clients("json/clients_Linux.json")
load_clients("json/clients_Linux.json");
createQR();
}
else if (navigator.userAgent.indexOf("iPhone") >= 0) {
load_clients("json/clients_iOS.json")
}
else {
load_clients("json/clients_Windows.json")
load_clients("json/clients_Windows.json");
createQR();
}
window.addEventListener("hashchange", rehash, false);

1
i/js/qrcode.min.js vendored Normal file

File diff suppressed because one or more lines are too long