-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
119 lines (95 loc) · 4.35 KB
/
script.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
const encounterDropdown = document.getElementById('encounter');
encounters.forEach(encounter => {
let option = document.createElement('option');
option.value = encounter.id;
option.textContent = encounter.name;
encounterDropdown.appendChild(option);
});
document.addEventListener("DOMContentLoaded", function () {
const addTimeInputButton = document.getElementById("addTimeInputButton");
const timeInputsContainer = document.getElementById("timeInputsContainer");
let timeInputCount = 0;
addTimeInputButton.addEventListener("click", function () {
timeInputCount++;
const timeInputDiv = document.createElement("div");
timeInputDiv.classList.add("input-group", "mb-2");
const timeInput = document.createElement("input");
timeInput.type = "text";
timeInput.classList.add("form-control");
timeInput.placeholder = "Enter time in seconds";
const timeInputAppend = document.createElement("div");
timeInputAppend.classList.add("input-group-append");
const deleteButton = document.createElement("button");
deleteButton.type = "button";
deleteButton.classList.add("btn", "btn-danger");
deleteButton.textContent = "Delete";
deleteButton.addEventListener("click", function () {
timeInputDiv.remove();
});
timeInputAppend.appendChild(deleteButton);
timeInputDiv.appendChild(timeInput);
timeInputDiv.appendChild(timeInputAppend);
timeInputsContainer.appendChild(timeInputDiv);
});
});
function generateWeakAura() {
let aura = textTemplate;
const encounterTime = "24";
const fontSize = document.getElementById('fontSize').value || "20";
const font = document.getElementById('font').value || "Friz Quadrata TT";
const encounterID = document.getElementById('encounter').value || "";
//aura.d.triggers["1"].trigger.duration = encounterTime;
//aura.d.fontSize = parseInt(fontSize, 10);
//aura.d.font = font;
//aura.d.load.encounterid = encounterID;
// Serialize
let serializedAura = serialize(aura);
// Deflate
let deflatedData = deflate(serializedAura);
// Encode
let encodedString = encode(deflatedData);
// Output
document.getElementById('output').value = `!WA:1!${encodedString}`;
document.getElementById('copyButton').disabled = false;
}
window.generateWeakAura = generateWeakAura;
function copyToClipboard() {
const textarea = document.getElementById('output');
textarea.select();
document.execCommand('copy');
const popup = document.getElementById('popupMessage');
popup.style.display = 'block';
setTimeout(() => {
popup.style.display = 'none';
}, 3000);
}
window.copyToClipboard = copyToClipboard;
function handleTriggerChange() {
const triggerValue = document.getElementById('trigger').value;
if (triggerValue === 'encounterTime') {
document.getElementById('encounterTimeField').style.display = 'block';
document.getElementById('encounterField').style.display = 'block';
} else {
document.getElementById('encounterTimeField').style.display = 'none';
document.getElementById('encounterField').style.display = 'none';
}
handleAuraTypeChange();
}
window.handleTriggerChange = handleTriggerChange;
function handleAuraTypeChange() {
const auraTypeValue = document.getElementById('auraType').value;
if (auraTypeValue === 'Progress Bar' || auraTypeValue === 'Icon') {
document.getElementById('sizeFields').style.display = 'block';
document.getElementById('heightField').style.display = 'block';
document.getElementById('fontSizeField').style.display = 'none';
} else if (auraTypeValue === 'Text') {
document.getElementById('sizeFields').style.display = 'none';
document.getElementById('heightField').style.display = 'none';
document.getElementById('fontSizeField').style.display = 'block';
} else {
document.getElementById('sizeFields').style.display = 'none';
document.getElementById('heightField').style.display = 'none';
document.getElementById('fontSizeField').style.display = 'none';
}
}
document.getElementById('auraType').addEventListener('change', handleAuraTypeChange);