Files
firefly-iii/resources/assets/v2/bootstrap.js

52 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-07-11 11:45:55 +02:00
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
2023-07-23 07:10:31 +02:00
// import things
2023-07-11 11:45:55 +02:00
import axios from 'axios';
2023-07-23 07:10:31 +02:00
import store from "store";
import observePlugin from 'store/plugins/observe';
2023-07-22 16:42:33 +02:00
import Alpine from "alpinejs";
2023-07-24 18:58:35 +02:00
import * as bootstrap from 'bootstrap'
2023-07-23 07:10:31 +02:00
// add plugin to store and put in window
store.addPlugin(observePlugin);
window.store = store;
// import even more
2023-07-22 16:42:33 +02:00
import {getVariable} from "./store/get-variable.js";
import {getViewRange} from "./support/get-viewrange.js";
// wait for 3 promises, because we need those later on.
window.bootstrapped = false;
Promise.all([
getVariable('viewRange'),
getVariable('darkMode'),
2023-07-23 07:10:31 +02:00
getVariable('locale'),
getVariable('language'),
2023-07-22 16:42:33 +02:00
]).then((values) => {
2023-07-23 07:10:31 +02:00
if (!store.get('start') || !store.get('end')) {
2023-07-22 16:42:33 +02:00
// calculate new start and end, and store them.
const range = getViewRange(values[0], new Date);
store.set('start', range.start);
store.set('end', range.end);
}
2023-07-24 18:58:35 +02:00
// save local in window.__ something
2023-08-12 07:53:11 +02:00
window.__localeId__ = values[2];
store.set('language', values[3]);
store.set('locale', values[3]);
2023-07-24 18:58:35 +02:00
2023-07-22 16:42:33 +02:00
const event = new Event('firefly-iii-bootstrapped');
document.dispatchEvent(event);
window.bootstrapped = true;
});
2023-07-11 11:45:55 +02:00
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
2023-07-22 16:42:33 +02:00
window.Alpine = Alpine