2016-07-23 08:12:31 +08:00
|
|
|
import Captions from '/imports/api/captions';
|
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-04-06 19:46:15 +08:00
|
|
|
import Settings from '/imports/ui/services/settings';
|
2016-07-23 08:12:31 +08:00
|
|
|
|
|
|
|
let getCCData = () => {
|
|
|
|
const meetingID = Auth.meetingID;
|
2016-08-10 06:35:16 +08:00
|
|
|
|
2017-04-06 19:46:15 +08:00
|
|
|
const ccSettings = Settings.cc;
|
2016-12-23 16:26:22 +08:00
|
|
|
|
2017-04-06 19:46:15 +08:00
|
|
|
let CCEnabled = ccSettings.enabled;
|
2016-08-10 06:35:16 +08:00
|
|
|
|
2016-08-09 05:45:09 +08:00
|
|
|
//associative array that keeps locales with arrays of string objects related to those locales
|
|
|
|
let captions = [];
|
2016-07-23 08:12:31 +08:00
|
|
|
|
2016-12-23 16:26:22 +08:00
|
|
|
//list of unique locales in the Captions Collection
|
2017-02-22 04:29:36 +08:00
|
|
|
if (CCEnabled) {
|
2016-12-23 16:26:22 +08:00
|
|
|
let locales = _.uniq(Captions.find({}, {
|
|
|
|
sort: { locale: 1 },
|
|
|
|
fields: { locale: true },
|
|
|
|
}).fetch().map(function (obj) {
|
|
|
|
return obj.locale;
|
|
|
|
}), true);
|
|
|
|
|
2016-12-24 02:49:17 +08:00
|
|
|
locales.forEach((locale) => {
|
2016-12-23 16:26:22 +08:00
|
|
|
let captionObjects = Captions.find({
|
|
|
|
meetingId: meetingID,
|
|
|
|
locale: locale,
|
|
|
|
}, {
|
|
|
|
sort: {
|
|
|
|
locale: 1,
|
|
|
|
'captionHistory.index': 1,
|
|
|
|
},
|
|
|
|
}).fetch();
|
|
|
|
|
|
|
|
let current = captionObjects[0];
|
|
|
|
captions[current.locale] = {
|
|
|
|
ownerId: current.captionHistory.ownerId ? current.captionHistory.ownerId : null,
|
|
|
|
captions: [],
|
|
|
|
};
|
|
|
|
while (current != null) {
|
|
|
|
captions[current.locale].captions.push({
|
|
|
|
captions: current.captionHistory.captions,
|
|
|
|
index: current.captionHistory.index,
|
|
|
|
});
|
|
|
|
current = captionObjects[current.captionHistory.next];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2016-07-23 08:12:31 +08:00
|
|
|
|
2016-12-23 16:26:22 +08:00
|
|
|
//fetching settings for the captions
|
2017-02-22 04:29:36 +08:00
|
|
|
let selectedLocale = ccSettings.locale;
|
|
|
|
let ccFontFamily = ccSettings.fontFamily ? ccSettings.fontFamily : 'Arial';
|
|
|
|
let ccFontSize = ccSettings.fontSize ? ccSettings.fontSize : 18;
|
|
|
|
let ccBackgroundColor = ccSettings.backgroundColor ? ccSettings.backgroundColor : '#f3f6f9';
|
|
|
|
let ccFontColor = ccSettings.fontColor ? ccSettings.fontColor : '#000000';
|
2016-07-23 08:12:31 +08:00
|
|
|
return {
|
2016-12-23 16:26:22 +08:00
|
|
|
locale: selectedLocale,
|
|
|
|
fontFamily: ccFontFamily,
|
|
|
|
fontSize: ccFontSize,
|
|
|
|
fontColor: ccFontColor,
|
|
|
|
backgroundColor: ccBackgroundColor,
|
2016-07-23 08:12:31 +08:00
|
|
|
captions: captions,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
getCCData,
|
|
|
|
};
|