「利用者:Dragoniez/scripts/AN Reporter.js」の版間の差分

削除された内容 追加された内容
致命的なバグを発見したため一旦v4.4にダウングレード Dragoniez (会話) による ID:88612726 の版を取り消し
タグ: 取り消し
v4.5 (修正版): 定型文報告機能の追加
2行目:
* AN Reporter (ANR)
* Author: Dragoniez
* Version: 4.45
*************************************/
//<nowiki>
336行目:
const modalHtml =
`<div class="anr-modal-dialog" title="AN Reporter" style="max-height: 80vh;">` +
` <div class="anr-modal-header">` +
` <h2>利用者を報告</h2>` +
` </div>` +
` <div class="anr-modal-body">` +
` <form>` +
` <div class="anr-target-div" style="${marginCSS}">` +
` <label for="anr-target-options" style="${labelCSS}">報告先</label>` +
` <select id="anr-target-options" style="${siCSS}">` +
` <option selected disabled hidden>選択してください</option>` +
` <option>${ANI}</option>` +
` <option>${ANS}</option>` +
` <option>${AN3RR}</option>` +
` </select>` +
` <div class="anr-target-pagelink-div" style="display: none;">` +
` <label class="anr-emptylabel" for="anr-target-pagelink" style="${labelCSS}"></label>` +
` <a id="anr-target-pagelink" href="" target="_blank">報告先を確認</a>` +
` </div>` +
` </div>` +
` <div class="anr-section-div" style="${marginCSS} display: none;">` +
// sectionsX +
` </div>` +
` <div class="anr-user-div" style="${marginCSS}">` +
userHtml +
` <div class="anr-btn-div">` +
` <button type="button" class="anr-addBtn" style="${btnCSS}">追加</button>` +
` </div>` +
` </div>` +
` <div class="anr-reasonpredefinedreasons-div" style="${marginCSS} display: none;">` +
` <label for="anr-reasonpredefinedreasons-textselect" style="${labelCSS}">理由定型文</label>` +
` <textareaselect id="anr-reasonpredefinedreasons-text" rows="8select" style="width: 100%${siCSS}"></textarea>` +
` <option selected>定型文を使用する場合は選択してください</divoption>` +
` <div class="anr-summary-div" style="${marginCSS}" </select>` +
` <input id="anr-summary-checkbox" type="checkbox"/div>` +
` <labeldiv forclass="anr-summaryreason-checkboxdiv" style="${marginCSS}">要約を指定</label>` +
` <textarealabel idfor="anr-summaryreason-text" rows="3" style="width: 100%; display: none;${labelCSS}">理由</textarealabel>` +
` <textarea id="anr-reason-text" rows="6" style="width: 100%"></divtextarea>` +
` </div>` +
` <div class="anr-checkboxsummary-div" style="${marginCSS}">` +
` <input checked id="anr-blockstatussummary-checkbox" type="checkbox">` +
` <label for="anr-blockstatussummary-checkbox">報告前にブロック状態要約チェック指定</label>` +
` <textarea id="anr-summary-text" rows="3" style="width: 100%; display: none;"><br/textarea>` +
` <input checked id="anr-duplicatereport-checkbox" type="checkbox"/div>` +
` <labeldiv forclass="anr-duplicatereportcheckbox-checkboxdiv" style="${marginCSS}">報告前に重複報告をチェック</label>` +
` </divinput checked id="anr-blockstatus-checkbox" type="checkbox">` +
` <label for="anr-blockstatus-checkbox">報告前にブロック状態をチェック</formlabel>` +
` </divbr>` +
` <input checked id="anr-duplicatereport-checkbox" type="checkbox">` +
` <label for="anr-duplicatereport-checkbox">報告前に重複報告をチェック</label>` +
` </div>` +
` </form>` +
` </div>` +
`</div>`;
 
