|
|
|
function onQuestsCompleteNotification(notificationData) {
|
|
|
|
var questType = notificationData.questType;
|
|
|
|
var deltaPoints = notificationData.deltaPoints;
|
|
|
|
var completeNum = notificationData.completeNum;
|
|
|
|
var periodQuestNumber = notificationData.periodQuestNumber;
|
|
|
|
var periodType = notificationData.periodType;
|
|
|
|
|
|
|
|
var pointMsgList = [];
|
|
|
|
deltaPoints.forEach(function (pointDeltaInfo) {
|
|
|
|
var msg = mw.msg('isekai-userpoints-point-name-num', pointDeltaInfo.name, pointDeltaInfo.icon, pointDeltaInfo.points);
|
|
|
|
pointMsgList.push(msg);
|
|
|
|
|
|
|
|
var separator = mw.msg('comma-separator');
|
|
|
|
var pointMsg = pointMsgList.join(separator);
|
|
|
|
|
|
|
|
var actionMsg = mw.msg('isekai-quests-type-' + questType + '-notification');
|
|
|
|
|
|
|
|
var completeNumMsg = '';
|
|
|
|
switch (periodType) {
|
|
|
|
case 'daily':
|
|
|
|
completeNumMsg = mw.msg('isekai-quests-daily-count', completeNum, periodQuestNumber);
|
|
|
|
break;
|
|
|
|
case 'weekly':
|
|
|
|
completeNumMsg = mw.msg('isekai-quests-weekly-count', completeNum, periodQuestNumber);
|
|
|
|
break;
|
|
|
|
case 'monthly':
|
|
|
|
completeNumMsg = mw.msg('isekai-quests-monthly-count', completeNum, periodQuestNumber);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
var notificationMsg = mw.msg('isekai-quests-complete-notification-message', actionMsg, pointMsg, completeNumMsg);
|
|
|
|
|
|
|
|
mw.notify('', {
|
|
|
|
title: mw.msg('isekai-quests-complete-notification-title'),
|
|
|
|
tag: 'isekai-userpoints-quest',
|
|
|
|
id: 'isekai-userpoints-quest-notify',
|
|
|
|
});
|
|
|
|
|
|
|
|
function changeNotifyContent() {
|
|
|
|
var notifyDom = document.querySelector('#isekai-userpoints-quest-notify');
|
|
|
|
if (notifyDom) {
|
|
|
|
notifyDom.querySelector('.mw-notification-content').innerHTML = notificationMsg;
|
|
|
|
} else {
|
|
|
|
requestAnimationFrame(changeNotifyContent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
changeNotifyContent();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
mw.hook('postEdit').add(function (data) {
|
|
|
|
console.log('onPostEdit');
|
|
|
|
|
|
|
|
var mwApi = new mw.Api();
|
|
|
|
mwApi.get({
|
|
|
|
action: 'userquestsgetnotification',
|
|
|
|
}).done(function (data) {
|
|
|
|
if (data.userquestsgetnotification && data.userquestsgetnotification.notification) {
|
|
|
|
onQuestsCompleteNotification(data.userquestsgetnotification.notification);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|