-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
58 lines (49 loc) · 1.52 KB
/
app.js
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
var textTag = document.getElementById('text-tag');
var textInput = document.getElementById('textInput');
var resultText = "";
function getCredit() {
var cr = ['', ''];
cr.push('สร้างได้ที่: [https://zugarzeeker.github.io/wish-you-tag/]')
return cr.join('\n');
}
function generateTag(text) {
var t = text.split(' ');
var s = [];
s.push('┏┷ ┓');
for (var i = 0, len = t.length; i < len; i++) {
s.push('┃ ??? ┃'.replace('???', t[i]));
}
s.push('┗━ ┛');
console.log(s);
return s.join('<br>');
}
function renderText() {
textTag.innerHTML = resultText;
}
function handleChange(event) {
$("#noti").text("");
resultText = generateTag(textInput.value);
renderText();
}
textInput.value = "แ อ พ ส ร้ า ง ข้ อ ค ว า ม ป้ า ย";
resultText = generateTag(textInput.value);
renderText();
var clipboard = new Clipboard('.btn', {
text: function(trigger) {
window.rt = resultText;
return resultText.split('<br>').join('\n') + getCredit();
}
});
clipboard.on('success', function(e) {
console.info('Action:', e.action);
console.info('Text:', e.text + getCredit());
console.info('Trigger:', e.trigger);
$("#noti").text("✔ คัดลอกแล้ว!");
// $("#copy-btn").text("✔ คัดลอกแล้ว!")
e.clearSelection();
});
clipboard.on('error', function(e) {
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
$("#noti").text("เกิดข้อผิดพลาด...");
});