This repository was archived by the owner on Jun 19, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
66 lines (58 loc) 路 2.22 KB
/
Copy pathmain.js
File metadata and controls
66 lines (58 loc) 路 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
(function () {
'use strict';
var text = typeof window.APP_TEXT !== 'undefined' ? window.APP_TEXT : {};
var config = typeof window.APP_CONFIG !== 'undefined' ? window.APP_CONFIG : {};
var get = window.Donation && window.Donation.get;
function applyTextConfig() {
document.title = (get && get(text, 'pageTitle')) || document.title;
document.querySelectorAll('[data-text]').forEach(function (el) {
var value = get && get(text, el.getAttribute('data-text'));
if (value != null) el.textContent = value;
});
}
var preferredContainer = document.getElementById('preferred-methods');
var otherContainer = document.getElementById('other-options');
var preferredMethods = window.DONATION_PAY_METHODS_PREFERRED || [];
var otherMethods = window.DONATION_PAY_METHODS_OTHER || [];
if (preferredContainer) {
for (var p = 0; p < preferredMethods.length; p++) {
if (preferredMethods[p] && typeof preferredMethods[p].render === 'function') {
preferredMethods[p].render(preferredContainer, config, text);
}
}
}
if (otherContainer) {
for (var o = 0; o < otherMethods.length; o++) {
if (otherMethods[o] && typeof otherMethods[o].render === 'function') {
otherMethods[o].render(otherContainer, config, text);
}
}
}
applyTextConfig();
var copyLabel = (get && get(text, 'crypto.copy')) || 'Copy';
var copiedLabel = (get && get(text, 'crypto.copied')) || 'Copied!';
var failedLabel = (get && get(text, 'crypto.failed')) || 'Failed';
document.querySelectorAll('.copy-btn').forEach(function (btn) {
btn.addEventListener('click', function () {
var id = this.getAttribute('data-copy');
var el = document.getElementById(id);
if (!el) return;
navigator.clipboard.writeText(el.textContent.trim()).then(
function () {
btn.textContent = copiedLabel;
btn.classList.add('copied');
setTimeout(function () {
btn.textContent = copyLabel;
btn.classList.remove('copied');
}, 2000);
},
function () {
btn.textContent = failedLabel;
setTimeout(function () {
btn.textContent = copyLabel;
}, 2000);
}
);
});
});
})();