A web-based drawing app
git clone git://soophie.de/outline
blob: 995a4e4302ffccf3f653cf363f97ed790311ece9 (23553 bytes)[doc][blame][raw]
1
import { FIREBASE, COLORS, PRIORITY_MODAL, LOCALES } from './constant.js';2
import { uuid, query, prevent } from './util.js';4
import locale from './mod/locale.js';5
import canvas from './mod/canvas.js';6
import cookie from './mod/cookie.js';8
let node;9
let state = {10
color: 54,11
color_list: [54, 2, 17, 27, 37, 12],12
radius: 14,13
region: [],14
crop: false,15
index: 0,16
device: null,17
device_fallback: null,18
device_list: {19
mouse: false,20
touch: false,21
pen: false,22
gamepad: false23
},24
pencil_list: [25
'pen',26
'marker',27
'eraser'28
],29
pencil: 'pen',30
timestamp: null,31
modal: null,32
tab: null,33
caption: null,34
option: {35
view_mode: false,36
crop_mode: false,37
dark_mode: false38
},39
history: [],40
redo_history: [],41
key: {}42
};44
export async function init() {46
locale.init();47
await locale.load('./asset/lang', LOCALES);48
canvas.init();50
node = query({51
wrapper: '.wrapper',52
controls: '.controls',53
modal_list: { query: '.modal', all: true },54
tab_list: { query: '.tab', all: true },55
header: '.header-list',56
hotbar: '.hotbar',57
hotbar_list: { query: '.hotbar .color', all: true },58
modal_color_list: { query: '.colors-modal .color', all: true },59
language_list: { query: '.more-modal .language-tab .item[data-event="change.language"]', all: true },60
device_list: { query: '.more-modal .device-tab .item[data-event="change.device"]', all: true },61
pencil_list: { query: '.pencil-modal .item[data-event="change.pencil"]', all: true },62
modal_event_list: { query: '[data-event*=".modal"]', all: true },63
tab_event_list: { query: '[data-event*=".tab"]', all: true },64
capture_event_list: { query: '[data-event*=".capture"]', all: true },65
tool_list: { query: '.tool', all: true },66
action_list: { query: '.action', all: true },67
notification: '.notification',68
scale_input: 'input.scale[type="range"]',69
clear: 'button.btn-apply[data-event="clear"]',70
pencil_tool: '.tool-item[data-code="pencil"]',71
option_event_fullscreen: '[data-event="toggle.fullscreen"]',72
option_event_view_mode: '[data-event="toggle.view-mode"]',73
option_event_dark_mode: '[data-event="toggle.dark-mode"]',74
undo_tool: '[data-lang="action.undo"]',75
redo_tool: '[data-lang="action.redo"]',76
colors_modal: '.colors-modal',77
mainbar: '.mainbar',78
sidebar: '.sidebar',79
edit_mode: '[data-event="close.view-mode"]',80
content: '.modal .content',81
caption_list: { query: '[data-event="open.content"]' , all: true },82
content_list: { query: '.content-item' , all: true },83
download: '#download',84
cookie: '.cookie',85
accept: '.button.accept'86
});88
update_language_list();90
fill_hotbar_list();91
fill_modal_color_list();93
bind_events(locale);95
node.wrapper.animate([96
{ opacity: 1 },97
{ opacity: 0, pointerEvents: 'none' }98
], {99
delay: 100,100
duration: 500,101
fill: 'both'102
});103
node.hotbar.animate([104
{ opacity: 0, bottom: '-10px' },105
{ opacity: 1 }106
], {107
delay: 600,108
easing: 'ease-out',109
duration: 250,110
fill: 'both'111
});113
if(!cookie.hasAccepted()) {114
node.cookie.classList.remove('hidden');115
cookie.requestPermission(node.accept)116
.then(function() {117
node.cookie.classList.add('hidden');118
load_resources();119
});120
}121
else {122
load_resources();123
}124
}126
function load_resources() {127
let dark_mode = localStorage.getItem('outline.custom.dark-mode');128
if(dark_mode && dark_mode === 'true') {129
document.body.classList.add('theme-dark');130
state.option.dark_mode = true;131
update_dark_mode_option({ passive: true });132
}133
try {134
firebase.initializeApp(FIREBASE);135
firebase.analytics();136
}137
catch(error) {138
console.warn('Unable to load Google Analytics!');139
}140
}142
function bind_events(locale) {143
document.addEventListener('dragstart', prevent);144
document.addEventListener('contextmenu', prevent);145
document.addEventListener('pointerdown', on_pointerdown);146
document.addEventListener('pointermove', on_pointermove);147
document.addEventListener('pointerup', on_pointerup);148
document.addEventListener('pointerout', on_pointerout);149
document.addEventListener('keydown', on_keydown);150
document.addEventListener('keyup', on_keyup);151
document.addEventListener('wheel', on_wheel);152
document.addEventListener('wheel', function(event) {153
if(event.ctrlKey) {154
prevent(event);155
}156
}, { passive: false });157
document.addEventListener('touchmove', function(event) {158
if(event.target !== node.scale_input && event.target !== node.colors_modal && !node.modal_color_list.includes(event.target) && event.target !== node.content) {159
event.preventDefault();160
}161
}, { passive: false });163
for(let item of node.language_list) {164
item.addEventListener('click', function(event) {165
let code = item.dataset.code;166
locale.change(code);167
update_language_list();168
});169
}170
for(let item of node.device_list) {171
item.addEventListener('click', function(event) {172
let code = item.dataset.code;173
if(state.device_list[code]) {174
state.device = code;175
update_device_list();176
}177
});178
}179
for(let item of node.pencil_list) {180
item.addEventListener('click', function(event) {181
state.pencil = item.dataset.code;182
update_pencil_list();183
state.modal = null;184
update_modal_list();185
});186
}187
for(let item of node.modal_event_list) {188
item.addEventListener('click', function(event) {189
let code = item.dataset.code;190
let match = /^(toggle|open|close).modal$/.exec(item.dataset.event);191
if(match) {192
if(!item.classList.contains('inactive')) {193
switch(match[1]) {194
case 'toggle':195
if(code) {196
state.modal = state.modal !== code ? code : null;197
update_modal_list();198
}199
break;200
case 'open':201
if(code && state.modal !== code) {202
state.modal = code;203
update_modal_list();204
}205
break;206
case 'close':207
if(state.modal !== null) {208
state.modal = null;209
update_modal_list();210
}211
break;212
default:213
break;214
}215
}216
}217
});218
}219
for(let item of node.tab_event_list) {220
item.addEventListener('click', function(event) {221
let code = item.dataset.code;222
let match = /^(open|close).tab/.exec(item.dataset.event);223
if(match) {224
switch(match[1]) {225
case 'open':226
if(code && state.tab !== code) {227
state.tab = code;228
update_tab_list();229
}230
break;231
case 'close':232
if(state.tab !== null) {233
state.tab = null;234
update_tab_list();235
}236
break;237
default:238
break;239
}240
}241
});242
}243
for(let item of node.capture_event_list) {244
item.addEventListener('click', function(event) {245
let code = item.dataset.code;246
if(code === 'download') {247
if(state.option.crop_mode) {248
state.option.crop_mode = false;249
canvas.draw_crop(state);250
canvas.get_canvas().style.cursor = 'default';251
}252
let data = canvas.create_capture(0, 0, window.innerWidth, window.innerHeight, 60);253
if(data) {254
node.download.download = `outline-${uuid()}.png`;255
node.download.href = data;256
node.download.click();257
}258
else {259
console.warn('Unable to create capture from current state!');260
}261
}262
if(code === 'crop') {263
state.option.crop_mode = true;264
state.region = [];265
canvas.draw_crop(state);266
canvas.get_canvas().style.cursor = 'crosshair';267
}268
state.modal = null;269
state.tab = null;270
update_modal_list();271
})272
}273
node.scale_input.addEventListener('input', function(event) {274
state.radius = parseInt(node.scale_input.value);275
state.point = {276
x: parseInt(window.innerWidth / 2),277
y: parseInt(window.innerHeight / 2)278
};279
canvas.draw_cursor(state);280
});281
node.clear.addEventListener('click', function(event) {282
canvas.clear(state);283
update_undo_and_redo();284
show_notification('notification.clear');285
state.modal = null;286
update_modal_list();287
});288
node.option_event_fullscreen.addEventListener('click', function(event) {289
if(!document.fullscreenElement) {290
document.documentElement.requestFullscreen();291
}292
else if(document.exitFullscreen) {293
document.exitFullscreen();294
}295
});296
window.addEventListener('fullscreenchange', on_fullscreenchange);297
node.option_event_view_mode.addEventListener('click', function(event) {298
state.option.view_mode = !state.option.view_mode;299
update_view_mode_option();300
});301
node.option_event_dark_mode.addEventListener('click', function(event) {302
state.option.dark_mode = !state.option.dark_mode;303
update_dark_mode_option();304
});305
node.undo_tool.addEventListener('click', function(event) {306
canvas.undo(state);307
update_undo_and_redo();308
});309
node.redo_tool.addEventListener('click', function(event) {310
canvas.redo(state);311
update_undo_and_redo();312
});313
node.edit_mode.addEventListener('click', function(event) {314
state.option.view_mode = false;315
update_view_mode_option();316
});317
for(let item of node.caption_list) {318
item.addEventListener('click', function(event) {319
state.caption = item.dataset.code;320
update_caption_list();321
});322
}324
window.addEventListener('beforeunload', function(event) {325
// ...326
});327
}329
function update_language_list() {330
let lang = locale.get_current();331
for(let item of node.language_list) {332
let code = item.dataset.code;333
item.classList[code === lang ? 'add' : 'remove']('active');334
}335
}337
function update_device_list() {338
if(!state.option.view_mode && !state.option.crop_mode) {339
canvas.get_canvas().style.cursor = state.device === 'mouse' ? 'none' : '';340
}341
for(let item of node.device_list) {342
let code = item.dataset.code;343
item.classList[code === state.device ? 'add' : 'remove']('active');344
item.classList[state.device_list[code] ? 'remove' : 'add']('inactive');345
}346
}348
function update_pencil_list() {349
for(let item of node.pencil_list) {350
let code = item.dataset.code;351
item.classList[code === state.pencil ? 'add' : 'remove']('active');352
if(code === state.pencil) {353
node.pencil_tool.querySelector('i.ico').innerHTML = item.querySelector('i.ico').innerHTML;354
}355
}356
}358
function update_hotbar() {359
for(let item of node.hotbar_list) {360
item.classList[node.hotbar_list[state.index] === item ? 'add' : 'remove']('active');361
}362
}364
function update_focus(bool) {365
for(let item of node.hotbar_list) {366
item.style.pointerEvents = bool ? '' : 'none';367
}368
for(let item of node.tool_list) {369
item.style.pointerEvents = bool ? '' : 'none';370
}371
for(let item of node.action_list) {372
item.style.pointerEvents = bool ? '' : 'none';373
}374
}376
function update_modal_list() {377
for(let item of node.modal_list) {378
item.classList.add('hidden');379
}380
for(let item of node.modal_event_list) {381
item.classList.remove('active');382
}383
state.tab = null;384
update_tab_list();385
state.caption = 'controls';386
update_caption_list();387
if(state.modal) {388
canvas.on_release(event, state, true);389
let modal = document.querySelector(`.modal.${state.modal}-modal`);390
let button = document.querySelector(`[data-event*=".modal"][data-code="${state.modal}"]`);391
if(modal) {392
modal.classList.remove('hidden');393
modal.animate([394
{ opacity: 0, marginTop: '-6px' },395
{ opacity: 1, marginTop: '0' }396
], {397
duration: 100,398
fill: 'both'399
});400
}401
if(button) {402
button.classList.add('active');403
}404
}405
}407
function update_tab_list() {408
for(let item of node.modal_list) {409
let main = item.querySelector('.main');410
if(main) {411
main.classList.remove('hidden');412
main.style.marginLeft = '0';413
}414
}415
for(let item of node.tab_list) {416
item.classList.add('hidden');417
}418
if(state.modal && state.tab) {419
let modal = document.querySelector(`.modal.${state.modal}-modal`);420
let tab = document.querySelector(`.${state.tab}-tab`);421
let main = modal.querySelector('.main');422
if(modal && tab && main) {423
tab.classList.remove('hidden');424
main.style.marginLeft = '-100%';425
main.classList.add('hidden');426
}427
}428
}430
function update_fullscreen_option() {431
let fullscreen = document.fullscreenElement;432
node.option_event_fullscreen.classList[fullscreen ? 'add' : 'remove']('active');433
node.option_event_fullscreen.querySelector('.ico').textContent = fullscreen ? 'toggle_on' : 'toggle_off';434
}436
function update_view_mode_option() {437
let view_mode = state.option.view_mode;438
show_notification(`notification.view-mode.${view_mode ? 'on' : 'off'}`);439
node.option_event_view_mode.classList[view_mode ? 'add' : 'remove']('active');440
node.option_event_view_mode.querySelector('.ico').textContent = view_mode ? 'toggle_on' : 'toggle_off';441
state.modal = null;442
state.tab = null;443
update_modal_list();444
if(view_mode) {445
canvas.on_release(null, state);446
canvas.clear_cursor();447
canvas.get_canvas().style.cursor = 'default';448
node.hotbar.classList.add('inactive');449
node.header.classList.add('inactive');450
node.hotbar.animate([451
{ opacity: 1 },452
{ opacity: 0, bottom: '-10px', pointerEvents: 'none' }453
], {454
easing: 'ease-out',455
duration: 250,456
fill: 'both'457
});458
node.mainbar.animate([459
{ opacity: 1, marginTop: 0 },460
{ opacity: 0, marginTop: '-60px' }461
], {462
easing: 'ease-out',463
duration: 250,464
fill: 'both'465
});466
node.sidebar.classList.remove('hidden');467
node.sidebar.animate([468
{ opacity: 0 },469
{ opacity: 1 }470
], {471
delay: 250,472
easing: 'ease-out',473
duration: 250,474
fill: 'both'475
});476
}477
else {478
state.option.crop_mode = false;479
canvas.draw_crop(state);480
canvas.on_release(null, state, true);481
canvas.get_canvas().style.cursor = 'none';482
node.hotbar.classList.remove('inactive');483
node.header.classList.remove('inactive');484
node.hotbar.animate([485
{ opacity: 0, bottom: '-10px' },486
{ opacity: 1, bottom: '30px' }487
], {488
easing: 'ease-out',489
duration: 250,490
fill: 'both'491
});492
node.mainbar.animate([493
{ opacity: 0, marginTop: '-60px' },494
{ opacity: 1, marginTop: 0 }495
], {496
easing: 'ease-out',497
duration: 250,498
fill: 'both'499
});500
node.sidebar.classList.add('hidden');501
}502
}504
const CONFIG_COOKIE_PROPERTY = 'outline.custom.accepted';506
function update_dark_mode_option(args) {507
let { passive = false } = args || {};508
let dark_mode = state.option.dark_mode;509
if(!passive) {510
show_notification(`notification.dark-mode.${dark_mode ? 'on' : 'off'}`);511
}512
node.option_event_dark_mode.classList[dark_mode ? 'add' : 'remove']('active');513
node.option_event_dark_mode.querySelector('.ico').textContent = dark_mode ? 'toggle_on' : 'toggle_off';514
document.body.classList[dark_mode ? 'add' : 'remove']('theme-dark');515
if(cookie.hasAccepted()) {516
localStorage.setItem('outline.custom.dark-mode', dark_mode);517
}518
}520
function update_undo_and_redo() {521
node.undo_tool.classList[state.history.length > 0 ? 'remove' : 'add']('inactive');522
node.redo_tool.classList[state.redo_history.length > 0 ? 'remove' : 'add']('inactive');523
}525
function update_caption_list() {526
for(let item of node.caption_list) {527
let code = item.dataset.code;528
item.classList[code === state.caption ? 'add' : 'remove']('active');529
}530
for(let item of node.content_list) {531
let code = item.dataset.code;532
item.classList[code === state.caption ? 'remove' : 'add']('hidden');533
}534
}536
function on_pointerdown(event) {537
// detect touch538
if(!state.device_list.touch && event.pointerType === 'touch') {539
state.device_list.touch = true;540
if(state.device) {541
show_notification('notification.input-device.touch.add');542
}543
else {544
state.device = 'touch';545
state.device_fallback = 'touch';546
}547
update_device_list();548
}549
// detect pen550
if(!state.device_list.pen && event.pointerType === 'pen') {551
state.device_list.pen = true;552
show_notification('notification.input-device.pencil.add');553
if(!state.device) {554
state.device = 'pen';555
state.device_fallback = 'pen';556
}557
update_device_list();558
}559
// drawing560
if(event.button == 0) {561
if(!state.option.view_mode && state.device === event.pointerType) {562
if(event.target === canvas.get_canvas()) {563
if(!PRIORITY_MODAL.includes(state.modal)) {564
update_focus(false);565
canvas.on_press(event, state);566
update_undo_and_redo();567
state.point = {568
x: event.layerX,569
y: event.layerY570
};571
canvas.draw_cursor(state);572
}573
}574
}575
if(state.option.view_mode && state.option.crop_mode) {576
if(event.target === canvas.get_canvas()) {577
state.crop = true;578
state.region = [];579
state.region[0] = { x: event.layerX, y: event.layerY };580
canvas.draw_crop(state);581
}582
}583
}584
}586
function on_pointermove(event) {587
// detect mouse588
if(!state.device_list.mouse && event.pointerType === 'mouse') {589
state.device_list.mouse = true;590
if(state.device) {591
show_notification('notification.input-device.mouse.add');592
}593
else {594
state.device = 'mouse';595
state.device_fallback = 'mouse';596
}597
update_device_list();598
}599
// drawing600
if(!state.option.view_mode && state.device === event.pointerType) {601
if(event.target === canvas.get_canvas()) {602
if(!PRIORITY_MODAL.includes(state.modal)) {603
canvas.on_move(event, state);604
}605
state.point = {606
x: event.layerX,607
y: event.layerY608
};609
}610
canvas.draw_cursor(state);611
}612
if(state.option.view_mode && state.option.crop_mode) {613
if(state.crop && event.target === canvas.get_canvas()) {614
state.region[1] = { x: event.layerX, y: event.layerY };615
canvas.draw_crop(state);616
}617
}618
}620
function on_pointerup(event) {621
if(event.button == 0) {622
if(!state.option.view_mode && state.device === event.pointerType) {623
canvas.on_release(event, state);624
update_undo_and_redo();625
update_focus(true);626
}627
if(state.option.view_mode && state.option.crop_mode) {628
if(state.crop && event.target === canvas.get_canvas()) {629
state.crop = false;630
state.region[1] = { x: event.layerX, y: event.layerY };631
canvas.draw_crop(state);632
let [ begin, end ] = state.region;633
let delta = {634
x: end.x - begin.x,635
y: end.y - begin.y636
};637
let x = begin.x < end.x ? begin.x : end.x;638
let y = begin.y < end.y ? begin.y : end.y;639
if(delta.x < 0) {640
delta.x *= -1;641
}642
if(delta.y < 0) {643
delta.y *= -1;644
}645
if(delta.x != 0 && delta.y != 0) {646
let data = canvas.create_capture(x, y, delta.x, delta.y);647
if(data) {648
node.download.download = `outline-${uuid()}.png`;649
node.download.href = data;650
node.download.click();651
state.option.crop_mode = false;652
canvas.draw_crop(state);653
canvas.get_canvas().style.cursor = 'default';654
}655
else {656
console.warn('Unable to create capture from current state!');657
}658
}659
}660
}661
}662
}664
function on_pointerout(event) {665
if(!state.option.view_mode && state.device === event.pointerType) {666
canvas.on_release(event, state);667
update_undo_and_redo();668
state.point = null;669
canvas.draw_cursor(state);670
}671
if(state.option.view_mode && state.option.crop_mode) {672
if(state.crop && event.target === canvas.get_canvas()) {673
state.crop = false;674
state.region = [];675
canvas.draw_crop(state);676
}677
}678
}680
function on_keydown(event) {681
if(!state.key[event.code]) {682
if(event.code === 'Escape') {683
if(state.tab) {684
state.tab = null;685
update_tab_list();686
return;687
}688
if(state.modal) {689
state.modal = null;690
update_modal_list();691
return;692
}693
if(state.option.view_mode && state.option.crop_mode) {694
state.option.crop_mode = false;695
canvas.draw_crop(state);696
canvas.get_canvas().style.cursor = 'default';697
}698
}699
if(!event.ctrlKey && !event.shiftKey && !event.altKey) {700
if(!state.option.view_mode) {701
if(event.code.startsWith('Digit')) {702
let i = parseInt(event.code.substr(5)) - 1;703
if(state.index !== i) {704
if(i >= 0 && i < state.color_list.length) {705
canvas.on_release(event, state);706
state.color = state.color_list[i];707
state.index = i;708
canvas.draw_cursor(state);709
update_hotbar();710
}711
}712
}713
if(event.code === 'KeyZ') {714
state.modal = state.modal !== 'colors' ? 'colors' : null;715
update_modal_list();716
}717
if(event.code === 'KeyX') {718
state.modal = state.modal !== 'scale' ? 'scale' : null;719
update_modal_list();720
}721
if(event.code === 'KeyC') {722
state.modal = state.modal !== 'pencil' ? 'pencil' : null;723
update_modal_list();724
}725
if(event.code === 'KeyV') {726
state.modal = state.modal !== 'clear' ? 'clear' : null;727
update_modal_list();728
}729
/*730
if(event.code === 'KeyB') {731
state.modal = state.modal !== 'multiplayer' ? 'multiplayer' : null;732
update_modal_list();733
}734
if(event.code === 'KeyN') {735
state.modal = state.modal !== 'account' ? 'account' : null;736
update_modal_list();737
}738
*/739
if(event.code === 'KeyM') {740
state.modal = state.modal !== 'more' ? 'more' : null;741
update_modal_list();742
}743
if(event.code === 'KeyQ') {744
canvas.on_release(event, state);745
state.pencil = state.pencil_list[0];746
canvas.draw_cursor(state);747
update_pencil_list();748
}749
if(event.code === 'KeyW') {750
canvas.on_release(event, state);751
state.pencil = state.pencil_list[1];752
canvas.draw_cursor(state);753
update_pencil_list();754
}755
if(event.code === 'KeyE') {756
canvas.on_release(event, state);757
state.pencil = state.pencil_list[2];758
canvas.draw_cursor(state);759
update_pencil_list();760
}761
if(event.code === 'KeyF') {762
if(!document.fullscreenElement) {763
document.documentElement.requestFullscreen();764
}765
else if(document.exitFullscreen) {766
document.exitFullscreen();767
}768
}769
}770
if(event.code === 'Space') {771
state.option.view_mode = !state.option.view_mode;772
update_view_mode_option();773
}774
}775
if(event.ctrlKey && !event.shiftKey && !event.altKey) {776
if(event.code === 'KeyY') {777
canvas.undo(state);778
update_undo_and_redo();779
}780
if(event.code === 'KeyZ') {781
canvas.redo(state);782
update_undo_and_redo();783
}784
}785
if(event.code === 'Enter') {786
if(state.modal === 'clear') {787
node.clear.click();788
}789
}790
state.key[event.code] = true;791
}792
}794
function on_keyup(event) {795
state.key[event.code] = false;796
}798
function on_wheel(event) {799
if(!state.option.view_mode && state.device === 'mouse') {800
if(event.target === canvas.get_canvas()) {801
let y = event.deltaY < 0 ? 1 : -1;802
if(state.radius + y > 2 - 1 && state.radius + y < 50 + 1) {803
canvas.on_release(event, state);804
state.radius += y;805
node.scale_input.value = state.radius;806
canvas.draw_cursor(state);807
}808
}809
}810
}812
function on_fullscreenchange(event) {813
update_fullscreen_option();814
}816
function fill_hotbar_list() {817
for(let [ i, item ] of Object.entries(node.hotbar_list)) {818
if(state.color_list.length > i) {819
item.style.background = COLORS[state.color_list[i]];820
item.addEventListener('click', function(event) {821
canvas.on_release(event, state);822
state.color = state.color_list[i];823
state.index = i;824
canvas.draw_cursor(state);825
update_hotbar();826
});827
if(state.index == i) {828
item.classList.add('active');829
}830
}831
}832
}834
function fill_modal_color_list() {835
for(let [ i, item ] of Object.entries(node.modal_color_list)) {836
if(COLORS.length > i) {837
item.style.background = COLORS[i];838
item.addEventListener('click', function(event) {839
canvas.on_release(event, state);840
state.color = i;841
state.modal = null;842
update_modal_list();843
canvas.draw_cursor(state);844
state.index = null;845
update_hotbar();846
});847
}848
}849
}851
function show_notification(message) {852
let code = uuid();853
state.timestamp = code;854
let content = node.notification.querySelector('.content');855
content.textContent = locale.get()[message];856
node.notification.animate([857
{ opacity: 0 },858
{ opacity: 1 }859
], {860
duration: 200,861
fill: 'both'862
});863
setTimeout(function() {864
if(state.timestamp === code) {865
node.notification.animate([866
{ opacity: 1 },867
{ opacity: 0 }868
], {869
duration: 200,870
fill: 'both'871
});872
}873
}, 1000);874
}