make choosing announcement less trash
This commit is contained in:
parent
261c6f64d0
commit
65b657ca0a
1 changed files with 6 additions and 3 deletions
|
@ -12,7 +12,7 @@ let viewCounter = 0;
|
||||||
let files = [];
|
let files = [];
|
||||||
let day;
|
let day;
|
||||||
let month;
|
let month;
|
||||||
let announcementArray;
|
let announcementArray = [];
|
||||||
let announcement;
|
let announcement;
|
||||||
let defaultViewOption = { version: version, viewCounter: viewCounter, file: files, day: day, month: month, announcement: announcement, proxy: proxy }
|
let defaultViewOption = { version: version, viewCounter: viewCounter, file: files, day: day, month: month, announcement: announcement, proxy: proxy }
|
||||||
|
|
||||||
|
@ -34,8 +34,11 @@ class DownloadController {
|
||||||
async index ({ view, request, locale }) {
|
async index ({ view, request, locale }) {
|
||||||
viewCounter++;
|
viewCounter++;
|
||||||
defaultViewOption.viewCounter = viewCounter;
|
defaultViewOption.viewCounter = viewCounter;
|
||||||
// Couldn't find a cleaner way to make it change with the browser locale
|
|
||||||
announcementArray = [Antl.forLocale(locale).formatMessage('announcement.1'), Antl.forLocale(locale).formatMessage('announcement.2'), Antl.forLocale(locale).formatMessage('announcement.3'), Antl.forLocale(locale).formatMessage('announcement.4'), Antl.forLocale(locale).formatMessage('announcement.5'), Antl.forLocale(locale).formatMessage('announcement.6'), Antl.forLocale(locale).formatMessage('announcement.7')];
|
for (let i = 0; Antl.forLocale(locale)._messages.fr.announcement.length > i; i++) {
|
||||||
|
announcementArray.push(Antl.forLocale(locale).formatMessage(`announcement.${i + 1}`));
|
||||||
|
}
|
||||||
|
|
||||||
// Get random announcement
|
// Get random announcement
|
||||||
defaultViewOption.announcement = announcementArray[Math.floor(Math.random() * announcementArray.length)];
|
defaultViewOption.announcement = announcementArray[Math.floor(Math.random() * announcementArray.length)];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue