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

@ -1,6 +1,6 @@
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<html>
<head>
<meta charset="utf-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1, user-scalable=0" name="viewport">
@ -12,20 +12,20 @@
<div class="main">
<noscript><h3>Вам нужен JavaScript для принятия этого приглашения.</h3></noscript>
<h3 class="text-center" id="heading"></h3>
<p class="text-center"><a class="btn btn-primary" id="button" href=""></a></p>
<input type="url" class="form-control text-center" id="url_in" readonly="readonly" value="">
<p class="text-center"><a class="btn btn-primary" id="button"></a></p>
<input type="url" class="form-control text-center" id="url_in" readonly/>
<div class="qrcode" id="qrcode"></div>
<p class="hint text-center" id="clients"></p>
<p class="lead" id="recommend"></p>
<ul class="lead" id="client_list"></ul>
<p class="lead" id="checkfulllist"></p>
<a onclick=''><p class="lead" id="create" hidden></p></a>
<p class="lead" id="createhide" hidden></p>
<p class="hint" id="xmppis"></p>
</div>
<script src="js/i18n-text.js"></script>
<script src="js/main.js"></script>
</body></html>
<script src="js/qrcode.min.js"></script>
</body>
</html>

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