A web-based drawing app
git clone git://soophie.de/outline
blob: 8e7be798131cb90845157c23ea8fb9e9613bfd20 (22504 bytes)[doc][blame][raw]
1
import { uuid } from './util.js';2
import { load } from './locale.js';3
import { read, key_pressed } from './gamepad.js';5
/* !!! JS -> PROPERTIES */6
// ^'([\w.-]+)':\s'(.*)',?$7
// $1=$29
window.toggle_modal = toggle_modal;10
window.open_tab = open_tab;11
window.close_tab = close_tab;12
window.change_device = change_device;13
window.change_language = change_language;14
window.clear_screen = clear_screen;16
let LANG;18
const KEY_BINDING = {19
0: 'A',20
1: 'B',21
2: 'X',22
3: 'Y',23
4: 'L1',24
5: 'R1',25
6: 'L2',26
7: 'R2',27
8: 'Option',28
9: 'Menu',29
10: 'L3',30
11: 'R3',31
12: 'Up',32
13: 'Down',33
14: 'Left',34
15: 'Right',35
16: 'Power',36
17: 'Assist',37
18: 'Capture'38
};40
const COLORS = {41
0: '#FFCDD2',42
1: '#E57373',43
2: '#F44336',44
3: '#D32F2F',45
4: '#B71C1C',46
5: '#F8BBD0',47
6: '#F06292',48
7: '#E91E63',49
8: '#C2185B',50
9: '#880E4F',51
10: '#E1BEE7',52
11: '#BA68C8',53
12: '#9C27B0',54
13: '#7B1FA2',55
14: '#4A148C',56
15: '#BBDEFB',57
16: '#64B5F6',58
17: '#2196F3',59
18: '#1976D2',60
19: '#0D47A1',61
20: '#B2EBF2',62
21: '#4DD0E1',63
22: '#00BCD4',64
23: '#0097A7',65
24: '#006064',66
25: '#B2DFDB',67
26: '#4DB6AC',68
27: '#009688',69
28: '#00796B',70
29: '#004D40',71
30: '#C8E6C9',72
31: '#81C784',73
32: '#4CAF50',74
33: '#388E3C',75
34: '#1B5E20',76
35: '#FFF9C4',77
36: '#FFF176',78
37: '#FFEB3B',79
38: '#FBC02D',80
39: '#F57F17',81
40: '#FFE0B2',82
41: '#FFB74D',83
42: '#FF9800',84
43: '#F57C00',85
44: '#E65100',86
45: '#D7CCC8',87
46: '#A1887F',88
47: '#795548',89
48: '#5D4037',90
49: '#3E2723',91
50: '#F5F5F5',92
51: '#E0E0E0',93
52: '#9E9E9E',94
53: '#616161',95
54: '#141414'96
};98
const COLOR = {99
0: '#141414',100
1: '#F44336',101
2: '#2196F3',102
3: '#009688',103
4: '#FFEB3B',104
5: '#9C27B0'105
};107
const COLORS_LENGTH = Object.values(COLORS).length;108
const COLOR_LENGTH = Object.values(COLOR).length;110
let canvas;111
let overlay;112
let g;113
let o;114
let ad;115
let hotbar;116
let toolbar;117
let actionbar;118
let colors;119
let actions;120
let tools;121
let modals;122
let device_options;123
let device_empty;124
let current_modal;125
let current_tab;126
let modal_colors;127
let colors_modal;128
let capture_modal;129
let clear_modal;130
let scale_range;132
let device;133
let devices = {134
mouse: false,135
touch: false,136
pen: false,137
gamepad: false138
};139
let fallback_device;141
let lang = 'en';142
let notification_code;144
let cache;145
let point;146
let last;147
let start;148
let index = 0;149
let radius = 14;150
let lock_x = false;151
let lock_y = false;152
let draw;153
let erase;154
let pressed = {};155
let arrow_y = 0;156
let arrow_x = 0;157
let left_modal = false;159
window.addEventListener('load', init);161
function init() {162
load('../asset/lang', ['en', 'de'])163
.then(function(data) {164
LANG = data;165
});166
canvas = document.querySelector('#canvas');167
canvas.width = window.innerWidth;168
canvas.height = window.innerHeight;169
g = canvas.getContext('2d');170
overlay = document.querySelector('#overlay');171
overlay.width = window.innerWidth;172
overlay.height = window.innerHeight;173
o = overlay.getContext('2d');174
window.onresize = function() {175
cache = g.getImageData(0, 0, canvas.width, canvas.height);176
canvas.width = window.innerWidth;177
canvas.height = window.innerHeight;178
g.putImageData(cache, 0, 0);179
cache = o.getImageData(0, 0, overlay.width, overlay.height);180
overlay.width = window.innerWidth;181
overlay.height = window.innerHeight;182
o.putImageData(cache, 0, 0);183
}184
let ripple = document.querySelectorAll('.ripple');185
for(let item of ripple) {186
item.addEventListener('pointerdown', function(event) {187
item.classList.add('ripple-active');188
});189
}190
document.addEventListener('touchmove', function(event) {191
let { target } = event;192
if(target !== scale_range) {193
event.preventDefault();194
}195
}, { passive: false });196
document.addEventListener('pointerup', function(event) {197
for(let item of ripple) {198
item.classList.remove('ripple-active');199
}200
});201
device_options = document.querySelectorAll('.settings-modal .device-tab .item[data-device]');202
device_empty = document.querySelector('.settings-modal .device-tab .item.empty');204
ad = document.querySelector('.controls .ad');205
hotbar = document.querySelector('.controls .hotbar');206
toolbar = document.querySelector('.controls .toolbar');207
actionbar = document.querySelector('.controls .actionbar');208
colors = Array.from(hotbar.querySelectorAll('.color'));209
actions = document.querySelectorAll('.actionbar .action');210
tools = document.querySelectorAll('.toolbar .tool');211
modals = document.querySelectorAll('.modal');212
modal_colors = document.querySelectorAll('.colors-modal .color');213
colors_modal = document.querySelector('.toolbar .tool[data-modal="colors"]');214
capture_modal = document.querySelector('.toolbar .tool[data-modal="capture"]');215
clear_modal = document.querySelector('.toolbar .tool[data-modal="clear"]');216
scale_range = document.querySelector('.scale-modal input[type="range"]');217
for(let i in colors) {218
if(COLOR_LENGTH > i) {219
if(i == index) {220
colors[i].classList.add('active');221
}222
colors[i].style.background = COLOR[i];223
colors[i].addEventListener('pointerdown', function(event) {224
for(let j in colors) {225
if(COLOR_LENGTH > j) {226
if(j == i) {227
index = j;228
}229
colors[j].classList[j == i ? 'add' : 'remove']('active');230
}231
}232
});233
}234
}235
for(let i in modal_colors) {236
if(COLORS_LENGTH > i) {237
modal_colors[i].style.background = COLORS[i];238
}239
}240
document.addEventListener('dragstart', function(event) {241
event.preventDefault();242
});243
document.addEventListener('contextmenu', function(event) {244
event.preventDefault();245
});246
scale_range.addEventListener('input', function(event) {247
radius = parseInt(scale_range.value);248
left_modal = false;249
point.x = parseInt(window.innerWidth / 2);250
point.y = parseInt(window.innerHeight / 2);251
});252
document.addEventListener('wheel', function(event) {253
if(device !== 'gamepad') {254
let { deltaY } = event;255
let y = deltaY < 0 ? 1 : -1;256
if(radius + y > 2 - 1 && radius + y < 50 + 1) {257
radius += y;258
scale_range.value = radius;259
}260
}261
});262
document.addEventListener('wheel', function(event) {263
if(device !== 'gamepad') {264
let { ctrlKey } = event;265
if(ctrlKey) {266
event.preventDefault();267
return;268
}269
}270
}, { passive: false });271
canvas.addEventListener('pointerdown', function(event) {272
let { layerX, layerY, buttons, pointerType, target } = event;273
if(!devices.touch && pointerType === 'touch') {274
devices.touch = true;275
if(device) {276
show_notification('notification.input-device.touch.add');277
}278
}279
if(!devices.pen && pointerType === 'pen') {280
devices.pen = true;281
show_notification('notification.input-device.pencil.add');282
}283
if(device !== 'gamepad') {284
if(!lock_x) {285
start.x = layerX;286
}287
if(!lock_y) {288
start.y = layerY;289
}290
if(current_modal && target === canvas) {291
toggle_modal(current_modal);292
left_modal = true;293
}294
else {295
left_modal = false;296
}297
if(device === pointerType) {298
if(!current_modal && !left_modal) {299
if(start.x !== null && start.y !== null) {300
if(buttons == 1) {301
draw_line(start, null, radius, COLOR[index]);302
}303
if(buttons == 2) {304
draw_line(start, null, radius, 'white');305
erase = true;306
last.x = null;307
last.y = null;308
}309
}310
}311
ad.style.pointerEvents = 'none';312
hotbar.style.pointerEvents = 'none';313
toolbar.style.pointerEvents = 'none';314
actionbar.style.pointerEvents = 'none';315
for(let modal of modals) {316
modal.style.pointerEvents = 'none';317
}318
}319
}320
});321
document.addEventListener('pointermove', function(event) {322
let { layerX, layerY, target, pointerType, buttons } = event;323
if(!devices.mouse && pointerType === 'mouse') {324
devices.mouse = true;325
}326
if(device !== 'gamepad') {327
draw = buttons == 1;328
erase = buttons == 2;329
if(buttons == 3) {330
draw = true;331
erase = true;332
}333
if(start.x !== null || start.y !== null) {334
last = start;335
start = {336
x: null,337
y: null338
};339
}340
if(device === pointerType) {341
left_modal = false;342
if(target == canvas) {343
if(!lock_x) {344
point.x = layerX;345
}346
if(!lock_y) {347
point.y = layerY;348
}349
}350
if(draw && erase) {351
last.x = null;352
last.y = null;353
}354
}355
if(!document.hasFocus()) {356
draw = false;357
erase = false;358
}359
}360
});361
document.addEventListener('pointerout', function(event) {362
if(device !== 'gamepad') {363
if(!lock_x && !lock_y) {364
point.x = null;365
point.y = null;366
}367
}368
});369
document.addEventListener('pointerup', function(event) {370
if(device !== 'gamepad') {371
let { buttons } = event;372
draw = buttons == 1;373
erase = buttons == 2;374
last.x = null;375
last.y = null;376
ad.style.pointerEvents = '';377
hotbar.style.pointerEvents = '';378
toolbar.style.pointerEvents = '';379
actionbar.style.pointerEvents = '';380
for(let modal of modals) {381
modal.style.pointerEvents = '';382
}383
}384
});385
document.addEventListener('keydown', function(event) {386
let { code, ctrlKey, shiftKey, altKey } = event;387
if(device !== 'gamepad') {388
let lock = event.getModifierState("CapsLock");389
if(!ctrlKey && !shiftKey && !altKey) {390
if(code === 'KeyX') {391
lock_y = !lock_y;392
lock_x = false;393
}394
if(code === 'KeyZ') {395
lock_x = !lock_x;396
lock_y = false;397
}398
if(!lock) {399
if(code.startsWith('Digit')) {400
let number = parseInt(code.substr(5)) - 1;401
if(number >= 0 && number < COLOR_LENGTH) {402
index = number;403
for(let i in colors) {404
if(COLOR_LENGTH > i) {405
colors[i].classList[i == index ? 'add' : 'remove']('active');406
}407
}408
}409
}410
}411
}412
}413
if(code === 'Escape') {414
if(current_tab) {415
close_tab(current_tab);416
}417
else if(current_modal) {418
toggle_modal(current_modal);419
}420
}421
});422
point = { x: null, y: null };423
last = { x: null, y: null };424
start = { x: null, y: null };425
update();426
}428
function update() {429
if(radius < 2) {430
radius = 2;431
}432
if(radius > 50) {433
radius = 50;434
}435
let gamepad = navigator.getGamepads()[0];436
if(gamepad) {437
if(!devices.gamepad) {438
devices.gamepad = true;439
show_notification('notification.input-device.gamepad.add');440
if(gamepad.vibrationActuator) {441
gamepad.vibrationActuator.playEffect("dual-rumble", {442
startDelay: 0,443
duration: 100,444
weakMagnitude: 1.0,445
strongMagnitude: 1.0446
});447
}448
}449
if(device === 'gamepad') {450
if(point.x == null && point.y == null) {451
point.x = parseInt(window.innerWidth / 2);452
point.y = parseInt(window.innerHeight / 2);453
}454
let input = read(gamepad);455
let speed = 4;456
draw = input.button['A'];457
erase = input.button['B'];458
if(pressed['L2'] && !pressed['R2']) {459
speed = 10;460
}461
if(pressed['R2'] && !pressed['L2']) {462
speed = 1;463
}464
// move465
if(!lock_x) {466
point.x += input.axes['Left'].x * speed;467
if(point.x < 0 ) {468
point.x = 0;469
}470
if(point.x > window.innerWidth) {471
point.x = window.innerWidth;472
}473
}474
if(!lock_y) {475
point.y += input.axes['Left'].y * speed;476
if(point.y < 0) {477
point.y = 0;478
}479
if(point.y > window.innerHeight) {480
point.y = window.innerHeight;481
}482
}483
// colors484
key_pressed('Option', input, function() {485
toggle_modal(colors_modal);486
});487
// capture488
key_pressed('Capture', input, function() {489
toggle_modal(capture_modal);490
});491
// draw492
key_pressed('A', input, function() {493
last.x = null;494
last.y = null;495
if(!current_modal) {496
left_modal = false;497
}498
});499
// erase500
key_pressed('B', input, function() {501
last.x = null;502
last.y = null;503
if(current_tab) {504
close_tab(current_tab);505
left_modal = true;506
}507
else if(current_modal) {508
toggle_modal(current_modal);509
left_modal = true;510
}511
else {512
left_modal = false;513
}514
});515
// sprint516
key_pressed('L2', input);517
// sneak518
key_pressed('R2', input);519
// clear520
key_pressed('Y', input, function() {521
toggle_modal(clear_modal);522
});523
// radius524
let y = -(input.axes['Right'].y / 2);525
if(y !== 0 && radius + y > 2 && radius + y < 50 + 1) {526
radius += y;527
scale_range.value = radius;528
}529
// lock y530
key_pressed('L3', input, function() {531
lock_y = !lock_y;532
lock_x = false;533
});534
// lock x535
key_pressed('R3', input, function() {536
lock_x = !lock_x;537
lock_y = false;538
});539
// color-wheel left540
key_pressed('L1', input, function() {541
if(index > 0) {542
index--;543
for(let i in colors) {544
if(COLOR_LENGTH > i) {545
colors[i].classList[i == index ? 'add' : 'remove']('active');546
}547
}548
}549
});550
// color-wheel right551
key_pressed('R1', input, function() {552
if(index < COLOR_LENGTH - 1) {553
index++;554
for(let i in colors) {555
if(COLOR_LENGTH > i) {556
colors[i].classList[i == index ? 'add' : 'remove']('active');557
}558
}559
}560
});561
key_pressed('Up', input, function() {562
if(arrow_y > 0) {563
arrow_y--;564
}565
});566
key_pressed('Down', input, function() {567
if(arrow_y < 10) {568
arrow_y++;569
}570
});571
key_pressed('Left', input, function() {572
if(arrow_x > 0) {573
arrow_x--;574
}575
});576
key_pressed('Right', input, function() {577
if(arrow_x < 4) {578
arrow_x++;579
}580
});581
}582
}583
else {584
if(devices.gamepad) {585
devices.gamepad = false;586
show_notification('notification.input-device.gamepad.remove');587
}588
}589
if(device !== 'gamepad') {590
let pos = arrow_y * 5 + arrow_x;591
if(modal_colors[pos].classList.contains('focus')) {592
modal_colors[pos].classList.remove('focus');593
}594
}595
// device mouse option596
let mouse_option = document.querySelector('.settings-modal .device-tab .item[data-device="mouse"]');597
if(devices.mouse && mouse_option.classList.contains('inactive')) {598
mouse_option.classList.remove('inactive');599
if(!device) {600
device = 'mouse';601
fallback_device = 'mouse';602
mouse_option.classList.add('active');603
}604
}605
// device touch option606
let touch_option = document.querySelector('.settings-modal .device-tab .item[data-device="touch"]');607
if(devices.touch && touch_option.classList.contains('inactive')) {608
touch_option.classList.remove('inactive');609
if(!device) {610
device = 'touch';611
fallback_device = 'touch';612
touch_option.classList.add('active');613
}614
}615
// device pen option616
let pen_option = document.querySelector('.settings-modal .device-tab .item[data-device="pen"]');617
if(devices.pen && pen_option.classList.contains('inactive')) {618
pen_option.classList.remove('inactive');619
if(!device) {620
device = 'pen';621
fallback_device = 'pen';622
pen_option.classList.add('active');623
}624
}625
// device gamepad option626
let gamepad_option = document.querySelector('.settings-modal .device-tab .item[data-device="gamepad"]');627
if(devices.gamepad && gamepad_option.classList.contains('inactive')) {628
gamepad_option.classList.remove('inactive');629
if(!device) {630
device = 'gamepad';631
fallback_device = 'gamepad';632
gamepad_option.classList.add('active');633
}634
}635
if(!devices.gamepad && !gamepad_option.classList.contains('inactive')) {636
gamepad_option.classList.add('inactive');637
gamepad_option.classList.remove('active');638
if(device === 'gamepad') {639
if(device !== fallback_device) {640
device = fallback_device;641
let option = document.querySelector(`.settings-modal .device-tab .item[data-device="${device}"]`);642
option.classList.add('active');643
}644
else {645
device = null;646
}647
point.x = null;648
point.y = null;649
last.x = null;650
last.y = null;651
}652
}653
// cursor visible654
canvas.style.cursor = device === 'mouse' ? 'none' : 'default';655
if(!current_modal && !left_modal) {656
// pencil657
if(draw && !erase) {658
if(point.x !== null && point.y !== null) {659
if(last.x !== null && last.y !== null) {660
draw_line(point, last, radius, COLOR[index]);661
}662
}663
}664
// eraser665
if(erase && !draw) {666
if(point.x !== null && point.y !== null) {667
if(last.x !== null && last.y !== null) {668
draw_line(point, last, radius, 'white');669
}670
}671
}672
}673
// at least one device674
let one_device = Object.values(devices).some(function(device) {675
return device;676
});677
if(one_device && !device_empty.classList.contains('hidden')) {678
device_empty.classList.add('hidden');679
}680
if(!one_device && device_empty.classList.contains('hidden')) {681
device_empty.classList.remove('hidden');682
}683
// navigate colors684
let pos = arrow_y * 5 + arrow_x;685
if(device === 'gamepad') {686
for(let [ i, item ] of Object.entries(modal_colors)) {687
item.classList[parseInt(i) == pos ? 'add' : 'remove']('focus');688
}689
}690
render();691
if(draw || erase) {692
last.x = point.x;693
last.y = point.y;694
}695
requestAnimationFrame(update);696
}698
function render() {699
if(radius < 2) {700
radius = 2;701
}702
o.clearRect(0, 0, window.innerWidth, window.innerHeight);703
if(point.x !== null && point.y !== null) {704
let touch_device = (device === 'touch' || device === 'pen');705
if(touch_device) {706
if(!left_modal) {707
o.fillStyle = 'white';708
o.beginPath();709
o.arc(point.x, point.y, parseInt(radius) + 2, 2 * Math.PI, 0);710
o.fill();711
o.fillStyle = COLOR[index];712
o.beginPath();713
o.arc(point.x, point.y, parseInt(radius), 2 * Math.PI, 0);714
o.fill();715
}716
}717
else {718
o.fillStyle = 'white';719
o.beginPath();720
o.arc(point.x, point.y, parseInt(radius) + 2, 2 * Math.PI, 0);721
o.fill();722
o.fillStyle = COLOR[index];723
o.beginPath();724
o.arc(point.x, point.y, parseInt(radius), 2 * Math.PI, 0);725
o.fill();726
}727
}728
if(!left_modal) {729
if(erase && !draw) {730
o.beginPath();731
o.lineWidth = 2;732
o.strokeStyle = 'white';733
o.moveTo(point.x, point.y - parseInt(radius) * 0.5);734
o.lineTo(point.x, point.y + parseInt(radius) * 0.5);735
o.moveTo(point.x - parseInt(radius) * 0.5, point.y);736
o.lineTo(point.x + parseInt(radius) * 0.5, point.y);737
o.stroke();738
}739
}740
if(lock_x || lock_y) {741
o.beginPath();742
o.lineWidth = 2;743
o.strokeStyle = 'white';744
if(lock_x) {745
o.moveTo(point.x, point.y - parseInt(radius));746
o.lineTo(point.x, point.y + parseInt(radius));747
}748
if(lock_y) {749
o.moveTo(point.x - parseInt(radius), point.y);750
o.lineTo(point.x + parseInt(radius), point.y);751
}752
o.stroke();753
}754
}756
function draw_line(point, last, radius, color) {757
if(last) {758
g.lineCap = 'round';759
g.strokeStyle = color;760
g.lineWidth = 2 * parseInt(radius);761
g.beginPath();762
g.moveTo(last.x + 0.5, last.y + 0.5);763
g.lineTo(point.x + 0.5, point.y + 0.5);764
g.stroke();765
}766
else {767
g.fillStyle = color;768
g.beginPath();769
g.arc(point.x, point.y, parseInt(radius), 2 * Math.PI, 0);770
g.fill();771
}772
}774
function change_device(element) {775
let value = element.dataset.device;776
if(devices[value]) {777
device = value;778
for(let item of device_options) {779
item.classList[element === item ? 'add' : 'remove']('active');780
}781
if(device !== 'gamepad') {782
point.x = null;783
point.y = null;784
last.x = null;785
last.y = null;786
}787
}788
}790
function change_language(element) {791
let code = element.dataset.code;792
lang = code;793
let items = document.querySelectorAll('[data-lang]');794
for(let item of items) {795
let prime = item.dataset.prime === 'true';796
let beta = item.dataset.beta === 'true';797
let type = item.dataset.type;798
let text = LANG[code][item.dataset.lang];799
let prime_content;800
let beta_content;801
if(prime) {802
prime_content = item.querySelector('b.prime-badge').textContent;803
}804
if(beta) {805
beta_content = item.querySelector('b.beta-badge').textContent;806
}807
if(text) {808
if(type === 'tooltip') {809
item.dataset.title = text;810
}811
else {812
item.textContent = text;813
}814
if(prime && type !== 'tooltip') {815
item.innerHTML += `<b class="prime-badge">${prime_content}</b>`;816
}817
if(beta && type !== 'tooltip') {818
item.innerHTML += `<b class="beta-badge">${beta_content}</b>`;819
}820
}821
}822
let options = document.querySelectorAll('.language-tab .item');823
for(let option of options) {824
option.classList[option === element ? 'add' : 'remove']('active');825
}826
}828
function toggle_modal(element) {829
let code = element.dataset.modal;830
let modal = document.querySelector(`.${code}-modal`);831
if(modal) {832
let open = modal.classList.contains('hidden');833
if(open) {834
current_modal = element;835
for(let item of actions) {836
if(item !== element) {837
item.classList.remove('active');838
}839
}840
for(let item of tools) {841
if(item !== element) {842
item.classList.remove('active');843
}844
}845
for(let item of modals) {846
if(item !== modal) {847
item.classList.add('hidden');848
}849
let main = item.querySelector('.main');850
if(main) {851
main.classList.remove('hidden');852
main.style.marginLeft = '0';853
}854
let tab_list = item.querySelector('.tab-list');855
if(tab_list) {856
let tabs = tab_list.querySelectorAll('.tab');857
for(let tab of tabs) {858
tab.classList.add('hidden');859
}860
}861
}862
if(code === 'colors') {863
if(device === 'gamepad') {864
modal_colors[0].classList.add('focus');865
arrow_x = 0;866
arrow_y = 0;867
}868
}869
}870
else {871
current_modal = null;872
}873
element.classList[open ? 'add' : 'remove']('active');874
modal.classList[open ? 'remove' : 'add']('hidden');875
modal.animate([876
{ opacity: 0, marginTop: '-6px' },877
{ opacity: 1, marginTop: '0' }878
], {879
duration: 100,880
fill: 'both'881
});882
}883
}885
function open_tab(element) {886
let code = element.dataset.tab;887
let main = element.parentNode.parentNode888
let tab = document.querySelector(`.${code}-tab`);889
if(tab) {890
main.style.marginLeft = '-100%';891
current_tab = tab.querySelector('.back');892
tab.classList.remove('hidden');893
main.classList.add('hidden');894
}895
}897
function close_tab(element) {898
let modal = element.parentNode.parentNode.parentNode.parentNode;899
let main = modal.querySelector('.main');900
let tab_list = modal.querySelector('.tab-list');901
let tabs = tab_list.querySelectorAll('.tab');902
for(let tab of tabs) {903
tab.classList.add('hidden');904
}905
main.classList.remove('hidden');906
main.style.marginLeft = '0';907
current_tab = null;908
}910
function show_notification(message) {911
let code = uuid();912
notification_code = code;913
let element = document.querySelector('.notification');914
let content = element.querySelector('.content');915
content.textContent = LANG[lang][message];916
element.animate([917
{ opacity: 0 },918
{ opacity: 1}919
], {920
duration: 200,921
fill: 'both'922
});923
setTimeout(function() {924
if(notification_code === code) {925
element.animate([926
{ opacity: 1 },927
{ opacity: 0}928
], {929
duration: 200,930
fill: 'both'931
});932
}933
}, 2000);934
}936
function clear_screen() {937
g.clearRect(0, 0, canvas.width, canvas.height);938
show_notification('notification.clear');939
toggle_modal(clear_modal);940
}