User:NQ/custom-scripts/reset.js

//User:NQ/WatchlistResetConfirm.js

mw.loader.using(['mediawiki.api', 'oojs-ui'], function {

$watchlistReset = $('#mw-watchlist-resetbutton'); $watchlistReset.insertAfter('#watchlist-message'); $watchlistReset.css({'display': 'inline', 'float': 'right'}); var messageDialog = new OO.ui.MessageDialog; var windowManager = new OO.ui.WindowManager; $('body').append(windowManager.$element); windowManager.addWindows([messageDialog]);

$watchlistReset.submit(function(event) {   event.preventDefault;

windowManager.openWindow(messageDialog, {     title: 'Confirm',      message: 'Mark all pages as visited?',      actions: [{ action: 'reject', label: 'Cancel', flags: ['safe', 'destructive'] },               { action: 'reset', label: 'Confirm', flags: ['primary', 'progressive']}]    }).then(function(opened) {      opened.then(function(closing, data) { if (data && data.action === 'reset') { new mw.Api.post({           action: 'setnotificationtimestamp',            entirewatchlist: '',            token: mw.user.tokens.get('editToken')          }).done(function {            $('.mw-changeslist-line-watched').removeClass('mw-changeslist-line-watched').addClass('mw-changeslist-line-not-watched');          }); }      });    });  }); });