2026-01-24 14:43:58 +01:00
|
|
|
import {type Can_Upload_Detail, I} from "./globals";
|
2026-01-13 19:15:47 +01:00
|
|
|
import {Upload} from "./class-upload";
|
|
|
|
|
import {DropContainer} from "./class-drop-container";
|
|
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
|
|
2026-01-24 14:43:58 +01:00
|
|
|
if( !document.getElementById( 'file-container' ) ) // Check if exists.
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Add PostID if edit.
|
|
|
|
|
let url_params = new URLSearchParams(window.location.search);
|
|
|
|
|
I.is_edit = url_params.has( 'edit_entry' );
|
|
|
|
|
I.reserved_post_id = url_params.get('edit_entry' ) || null;
|
2026-01-13 19:15:47 +01:00
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
I.drop_container = new DropContainer( document.getElementById( 'file-container' ) as HTMLElement, document.getElementById( 'file-container-text' ) as HTMLElement );
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
document.addEventListener( 'can_upload', (e: CustomEvent<Can_Upload_Detail> ) => {
|
|
|
|
|
|
|
|
|
|
const { file } = e.detail;
|
2026-01-24 14:43:58 +01:00
|
|
|
if( !I.during_upload ) // @ts-ignore
|
2026-01-13 19:15:47 +01:00
|
|
|
I.upload = new Upload( file );
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
})
|