MediaWiki:Gadget-eventslist.js: Difference between revisions

No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 16: Line 16:
// TODO: Cache Vos as well
// TODO: Cache Vos as well


;(function($, mw, rs){
;(function($, mw, gs){
var portletLink,
var portletLink,
$popup,
$popup,
Line 147: Line 147:


// Check browser supports notifications
// Check browser supports notifications
self.supportNotif = rs.canSendBrowserNotifs();
self.supportNotif = gs.canSendBrowserNotifs();
// TODO: Check if using service worker notifications
// TODO: Check if using service worker notifications


Line 226: Line 226:
autoClose: true,
autoClose: true,
classes: ['gsw-events-popup oo-ui-labelElement-invisible'],
classes: ['gsw-events-popup oo-ui-labelElement-invisible'],
hideWhenOutOfView: (rs.isUsingStickyHeader() ? true : false),
hideWhenOutOfView: (gs.isUsingStickyHeader() ? true : false),
invisibleLabel: true,
invisibleLabel: true,
label: 'Events',
label: 'Events',
Line 286: Line 286:
mw.log('Loading settings');
mw.log('Loading settings');
return new Promise( function (resolve, reject) {
return new Promise( function (resolve, reject) {
if (!rs.hasLocalStorage()) {
if (!gs.hasLocalStorage()) {
console.warn('Browser does not support localStorage');
console.warn('Browser does not support localStorage');
reject();
reject();
Line 318: Line 318:
}
}


if (!rs.hasLocalStorage()) {
if (!gs.hasLocalStorage()) {
console.warn('Browser does not support localStorage');
console.warn('Browser does not support localStorage');
return false;
return false;
Line 343: Line 343:
self.settings.notiftype[key] = value;
self.settings.notiftype[key] = value;


if (!rs.hasLocalStorage()) {
if (!gs.hasLocalStorage()) {
console.warn('Browser does not support localStorage');
console.warn('Browser does not support localStorage');
return false;
return false;
Line 1,403: Line 1,403:


// Latest rotations and settings from localStorage
// Latest rotations and settings from localStorage
if (rs.hasLocalStorage()) {
if (gs.hasLocalStorage()) {
var last = {};
var last = {};
try {
try {
Line 1,460: Line 1,460:
vosjson.districts.forEach( function (clan) {
vosjson.districts.forEach( function (clan) {
if (self.settings.notiftype['vos' + clan] && self.settings.notiftype.vos == 'Some' || self.settings.notiftype.allvos) {
if (self.settings.notiftype['vos' + clan] && self.settings.notiftype.vos == 'Some' || self.settings.notiftype.allvos) {
var img = rs.getFileURL(clan + ' Clan.png');
var img = gs.getFileURL(clan + ' Clan.png');
vosnotifs.push( { title:'VoS ' + clan, opts:{
vosnotifs.push( { title:'VoS ' + clan, opts:{
badge: img,
badge: img,
Line 1,477: Line 1,477:


// Save the last rotations to localstorage if possible
// Save the last rotations to localstorage if possible
if (rs.hasLocalStorage()) {
if (gs.hasLocalStorage()) {
var string = JSON.stringify(self.lastRot);
var string = JSON.stringify(self.lastRot);
try {
try {
Line 1,573: Line 1,573:
// Daily
// Daily
var dailyReset = moment(now).add(1, 'days').startOf('day'),
var dailyReset = moment(now).add(1, 'days').startOf('day'),
img = '/images/thumb/0/08/D%26D_token_%28daily%29_detail.png/200px-D%26D_token_%28daily%29_detail.png';
img = '';
if (dailyReset.diff(now, 'minutes') <= 10) {
if (dailyReset.diff(now, 'minutes') <= 10) {
notifs.push( { title:'Daily Reset', opts:{
notifs.push( { title:'Daily Reset', opts:{
Line 1,590: Line 1,590:
// Weekly
// Weekly
var weeklyReset = moment(now).day(3).startOf('day'),
var weeklyReset = moment(now).day(3).startOf('day'),
img = '/images/4/47/D%26D_token_%28weekly%29_detail.png';
img = '';
if (now.isAfter(weeklyReset)) {
if (now.isAfter(weeklyReset)) {
weeklyReset.add(1, 'week');
weeklyReset.add(1, 'week');
Line 1,622: Line 1,622:
// Monthly
// Monthly
var monthlyReset = moment(now).add(1, 'months').startOf('month'),
var monthlyReset = moment(now).add(1, 'months').startOf('month'),
img = '/images/thumb/a/a7/D%26D_token_%28monthly%29_detail.png/200px-D%26D_token_%28monthly%29_detail.png';
img = '';
if (monthlyReset.diff(now, 'minutes') <= 10) {
if (monthlyReset.diff(now, 'minutes') <= 10) {
notifs.push( { title:'Monthly Reset', opts:{
notifs.push( { title:'Monthly Reset', opts:{
Line 1,691: Line 1,691:
self.sendNotifs( dnotifs );
self.sendNotifs( dnotifs );
// Save the last rotations to localstorage if possible
// Save the last rotations to localstorage if possible
if (rs.hasLocalStorage()) {
if (gs.hasLocalStorage()) {
var string = JSON.stringify(self.lastRot);
var string = JSON.stringify(self.lastRot);
try {
try {
Line 1,748: Line 1,748:
// Generate notification
// Generate notification
if (pofnots.length > 0) {
if (pofnots.length > 0) {
var img = '/images/1/18/Farming.png',
var img = '',
nbod = 'Spawning soon:',
nbod = 'Spawning soon:',
len = pofnots.length,
len = pofnots.length,
Line 1,783: Line 1,783:
if (spot[0] != self.lastRot.mgspot) {
if (spot[0] != self.lastRot.mgspot) {
self.lastRot.mgspot = spot[0];
self.lastRot.mgspot = spot[0];
var img = '/images/c/c8/Current_spotlight_icon.png';
var img = '';


notifs.push( { title:'Minigame Spotlight', opts:{
notifs.push( { title:'Minigame Spotlight', opts:{
Line 1,824: Line 1,824:
// Save the last rotations to localstorage if possible
// Save the last rotations to localstorage if possible
if (rs.hasLocalStorage()) {
if (gs.hasLocalStorage()) {
var string = JSON.stringify(self.lastRot);
var string = JSON.stringify(self.lastRot);
try {
try {