/** NOTE: * depricated code for tag-system is commented-out and kept in the source-code * as case-study; the code is operational; */ // Globals // ----------------------------------------------------------------------------- // NOTE: // Variable `entity_id` is defined before evaluating this script // id (int) : the id of edited post (or 0 if new post) var lesson; var id = (entity_id == 0) ? false : entity_id; var categories = [ // Nope! root can not be a post's category ... { id: 0 , label: 'Ρίζα (root)' } ]; var privileges = [ { id: 0, label: '_Δημόσιο_'} ]; var files = []; // array of { id:.., title:.., type:.., path:.. } records // TODO: support tags // var tags = []; // array of integers // an alternative--id when a lesson_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 course record by course-id // --- -- -- - - - function course_record(id) { var record = 0; categories.forEach(el => { if (el.id == id) record = el; }); return record; } // Modal HTML Creators // ----------------------------------------------------------------------------- const modal_header = (title) => { return [ '