// Globals // ----------------------------------------------------------------------------- // NOTE: // Variable `id` is defined before evaluating this script // id (int) : the id of edited post (or 0 if new post) var post; var categories = [ // Nope! root can not be a post's category ... { id: 0 , label: 'Ρίζα (root)' } ]; var tags = []; // array of integers var files = []; // array of { id:.., title:.., type:.., path:.. } records const files_root = 'https://cdn.sklavenitis.co.gr/'; // files root firectory var pageUrl = new URL(window.location.href); // an alternative--id when a post id not exists (needed for file-upload) // ... consist of a 6-digit date string + random number up to 999 const yymmdd = new Date().toISOString().slice(2, 10).replaceAll('-',''); var rnd999 = Math.floor(Math.random() * 1000); var altID = (id == 0) ? ( yymmdd +'-'+ rnd999.toString() ) : id; // Supplamentary functions // ----------------------------------------------------------------------------- // function for sorting an array by 'label' attribute // --- -- -- - - - function compare_label (a,b) { if ( a.label < b.label ) { return -1; } if ( a.label > b.label ) { return 1; } return 0; } // return category record by category-id // --- -- -- - - - function category_record(id) { var record = 0; categories.forEach(el => { if (el.id == id) record = el; }); return record; } // Modal HTML Creators // ----------------------------------------------------------------------------- const modal_header = (title) => { return [ '