MediaWiki:Gadget-eventslist.js: Difference between revisions
No edit summary |
No edit summary |
||
| Line 16: | Line 16: | ||
// TODO: Cache Vos as well | // TODO: Cache Vos as well | ||
;(function($, mw, | ;(function($, mw, gs){ | ||
var portletLink, | var portletLink, | ||
$popup, | $popup, | ||
| Line 147: | Line 147: | ||
// Check browser supports notifications | // Check browser supports notifications | ||
self.supportNotif = | 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: ( | 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 (! | if (!gs.hasLocalStorage()) { | ||
console.warn('Browser does not support localStorage'); | console.warn('Browser does not support localStorage'); | ||
reject(); | reject(); | ||
| Line 318: | Line 318: | ||
} | } | ||
if (! | 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 (! | 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 ( | 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 = | 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 ( | if (gs.hasLocalStorage()) { | ||
var string = JSON.stringify(self.lastRot); | var string = JSON.stringify(self.lastRot); | ||
try { | try { | ||
| 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 ( | if (gs.hasLocalStorage()) { | ||
var string = JSON.stringify(self.lastRot); | var string = JSON.stringify(self.lastRot); | ||
try { | try { | ||
| Line 1,824: | Line 1,824: | ||
// Save the last rotations to localstorage if possible | // Save the last rotations to localstorage if possible | ||
if ( | if (gs.hasLocalStorage()) { | ||
var string = JSON.stringify(self.lastRot); | var string = JSON.stringify(self.lastRot); | ||
try { | try { | ||