html5-infobeamer-dhcp/assets/js/custom/services/service.js

56 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-10-30 22:30:09 +01:00
'use strict';
import * as lodash from "../../lodash/lodash-core.js";
import * as sol from "../../solight/sol.js";
const process_data = (scheduleFile) =>
sol.processScheduleFile(scheduleFile);
const event_modus_string = (event) => {
const questionId = 1392;
const answers = sol.eventAnswers(event);
const answer = answers.filter(a => a.get('question') === questionId);
const modus = answer.length > 0 ? answer[0].get('answer') : '???';
return modus;
};
const trackIndexMap = new Map([
['Andere', 0],
['Ethik, Wissenschaft, Kultur & Gesellschaft', 1],
['Recht & Politik', 2],
['Netzwerke, Security, Hard- & Software', 3],
['Digitale Selbstverteidigung', 4]]);
const track_index = (track) =>
trackIndexMap.get(track);
const sort_tracks = (tracks) =>
lodash.sortBy(tracks, track_index);
const person_names_concat = (persons) =>
// persons.map(p => sol.personName(p)).join(', ');
// persons.map(p => sol.personName(p)).join(' & ');
persons.map(p => sol.personName(p)).join(' · ');
const ndash_fix_regexp = RegExp('\\s+-\\s+');
const ndash_fix_replacement = ' ';
const fix_dash = (string) =>
string.replace(ndash_fix_regexp, ndash_fix_replacement);
export {
process_data,
event_modus_string,
track_index,
sort_tracks,
person_names_concat,
fix_dash
}