User:Monster Domosed/common.js: Difference between revisionsGive feedback
No edit summary |
No edit summary |
||
| Line 40: | Line 40: | ||
{ id: 'warden', name: 'Warden' }, | { id: 'warden', name: 'Warden' }, | ||
{ id: 'wraith', name: 'Wraith' }, | { id: 'wraith', name: 'Wraith' }, | ||
{ id: 'yamato', name: 'Yamato | { id: 'yamato', name: 'Yamato' } | ||
]; | ]; | ||
| Line 79: | Line 78: | ||
} | } | ||
function applyStoredIcon() { | function applyStoredIcon() { | ||
var icon = getCachedIcon() || 'rem'; | var icon = getCachedIcon() || 'rem'; | ||
| Line 106: | Line 102: | ||
} | } | ||
function createIconSelector() { | function createIconSelector() { | ||
var currentIcon = getCachedIcon() || 'rem'; | var currentIcon = getCachedIcon() || 'rem'; | ||
| Line 144: | Line 137: | ||
if (remClickCount >= 5) { | if (remClickCount >= 5) { | ||
remClickCount = 0; | remClickCount = 0; | ||
var msg = buddyMessages[Math.floor(Math.random() * buddyMessages.length)]; | var msg = buddyMessages[Math.floor(Math.random() * buddyMessages.length)]; | ||
| Line 164: | Line 155: | ||
} | } | ||
function selectIcon(iconId) { | function selectIcon(iconId) { | ||
var currentIcon = getCachedIcon() || 'rem'; | |||
if (currentIcon === iconId) { | |||
return; | |||
} | |||
setCachedIcon(iconId); | |||
applyIcon(iconId); | |||
mw.loader.using(['mediawiki.api'], function () { | |||
var api = new mw.Api(); | |||
api.saveOption(PREFERENCE_KEY, iconId) | |||
.done(function () { | |||
if (iconId !== 'rem-helper') { | |||
mw.notify('Icon updated successfully!', { | |||
type: 'success' | |||
}); | |||
} | |||
}) | |||
.fail(function () { | |||
mw.notify('Failed to save icon.', { | |||
type: 'error' | |||
}); | |||
}); | |||
}); | |||
} | |||
mw.loader.using(['mediawiki.util'], function () { | mw.loader.using(['mediawiki.util'], function () { | ||
applyStoredIcon(); | applyStoredIcon(); | ||