-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathwindow-snapper.html
371 lines (320 loc) · 14.4 KB
/
window-snapper.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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<!--
VISUAL WINDOW SNAPPING (Multi-Monitor) by the BetterTouchTool community.
Forum link: https://community.folivora.ai/t/visual-window-snapping/2863
Authors of this script:
- panda
- Jerosh
- GoldenChaos
- yyuuiko
Thanks for using it!
-->
<html>
<head>
<style>
.main-container { /* MAIN WRAPPER */
margin: 50px;
left: calc(50% - 165px);
top: calc(50% - 130px);
position: fixed;
}
.grid-container,
.monitor { /* MAIN GRID */
display: grid;
height: 150px;
width: 150px;
margin-left: 40px;
margin-right: 40px;
padding: 1px;
background: rgba(179, 178, 177, .5);
-webkit-backdrop-filter: blur(48px) saturate(200%);
border-radius: 38px;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr;
grid-gap: 0px 0px;
grid-template-areas: "TopLeft TopRight""BottomLeft BottomRight";
box-shadow: rgba(0,0,0,.5) 0 0 0 1px, rgba(0,0,0,.5) 0 12px 50px;
overflow: hidden;
transition: 0.2s;
}
.monitor { /* MULTI-MONITOR SUPPORT */
height: 100px;
width: 40px;
border-radius: 15px;
}
.monitor-left {
position: fixed;
left: calc(50% - 180px);
top: calc(50% - 55px);
}
.monitor-right{
position: fixed;
right: calc(50% - 180px);
top: calc(50% - 55px);
}
.monitor .cell,
.monitor .arrow {
position: absolute;
top: 1px;
bottom: 1px;
left: 1px;
right: 1px;
border-radius: 14px;
}
.monitor .cell .arrow {
background-image: url("https://raw.githubusercontent.com/GoldenChaos/GoldenChaos-BTT/master/touchbar-icons/back.png");
background-position: center center;
background-repeat: no-repeat;
-webkit-filter: invert();
}
.monitor-right .cell .arrow {
background-image: url("https://raw.githubusercontent.com/GoldenChaos/GoldenChaos-BTT/master/touchbar-icons/forward.png");
}
.monitor:hover {
-webkit-backdrop-filter: blur(48px) brightness(100%) saturate(180%);
background-color: rgba(255,255,255,.45);
transition: 0.1s;
transform: scale(1.05);
}
.monitor:hover .cell {
opacity: 0.7;
-webkit-backdrop-filter: saturate(100%);
transition: 0.01s;
}
/* CELL HIGHLIGHTS AND STYLES */
.cell {
background: rgba(49, 48, 44, .5);
-webkit-backdrop-filter: saturate(100%);
mix-blend-mode: multiply;
transition: 0.01s;
}
.highlighted { /* REPRESENTATION Style */
-webkit-backdrop-filter: brightness(100%) saturate(180%);
background-color: rgba(255,255,255,.45);
transition: 0.2s;
}
.highlightCell { /* BUTTON Style */
opacity: .7;
-webkit-backdrop-filter: saturate(100%);
transition: 0.2s;
}
.TopLeft {
display: grid;
grid-area: TopLeft;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr;
grid-gap: 1px 1px;
grid-template-areas: "TopLeftTopLeft TopLeftTopRight""TopLeftBottomLeft TopLeftBottomRight";
border-top-left-radius: 37px;
}
.TopLeftTopLeft {
grid-area: TopLeftTopLeft;
border-top-left-radius: 37px;
-webkit-background-clip: padding-box;
background-clip: padding-box;
}
.TopLeftBottomLeft {
grid-area: TopLeftBottomLeft;
}
.TopLeftTopRight {
grid-area: TopLeftTopRight;
}
.TopLeftBottomRight {
grid-area: TopLeftBottomRight;
}
.TopRight {
display: grid;
grid-area: TopRight;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr;
grid-gap: 1px 1px;;
grid-template-areas: "TopRightTopLeft TopRightTopRight""TopRightBottomLeft TopRightBottomRight";
border-top-right-radius: 37px;
}
.TopRightTopLeft {
grid-area: TopRightTopLeft;
}
.TopRightTopRight {
grid-area: TopRightTopRight;
border-top-right-radius: 37px;
-webkit-background-clip: padding-box;
background-clip: padding-box;
}
.TopRightBottomLeft {
grid-area: TopRightBottomLeft;
}
.TopRightBottomRight {
grid-area: TopRightBottomRight;
}
.BottomLeft {
display: grid;
grid-area: BottomLeft;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr;
grid-gap: 1px 1px;;
grid-template-areas: "BottomLeftTopLeft BottomLeftTopRight""BottomLeftBottomLeft BottomLeftBottomRight";
border-bottom-left-radius: 37px;
}
.BottomLeftTopLeft {
grid-area: BottomLeftTopLeft;
}
.BottomLeftTopRight {
grid-area: BottomLeftTopRight;
}
.BottomLeftBottomLeft {
grid-area: BottomLeftBottomLeft;
border-bottom-left-radius: 37px;
-webkit-background-clip: padding-box;
background-clip: padding-box;
}
.BottomLeftBottomRight {
grid-area: BottomLeftBottomRight;
}
.BottomRight {
display: grid;
grid-area: BottomRight;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr;
border-bottom-right-radius: 37px;
grid-gap: 1px 1px;;
grid-template-areas: "BottomRightTopLeft BottomRightTopRight""BottomRightBottomLeft BottomRightBottomRight";
}
.BottomRightTopLeft {
grid-area: BottomRightTopLeft;
}
.BottomRightTopRight {
grid-area: BottomRightTopRight;
-webkit-background-clip: padding-box;
background-clip: padding-box;
}
.BottomRightBottomLeft {
grid-area: BottomRightBottomLeft;
}
.BottomRightBottomRight {
grid-area: BottomRightBottomRight;
border-bottom-right-radius: 37px;
}
.TopLeftTopLeft:hover,
.TopRightTopRight:hover,
.BottomLeftBottomLeft:hover,
.BottomRightBottomRight:hover {
background: rgba(49, 48, 44, .5);
}
</style>
<script>
window.currentlyHighlighted = [];
// Add Highlight FX for Representation
function addHighlight(classNames) {
for (var i = 0; i < classNames.length; i++) {
window.currentlyHighlighted.push(classNames[i]);
document.getElementsByClassName(classNames[i]).item(0).classList.add('highlighted');
}
}
// Remove Highlight FX for Representation
function removeHighlight(classNames) {
for (var i = 0; i < classNames.length; i++) {
window.currentlyHighlighted = window.currentlyHighlighted.filter(e => e !== classNames[i]);
document.getElementsByClassName(classNames[i]).item(0).classList.remove('highlighted');
}
}
// Add Highlight FX for Button
function addCellHighlight(classNames) {
for (var i = 0; i < classNames.length; i++) {
window.currentlyHighlighted.push(classNames[i]);
document.getElementsByClassName(classNames[i]).item(0).classList.add('highlightCell');
}
}
// Remove Highlight FX for Button
function removeCellHighlight(classNames) {
for (var i = 0; i < classNames.length; i++) {
window.currentlyHighlighted = window.currentlyHighlighted.filter(e => e !== classNames[i]);
document.getElementsByClassName(classNames[i]).item(0).classList.remove('highlightCell');
}
}
function uniq(a) {
var prims = {
"boolean": {},
"number": {},
"string": {}
},
objs = [];
return a.filter(function(item) {
var type = typeof item;
if (type in prims)
return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true);
else
return objs.indexOf(item) >= 0 ? false : objs.push(item);
});
}
function performAction() {
console.log(uniq(window.currentlyHighlighted));
var trigger = '';
if (window.currentlyHighlighted.indexOf('TopLeft') !== -1 &&
window.currentlyHighlighted.indexOf('TopRight') !== -1 &&
window.currentlyHighlighted.indexOf('BottomLeft') !== -1 &&
window.currentlyHighlighted.indexOf('BottomRight') !== -1) {
trigger = 'Maximize';
} else if (window.currentlyHighlighted.indexOf('TopLeft') !== -1 &&
window.currentlyHighlighted.indexOf('TopRight') !== -1) {
trigger = 'Top Half';
} else if (window.currentlyHighlighted.indexOf('BottomLeft') !== -1 &&
window.currentlyHighlighted.indexOf('BottomRight') !== -1) {
trigger = 'Bottom Half';
} else if (window.currentlyHighlighted.indexOf('TopLeft') !== -1 &&
window.currentlyHighlighted.indexOf('BottomLeft') !== -1) {
trigger = 'Left Half';
} else if (window.currentlyHighlighted.indexOf('TopRight') !== -1 &&
window.currentlyHighlighted.indexOf('BottomRight') !== -1) {
trigger = 'Right Half';
} else if (window.currentlyHighlighted.indexOf('TopRight') !== -1) {
trigger = 'Top Right Quarter';
} else if (window.currentlyHighlighted.indexOf('TopLeft') !== -1) {
trigger = 'Top Left Quarter';
} else if (window.currentlyHighlighted.indexOf('BottomLeft') !== -1) {
trigger = 'Bottom Left Quarter';
} else if (window.currentlyHighlighted.indexOf('BottomRight') !== -1) {
trigger = 'Bottom Right Quarter';
} else if (window.currentlyHighlighted.indexOf('LeftMonitor') !== -1) {
trigger = 'Move to Left Monitor';
} else if (window.currentlyHighlighted.indexOf('RightMonitor') !== -1) {
trigger = 'Move to Right Monitor';
}
console.log('trigger', trigger);
window.BTT.callHandler('trigger_named', {
trigger_name: trigger,
closeFloatingHTMLMenu: 1
})
}
</script>
</head>
<body>
<div class="main-container">
<!-- Current Monitor Pallete -->
<div class="grid-container" onclick="performAction()">
<div class="TopLeft" onmouseover="addHighlight(['TopLeft']);" onmouseout="removeHighlight(['TopLeft']);">
<div class="TopLeftTopLeft area-overlap cell" onmouseover="addHighlight(['TopLeftTopLeft']); addCellHighlight(['TopLeftTopLeft'])" onmouseout="removeHighlight(['TopLeftTopLeft']); removeCellHighlight(['TopLeftTopLeft'])"></div>
<div class="TopLeftBottomLeft cell" onmouseover="addHighlight(['BottomLeft', 'TopLeft']); addCellHighlight(['TopLeftBottomLeft', 'BottomLeftTopLeft'])" onmouseout="removeHighlight(['BottomLeft', 'TopLeft']); removeCellHighlight([ 'TopLeftBottomLeft', 'BottomLeftTopLeft'])"></div>
<div class="TopLeftTopRight cell" onmouseover="addHighlight(['TopRight', 'TopLeft']); addCellHighlight(['TopLeftTopRight', 'TopRightTopLeft']);" onmouseout="removeHighlight(['TopRight', 'TopLeft']); removeCellHighlight(['TopLeftTopRight', 'TopRightTopLeft'])"></div>
<div class="TopLeftBottomRight cell" onmouseover="addHighlight(['TopRight', 'BottomRight', 'BottomLeft', 'TopLeft']); addCellHighlight(['TopLeftBottomRight', 'TopRightBottomLeft', 'BottomLeftTopRight', 'BottomRightTopLeft'])" onmouseout="removeHighlight(['TopRight', 'BottomRight', 'BottomLeft', 'TopLeft']); removeCellHighlight(['TopLeftBottomRight', 'TopRightBottomLeft', 'BottomLeftTopRight', 'BottomRightTopLeft'])"></div>
</div>
<div class="TopRight" onmouseover="addHighlight(['TopRight'])" onmouseout="removeHighlight(['TopRight'])">
<div class="TopRightTopLeft area-overlap cell" onmouseover="addHighlight(['TopRight', 'TopLeft']); addCellHighlight([ 'TopLeftTopRight', 'TopRightTopLeft'])" onmouseout="removeHighlight(['TopRight', 'TopLeft']); removeCellHighlight(['TopLeftTopRight', 'TopRightTopLeft'])"></div>
<div class="TopRightTopRight cell" onmouseover="addHighlight(['TopRightTopRight']); addCellHighlight(['TopRightTopRight'])" onmouseout="removeHighlight(['TopRightTopRight']); removeCellHighlight(['TopRightTopRight'])"></div>
<div class="TopRightBottomLeft cell" onmouseover="addHighlight(['TopRight', 'BottomRight', 'BottomLeft', 'TopLeft']); addCellHighlight(['TopLeftBottomRight', 'TopRightBottomLeft', 'BottomLeftTopRight', 'BottomRightTopLeft'])" onmouseout="removeHighlight(['TopRight', 'BottomRight', 'BottomLeft', 'TopLeft']); removeCellHighlight(['TopLeftBottomRight', 'TopRightBottomLeft', 'BottomLeftTopRight', 'BottomRightTopLeft'])"></div>
<div class="TopRightBottomRight cell" onmouseover="addHighlight(['TopRight', 'BottomRight']); addCellHighlight(['TopRightBottomRight', 'BottomRightTopRight'])" onmouseout="removeHighlight(['TopRight', 'BottomRight']); removeCellHighlight(['TopRightBottomRight', 'BottomRightTopRight'])"></div>
</div>
<div class="BottomLeft" onmouseover="addHighlight(['BottomLeft'])" onmouseout="removeHighlight(['BottomLeft'])">
<div class="BottomLeftTopLeft area-overlap cell" onmouseover="addHighlight(['BottomLeft', 'TopLeft']); addCellHighlight([ 'TopLeftBottomLeft', 'BottomLeftTopLeft'])" onmouseout="removeHighlight(['BottomLeft', 'TopLeft']); removeCellHighlight(['TopLeftBottomLeft', 'BottomLeftTopLeft'])"></div>
<div class="BottomLeftTopRight cell" onmouseover="addHighlight(['TopRight', 'BottomRight', 'BottomLeft', 'TopLeft']); addCellHighlight([ 'TopLeftBottomRight', 'TopRightBottomLeft', 'BottomLeftTopRight', 'BottomRightTopLeft'])" onmouseout="removeHighlight(['TopRight', 'BottomRight', 'BottomLeft', 'TopLeft']); removeCellHighlight(['TopLeftBottomRight', 'TopRightBottomLeft', 'BottomLeftTopRight', 'BottomRightTopLeft'])"></div>
<div class="BottomLeftBottomLeft cell" onmouseover="addHighlight(['BottomLeftBottomLeft']); addCellHighlight(['BottomLeftBottomLeft'])" onmouseout="removeHighlight(['BottomLeftBottomLeft']); removeCellHighlight(['BottomLeftBottomLeft'])"></div>
<div class="BottomLeftBottomRight cell" onmouseover="addHighlight(['BottomLeft', 'BottomRight']); addCellHighlight(['BottomRightBottomLeft', 'BottomLeftBottomRight'])" onmouseout="removeHighlight(['BottomLeft', 'BottomRight']); removeCellHighlight([ 'BottomRightBottomLeft', 'BottomLeftBottomRight'])"></div>
</div>
<div class="BottomRight" onmouseover="addHighlight(['BottomRight'])" onmouseout="removeHighlight(['BottomRight'])">
<div class="BottomRightTopLeft cell" onmouseover="addHighlight(['TopRight', 'BottomRight', 'BottomLeft', 'TopLeft']); addCellHighlight([ 'TopLeftBottomRight', 'TopRightBottomLeft', 'BottomLeftTopRight', 'BottomRightTopLeft'])" onmouseout="removeHighlight(['TopRight', 'BottomRight', 'BottomLeft', 'TopLeft']); removeCellHighlight(['TopLeftBottomRight', 'TopRightBottomLeft', 'BottomLeftTopRight', 'BottomRightTopLeft'])"></div>
<div class="BottomRightTopRight cell" onmouseover="addHighlight(['BottomRight', 'TopRight']); addCellHighlight(['TopRightBottomRight', 'BottomRightTopRight'])" onmouseout="removeHighlight(['BottomRight', 'TopRight']); removeCellHighlight(['TopRightBottomRight', 'BottomRightTopRight'])"></div>
<div class="BottomRightBottomLeft cell" onmouseover="addHighlight(['BottomLeft', 'BottomRight']); addCellHighlight(['BottomRightBottomLeft', 'BottomLeftBottomRight'])" onmouseout="removeHighlight(['BottomLeft', 'BottomRight']); removeCellHighlight([ 'BottomRightBottomLeft', 'BottomLeftBottomRight'])"></div>
<div class="BottomRightBottomRight cell" onmouseover="addHighlight(['BottomRightBottomRight']); addCellHighlight(['BottomRightBottomRight'])" onmouseout="removeHighlight(['BottomRightBottomRight']); removeCellHighlight(['BottomRightBottomRight'])"></div>
</div>
</div>
</div>
</body>
</html>