From 20bbcd8e12cc9552e7cdec9415d9434397b54d9a Mon Sep 17 00:00:00 2001 From: OldHawk Date: Sun, 28 Jan 2018 21:21:28 +0800 Subject: [PATCH] feat(core): show new examination notice message at top of home --- config/env/torrents.js | 54 ++++++++++++++++--- modules/core/client/app/trans-string-en.js | 3 +- modules/core/client/app/trans-string-zh.js | 3 +- .../controllers/home.client.controller.js | 48 +++++++++++++++++ modules/core/client/less/home.less | 33 ++++++++++++ modules/core/client/less/mt.less | 26 --------- .../core/client/views/home.client.view.html | 12 ++++- 7 files changed, 144 insertions(+), 35 deletions(-) diff --git a/config/env/torrents.js b/config/env/torrents.js index b1288766..002c7910 100644 --- a/config/env/torrents.js +++ b/config/env/torrents.js @@ -866,12 +866,17 @@ module.exports = { * * Global torrent sales settings * - * @global: global sale settings - * @value: number value of @torrentSalesType, like 'U2/Free' etc, this value priority torrent @torrentSalesType - * @vip: vip sale settings - * @value: upload and download ratio - * @Ur: upload ratio, like 1.25 is upload scaling plus 25% - * @Dr: download ratio + * @global: global sale settings + * @value: number value of @torrentSalesType, like 'U2/Free' etc, this value priority torrent @torrentSalesType + * @startAt: sale start time + * @expires: sale expires time + * @noticeMsg: notice translate string show at top of home + * @noticeShowAt: notice begin time to show + * @timeFormats: time string format + * @vip: vip sale settings + * @value: upload and download ratio + * @Ur: upload ratio, like 1.5 is upload scaling plus 50% + * @Dr: download ratio */ torrentGlobalSales: { global: { @@ -887,6 +892,43 @@ module.exports = { } }, + /** + * @examination + * + * examination system settings + * + * @incrementData: examination requirements data settings + * @upload: increment uploaded data size + * @download: increment downloaded data size + * @score: increment score number + * @timeSet: examination time settings + * @startAt: examination start time + * @endAt: examination end time + * @noticeMsg: notice translate string show at top of home + * @noticeShowAt: notice begin time to show + * @timeFormats: time string format + * + * ------------------------------------------------------------------------------ + * !IMPORTANT NOTE: + * IF YOU START A NEW EXAMINATION, PLEASE SETTING THESE CONFIGURE ITEMS, + * AND INIT ALL USER ACCOUNT`S EXAMINATION INFO BEFORE THE EXAMINATION STARTING + * ------------------------------------------------------------------------------ + */ + examination: { + incrementData: { + upload: 1024 * 1024 * 1024 * 500, //500G + download: 1024 * 1024 * 1024 * 300, //300G + score: 20000 + }, + timeSet: { + startAt: '2018-02-01 00:00:00', + endAt: '2018-03-01 00:00:00', + noticeMsg: 'SITE_NOTICE.EXAMINATION_NOTICE', + noticeShowAt: '2018-01-28 00:00:00', + timeFormats: 'YYYY-MM-DD HH:mm:ss' + } + }, + /** * @chat * diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 5ede6e90..0d357f27 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -1563,7 +1563,8 @@ }, SITE_NOTICE: { - GLOBAL_SALES_NOTICE: '### IMPORTANT NOTICE: \n :radio: **Happy new year 2018**, **{{site_name}}** global sale is coming, sales value is **{{sale_value}}**, sales start at **{{sale_start_at | date: "yyyy-MM-dd HH:mm"}}** and continued **{{sale_days}}** days and end at **{{sale_end_at | date: "yyyy-MM-dd HH:mm"}}**, Thank you for all the help and support you have been giving us all the time!' + GLOBAL_SALES_NOTICE: '### IMPORTANT NOTICE: \n :radio: **Happy new year 2018**, **{{site_name}}** global sale is coming, sales value is **{{sale_value}}**, sales start at **{{sale_start_at | date: "yyyy-MM-dd HH:mm"}}** and continued **{{sale_days}}** days and end at **{{sale_end_at | date: "yyyy-MM-dd HH:mm"}}**, Thank you for all the help and support you have been giving us all the time!', + EXAMINATION_NOTICE: '### IMPORTANT NOTICE: \n :radio: **{{site_name}}** will take a new incremental examination from **{{examination_start_at | date: "yyyy-MM-dd HH:mm"}}** to **{{examination_end_at | date: "yyyy-MM-dd HH:mm"}}**, Incremental data requirements: upload **{{data_upload | bytes:2}}**, download **{{data_download | bytes:2}}**, score **{{data_score}}**, Please arrange your own time and hope to pass the exam smoothly. All VIP users are exempt from this examination, The unfinished user account will be banned.' } }; diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 60af84d6..333f4aa2 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -1563,7 +1563,8 @@ }, SITE_NOTICE: { - GLOBAL_SALES_NOTICE: '### 重要通知! \n :radio: **新年快乐 2018**, **{{site_name}}** 新年促销活动已准备就绪, 促销活动类型为 **{{sale_value}}** , 活动将开始于 **{{sale_start_at | date: "yyyy-MM-dd HH:mm"}}** 并持续 **{{sale_days}}** 天, 结束于 **{{sale_end_at | date: "yyyy-MM-dd HH:mm"}}**, 并感谢所有会员用户一直以来给予我们的帮助与支持!' + GLOBAL_SALES_NOTICE: '### 重要通知! \n :radio: **新年快乐 2018**, **{{site_name}}** 新年促销活动已准备就绪, 促销活动类型为 **{{sale_value}}** , 活动将开始于 **{{sale_start_at | date: "yyyy-MM-dd HH:mm"}}** 并持续 **{{sale_days}}** 天, 结束于 **{{sale_end_at | date: "yyyy-MM-dd HH:mm"}}**, 并感谢所有会员用户一直以来给予我们的帮助与支持!', + EXAMINATION_NOTICE: '### 重要通知!: \n :radio: **{{site_name}}** 将从 **{{examination_start_at | date: "yyyy-MM-dd HH:mm"}}** 到 **{{examination_end_at | date: "yyyy-MM-dd HH:mm"}}** 进行一次新的增量考试, 增量数据要求: 上传 **{{data_upload | bytes:2}}**, 下载 **{{data_download | bytes:2}}**, 积分 **{{data_score}}**, 请各位会员安排好自已的时间,并祝您顺利通过这次考试. 所有vip用户可免于此次考试, 考试未达标的用户帐号将会被禁止.' } }; diff --git a/modules/core/client/controllers/home.client.controller.js b/modules/core/client/controllers/home.client.controller.js index a11d534b..e10ec787 100644 --- a/modules/core/client/controllers/home.client.controller.js +++ b/modules/core/client/controllers/home.client.controller.js @@ -16,6 +16,7 @@ vm.appConfig = MeanTorrentConfig.meanTorrentConfig.app; vm.TGI = TorrentGetInfoServices; vm.globalSalesConfig = MeanTorrentConfig.meanTorrentConfig.torrentGlobalSales; + vm.examinationConfig = MeanTorrentConfig.meanTorrentConfig.examination; vm.forumsConfig = MeanTorrentConfig.meanTorrentConfig.forumsConfig; vm.itemsPerPageConfig = MeanTorrentConfig.meanTorrentConfig.itemsPerPage; @@ -107,6 +108,53 @@ }, 1000); }; + /** + * getExaminationNoticeMessage + * @returns {*} + */ + vm.getExaminationNoticeMessage = function () { + var start = moment(vm.examinationConfig.timeSet.startAt, vm.examinationConfig.timeSet.timeFormats).valueOf(); + var end = moment(vm.examinationConfig.timeSet.endAt, vm.examinationConfig.timeSet.timeFormats).valueOf(); + var ts = $translate.instant('SITE_NOTICE.EXAMINATION_NOTICE', { + site_name: vm.appConfig.name, + examination_start_at: start, + examination_end_at: end, + data_upload: vm.examinationConfig.incrementData.upload, + data_download: vm.examinationConfig.incrementData.download, + data_score: vm.examinationConfig.incrementData.score + }); + + return marked(ts, {sanitize: false}); + }; + + /** + * showExaminationNotice + * @returns {boolean} + */ + vm.showExaminationNotice = function () { + var showat = moment(vm.examinationConfig.timeSet.noticeShowAt, vm.examinationConfig.timeSet.timeFormats).valueOf(); + var start = moment(vm.examinationConfig.timeSet.startAt, vm.examinationConfig.timeSet.timeFormats).valueOf(); + var now = Date.now(); + + if (now > showat && now < start) { + return true; + } else { + return false; + } + }; + + /** + * openExaminationNotice + */ + vm.openExaminationNotice = function () { + var e = $('.examination_notice'); + + $timeout(function () { + e.slideDown(800); + e.removeClass('panel-collapsed'); + }, 1000); + }; + /** * onCloseNoticeClicked * @param cls diff --git a/modules/core/client/less/home.less b/modules/core/client/less/home.less index 379aae18..d90d2731 100644 --- a/modules/core/client/less/home.less +++ b/modules/core/client/less/home.less @@ -1,5 +1,38 @@ @import (reference) "../../../core/client/less/mt-var.less"; +.home_notice { + padding-top: 20px; + .alert { + position: relative; + } + h3, .h3 { + margin-top: 10px; + } + p { + font-size: 16px; + } + .sale_key { + color: @brand-danger; + } + .fa-close { + position: absolute; + top: 20px; + right: 20px; + cursor: pointer; + color: #888; + &:hover { + color: @brand-danger; + } + } +} + +.sales_notice { + background-color: @brand-success; +} +.examination_notice { + background-color: @brand-danger; +} + .home-help, .home-notice, .home-new-topic, .home-new-torrents { margin: 20px 0; color: #4d4e53; diff --git a/modules/core/client/less/mt.less b/modules/core/client/less/mt.less index 4cc36a1a..9fdca5c1 100644 --- a/modules/core/client/less/mt.less +++ b/modules/core/client/less/mt.less @@ -1834,32 +1834,6 @@ body { word-break: break-all; } -.sales_notice { - background-color: @brand-success; - padding-top: 20px; - .alert { - position: relative; - } - h3, .h3 { - margin-top: 10px; - } - p { - font-size: 16px; - } - .sale_key { - color: @brand-danger; - } - .fa-close { - position: absolute; - top: 20px; - right: 20px; - cursor: pointer; - &:hover { - color: @brand-danger; - } - } -} - //popup overlay---------------------------------------------- /* csslint ignore:start */ .warning_popup { diff --git a/modules/core/client/views/home.client.view.html b/modules/core/client/views/home.client.view.html index 46b734d0..125b78af 100644 --- a/modules/core/client/views/home.client.view.html +++ b/modules/core/client/views/home.client.view.html @@ -1,5 +1,5 @@
-