「利用者:Dragoniez/scripts/AN Reporter.js」の版間の差分
削除された内容 追加された内容
m v4.6.1: 前回と同様、またAPIのコードがいじられたような挙動を確認したため対応 |
v4.7: 予告通り、LTAの名称はAPIから取得する方式に変更 (ANR-R008) |
||
2行目:
* AN Reporter (ANR)
* Author: Dragoniez
* Version: 4.
*************************************/
//<nowiki>
72行目:
var scriptAd = ' ([[User:Dragoniez/AN Reporter|AN Reporter]])';
}
if (debugMode.portletLink) {
var portletLinkText = '報告β';
} else {
var portletLinkText = '報告';
}
// Skin-dependent options
178行目:
const KIYOSHIMA = 'Wikipedia:管理者伝言板/投稿ブロック/清島達郎';
const SHINJU = 'Wikipedia:管理者伝言板/投稿ブロック/真珠王子';
// Username input
let userHtml =
355 ⟶ 230行目:
` </div>` +
` </div>` +
` <div class="anr-section-i-div" style="${marginCSS} display: none;">` +
` <select id="anr-section-i-select" style="${siCSS}">` +
` <option selected disabled hidden class="anr-section-options-initial">選択してください</option>` +
` <option id="anr-section-i-options-date"></option>` +
` <option>不適切な利用者名</option>` +
` <option>公開アカウント</option>` +
` <option>公開プロキシ・ゾンビマシン・ボット・不特定多数</option>` +
` <option>犯罪行為またはその疑いのある投稿</option>` +
` </select>` +
` </div>` +
` <div class="anr-section-s-div" style="${marginCSS} display: none;">` +
` <label for="anr-section-s-select" style="${labelCSS}">名称</label>` +
` <select id="anr-section-s-select" style="${siCSS}">` +
` <option selected disabled hidden class="anr-section-options-initial">選択してください</option>` +
` <optgroup label="系列が立てられていないもの">` +
` <option>著作権侵害・犯罪予告</option>` +
` <option>名誉毀損・なりすまし・個人情報</option>` +
` <option>妨害編集・いたずら</option>` +
` <option>その他</option>` +
` </optgroup>` +
` <optgroup id="anr-section-s-lta" label="LTA">` +
// getSectionsS()
` </optgroup>` +
` </select>` +
` </div>` +
` <div class="anr-user-div" style="${marginCSS}">` +
414 ⟶ 312行目:
// Function to initialze the modal dialog
function initializeDialog(){
// Get sections on WP:AN/S
getSectionsS();
// Initialize the design of the dialog
// Show VIP list
VIPList();
// Show the select box for predefined reasons if they're predefined by the user
getPredefinedReasons();
// Initialize variables
475 ⟶ 379行目:
}
}
// Function to get sections on WP:AN/S from the API
function getSectionsS() {
new mw.Api().get({
'action': 'parse',
'page': ANS,
'prop': 'sections',
'formatversion': 2
}).then(function(res){
if (res && res.parse) {
// Get VIP's names
const sectionInfo = res.parse.sections;
const excludeList = [
'系列が立てられていないもの',
'著作権侵害・犯罪予告',
'名誉毀損・なりすまし・個人情報',
'妨害編集・いたずら',
'その他',
'A. 最優先',
'暫定A',
'休止中A',
'B. 優先度高',
'暫定B',
'休止中B',
'C. 優先度中',
'暫定C',
'休止中C',
'D. 優先度低',
'暫定D',
'休止中D',
'N. 未分類',
'サブページなし',
'休止中N'
];
let sectionList = [];
for (let i = 0; i < sectionInfo.length; i++) {
if (!isInArray(sectionInfo[i].line, excludeList) && sectionInfo[i].index.indexOf('T') === -1) {
sectionList.push(`<option>${sectionInfo[i].line}</option>`);
}
}
$('#anr-section-s-lta').append(sectionList.join(''));
} else {
alert('WP:AN/Sのセクションリストを取得できませんでした。ダイアログを開き直すと改善する場合があります。');
}
}).catch(function(){
alert('WP:AN/Sのセクションリストを取得できませんでした。ダイアログを開き直すと改善する場合があります。');
});
}
// Function to change the CSS of the dialog and to get predifined reasons
function dialogCSS() {
// CSS for the dialog
493 ⟶ 446行目:
$('.ui-dialog').css('font-size', fSize);
}
// function getPredefinedReasons() {
if (typeof anrPredefinedReasons !== 'undefined') { // If the user has fixed reasons prepared
514 ⟶ 469行目:
alert('エラー: common.js内の定型文の変数定義が不正です。配列 "[理由1, 理由2...]" 形式で指定してください。');
}
}
}
561 ⟶ 516行目:
' <select id="anr-viplist-select">' +
' <option selected disabled hidden>[[Wikipedia:進行中の荒らし行為]]を検索</option>' +
vipList.join('') +
' </select>' +
` <button type="button" class="anr-viplist-btn" style="${btnCSS}">コピー</button>` +
673 ⟶ 628行目:
// Get the name of the section to edit
let pageToEdit = $('#anr-target-options').children('option').filter(':selected').text();
let sectionToEdit = '選択してください';
let fixedReason = $('#anr-predefinedreasons-select').find('option').filter(':selected').text();
let reportToANS = false;
680 ⟶ 634行目:
if (pageToEdit === ANI) { // If WP:AN/I is selected as the target page to edit
sectionToEdit = $('#anr-section
// Update the target section for cases in which the date has changed since the date-dependent section was chosen
if (sectionToEdit.match(/^\d{4}年\d{1,2}月\d{1,2}日 - \d{1,2}日新規報告$/) !== null) {
sectionToEdit = getSectionI(false);
$('#anr-section
}
691 ⟶ 645行目:
reportToANS = true;
const ANSOptSelected = $('#anr-section-s-select').find('option').filter(':selected').text();
switch(ANSOptSelected) {
case 'Iccic系 (Iccic)':
722 ⟶ 677行目:
}
// The reason of the report
fixedReason = fixedReason === '定型文を使用する場合は選択してください' ? '': fixedReason;
let reason = fixedReason + $('#anr-reason-text').val().trim2();
833 ⟶ 788行目:
// Initialize the design of the dialog
// Convert text on the dialog to html
1,735 ⟶ 1,690行目:
// Initialize the design of the dialog
// Convert the wikitext to an html form
2,072 ⟶ 2,027行目:
$(document).off('change', '#anr-target-options').on('change', '#anr-target-options', function(){
const selectedTar = $(this).children('option').filter(':selected').text();
$('.anr-section-options-initial').prop('selected', true); // Reset the dropdown value
switch(selectedTar) {
case ANI:
$('.anr-section-i-div').
$('.anr-section-s-div').
$('#anr-section
$('#anr-section
$('.anr-target-pagelink-div').css('display', 'block');
$('#anr-target-pagelink').attr('href', mw.util.getUrl(ANI));
break;
case ANS:
$('.anr-section-i-div').
$('.anr-section-s-div').
$('#anr-section
//$('#select2-anr-section
$('.anr-target-pagelink-div').css('display', 'block');
$('#anr-target-pagelink').attr('href', mw.util.getUrl(ANS));
break;
case AN3RR:
$('.anr-section-i-div').
$('.anr-section-s-div').css('display', 'none');
$('.anr-target-pagelink-div').css('display', 'block');
$('#anr-target-pagelink').attr('href', mw.util.getUrl(AN3RR));
2,101 ⟶ 2,055行目:
// Add section name to the '報告先' link when section is specified
$(document).off('change', '#anr-section
.on('change', '#anr-section
let tarSection = '';
let tarPage = '';
if ($(this).attr('id') === 'anr-section
tarPage = ANI;
} else if ($(this).attr('id') === 'anr-section
tarPage = ANS;
}
2,629 ⟶ 2,583行目:
} else {
resolve(res.query.logevents[0].logid);
}
});
});
|