Merge pull request 'qrcode' (#23) from LibreHacker/switching:master3 into master
Reviewed-on: http://git.macaw.me:3000/Tolstoevsky/fedi/pulls/23
This commit is contained in:
commit
9d85558474
18
i/index.html
18
i/index.html
@ -1,6 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html><head>
|
<html>
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta content="IE=edge" http-equiv="X-UA-Compatible">
|
<meta content="IE=edge" http-equiv="X-UA-Compatible">
|
||||||
<meta content="width=device-width, initial-scale=1, user-scalable=0" name="viewport">
|
<meta content="width=device-width, initial-scale=1, user-scalable=0" name="viewport">
|
||||||
@ -12,20 +12,20 @@
|
|||||||
<div class="main">
|
<div class="main">
|
||||||
<noscript><h3>Вам нужен JavaScript для принятия этого приглашения.</h3></noscript>
|
<noscript><h3>Вам нужен JavaScript для принятия этого приглашения.</h3></noscript>
|
||||||
<h3 class="text-center" id="heading"></h3>
|
<h3 class="text-center" id="heading"></h3>
|
||||||
<p class="text-center"><a class="btn btn-primary" id="button" href=""></a></p>
|
<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="readonly" value="">
|
<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="hint text-center" id="clients"></p>
|
||||||
<p class="lead" id="recommend"></p>
|
<p class="lead" id="recommend"></p>
|
||||||
|
|
||||||
<ul class="lead" id="client_list"></ul>
|
<ul class="lead" id="client_list"></ul>
|
||||||
|
|
||||||
<p class="lead" id="checkfulllist"></p>
|
<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>
|
<p class="hint" id="xmppis"></p>
|
||||||
</div>
|
</div>
|
||||||
<script src="js/i18n-text.js"></script>
|
<script src="js/i18n-text.js"></script>
|
||||||
<script src="js/main.js"></script>
|
<script src="js/main.js"></script>
|
||||||
|
<script src="js/qrcode.min.js"></script>
|
||||||
|
</body>
|
||||||
</body></html>
|
</html>
|
||||||
|
23
i/js/main.js
23
i/js/main.js
@ -52,12 +52,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: proper error checking / display / Creation of invitations
|
// 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];
|
var name = jid.split("@")[0];
|
||||||
name = name.charAt(0).toUpperCase() + name.slice(1);
|
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() {
|
function translate_ui() {
|
||||||
@ -68,18 +72,23 @@
|
|||||||
document.getElementById(id).innerHTML = i18n.text(key_prefix + id, display_data);
|
document.getElementById(id).innerHTML = i18n.text(key_prefix + id, display_data);
|
||||||
});
|
});
|
||||||
// and agnostic
|
// 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);
|
document.getElementById(id).innerHTML = i18n.text(id, display_data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function rehash() {
|
function rehash() {
|
||||||
display_data = load_hash();
|
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;
|
document.getElementById('url_in').value = "xmpp:" + display_data.jid;
|
||||||
translate_ui();
|
translate_ui();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createQR() {
|
||||||
|
display_data = load_hash();
|
||||||
|
new QRCode(document.getElementById("qrcode"), "xmpp:" + display_data.jid);
|
||||||
|
}
|
||||||
|
|
||||||
function load_done() {
|
function load_done() {
|
||||||
if (initialized) return;
|
if (initialized) return;
|
||||||
initialized = true;
|
initialized = true;
|
||||||
@ -96,13 +105,15 @@
|
|||||||
load_clients("json/clients_Android.json")
|
load_clients("json/clients_Android.json")
|
||||||
}
|
}
|
||||||
else if (navigator.userAgent.indexOf("Linux") >= 0) {
|
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) {
|
else if (navigator.userAgent.indexOf("iPhone") >= 0) {
|
||||||
load_clients("json/clients_iOS.json")
|
load_clients("json/clients_iOS.json")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
load_clients("json/clients_Windows.json")
|
load_clients("json/clients_Windows.json");
|
||||||
|
createQR();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener("hashchange", rehash, false);
|
window.addEventListener("hashchange", rehash, false);
|
||||||
|
1
i/js/qrcode.min.js
vendored
Normal file
1
i/js/qrcode.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user