MediaWiki:Gadget-watchlist.js: различия между версиями
Содержимое удалено Содержимое добавлено
м исправление |
используем mw.Api() для API-запроса вместо $.ajax() |
||
Строка 241:
function changeWatchState(e) {
var $star = $(this), errorMsg = '';
var req = {▼
title: getLinkTitle($star)▼
};▼
var action;
if ($star.attr('href').includes('&action=unwatch')) {
action = 'unwatch';
} else {
action = 'watch';
}
$star
.removeClass('gadgetWatchlist-failure')
.addClass('gadgetWatchlist-waiting');
new mw.Api().postWithToken('watch', {
unwatch: unwatch,
if (!resp.
errorMsg = resp.error.info;▼
} else if (!resp.watch) {▼
errorMsg = 'empty response';
} else if (typeof resp.watch[0].unwatched === '
changeWatchStateSuccess(
} else if (typeof resp.watch[0].watched === '
changeWatchStateSuccess(
} else {
errorMsg = strings.unrecognizedReponse;
}
},
data.textStatus ||
complete: function () { // update unwatch link▼
$star.removeClass('gadgetWatchlist-waiting');▼
(data.error && data.error.info)
$star▼
);
.attr('title', strings.error + ': ' + errorMsg)▼
.addClass('gadgetWatchlist-failure gadgetWatchlist-' + action + 'Link');▼
errorMsg += ': ' + errorText;
}
if (errorMsg) {
}
});
e.preventDefault();
}
|