A web-based drawing app
git clone git://soophie.de/outline
130
state.option.dark_mode = true;131
update_dark_mode_option({ passive: true });132
}133
let lang = localStorage.getItem('outline.custom.lang');134
if(lang && LOCALES.includes(lang)) {135
locale.change(lang);136
update_language_list();137
}138
try {139
firebase.initializeApp(FIREBASE);140
firebase.analytics();
166
}, { passive: false });168
for(let item of node.language_list) {164
item.addEventListener('click', function(event) {169
item.addEventListener('click', function() {170
let code = item.dataset.code;171
locale.change(code);172
update_language_list();173
});174
}175
for(let item of node.device_list) {171
item.addEventListener('click', function(event) {176
item.addEventListener('click', function() {177
let code = item.dataset.code;178
if(state.device_list[code]) {179
state.device = code;
182
});183
}184
for(let item of node.pencil_list) {180
item.addEventListener('click', function(event) {185
item.addEventListener('click', function() {186
state.pencil = item.dataset.code;187
update_pencil_list();188
state.modal = null;
190
});191
}192
for(let item of node.modal_event_list) {188
item.addEventListener('click', function(event) {193
item.addEventListener('click', function() {194
let code = item.dataset.code;195
let match = /^(toggle|open|close).modal$/.exec(item.dataset.event);196
if(match) {
222
});223
}224
for(let item of node.tab_event_list) {220
item.addEventListener('click', function(event) {225
item.addEventListener('click', function() {226
let code = item.dataset.code;227
let match = /^(open|close).tab/.exec(item.dataset.event);228
if(match) {
246
});247
}248
for(let item of node.capture_event_list) {244
item.addEventListener('click', function(event) {249
item.addEventListener('click', function() {250
let code = item.dataset.code;251
if(code === 'download') {252
if(state.option.crop_mode) {
275
update_modal_list();276
})277
}273
node.scale_input.addEventListener('input', function(event) {278
node.scale_input.addEventListener('input', function() {279
state.radius = parseInt(node.scale_input.value);280
state.point = {281
x: parseInt(window.innerWidth / 2),
283
};284
canvas.draw_cursor(state);285
});281
node.clear.addEventListener('click', function(event) {286
node.clear.addEventListener('click', function() {287
canvas.clear(state);288
update_undo_and_redo();289
show_notification('notification.clear');290
state.modal = null;291
update_modal_list();292
});288
node.option_event_fullscreen.addEventListener('click', function(event) {293
node.option_event_fullscreen.addEventListener('click', function() {294
if(!document.fullscreenElement) {295
document.documentElement.requestFullscreen();296
}
299
}300
});301
window.addEventListener('fullscreenchange', on_fullscreenchange);297
node.option_event_view_mode.addEventListener('click', function(event) {302
node.option_event_view_mode.addEventListener('click', function() {303
state.option.view_mode = !state.option.view_mode;304
update_view_mode_option();305
});301
node.option_event_dark_mode.addEventListener('click', function(event) {306
node.option_event_dark_mode.addEventListener('click', function() {307
state.option.dark_mode = !state.option.dark_mode;308
update_dark_mode_option();309
});305
node.undo_tool.addEventListener('click', function(event) {310
node.undo_tool.addEventListener('click', function() {311
canvas.undo(state);312
update_undo_and_redo();313
});309
node.redo_tool.addEventListener('click', function(event) {314
node.redo_tool.addEventListener('click', function() {315
canvas.redo(state);316
update_undo_and_redo();317
});313
node.edit_mode.addEventListener('click', function(event) {318
node.edit_mode.addEventListener('click', function() {319
state.option.view_mode = false;320
update_view_mode_option();321
});322
for(let item of node.caption_list) {318
item.addEventListener('click', function(event) {323
item.addEventListener('click', function() {324
state.caption = item.dataset.code;325
update_caption_list();326
});327
}324
window.addEventListener('beforeunload', function(event) {329
window.addEventListener('beforeunload', function() {330
// ...331
});332
}
337
let code = item.dataset.code;338
item.classList[code === lang ? 'add' : 'remove']('active');339
}340
if(cookie.hasAccepted()) {341
localStorage.setItem('outline.custom.lang', lang);342
}343
}345
function update_device_list() {
509
}510
}504
const CONFIG_COOKIE_PROPERTY = 'outline.custom.accepted';512
function update_dark_mode_option(args) {513
let { passive = false } = args || {};514
let dark_mode = state.option.dark_mode;
773
}774
}775
}776
if(state.option.view_mode && !state.option.crop_mode) {777
if(event.code === 'KeyZ') {778
state.modal = state.modal !== 'capture' ? 'capture' : null;779
update_modal_list();780
}781
}782
if(event.code === 'Space') {783
state.option.view_mode = !state.option.view_mode;784
update_view_mode_option();
821
}822
}812
function on_fullscreenchange(event) {824
function on_fullscreenchange() {825
update_fullscreen_option();826
}
33
if(value === 'install') {34
element.addEventListener('click', function() {35
if(state.deferredPrompt) {36
/*37
state.deferredPrompt.prompt();38
state.deferredPrompt.userChoice.then(function(result) {38
// let installed = result.outcome === 'accepted';39
let installed = result.outcome === 'accepted';40
});41
*/42
}43
else {44
show_notification('main.upcoming');
117
if(dark_mode && dark_mode === 'true') {118
document.body.classList.add('theme-dark');119
}120
let lang = localStorage.getItem('outline.custom.lang');121
if(lang && LOCALES.includes(lang)) {122
locale.change(lang);123
}124
try {125
firebase.initializeApp(FIREBASE);126
firebase.analytics();
279
function set_data(data) {280
let image = new Image();281
image.onload = function(event) {281
image.onload = function() {282
g.drawImage(image, 0, 0);283
m.drawImage(image, 0, 0);284
t.drawImage(image, 0, 0);
1
const CONFIG_COOKIE_PROPERTY = 'outline.custom.accepted';3
function requestPermission(element) {4
return new Promise(function(resolve, reject) {4
return new Promise(function(resolve) {5
element.onclick = function() {6
localStorage.setItem(CONFIG_COOKIE_PROPERTY, true);7
resolve();
1
import { LOCALES } from '../constant.js';3
import cookie from './cookie.js';5
const LINE_BREAK_PATTERN = /\r\n|\r|\n/;6
const PROPERTY_PATTERN = /^([\w+.-]+)=([^=]*)$/;8
let lang = {};7
let default_lang;9
let current_lang;11
/**
16
*/17
function init() {18
let code = 'en';19
if(cookie.hasAccepted()) {20
let lang = localStorage.getItem('outline.custom.lang');21
if(lang && LOCALES.includes(lang)) {22
current_lang = lang;23
return;24
}25
}26
if(typeof navigator !== 'undefined') {27
if(LOCALES.includes(navigator.language)) {28
code = navigator.language;
39
}40
}41
}34
default_lang = code;42
current_lang = code;43
}
51
@param {string[]} locales - The list containing all locales.52
@return {Object} The locale object.53
*/47
async function load(path, locales, callback) {54
async function load(path, locales) {55
for(let code of locales) {56
let text = await fetch(`${path}/${code}.properties`)57
.then(function(response) {
67
lang[code] = parse(text);68
}69
}63
if(callback) {64
callback();65
}70
change(current_lang);71
}