This repository has been archived by the owner on Sep 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
permissionEditor.html
190 lines (174 loc) · 9.13 KB
/
permissionEditor.html
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<html>
<link rel="stylesheet" href="main.css">
<meta charset="utf8">
<div style="width: 100vw; overflow: auto; height: 100vh; margin-top: -8px; margin-left: -8px; filter: blur(22px); border-radius: 14px; transition: scale 0.3s ease, filter 0.5s ease; scale: 0.1;" id="everything_container">
<div id="editorContent" style="height: 90vh; width: 100vw; background-color: #FFFFFF10; overflow: auto;">
<div class="ring"></div>
</div>
<div id="selectorMenu" class="flexbox" style="height: auto; justify-content: left; width: 100vw; background-color: #FFFFFF08;">
<div id="buttonsContainer" class="flexbox" style="width: 100vw; height: 10vh; transition: scale 5.3s ease;">
<div class="barbuttontexta" id="permissions-name"></div>
<div class="barbuttonshift flexbox" style="margin-right: 1vw; width: 13vw; margin-left: auto;" onclick="closepermissions()">
<div class="image checkmark" style="width: 30% !important; height: 30px !important; margin: auto !important;"></div>
<div style="margin: auto;">
<div class="barbuttontexta">Close</div>
<div class="smalltext" style="opacity: 50%; font-size: 8px;">CTRL+TAB</div>
</div>
</div>
</div>
</div>
</div>
<script src="./AppData/Kits/settings.js"></script>
<script src="./AppData/Kits/Loader.js"></script>
<script>
var datjson = JSON.parse(fs.readFileSync('./AppData/data.json'))
let themeColor = datjson.color
document.getElementById('everything_container').style.background = `linear-gradient(45deg, ${themeColor} 0%, #121212 ${editorSettings.smoothness})`
document.body.style.transition = 'all 0.2s ease'
document.body.style.backgroundColor = '#FFFFFF00'
const {ipcRenderer} = require('electron')
let data;
document.onkeydown=function(permissions) {
if (permissions.key == 'Tab' && permissions.ctrlKey == true) {
closepermissions()
}
if (permissions.key.toLowerCase() == 'q' && permissions.ctrlKey == true) {
closepermissions()
}
}
ipcRenderer.on('data', (event, _data) => {
document.getElementById('everything_container').style.transition = `all 0.${editorSettings.commonAnimation}s ease`
document.getElementById('everything_container').style.scale = '1'
document.getElementById('everything_container').style.filter = 'blur(0px)'
data = _data;
console.log(data)
refreshBoundaries();
document.getElementById('permissions-name').innerHTML = `<span style="opacity: 50%">Editing Boundaries Of</span> ${data.name}`
})
function refreshBoundaries() {
document.getElementById('editorContent').innerHTML = `
<br>
<div class="barbuttontexta noanims" style="margin-left: 2vw; margin-right: 0%; text-align: left; font-size: 23px;">Boundaries</div>
<div class="sepbars noanims"></div>
<div class="flexbox dimension" id="permissionsRequired" style="overflow: auto; width: 95vw; height: 62vh; background-color: #FFFFFF07; margin: auto; border-radius: 9px; padding: 9px;"></div>
<div class="flexbox dimension" style="width: 95vw; height: 8vh; margin-bottom: 1vh; background-color: #FFFFFF07; border-radius: 9px; padding: 9px; margin: auto; margin-top: 2vh;">
<div class="barbuttontexta">Limited To</div>
<div class="barbuttonshift borderright" onclick="toggleLimit(this)" style="padding-top: 2vh; padding-bottom: 2vh;" id="any"><div class="barbuttontexta">Any</div></div>
<div class="barbuttonshift bordercenter" onclick="toggleLimit(this)" style="padding-top: 2vh; padding-bottom: 2vh;" id="dm"><div class="barbuttontexta">DM Only</div></div>
<div class="barbuttonshift borderleft" onclick="toggleLimit(this)" style="padding-top: 2vh; padding-bottom: 2vh;" id="guild"><div class="barbuttontexta">Guild Only</div></div>
</div>`
completeBoundaryList()
}
let boundaries = {
'ADMINISTRATOR': "Administrator",
'MODERATE_MEMBERS': "Timeout Members",
'KICK_MEMBERS': "Kick Members",
'BAN_MEMBERS': "Ban Members",
'MANAGE_ROLES': "Manage Roles",
'MANAGE_MESSAGES': "Manage Messages",
'ADD_REACTIONS': "Add Reactions",
'ATTACH_FILES': "Attach Files",
'MANAGE_CHANNELS': "Manage Channels",
'MANAGE_WEBHOOKS': "Manage Webhooks",
'CHANGE_NICKNAME': "Change Nickname",
'MANAGE_NICKNAMES': "Manage Nicknames",
'CREATE_PUBLIC_THREADS': "Create Threads",
'MANAGE_THREADS': "Manage Threads",
'CREATE_EVENTS': "Create Events",
'MANAGE_EVENTS': "Manage Events",
'MENTION_EVERYONE': "Mention Everyone",
'VIEW_AUDIT_LOG': "View Audit Logs",
'MANAGE_GUILD': "Manage Server",
'SPEAK': "Speak",
'CONNECT': "Join Voice Channels",
'MUTE_MEMBERS': "Mute Members",
'DEAFEN_MEMBERS': "Deafen Members",
'MOVE_MEMBERS': "Move Members",
'USE_VAD': "Use VAD",
'USE_SOUNDBOARD': "Use Soundboard",
'USE_EXTERNAL_SOUNDS': "Use External Sounds",
'SEND_VOICE_MESSAGES': "Send Voice Messages"
}
function completeBoundaryList() {
if (!data.boundary) {
data.boundary = {
limits: [],
worksIn: 'guild'
}
}
document.getElementById(data.boundary.worksIn).style.backgroundColor = '#FFFFFF20'
let endHTML = ``
for (let permission in boundaries) {
let selected = false;
if (data.boundary.limits.includes(permission)) {
selected = true;
}
endHTML += `
<div id="${permission}" onclick="toggleBoundary('${permission}')" class="hoverablez dimension flexbox" style="width: calc(49% - 18px); padding: 9px; border-radius: 9px; transition: all 0.1s ease, background-color 0.06s ease; margin: auto; margin-top: 1vh;">
<div class="barbuttontexta" style="margin-left: 1vw; text-align: left;">${boundaries[permission]}</div>
<div class="barbuttontexta flexbox" style="margin-right: 2vw; opacity: 50%;"><div id="${permission}selected" style="transition: width 0.6s cubic-bezier(1,-0.96,0,1.92), opacity 0.2s ease; width: ${selected == true ? '0' : '28'}px; overflow-x: auto; margin-right: 4px;">Not</div> Required</div>
<div class="dimension" id="${permission}color" style="transition: all 0.2s ease; background-color: ${selected == true ? '#32a85080' : '#a8323280' }; width: 2.5vw; height: 2.5vw; margin-top: auto; margin-bottom: auto; margin-right: 1vw; border-radius: 0.5vw;"></div>
</div>
`
}
document.getElementById('permissionsRequired').innerHTML = endHTML
}
function toggleLimit(what) {
document.getElementById(data.boundary.worksIn).style.backgroundColor = ''
data.boundary.worksIn = what.id;
what.style.backgroundColor = '#FFFFFF20'
}
function toggleBoundary(permission) {
let parent = document.getElementById(permission)
let colorTile = document.getElementById(`${permission}color`)
let selectionIndicator = document.getElementById(`${permission}selected`)
setTimeout(() => {
if (data.boundary.limits.includes(permission)) {
for (let _permission in data.boundary.limits) {
console.log(_permission, data.boundary.limits[_permission], permission)
if (data.boundary.limits[_permission] == permission) {
data.boundary.limits.splice(_permission, 1);
// selectionIndicator.style.opacity = '1'
selectionIndicator.style.width = '28px'
colorTile.style.backgroundColor = '#a8323280'
parent.style.filter = ''
}
}
} else {
data.boundary.limits.push(permission)
// selectionIndicator.style.opacity = '0'
selectionIndicator.style.width = '0px'
colorTile.style.backgroundColor = '#32a85080'
parent.style.filter = ''
}
}, 200)
}
function validateInput(event) {
const div = event.target;
const text = div.textContent;
// Save the current cursor position
const selection = window.getSelection();
const range = selection.getRangeAt(0);
const offset = range.startOffset;
// Remove image tags
const sanitizedText = text.replace(/<img\b[^>]*>/gi, '');
// Update the content of the div with sanitized text
div.innerHTML = sanitizedText;
// Restore the cursor position
const updatedRange = document.createRange();
updatedRange.setStart(div.firstChild, offset);
updatedRange.collapse(true);
selection.removeAllRanges();
selection.addRange(updatedRange);
}
function closepermissions() {
document.getElementById('everything_container').style.scale = '0'
document.body.style.transition = 'all 0.2s ease'
document.body.style.backgroundColor = '#FFFFFF00'
document.getElementById('everything_container').style.filter = 'blur(40px)'
setTimeout(() => {
ipcRenderer.send('permissionsClosed', data.boundary)
}, 500)
}
</script>
</html>