408 ⟶ 414行目:
function initializeDialog(){
 
// CSSInitialize the design of the dialog
dialogCSSdialogDesign(true);
// Show VIP list
470 ⟶ 476行目:
}
// Function to change the CSS of the dialog**
* Function to change the CSS of the dialog and to get predifined reasons
function dialogCSS() {
* @param {Boolean} getPredifinedReasons Get fixed reasons from the user's common.js
* @returns
*/
function dialogCSSdialogDesign(getPredifinedReasons) {
 
// CSS for the dialog
$('.ui-dialog-content, .ui-dialog-buttonpane, .ui-corner-all, .ui-draggable, .ui-resizable').css('background', '#FFF0E4');
$('.ui-button').css({
479 ⟶ 491行目:
$('.ui-dialog-titlebar, .ui-dialog-titlebar-close').attr('style', 'background: #FEC493 !important;');
$('.ui-dialog').css('font-size', fSize);
 
// Show the select div for predefined report reasons if they're predefined
if (!getPredifinedReasons) return; // If the parameter is not true, don't run the code below
if (typeof anrPredefinedReasons !== 'undefined') { // If the user has fixed reasons prepared
 
if (Array.isArray(anrPredefinedReasons)) { // If the fixed reasons are prepared as an array
 
if (anrPredefinedReasons.length === 0) return;
 
const $reasons = $('#anr-predefinedreasons-select');
$reasons.css('width', $('#anr-target-options').width()).select2();
 
let reasonsArr = [];
for (let i = 0; i < anrPredefinedReasons.length; i++) {
reasonsArr.push(`<option>${anrPredefinedReasons[i]}</option>`);
}
$reasons.append(reasonsArr.join(''));
$('.anr-predefinedreasons-div').css('display', 'block');
 
} else { // If the fixed reasons are NOT prepared as an array
alert('エラー: common.js内の定型文の変数定義が不正です。配列 "[理由1, 理由2...]" 形式で指定してください。');
}
}
}
 
528 ⟶ 564行目:
` <button type="button" class="anr-viplist-btn" style="${btnCSS}">コピー</button>` +
'</div>';
$('.anr-reasonpredefinedreasons-div').before(VIPListHtml);
$('#anr-viplist-select').select2();
resolve();
638 ⟶ 674行目:
let sectionToEdit = '選択してください';
const ANSOptSelected = $('#anr-section-options-s').find('option').filter(':selected').text();
let fixedReason = $('#anr-predefinedreasons-select').find('option').filter(':selected').text();
let reportToANS = false;
 
683 ⟶ 720行目:
 
}
// The reason of the report
fixedReason = fixedReason === '定型文を使用する場合は選択してください' ? '': fixedReason;
let reason = fixedReason + $('#anr-reason-text').val().trim2();
 
// Check if necessary fields are filled
688 ⟶ 729行目:
pageToEdit === '選択してください' || // The page dropdown's remained 選択してください
sectionToEdit === '選択してください' || // The section dropdown's remained 選択してください
$('#anr-reason-text').val().trim2() === '' || // No reason is given
users.length === 0 // No username is given
) {
rqFieldsEmpty = true;
}
 
// UserAN template andIf the reason ofdoesn't thecontain a signature, add reportone
constif UserAN(reason.substring(reason.length - 4) !== '{{UserAN|t=TYPE|USER}}~~~~';) {
let reason = $('#anr-reason-text').val().trim2();
if (reason.substring(reason.length - 4) !== '~~~~') { // If reason doesn't contain signature, add one
reason = reason + '--~~~~';
}
711 ⟶ 750行目:
// Get text to add to the page
let textToSubmit = '';
const UserAN = '{{UserAN|t=TYPE|USER}}';
if (users.length < 2) { // If user to report is just one
textToSubmit = '\* ' + UserAN.replaceAll2('TYPE', types[0], 'USER', users[0]) + ' - ' + reason;
791 ⟶ 831行目:
'open': async function(){
 
// CSSInitialize the design of the dialog
dialogCSSdialogDesign(false);
 
// Convert text on the dialog to html
1,689 ⟶ 1,729行目:
'open': async function(){
 
// CSSInitialize the design of the dialog
dialogCSSdialogDesign(false);
 
// Convert the wikitext to an html form
2,032 ⟶ 2,072行目:
$('.anr-section-div').append(sectionsI);
$('#anr-section-options-i-date').text(getSectionI(false));
$('#anr-section-options-i').css({'width': $(this).width()});
$('.anr-section-div').css('display', 'block');
$('.anr-target-pagelink-div').css('display', 'block');