From 70ccf2ddb63b938364edce557a24bd361cb4caa4 Mon Sep 17 00:00:00 2001 From: Sir Sputnik Date: Wed, 6 Mar 2024 20:51:04 -0500 Subject: [PATCH 1/2] Added functionality for Minerva skin and mobile devices --- spihelper-minerva.css | 42 ++++++++++++ spihelper.css | 4 ++ spihelper.js | 145 +++++++++++++++++++++++++++++------------- 3 files changed, 148 insertions(+), 43 deletions(-) create mode 100644 spihelper-minerva.css diff --git a/spihelper-minerva.css b/spihelper-minerva.css new file mode 100644 index 0000000..a46517c --- /dev/null +++ b/spihelper-minerva.css @@ -0,0 +1,42 @@ +.spiHelper_ViewDiv { + margin: 0 auto; + width: 90%; + max-width: 993.3px; +} + +.spiHelper_ViewDiv input[type="text"], +.spiHelper_ViewDiv input[type="button"], +.spiHelper_ViewDiv select { + padding: 1px 4px; + border: solid 1px #8f8f9d; +} + +.spiHelper_ViewDiv ul { + margin: 4px 0; +} + +.spiHelper_ViewDiv textarea { + display: block; +} + +#spiHelper_blockTable input[type="text"], +#spiHelper_blockTable select, +#spiHelper_userInfoTable input[type="text"] { + width: 80px; +} + +#spiHelper_blockTable th, +#spiHelper_blockTable .spiHelper_adminClass span { + font-size: 10px; +} + +#spiHelper_blockTable .spiHelper_adminClass input[type="text"] { + width: 70px; +} + +#spiHelper_blockTable .spiHelper_adminClass input[type="checkbox"] { + display: block; +} + + + diff --git a/spihelper.css b/spihelper.css index 5f68364..29f7b02 100644 --- a/spihelper.css +++ b/spihelper.css @@ -29,3 +29,7 @@ #spiHelper_actionViewDiv > div { display: none; } + +#spiHelper_blockTable thead { + border-bottom:2px solid black; +} diff --git a/spihelper.js b/spihelper.js index 06481d4..a0ae685 100644 --- a/spihelper.js +++ b/spihelper.js @@ -8,8 +8,9 @@ // Adapted from [[User:Mr.Z-man/closeAFD]] importStylesheet('User:GeneralNotability/spihelper-dev.css') +if(mw.config.get('skin') == 'minerva') + importStylesheet('User:Sir Sputnik/spihelper-minerva.css') importScript('User:Timotheus Canens/displaymessage.js') - // Typedefs /** * @typedef SelectOption @@ -270,6 +271,7 @@ const spiHelperSectionRegex = /^(?:===[^=]*===|=====[^=]*=====)\s*$/m const spiHelperHiddenCharNormRegex = /\u200E/g /* Other globals */ +const spiHelperIsMobile = mw.config.get('skin') == 'minerva' /** @type{string} Advert to append to the edit summary of edits */ const spihelperAdvert = ' (using [[:w:en:WP:SPIH|spihelper.js]])' @@ -294,7 +296,7 @@ if (mw.config.get('wgPageName').includes('Wikipedia:Sockpuppet_investigations/') // Main functions - do the meat of the processing and UI work const spiHelperTopViewHTML = ` -
+

Handling SPI case

@@ -409,7 +411,7 @@ async function spiHelperInit () { } const spiHelperActionViewHTML = ` -
+
Back to top menu

Handling SPI case

@@ -440,12 +442,30 @@ const spiHelperActionViewHTML = ` - - - - - - + + + + + + @@ -454,7 +474,7 @@ const spiHelperActionViewHTML = ` - +
UsernameInteraction analyserInteraction timelineTimecardConsolidated timelinePagesCU wiki + Interaction analyser + IA + + Interaction timeline + IT + + Timecard + TC + + Consolidated timeline + CT + + Pages + PG + + CU wiki + CU +
(All users)
@@ -502,31 +522,33 @@ const spiHelperActionViewHTML = ` - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - + + +
UsernameBlk?DurationACBAB/AONTPNEMTagAlt MasterReq Lock?
(All users)
UsernameBlk?DurationACBAB/AONTPNEMTagAlt MasterReq Lock?
(All users)
@@ -833,6 +855,8 @@ async function spiHelperGenerateForm () { } else { $('#spiHelper_blockTagHeader', $actionView).text('Tagging socks') } + if(spiHelperIsMobile) + spiHelperInitMobileBlockTable(); // Wire up the "select all" options $('#spiHelper_block_doblock', $actionView).on('click', function (e) { spiHelperSetAllTableColumnOpts($(e.target), 'block') @@ -922,8 +946,14 @@ async function spiHelperGenerateForm () { await spiHelperGenerateLinksTableLine(possibleips[i], spiHelperLinkTableUserCount) } $('#spiHelper_sockLinksView', $actionView).show() + if(spiHelperIsMobile) + $('.user-link-dt').hide(); + else + $('.user-link-mobile').hide(); } $('#spiHelper_blockTagView', $actionView).show() + if(spiHelperIsMobile) + spiHelperInitMobileBlockTable(); } // Wire up the submit button $('#spiHelper_performActions', $actionView).one('click', () => { @@ -3043,28 +3073,29 @@ async function spiHelperGenerateBlockTableLine (name, defaultblock, id) { const $table = $('#spiHelper_blockTable', document) const $row = $('') + const $adminRow = spiHelperIsMobile ? $('').addClass('spiHelper_adminClass') : $row // Username $('').append($('').attr('type', 'text').attr('id', 'spiHelper_block_username' + id) .val(name).addClass('.spihelper-widthlimit')).appendTo($row) // Block checkbox (only for admins) $('').addClass('spiHelper_adminClass').append($('').attr('type', 'checkbox') - .attr('id', 'spiHelper_block_doblock' + id).prop('checked', block)).appendTo($row) + .attr('id', 'spiHelper_block_doblock' + id).prop('checked', block)).appendTo($adminRow) // Block duration (only for admins) $('').addClass('spiHelper_adminClass').append($('').attr('type', 'text') .attr('id', 'spiHelper_block_duration' + id).val(duration) - .addClass('.spihelper-widthlimit')).appendTo($row) + .addClass('.spihelper-widthlimit')).appendTo($adminRow) // Account creation blocked (only for admins) $('').addClass('spiHelper_adminClass').append($('').attr('type', 'checkbox') - .attr('id', 'spiHelper_block_acb' + id).prop('checked', acb)).appendTo($row) + .attr('id', 'spiHelper_block_acb' + id).prop('checked', acb)).appendTo($adminRow) // Autoblock (only for admins) $('').addClass('spiHelper_adminClass').append($('').attr('type', 'checkbox') - .attr('id', 'spiHelper_block_ab' + id).prop('checked', ab)).appendTo($row) + .attr('id', 'spiHelper_block_ab' + id).prop('checked', ab)).appendTo($adminRow) // Revoke talk page access (only for admins) $('').addClass('spiHelper_adminClass').append($('').attr('type', 'checkbox') - .attr('id', 'spiHelper_block_tp' + id).prop('checked', ntp)).appendTo($row) + .attr('id', 'spiHelper_block_tp' + id).prop('checked', ntp)).appendTo($adminRow) // Block email access (only for admins) $('').addClass('spiHelper_adminClass').append($('').attr('type', 'checkbox') - .attr('id', 'spiHelper_block_email' + id).prop('checked', nem)).appendTo($row) + .attr('id', 'spiHelper_block_email' + id).prop('checked', nem)).appendTo($adminRow) // Tag select box $('').append($('').attr('type', 'checkbox').attr('id', 'spiHelper_block_lock' + id) .prop('disabled', mw.util.isIPAddress(name, true))).appendTo($row) $table.append($row) + if(spiHelperIsMobile) { + $table.append($adminRow) + $('#spiHelper_blockTable th.spiHelper_adminClass').each((thIndex,th) => { + $(th).children().clone().insertAfter($adminRow.find('td').eq(thIndex).find('input[type="checkbox"]')) + }) + } // Generate the select entries spiHelperGenerateSelect('spiHelper_block_tag' + id, spiHelperTagOptions) @@ -3087,6 +3124,26 @@ async function spiHelperGenerateBlockTableLine (name, defaultblock, id) { }) } +async function spiHelperInitMobileBlockTable() { + 'use strict' + + $('#spiHelper_blockTable th.spiHelper_adminClass').hide() + const $allRow=$('#spiHelper_block_allusers') + const $adminCells=$allRow.find('.spiHelper_adminClass') + $adminCells.detach() + const $allAdminRow=$('') + $allAdminRow.addClass('spiHelper_adminClass').insertAfter($allRow).append($adminCells) + $('#spiHelper_blockTable th.spiHelper_adminClass').each((thIndex,th) => { + $(th).children().clone().insertAfter($allAdminRow.find('td').eq(thIndex).find('input[type="checkbox"]')) + }) +} + +async function spiHelperInitMobileUserInfoTable() { + 'use strict' + + +} + async function spiHelperGenerateLinksTableLine (username, id) { 'use strict' @@ -3425,13 +3482,15 @@ async function spiHelperAddLink () { 'use strict' await spiHelperLoadSettings() await mw.loader.load('mediawiki.util') - const initLink = mw.util.addPortletLink('p-cactions', '#', 'SPI', 'ca-spiHelper') + let portlet = spiHelperIsMobile ? 'p-personal' : 'p-cactions' + const initLink = mw.util.addPortletLink(portlet , '#', 'SPI', 'ca-spiHelper') initLink.addEventListener('click', (e) => { e.preventDefault() return spiHelperInit() }) - if (mw.config.get('wgCategories').includes('SPI cases awaiting archive') && spiHelperIsClerk()) { - const oneClickArchiveLink = mw.util.addPortletLink('p-cactions', '#', 'SPI-Archive', 'ca-spiHelperArchive') + const $awaitingArchiveCat = $('#mw-normal-catlinks a:contains("SPI cases awaiting archive")') + if ($awaitingArchiveCat.length > 0 && spiHelperIsClerk()) { + const oneClickArchiveLink = mw.util.addPortletLink(portlet, '#', 'SPI-Archive', 'ca-spiHelperArchive') $(oneClickArchiveLink).one('click', (e) => { e.preventDefault() return spiHelperOneClickArchive() From 92b8534efa009840ffad3c41361d7b4dc53d915a Mon Sep 17 00:00:00 2001 From: SirSputnik Date: Fri, 21 Jun 2024 22:13:50 -0400 Subject: [PATCH 2/2] Fixed visibility for admin functions --- spihelper.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spihelper.js b/spihelper.js index fdcf7ef..8f440c9 100644 --- a/spihelper.js +++ b/spihelper.js @@ -311,7 +311,7 @@ const spiHelperTopViewHTML = `
  • - +
  • @@ -3126,8 +3126,8 @@ async function spiHelperGenerateBlockTableLine (name, defaultblock, id) { async function spiHelperInitMobileBlockTable() { 'use strict' - - $('#spiHelper_blockTable th.spiHelper_adminClass').hide() + if(!spiHelperIsAdmin()) + $('#spiHelper_blockTable .spiHelper_adminClass').hide() const $allRow=$('#spiHelper_block_allusers') const $adminCells=$allRow.find('.spiHelper_adminClass') $adminCells.detach()