annotate mod_invites_page/static/invite.js @ 5963:c61a82f80e57 default tip

mod_pubsub_serverinfo: Reference workaround for issue #1841
author Guus der Kinderen <guus.der.kinderen@gmail.com>
date Wed, 11 Sep 2024 14:02:39 +0200
parents ef3aa6901a93
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5719
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 (function () {
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 // If QR lib loaded ok, show QR button on desktop devices
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 if(window.QRCode) {
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 new QRCode(document.getElementById("qr-invite-page"), document.location.href);
5723
5f7f6ee32a11 mod_invites_page: Stop displaying the QRCode to mobile devices
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 5721
diff changeset
5 document.getElementById('qr-button-container').classList.add("d-md-block");
5719
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 }
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 // Detect current platform and show/hide appropriate clients
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 if(window.platform) {
5725
ef3aa6901a93 mod_invites_page: Add support for Haiku and mobile Linux
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 5723
diff changeset
10 let platform_friendly = null;
ef3aa6901a93 mod_invites_page: Add support for Haiku and mobile Linux
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 5723
diff changeset
11 let platform_classname = null;
5719
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 switch(platform.os.family) {
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14 case "Ubuntu":
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 case "Linux":
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16 case "Fedora":
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 case "Red Hat":
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 case "SuSE":
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19 platform_friendly = platform.os.family + " (Linux)";
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20 platform_classname = "linux";
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 break;
5725
ef3aa6901a93 mod_invites_page: Add support for Haiku and mobile Linux
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 5723
diff changeset
22 case "Linux aarch64":
ef3aa6901a93 mod_invites_page: Add support for Haiku and mobile Linux
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 5723
diff changeset
23 platform_friendly = "Linux mobile";
ef3aa6901a93 mod_invites_page: Add support for Haiku and mobile Linux
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 5723
diff changeset
24 platform_classname = "linux";
ef3aa6901a93 mod_invites_page: Add support for Haiku and mobile Linux
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 5723
diff changeset
25 break;
ef3aa6901a93 mod_invites_page: Add support for Haiku and mobile Linux
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 5723
diff changeset
26 case "Haiku R1":
ef3aa6901a93 mod_invites_page: Add support for Haiku and mobile Linux
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 5723
diff changeset
27 platform_friendly = "Haiku";
ef3aa6901a93 mod_invites_page: Add support for Haiku and mobile Linux
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 5723
diff changeset
28 platform_classname = "haiku";
ef3aa6901a93 mod_invites_page: Add support for Haiku and mobile Linux
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 5723
diff changeset
29 break;
5719
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 case "Windows Phone":
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31 platform_friendly = "Windows Phone";
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32 platform_classname = "windows-phone";
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 break;
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34 default:
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35 if(platform.os.family.startsWith("Windows")) {
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 platform_friendly = "Windows";
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 platform_classname = "windows";
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 } else {
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 platform_friendly = platform.os.family;
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 platform_classname = platform_friendly.toLowerCase();
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 }
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 }
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 if(platform_friendly && platform_classname) {
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 if(document.querySelectorAll('.client-card .client-platform-badge-'+platform_classname).length == 0) {
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 // No clients recognised for this platform, do nothing
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47 return;
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48 }
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49 // Hide clients not for this platform
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 const client_cards = document.getElementsByClassName('client-card');
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 for (let card of client_cards) {
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52 if (card.classList.contains('app-platform-'+platform_classname))
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53 card.classList.add('supported-platform');
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
54 else if (!card.classList.contains('app-platform-web'))
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
55 card.hidden = true;
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
56 const badges = card.querySelectorAll('.client-platform-badge');
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
57 for (let badge of badges) {
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
58 if (badge.classList.contains('client-platform-badge-'+platform_classname)) {
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
59 badge.classList.add("badge-success");
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
60 badge.classList.remove("badge-info");
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
61 } else {
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62 badge.classList.add("badge-secondary");
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
63 badge.classList.remove("badge-info");
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64 }
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
65 }
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
66 }
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
67 const show_all_clients_button_container = document.getElementById('show-all-clients-button-container');
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
68 show_all_clients_button_container.querySelector('.platform-name').innerHTML = platform_friendly;
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
69 show_all_clients_button_container.classList.remove("d-none");
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
70 document.getElementById('show-all-clients-button').addEventListener('click', function (e) {
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
71 for (let card of client_cards)
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
72 card.hidden = false;
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
73 show_all_clients_button_container.hidden = true;
5721
40558231ab7d mod_invites_page: Typo in preventing the default event when clicking on show all
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 5719
diff changeset
74 e.preventDefault();
5719
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
75 });
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
76 }
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
77 }
18bae78282a6 mod_invites_page: Move the JS script to its own file
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
78 })();