Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

User:Justarandomamerican/globalUserLock.js: Difference between revisions

From WikiOasis Meta
No edit summary
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 6: Line 6:
  * Designed for use on Meta-Wiki or any CentralAuth-enabled wiki
  * Designed for use on Meta-Wiki or any CentralAuth-enabled wiki
  * by stewards or staff with global lock permissions.
  * by stewards or staff with global lock permissions.
*
* Usage: Add to your common.js or Special:MyPage/common.js
*  mw.loader.load('https://your-wiki/path/to/globalUserLock.js');
*
* API actions used:
*  - query + list=globalallusers  (find matching accounts)
*  - centralauth (lock accounts)
*  - checktoken / tokens          (CSRF)
*
* Author: AI
* License: Public domain
  */
  */


Line 23: Line 12:


// ── Constants ──────────────────────────────────────────────────────────────
// ── Constants ──────────────────────────────────────────────────────────────
const TOOL_TITLE  = 'Global User Lock';
const PORTLET_ID  = 'ca-global-user-lock';
const MAX_ACCOUNTS = 200;


const TOOL_ID      = 'global-user-lock-tool';
// ── Load Dependencies First ────────────────────────────────────────────────
const TOOL_TITLE  = 'Global User Lock Tool';
$.when(
const API_ENDPOINT = mw.config.get( 'wgScriptPath' ) + '/api.php';
mw.loader.using( [ 'mediawiki.util', 'mediawiki.api', 'oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows' ] ),
$.ready
).then( function () {


// Maximum accounts to process in a single run (safety cap)
// Initialize the MediaWiki API helper
const MAX_ACCOUNTS = 200;
const api = new mw.Api();


// ── Styles ─────────────────────────────────────────────────────────────────
// ── OOUI Dialog Definition ─────────────────────────────────────────────
 
function GULDialog( config ) {
mw.util.addCSS( `
GULDialog.super.call( this, config );
#${ TOOL_ID } {
font-family: inherit;
max-width: 780px;
margin: 1.5em auto;
border: 1px solid #a2a9b1;
border-radius: 3px;
background: #f8f9fa;
}
}
#${ TOOL_ID } .gul-header {
OO.inheritClass( GULDialog, OO.ui.ProcessDialog );
background: #36c;
color: #fff;
padding: 10px 16px;
font-size: 1.1em;
font-weight: bold;
border-radius: 3px 3px 0 0;
display: flex;
align-items: center;
gap: 8px;
}
#${ TOOL_ID } .gul-header svg {
flex-shrink: 0;
}
#${ TOOL_ID } .gul-body {
padding: 16px;
}
#${ TOOL_ID } fieldset {
border: 1px solid #c8ccd1;
border-radius: 3px;
padding: 10px 14px;
margin: 0 0 14px;
background: #fff;
}
#${ TOOL_ID } legend {
font-weight: bold;
padding: 0 4px;
font-size: 0.95em;
}
#${ TOOL_ID } label {
display: block;
margin-bottom: 4px;
font-size: 0.92em;
}
#${ TOOL_ID } input[type="text"],
#${ TOOL_ID } textarea,
#${ TOOL_ID } select {
width: 100%;
box-sizing: border-box;
padding: 5px 7px;
border: 1px solid #a2a9b1;
border-radius: 2px;
font-size: 0.93em;
font-family: inherit;
background: #fff;
}
#${ TOOL_ID } textarea {
resize: vertical;
min-height: 64px;
}
#${ TOOL_ID } .gul-checkbox-row {
display: flex;
align-items: center;
gap: 6px;
margin-top: 8px;
font-size: 0.92em;
}
#${ TOOL_ID } .gul-checkbox-row input[type="checkbox"] {
width: auto;
}
#${ TOOL_ID } .gul-actions {
display: flex;
gap: 8px;
flex-wrap: wrap;
margin-top: 6px;
}
#${ TOOL_ID } button {
padding: 6px 14px;
border: 1px solid #a2a9b1;
border-radius: 2px;
cursor: pointer;
font-size: 0.92em;
font-family: inherit;
background: #fff;
}
#${ TOOL_ID } button.gul-primary {
background: #36c;
color: #fff;
border-color: #2a4b8d;
font-weight: bold;
}
#${ TOOL_ID } button.gul-primary:hover { background: #2a4b8d; }
#${ TOOL_ID } button.gul-danger {
background: #d73333;
color: #fff;
border-color: #b32424;
font-weight: bold;
}
#${ TOOL_ID } button.gul-danger:hover { background: #b32424; }
#${ TOOL_ID } button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
#${ TOOL_ID } .gul-status {
margin: 10px 0 0;
padding: 8px 12px;
border-radius: 2px;
font-size: 0.91em;
display: none;
}
#${ TOOL_ID } .gul-status.info    { background: #eaf3fb; border: 1px solid #72a0d3; display: block; }
#${ TOOL_ID } .gul-status.success { background: #d5fdf4; border: 1px solid #14866d; display: block; }
#${ TOOL_ID } .gul-status.error  { background: #fee7e6; border: 1px solid #d73333; display: block; }
#${ TOOL_ID } .gul-status.warning { background: #fef6e7; border: 1px solid #fc3; display: block; }
#${ TOOL_ID } .gul-results-wrap {
display: none;
margin-top: 14px;
}
#${ TOOL_ID } .gul-results-wrap.visible { display: block; }
#${ TOOL_ID } .gul-results-table {
width: 100%;
border-collapse: collapse;
font-size: 0.89em;
background: #fff;
}
#${ TOOL_ID } .gul-results-table th,
#${ TOOL_ID } .gul-results-table td {
border: 1px solid #c8ccd1;
padding: 5px 8px;
text-align: left;
vertical-align: middle;
}
#${ TOOL_ID } .gul-results-table th {
background: #eaecf0;
font-weight: bold;
}
#${ TOOL_ID } .gul-results-table tr:nth-child(even) td { background: #f8f9fa; }
#${ TOOL_ID } .gul-results-table .gul-status-cell {
text-align: center;
white-space: nowrap;
}
#${ TOOL_ID } .badge {
display: inline-block;
padding: 1px 7px;
border-radius: 10px;
font-size: 0.85em;
font-weight: bold;
}
#${ TOOL_ID } .badge-pending  { background: #eaecf0; color: #555; }
#${ TOOL_ID } .badge-locked  { background: #d5fdf4; color: #14866d; }
#${ TOOL_ID } .badge-failed  { background: #fee7e6; color: #d73333; }
#${ TOOL_ID } .badge-skipped  { background: #fef6e7; color: #b45a00; }
#${ TOOL_ID } .gul-progress {
height: 8px;
background: #eaecf0;
border-radius: 4px;
overflow: hidden;
margin-top: 8px;
display: none;
}
#${ TOOL_ID } .gul-progress.visible { display: block; }
#${ TOOL_ID } .gul-progress-bar {
height: 100%;
background: #36c;
width: 0%;
transition: width 0.3s ease;
}
#${ TOOL_ID } .gul-select-all-row {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 6px;
font-size: 0.91em;
}
#${ TOOL_ID } .gul-count {
color: #555;
font-size: 0.88em;
margin-left: auto;
}
#${ TOOL_ID } .gul-summary {
font-size: 0.9em;
margin-top: 10px;
padding: 8px 12px;
background: #fff;
border: 1px solid #c8ccd1;
border-radius: 2px;
}
` );


// ── Build UI ───────────────────────────────────────────────────────────────
GULDialog.static.name    = 'gulDialog';
GULDialog.static.title  = TOOL_TITLE;
GULDialog.static.size    = 'large';
GULDialog.static.actions = [
{ action: 'close', label: 'Close', flags: [ 'safe', 'close' ] }
];


function buildUI() {
GULDialog.prototype.initialize = function () {
const $container = $( '<div>' ).attr( 'id', TOOL_ID );
GULDialog.super.prototype.initialize.call( this );
injectCSS();
this.$body.append( buildPanelContent() );
bindEvents();
};


// Header
GULDialog.prototype.getActionProcess = function ( action ) {
$container.append( `
if ( action === 'close' ) {
<div class="gul-header">
return new OO.ui.Process( function () {
<svg width="18" height="18" viewBox="0 0 20 20" fill="currentColor">
this.close();
<path d="M10 2a4 4 0 0 1 4 4v1h1a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1V6a4 4 0 0 1 4-4zm0 9a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm0-7a2 2 0 0 0-2 2v1h4V6a2 2 0 0 0-2-2z"/>
}, this );
</svg>
}
${ TOOL_TITLE }
return GULDialog.super.prototype.getActionProcess.call( this, action );
</div>
};
` );


const $body = $( '<div>' ).addClass( 'gul-body' );
GULDialog.prototype.getBodyHeight = function () {
return Math.min( Math.round( window.innerHeight * 0.82 ), 680 );
};


// ── Search fieldset
// ── Dialog Manager ─────────────────────────────────────────────────────
const $searchFs = $( '<fieldset>' ).append( '<legend>Search Parameters</legend>' );
let windowManager = null;


$searchFs.append( `
function openDialog() {
<label for="gul-query">Username contains (substring match, case-insensitive):</label>
if ( !windowManager ) {
<input type="text" id="gul-query" placeholder="e.g. spambot, vandal2024" autocomplete="off" />
windowManager = new OO.ui.WindowManager();
` );
$( document.body ).append( windowManager.$element );
windowManager.addWindows( [ new GULDialog() ] );
}
windowManager.openWindow( 'gulDialog' );
}


$searchFs.append( `
// ── Entry point ────────────────────────────────────────────────────────
<label style="margin-top:10px;" for="gul-from">
const $link = $( mw.util.addPortletLink(
Start from username (optional, for pagination):
'p-cactions',
</label>
'#',
<input type="text" id="gul-from" placeholder="Leave blank to start from beginning" autocomplete="off" />
TOOL_TITLE,
` );
PORTLET_ID,
'Find and globally lock accounts by username substring'
) );


$body.append( $searchFs );
$link.on( 'click', function ( e ) {
e.preventDefault();
openDialog();
} );


// ── Lock options fieldset
// ── CSS (injected once) ────────────────────────────────────────────────
const $lockFs = $( '<fieldset>' ).append( '<legend>Lock Options</legend>' );
let cssInjected = false;
function injectCSS() {
if ( cssInjected ) { return; }
cssInjected = true;


$lockFs.append( `
mw.util.addCSS( `
<label for="gul-reason">Lock reason (will appear in CentralAuth log):</label>
.gul-body, .gul-results-wrap, .gul-select-all-row, .gul-actions, .gul-checkbox-row {
<textarea id="gul-reason" rows="2" placeholder="e.g. Cross-wiki spam; username policy violation"></textarea>
--gul-bg:          #fff;
` );
--gul-bg-subtle:    #f8f9fa;
--gul-bg-muted:    #eaecf0;
--gul-border:      #c8ccd1;
--gul-border-input: #a2a9b1;
--gul-text:        #202122;
--gul-text-muted:  #555;
--gul-info-bg:      #eaf3fb;
--gul-info-border:  #72a0d3;
--gul-info-text:    #0645ad;
--gul-ok-bg:        #d5fdf4;
--gul-ok-border:    #14866d;
--gul-ok-text:      #14866d;
--gul-err-bg:      #fee7e6;
--gul-err-border:  #d73333;
--gul-err-text:    #b32424;
--gul-warn-bg:      #fef6e7;
--gul-warn-border:  #fc3;
--gul-warn-text:    #b45a00;
--gul-badge-neutral-bg:  #eaecf0;
--gul-badge-neutral-text: #555;
--gul-badge-locked-bg:    #d5fdf4;
--gul-badge-locked-text:  #14866d;
--gul-badge-failed-bg:    #fee7e6;
--gul-badge-failed-text:  #d73333;
--gul-badge-skipped-bg:  #fef6e7;
--gul-badge-skipped-text: #b45a00;
--gul-btn-bg:          #fff;
--gul-btn-border:      #a2a9b1;
--gul-btn-text:        #202122;
--gul-primary-bg:      #3366cc;
--gul-primary-bg-hover: #2a4b8d;
--gul-danger-bg:        #d73333;
--gul-danger-bg-hover:  #b32424;
--gul-track-bg:  #eaecf0;
--gul-track-fill: #3366cc;
}
@media ( prefers-color-scheme: dark ) {
.gul-body, .gul-results-wrap, .gul-select-all-row, .gul-actions, .gul-checkbox-row {
--gul-bg:          #1e2124;
--gul-bg-subtle:    #27292d;
--gul-bg-muted:    #2e3136;
--gul-border:      #3d4146;
--gul-border-input: #54595d;
--gul-text:        #eaecf0;
--gul-text-muted:  #a2a9b1;
--gul-info-bg:      #162032;
--gul-info-border:  #3a6ea8;
--gul-info-text:    #8ab4f8;
--gul-ok-bg:        #0d2b24;
--gul-ok-border:    #1d6b58;
--gul-ok-text:      #4dd0a8;
--gul-err-bg:      #2d1212;
--gul-err-border:  #a02020;
--gul-err-text:    #f08080;
--gul-warn-bg:      #2b2100;
--gul-warn-border:  #a87f00;
--gul-warn-text:    #f0c040;
--gul-badge-neutral-bg:  #2e3136;
--gul-badge-neutral-text: #a2a9b1;
--gul-badge-locked-bg:    #0d2b24;
--gul-badge-locked-text:  #4dd0a8;
--gul-badge-failed-bg:    #2d1212;
--gul-badge-failed-text:  #f08080;
--gul-badge-skipped-bg:  #2b2100;
--gul-badge-skipped-text: #f0c040;
--gul-btn-bg:          #2e3136;
--gul-btn-border:      #54595d;
--gul-btn-text:        #eaecf0;
--gul-primary-bg:      #3a6ea8;
--gul-primary-bg-hover: #2a5298;
--gul-danger-bg:        #a02020;
--gul-danger-bg-hover:  #7a1818;
--gul-track-bg:  #2e3136;
--gul-track-fill: #3a6ea8;
}
}
.skin-theme-clientpref-night .gul-body, .skin-theme-clientpref-night .gul-results-wrap, .skin-theme-clientpref-night .gul-select-all-row, .skin-theme-clientpref-night .gul-actions, .skin-theme-clientpref-night .gul-checkbox-row {
--gul-bg:          #1e2124; --gul-bg-subtle:    #27292d; --gul-bg-muted:    #2e3136; --gul-border:      #3d4146; --gul-border-input: #54595d; --gul-text:        #eaecf0; --gul-text-muted:  #a2a9b1; --gul-info-bg:      #162032; --gul-info-border:  #3a6ea8; --gul-info-text:    #8ab4f8; --gul-ok-bg:        #0d2b24; --gul-ok-border:    #1d6b58; --gul-ok-text:      #4dd0a8; --gul-err-bg:      #2d1212; --gul-err-border:  #a02020; --gul-err-text:    #f08080; --gul-warn-bg:      #2b2100; --gul-warn-border:  #a87f00; --gul-warn-text:    #f0c040; --gul-badge-neutral-bg:  #2e3136; --gul-badge-neutral-text: #a2a9b1; --gul-badge-locked-bg:    #0d2b24; --gul-badge-locked-text:  #4dd0a8; --gul-badge-failed-bg:    #2d1212; --gul-badge-failed-text:  #f08080; --gul-badge-skipped-bg:  #2b2100; --gul-badge-skipped-text: #f0c040; --gul-btn-bg:          #2e3136; --gul-btn-border:      #54595d; --gul-btn-text:        #eaecf0; --gul-primary-bg:      #3a6ea8; --gul-primary-bg-hover: #2a5298; --gul-danger-bg:        #a02020; --gul-danger-bg-hover:  #7a1818; --gul-track-bg:  #2e3136; --gul-track-fill: #3a6ea8;
}
.gul-body { padding: 14px 16px; font-family: inherit; color: var(--gul-text); overflow-y: auto; }
.gul-body fieldset { border: 1px solid var(--gul-border); border-radius: 3px; padding: 10px 14px; margin: 0 0 14px; background: var(--gul-bg); color: var(--gul-text); }
.gul-body legend { font-weight: bold; padding: 0 4px; font-size: 0.95em; color: var(--gul-text); }
.gul-body label { display: block; margin-bottom: 4px; font-size: 0.92em; color: var(--gul-text); }
.gul-body input[type="text"], .gul-body textarea { width: 100%; box-sizing: border-box; padding: 5px 7px; border: 1px solid var(--gul-border-input); border-radius: 2px; font-size: 0.93em; font-family: inherit; background: var(--gul-bg); color: var(--gul-text); }
.gul-body input[type="text"]:focus, .gul-body textarea:focus { outline: 2px solid var(--gul-track-fill); outline-offset: 1px; }
.gul-body textarea { resize: vertical; min-height: 60px; }
.gul-checkbox-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 0.92em; color: var(--gul-text); }
.gul-checkbox-row input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--gul-track-fill); }
.gul-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.gul-actions button { padding: 6px 14px; border: 1px solid var(--gul-btn-border); border-radius: 2px; cursor: pointer; font-size: 0.92em; font-family: inherit; background: var(--gul-btn-bg); color: var(--gul-btn-text); }
.gul-actions button.gul-primary { background: var(--gul-primary-bg); color: #fff; border-color: var(--gul-primary-bg-hover); font-weight: bold; }
.gul-actions button.gul-primary:hover { background: var(--gul-primary-bg-hover); }
.gul-actions button.gul-danger { background: var(--gul-danger-bg); color: #fff; border-color: var(--gul-danger-bg-hover); font-weight: bold; }
.gul-actions button.gul-danger:hover { background: var(--gul-danger-bg-hover); }
.gul-actions button:disabled { opacity: 0.5; cursor: not-allowed; }
.gul-status { margin: 10px 0 0; padding: 8px 12px; border-radius: 2px; font-size: 0.91em; display: none; }
.gul-status.info { background: var(--gul-info-bg); border: 1px solid var(--gul-info-border); color: var(--gul-info-text); display: block; }
.gul-status.success { background: var(--gul-ok-bg); border: 1px solid var(--gul-ok-border); color: var(--gul-ok-text); display: block; }
.gul-status.error { background: var(--gul-err-bg); border: 1px solid var(--gul-err-border); color: var(--gul-err-text); display: block; }
.gul-status.warning { background: var(--gul-warn-bg); border: 1px solid var(--gul-warn-border); color: var(--gul-warn-text); display: block; }
.gul-progress { height: 8px; background: var(--gul-track-bg); border-radius: 4px; overflow: hidden; margin-top: 8px; display: none; }
.gul-progress.visible { display: block; }
.gul-progress-bar { height: 100%; background: var(--gul-track-fill); width: 0%; transition: width 0.3s ease; }
.gul-results-wrap { display: none; margin-top: 14px; }
.gul-results-wrap.visible { display: block; }
.gul-select-all-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 0.91em; color: var(--gul-text); }
.gul-count { color: var(--gul-text-muted); font-size: 0.88em; margin-left: auto; }
.gul-results-table { width: 100%; border-collapse: collapse; font-size: 0.89em; background: var(--gul-bg); color: var(--gul-text); }
.gul-results-table th, .gul-results-table td { border: 1px solid var(--gul-border); padding: 5px 8px; text-align: left; vertical-align: middle; }
.gul-results-table th { background: var(--gul-bg-muted); font-weight: bold; color: var(--gul-text); }
.gul-results-table tr:nth-child(even) td { background: var(--gul-bg-subtle); }
.gul-status-cell { text-align: center; white-space: nowrap; }
.gul-badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 0.85em; font-weight: bold; }
.gul-badge-pending, .gul-badge-active  { background: var(--gul-badge-neutral-bg); color: var(--gul-badge-neutral-text); }
.gul-badge-locked  { background: var(--gul-badge-locked-bg); color: var(--gul-badge-locked-text); }
.gul-badge-failed  { background: var(--gul-badge-failed-bg); color: var(--gul-badge-failed-text); }
.gul-badge-skipped { background: var(--gul-badge-skipped-bg); color: var(--gul-badge-skipped-text); }
.gul-summary { font-size: 0.9em; margin-top: 10px; padding: 8px 12px; background: var(--gul-bg); border: 1px solid var(--gul-border); border-radius: 2px; color: var(--gul-text); }
` );
}


$lockFs.append( `
// ── Build panel content ────────────────────────────────────────────────
<div class="gul-checkbox-row">
function buildPanelContent() {
<input type="checkbox" id="gul-hide" />
const $body = $( '<div>' ).addClass( 'gul-body' );
<label for="gul-hide" style="margin:0;">Hide username (sets <code>hidden</code> flag — requires suppressor right)</label>
</div>
<div class="gul-checkbox-row">
<input type="checkbox" id="gul-suppress" />
<label for="gul-suppress" style="margin:0;">Suppress username (sets <code>suppressed</code> flag — requires suppressor right)</label>
</div>
<div class="gul-checkbox-row">
<input type="checkbox" id="gul-skip-locked" checked />
<label for="gul-skip-locked" style="margin:0;">Skip accounts already globally locked</label>
</div>
` );


$body.append( $lockFs );
const $searchFs = $( '<fieldset>' ).append( '<legend>Search Parameters</legend>' );
$searchFs.append( `
<label for="gul-query">Username contains (substring match, case-insensitive):</label>
<input type="text" id="gul-query" placeholder="e.g. spambot, vandal2024" autocomplete="off" />
` );
$searchFs.append( `
<label style="margin-top:10px;" for="gul-from">Start from username (optional — for pagination):</label>
<input type="text" id="gul-from" placeholder="Leave blank to start from the beginning" autocomplete="off" />
` );
$body.append( $searchFs );


// ── Actions
const $lockFs = $( '<fieldset>' ).append( '<legend>Lock Options</legend>' );
const $actions = $( '<div>' ).addClass( 'gul-actions' );
$lockFs.append( `
const $btnSearch = $( '<button>' ).addClass( 'gul-primary' ).attr( 'id', 'gul-btn-search' ).text( '🔍 Search Accounts' );
<label for="gul-reason">Lock reason (will appear in CentralAuth log):</label>
const $btnLock  = $( '<button>' ).addClass( 'gul-danger' ).attr( 'id', 'gul-btn-lock' ).text( '🔒 Lock Selected' ).prop( 'disabled', true );
<textarea id="gul-reason" rows="2" placeholder="e.g. Cross-wiki spam; username policy violation"></textarea>
const $btnClear  = $( '<button>' ).attr( 'id', 'gul-btn-clear' ).text( 'Clear' );
` );
$actions.append( $btnSearch, $btnLock, $btnClear );
$lockFs.append( `
$body.append( $actions );
<div class="gul-checkbox-row">
<input type="checkbox" id="gul-hide" />
<label for="gul-hide" style="margin:0;">Hide username (<code>hidden = 1</code> flag — requires suppressor right)</label>
</div>
<div class="gul-checkbox-row">
<input type="checkbox" id="gul-suppress" />
<label for="gul-suppress" style="margin:0;">Suppress username (<code>hidden = 2</code> flag — requires suppressor right)</label>
</div>
<div class="gul-checkbox-row">
<input type="checkbox" id="gul-skip-locked" checked />
<label for="gul-skip-locked" style="margin:0;">Skip accounts that are already globally locked</label>
</div>
` );
$body.append( $lockFs );


// Status
$body.append(
const $status = $( '<div>' ).addClass( 'gul-status' ).attr( 'id', 'gul-status' );
$( '<div>' ).addClass( 'gul-actions' ).append(
$body.append( $status );
$( '<button>' ).addClass( 'gul-primary' ).attr( 'id', 'gul-btn-search' ).text( '🔍 Search Accounts' ),
$( '<button>' ).addClass( 'gul-danger'  ).attr( 'id', 'gul-btn-lock'  ).text( '🔒 Lock Selected' ).prop( 'disabled', true ),
$( '<button>' )                          .attr( 'id', 'gul-btn-clear'  ).text( 'Clear' )
)
);


// Progress bar
$body.append( $( '<div>' ).addClass( 'gul-status' ).attr( 'id', 'gul-status' ) );
const $progress = $( '<div>' ).addClass( 'gul-progress' ).attr( 'id', 'gul-progress' );
$body.append( $( '<div>' ).addClass( 'gul-progress' ).attr( 'id', 'gul-progress' ).append(
$progress.append( $( '<div>' ).addClass( 'gul-progress-bar' ).attr( 'id', 'gul-progress-bar' ) );
$( '<div>' ).addClass( 'gul-progress-bar' ).attr( 'id', 'gul-progress-bar' )
$body.append( $progress );
) );


// Results
$body.append( $( '<div>' ).addClass( 'gul-results-wrap' ).attr( 'id', 'gul-results-wrap' ) );
const $resultsWrap = $( '<div>' ).addClass( 'gul-results-wrap' ).attr( 'id', 'gul-results-wrap' );
$body.append( $resultsWrap );


$container.append( $body );
return $body;
}


return $container;
// ── Bind events ────────────────────────────────────────────────────────
}
function bindEvents() {
$( document )
.off( '.gul' )
.on( 'click.gul',  '#gul-btn-search', onSearch )
.on( 'click.gul',  '#gul-btn-lock',  onLock  )
.on( 'click.gul',  '#gul-btn-clear',  onClear  )
.on( 'keydown.gul', '#gul-query', function ( e ) {
if ( e.key === 'Enter' ) { onSearch(); }
} )
.on( 'change.gul', '#gul-select-all', function () {
$( '.gul-user-cb' ).prop( 'checked', this.checked );
} );
}


// ── Helpers ────────────────────────────────────────────────────────────────
// ── UI helpers ─────────────────────────────────────────────────────────
function setStatus( msg, type ) {
$( '#gul-status' ).removeClass( 'info success error warning' ).addClass( type ).html( msg );
}
function clearStatus() {
$( '#gul-status' ).removeClass( 'info success error warning' ).html( '' ).hide();
}
function setBadge( username, type, text ) {
$( 'tr[data-user="' + $.escapeSelector( username ) + '"] .gul-status-cell' )
.html( '<span class="gul-badge gul-badge-' + type + '">' + text + '</span>' );
}
function setProgress( done, total ) {
const pct = total > 0 ? Math.round( done / total * 100 ) : 0;
$( '#gul-progress-bar' ).css( 'width', pct + '%' );
}


function setStatus( msg, type ) {
// ── API helpers ────────────────────────────────────────────────────────
const $s = $( '#gul-status' );
function fetchMatchingUsers( query, fromUser ) {
$s.removeClass( 'info success error warning' ).addClass( type ).html( msg );
const deferred    = $.Deferred();
}
const results    = [];
const queryLc    = query.toLowerCase();
let  continueFrom = fromUser || undefined;
let  exhausted  = false;
let  page        = 0;


function clearStatus() {
setStatus( 'Searching CentralAuth for matching usernames…', 'info' );
$( '#gul-status' ).removeClass( 'info success error warning' ).hide().html( '' );
}


function setBadge( username, type, text ) {
function fetchPage() {
const $cell = $( `#gul-row-${ CSS.escape( username ) } .gul-status-cell` );
if ( exhausted || results.length >= MAX_ACCOUNTS ) {
$cell.html( `<span class="badge badge-${ type }">${ text }</span>` );
deferred.resolve( results.slice( 0, MAX_ACCOUNTS ) );
}
return;
}


function setProgress( done, total ) {
const params = {
const pct = total > 0 ? Math.round( ( done / total ) * 100 ) : 0;
action:  'query',
$( '#gul-progress-bar' ).css( 'width', pct + '%' );
list:   'globalallusers',
}
agulimit: '500',
aguprop: 'lockinfo',
format:  'json'
};
if ( continueFrom ) { params.agufrom = continueFrom; }


// ── API helpers ────────────────────────────────────────────────────────────
api.get( params )
.done( function ( data ) {
const users = ( data.query || {} ).globalallusers || [];
page++;


/**
users.forEach( function ( u ) {
* Fetch a CSRF token for CentralAuth write operations.
if ( u.name.toLowerCase().includes( queryLc ) ) {
* @return {jQuery.Promise<string>}
results.push( u );
*/
}
function getCsrfToken() {
} );
return $.ajax( {
url: API_ENDPOINT,
data: {
action: 'query',
meta:  'tokens',
type:  'csrf',
format: 'json'
}
} ).then( function ( data ) {
return data.query.tokens.csrftoken;
} );
}


/**
setStatus(
* Fetch all global users whose name contains `query`.
'Searched ~' + ( page * 500 ) + ' usernames, found ' +
* Uses globalallusers with a "from" trick:  we search from `aufrom`
results.length + ' match(es) so far…', 'info'
* and filter client-side since the API doesn't support substring
);
* search — we iterate until names no longer contain the substring
* using the `auprefix` param where possible, and fall back to
* fetching batches and filtering.
*
* Note: The CentralAuth API exposes `list=globalallusers` which
* supports `agufrom` and `aguto` but not substring; we therefore
* page through results and filter locally.
*
* @param {string} query
* @param {string} fromUser
* @return {jQuery.Promise<Array>}
*/
function fetchMatchingUsers( query, fromUser ) {
const deferred  = $.Deferred();
const results  = [];
const queryLc  = query.toLowerCase();
let  continueToken = fromUser || undefined;
let  done      = false;
let  page      = 0;
 
setStatus( 'Searching CentralAuth for matching usernames…', 'info' );
 
function fetchPage() {
if ( done || results.length >= MAX_ACCOUNTS ) {
deferred.resolve( results.slice( 0, MAX_ACCOUNTS ) );
return;
}
 
const params = {
action:    'query',
list:      'globalallusers',
agulimit:  '500',
aguprop:  'lockinfo|registration',
format:    'json'
};
if ( continueToken ) {
params.agufrom = continueToken;
}


$.ajax( { url: API_ENDPOINT, data: params } )
if ( !users.length || !( data.continue && data.continue.agufrom ) ) {
.done( function ( data ) {
exhausted = true;
const users = ( data.query || {} ).globalallusers || [];
deferred.resolve( results.slice( 0, MAX_ACCOUNTS ) );
page++;
} else {
 
continueFrom = data.continue.agufrom;
if ( users.length === 0 ) {
fetchPage();
done = true;
deferred.resolve( results.slice( 0, MAX_ACCOUNTS ) );
return;
}
 
users.forEach( function ( u ) {
if ( u.name.toLowerCase().includes( queryLc ) ) {
results.push( u );
}
}
} )
.fail( function ( code ) {
deferred.reject( 'API request failed: ' + code );
} );
} );
}


setStatus(
fetchPage();
`Searched ${ page * 500 } usernames, found ${ results.length } match(es) so far…`,
return deferred.promise();
'info'
);
 
// Continue token
if ( data.continue && data.continue.agufrom ) {
continueToken = data.continue.agufrom;
fetchPage();
} else {
done = true;
deferred.resolve( results.slice( 0, MAX_ACCOUNTS ) );
}
} )
.fail( function ( xhr ) {
deferred.reject( 'API request failed: ' + xhr.statusText );
} );
}
}


fetchPage();
function lockAccount( username, reason, hide, suppress ) {
return deferred.promise();
const payload = {
}
action: 'setglobalaccountstatus',
user:  username,
locked: 'lock',
reason: reason,
format: 'json'
};


/**
if ( suppress ) {
* Lock a single global account via the CentralAuth API.
payload.hidden = 'suppressed';
*
} else if ( hide ) {
* @param {string}  username
payload.hidden = 'lists';
* @param {string}  token    CSRF token
}
* @param {string}  reason
* @param {boolean} hide      Apply "hidden" flag
* @param {boolean} suppress  Apply "suppressed" flag
* @return {jQuery.Promise}
*/
function lockAccount( username, token, reason, hide, suppress ) {
// Build the "statechange" value
// Possible states: lock, unlock, hide, suppress, unsuppress
const states = { locked: 'lock' };
if ( suppress ) {
states.hidden = 'suppress';
} else if ( hide ) {
states.hidden = 'hide';
}
 
const params = {
action:        'centralauth',
user:          username,
reason:        reason,
token:        token,
format:        'json'
};
 
// Encode state changes as pipe-separated key=value pairs
const stateStr = Object.entries( states )
.map( ( [ k, v ] ) => `${ k }=${ v }` )
.join( '|' );
params.statechange = stateStr;


return $.ajax( {
return api.postWithToken( 'setglobalaccountstatus', payload );
url:    API_ENDPOINT,
method: 'POST',
data:  params
} );
}
 
// ── Render results table ───────────────────────────────────────────────────
 
function renderResultsTable( users ) {
const $wrap = $( '#gul-results-wrap' );
$wrap.empty();
 
if ( users.length === 0 ) {
$wrap.append( '<p><em>No matching accounts found.</em></p>' );
$wrap.addClass( 'visible' );
return;
}
}


// Select-all row
// ── Render results table ───────────────────────────────────────────────
const $selRow = $( '<div>' ).addClass( 'gul-select-all-row' );
function renderResultsTable( users ) {
const $selAll = $( '<input type="checkbox" id="gul-select-all">' ).prop( 'checked', true );
const $wrap = $( '#gul-results-wrap' ).empty().removeClass( 'visible' );
$selRow.append(
$selAll,
$( '<label>' ).attr( 'for', 'gul-select-all' ).css( 'margin', '0' ).text( 'Select / deselect all' ),
$( '<span>' ).addClass( 'gul-count' ).text( `${ users.length } account(s) found` )
);
$wrap.append( $selRow );


// Table
if ( users.length === 0 ) {
const $table = $( '<table>' ).addClass( 'gul-results-table' );
$wrap.append( '<p><em>No matching accounts found.</em></p>' ).addClass( 'visible' );
$table.append( `
return;
<thead>
}
<tr>
<th style="width:28px;"></th>
<th>Username</th>
<th>Registered</th>
<th>Currently locked?</th>
<th style="width:100px;">Action status</th>
</tr>
</thead>
` );
 
const $tbody = $( '<tbody>' );
users.forEach( function ( u ) {
const isLocked = !!u.locked;
const rowId    = `gul-row-${ CSS.escape( u.name ) }`;
const $row    = $( '<tr>' ).attr( 'id', rowId );
 
const $cb = $( '<input type="checkbox" class="gul-user-cb">' )
.val( u.name )
.prop( 'checked', true );


$row.append(
$wrap.append(
$( '<td>' ).append( $cb ),
$( '<div>' ).addClass( 'gul-select-all-row' ).append(
$( '<td>' ).text( u.name ),
$( '<input>' ).attr( { type: 'checkbox', id: 'gul-select-all' } ).prop( 'checked', true ),
$( '<td>' ).text( u.registration ? u.registration.slice( 0, 10 ) : '' ),
$( '<label>' ).attr( 'for', 'gul-select-all' ).css( 'margin', '0' ).text( 'Select / deselect all' ),
$( '<td style="text-align:center;">' ).html(
$( '<span>' ).addClass( 'gul-count' ).text( users.length + ' account(s) found' )
isLocked
)
? '<span class="badge badge-locked">Locked</span>'
: '<span class="badge badge-pending">Active</span>'
),
$( '<td>' ).addClass( 'gul-status-cell' )
.html( '<span class="badge badge-pending">Pending</span>' )
);
);
$tbody.append( $row );
} );


$table.append( $tbody );
const $tbody = $( '<tbody>' );
$wrap.append( $table );
users.forEach( function ( u ) {
$wrap.addClass( 'visible' );
const isLocked = u.locked !== undefined;
const $row = $( '<tr>' ).attr( 'data-user', u.name );


// Select-all toggle
$row.append(
$( '#gul-select-all' ).on( 'change', function () {
$( '<td>' ).append( $( '<input>' ).attr( { type: 'checkbox', class: 'gul-user-cb' } ).val( u.name ).prop( 'checked', true ) ),
$( '.gul-user-cb' ).prop( 'checked', this.checked );
$( '<td>' ).append( $( '<a>' ).attr( { href: mw.util.getUrl( 'Special:CentralAuth/' + u.name ), target: '_blank', rel: 'noopener' } ).text( u.name ) ),
} );
$( '<td>' ).css( 'text-align', 'center' ).html( isLocked ? '<span class="gul-badge gul-badge-locked">Locked</span>' : '<span class="gul-badge gul-badge-active">Active</span>' ),
}
$( '<td>' ).addClass( 'gul-status-cell' ).html( '<span class="gul-badge gul-badge-pending">Pending</span>' )
 
);
// ── Main logic ─────────────────────────────────────────────────────────────
$tbody.append( $row );
} );


function onSearch() {
$wrap.append(
const query = $( '#gul-query' ).val().trim();
$( '<table>' ).addClass( 'gul-results-table' ).append(
if ( !query ) {
$( '<thead>' ).append( $( '<tr>' ).append(
setStatus( 'Please enter a search string.', 'error' );
$( '<th>' ).css( 'width', '28px' ), $( '<th>' ).text( 'Username' ),
return;
$( '<th>' ).text( 'Currently locked?' ), $( '<th>' ).css( 'width', '110px' ).text( 'Action status' )
) ),
$tbody
)
).addClass( 'visible' );
}
}


$( '#gul-btn-search' ).prop( 'disabled', true );
// ── Main handlers ──────────────────────────────────────────────────────
$( '#gul-btn-lock' ).prop( 'disabled', true );
function onSearch() {
$( '#gul-results-wrap' ).removeClass( 'visible' ).empty();
const query = $( '#gul-query' ).val().trim();
$( '#gul-progress' ).removeClass( 'visible' );
if ( !query ) {
clearStatus();
setStatus( 'Please enter a search string.', 'error' );
return;
}


fetchMatchingUsers( query, $( '#gul-from' ).val().trim() )
$( '#gul-btn-search, #gul-btn-lock' ).prop( 'disabled', true );
.done( function ( users ) {
$( '#gul-progress' ).removeClass( 'visible' );
renderResultsTable( users );
clearStatus();
if ( users.length > 0 ) {
$( '#gul-btn-lock' ).prop( 'disabled', false );
setStatus(
`Found <strong>${ users.length }</strong> account(s) matching "<strong>${ mw.html.escape( query ) }</strong>".` +
( users.length >= MAX_ACCOUNTS ? ` (Results capped at ${ MAX_ACCOUNTS }.)` : '' ),
'info'
);
} else {
setStatus( `No accounts found matching "${ mw.html.escape( query ) }".`, 'warning' );
}
} )
.fail( function ( err ) {
setStatus( 'Search failed: ' + mw.html.escape( err ), 'error' );
} )
.always( function () {
$( '#gul-btn-search' ).prop( 'disabled', false );
} );
}


function onLock() {
fetchMatchingUsers( query, $( '#gul-from' ).val().trim() )
const reason  = $( '#gul-reason' ).val().trim();
.done( function ( users ) {
const hide    = $( '#gul-hide' ).prop( 'checked' );
renderResultsTable( users );
const suppress = $( '#gul-suppress' ).prop( 'checked' );
if ( users.length > 0 ) {
const skipLocked = $( '#gul-skip-locked' ).prop( 'checked' );
$( '#gul-btn-lock' ).prop( 'disabled', false );
 
setStatus( 'Found <strong>' + users.length + '</strong> account(s) matching "' + mw.html.escape( query ) + '".' + ( users.length >= MAX_ACCOUNTS ? ' (Capped at ' + MAX_ACCOUNTS + ')' : '' ), 'info' );
if ( !reason ) {
} else {
setStatus( 'A lock reason is required.', 'error' );
setStatus( 'No accounts found matching "' + mw.html.escape( query ) + '".', 'warning' );
return;
}
} )
.fail( function ( err ) { setStatus( 'Search failed: ' + mw.html.escape( String( err ) ), 'error' ); } )
.always( function () { $( '#gul-btn-search' ).prop( 'disabled', false ); } );
}
}


// Collect selected usernames
function onLock() {
const selected = [];
const reason    = $( '#gul-reason'     ).val().trim();
$( '.gul-user-cb:checked' ).each( function () {
const hide      = $( '#gul-hide'        ).prop( 'checked' );
selected.push( $( this ).val() );
const suppress  = $( '#gul-suppress'    ).prop( 'checked' );
} );
const skipLocked = $( '#gul-skip-locked' ).prop( 'checked' );


if ( selected.length === 0 ) {
if ( !reason ) {  
setStatus( 'No accounts selected.', 'warning' );
setStatus( '🛑 A lock reason is required before locking.', 'error' );
return;
$( '#gul-reason' ).trigger( 'focus' );
}
return;  
}


if ( !confirm(
const selected = [];
`You are about to globally lock ${ selected.length } account(s).\n\n` +
$( '.gul-user-cb:checked' ).each( function () { selected.push( $( this ).val() ); } );
`Reason: ${ reason }\n` +
( hide    ? 'Hide username: YES\n'    : '' ) +
( suppress ? 'Suppress username: YES\n' : '' ) +
'\nThis action will be logged. Proceed?'
) ) {
return;
}


$( '#gul-btn-lock, #gul-btn-search' ).prop( 'disabled', true );
if ( selected.length === 0 ) { setStatus( 'No accounts selected.', 'warning' ); return; }
$( '#gul-progress' ).addClass( 'visible' );
setProgress( 0, selected.length );
setStatus( 'Fetching CSRF token…', 'info' );


getCsrfToken()
const $btn = $( '#gul-btn-lock' );
.then( function ( token ) {
setStatus( `Locking ${ selected.length } account(s)…`, 'info' );


let done    = 0;
// ── INLINE CONFIRMATION ──
let locked  = 0;
// First click: Change button state and wait for second click
let skipped = 0;
if ( !$btn.data( 'ready-to-lock' ) ) {
let failed  = 0;
$btn.data( 'ready-to-lock', true )
.text( '⚠️ Confirm Lock (' + selected.length + ')' )
.css( { 'background-color': '#5a1010', 'border-color': '#3a0000' } );


// Sequential processing to avoid API rate limits
setStatus( '⚠️ <strong>WARNING:</strong> You are about to lock ' + selected.length + ' account(s). Click the button again to proceed.', 'warning' );
function processNext( index ) {
if ( index >= selected.length ) {
// Finished
setProgress( done, selected.length );
setStatus(
`Done. <strong>${ locked }</strong> locked, ` +
`<strong>${ skipped }</strong> skipped, ` +
`<strong>${ failed }</strong> failed.`,
failed > 0 ? 'warning' : 'success'
);
$( '#gul-btn-search' ).prop( 'disabled', false );


// Add summary row
// Reset if they don't click within 5 seconds
const $existing = $( '#gul-lock-summary' );
setTimeout( function () {
if ( $existing.length ) $existing.remove();
if ( $btn.data( 'ready-to-lock' ) ) {
$( '#gul-results-wrap' ).append(
$btn.data( 'ready-to-lock', false )
$( '<div>' ).attr( 'id', 'gul-lock-summary' ).addClass( 'gul-summary' ).html(
.text( '🔒 Lock Selected' )
`<strong>Summary:</strong> ${ locked } locked · ${ skipped } skipped · ${ failed } failed`
.css( { 'background-color': '', 'border-color': '' } );
)
clearStatus();
);
return;
}
}
}, 5000 );
return;
}


const username = selected[ index ];
// Second click: Reset button visuals and proceed
const $row    = $( `#gul-row-${ CSS.escape( username ) }` );
$btn.data( 'ready-to-lock', false ).css( { 'background-color': '', 'border-color': '' } );
const isLocked = $row.find( 'td:nth-child(4)' ).text().trim() === 'Locked';
$( '#gul-btn-lock, #gul-btn-search' ).prop( 'disabled', true );
$( '#gul-progress' ).addClass( 'visible' );
setProgress( 0, selected.length );
setStatus( 'Locking ' + selected.length + ' account(s)…', 'info' );
let done = 0, locked = 0, skipped = 0, failed = 0;


if ( skipLocked && isLocked ) {
function processNext( i ) {
skipped++;
if ( i >= selected.length ) {
done++;
setProgress( done, selected.length );
setBadge( username, 'skipped', 'Skipped' );
setStatus( 'Done. <strong>' + locked + '</strong> locked, <strong>' + skipped + '</strong> skipped, <strong>' + failed + '</strong> failed.', failed > 0 ? 'warning' : 'success' );
setProgress( done, selected.length );
$( '#gul-btn-search' ).prop( 'disabled', false );
processNext( index + 1 );
$( '#gul-lock-summary' ).remove();
return;
$( '#gul-results-wrap' ).append( $( '<div id="gul-lock-summary">' ).addClass( 'gul-summary' ).html( '<strong>Summary:</strong> ' + locked + ' locked · ' + skipped + ' skipped · ' + failed + ' failed' ) );
}
return;
}


setBadge( username, 'pending', 'Locking…' );
const username = selected[ i ];
const wasLocked = $( 'tr[data-user="' + $.escapeSelector( username ) + '"] td:nth-child(3)' ).text().trim() === 'Locked';


lockAccount( username, token, reason, hide, suppress )
if ( skipLocked && wasLocked ) {
.done( function ( data ) {
skipped++; done++;
if ( data.centralauth && data.centralauth.status === 'ok' ) {
setBadge( username, 'skipped', 'Skipped' );
locked++;
setProgress( done, selected.length );
setBadge( username, 'locked', 'Locked ✓' );
processNext( i + 1 );
} else if ( data.error ) {
return;
failed++;
setBadge( username, 'failed', 'Error: ' + mw.html.escape( data.error.info || data.error.code ) );
} else {
// Treat an empty-but-non-error response as likely success
// (some MediaWiki versions return differently shaped responses)
locked++;
setBadge( username, 'locked', 'Locked ✓' );
}
} )
.fail( function () {
failed++;
setBadge( username, 'failed', 'Network error' );
} )
.always( function () {
done++;
setProgress( done, selected.length );
setStatus(
`Processing ${ done } / ${ selected.length }…`,
'info'
);
// Small delay to be polite to the API
setTimeout( function () {
processNext( index + 1 );
}, 300 );
} );
}
}


processNext( 0 );
setBadge( username, 'pending', 'Locking…' );
} )
.fail( function () {
setStatus( 'Failed to obtain CSRF token. Are you logged in with sufficient rights?', 'error' );
$( '#gul-btn-lock, #gul-btn-search' ).prop( 'disabled', false );
} );
}


function onClear() {
lockAccount( username, reason, hide, suppress )
$( '#gul-query, #gul-from, #gul-reason' ).val( '' );
.done( function ( result ) {
$( '#gul-hide, #gul-suppress' ).prop( 'checked', false );
if ( result.error ) {
$( '#gul-skip-locked' ).prop( 'checked', true );
failed++;
$( '#gul-results-wrap' ).removeClass( 'visible' ).empty();
setBadge( username, 'failed', 'Error: ' + mw.html.escape( result.error.info || result.error.code ) );
$( '#gul-progress' ).removeClass( 'visible' );
} else {
$( '#gul-progress-bar' ).css( 'width', '0%' );
locked++;
clearStatus();
setBadge( username, 'locked', 'Locked ✓' );
$( '#gul-btn-lock' ).prop( 'disabled', true );
}
}
} )
 
.fail( function ( code, result ) {
// ── Initialise ─────────────────────────────────────────────────────────────
failed++;  
 
const errMsg = (result && result.error && result.error.info) ? result.error.info : code;
function init() {
setBadge( username, 'failed', 'Error: ' + mw.html.escape( errMsg ) );  
// Only load on Special:CentralAuth or Special:GlobalUserRights
} )
// (or remove the guard below to load everywhere)
.always( function () {
const special = mw.config.get( 'wgCanonicalSpecialPageName' );
done++;
if ( special !== 'CentralAuth' && special !== 'GlobalUserRights' ) {
setProgress( done, selected.length );
// Load on any page via mw.util.addPortletLink trigger
setStatus( 'Processing ' + done + ' / ' + selected.length + '', 'info' );
// Uncomment to restrict:
setTimeout( function () { processNext( i + 1 ); }, 300 );
// return;
} );
}
processNext( 0 );
}
}


const $ui = buildUI();
function onClear() {
// Reset the confirmation button state if clear is clicked
const $btn = $( '#gul-btn-lock' );
$btn.data( 'ready-to-lock', false )
.text( '🔒 Lock Selected' )
.css( { 'background-color': '', 'border-color': '' } )
.prop( 'disabled', true );


// Try to insert after the heading on Special pages, else append to content
$( '#gul-query, #gul-from, #gul-reason' ).val( '' );
const $heading = $( '#firstHeading, h1.firstHeading' ).first();
$( '#gul-hide, #gul-suppress' ).prop( 'checked', false );
if ( $heading.length ) {
$( '#gul-skip-locked' ).prop( 'checked', true );
$heading.after( $ui );
$( '#gul-results-wrap' ).removeClass( 'visible' ).empty();
} else {
$( '#gul-progress' ).removeClass( 'visible' );
$( '#mw-content-text' ).prepend( $ui );
$( '#gul-progress-bar' ).css( 'width', '0%' );
clearStatus();
}
}


// Bind events
} ); // End of mw.loader.using().then()
$( '#gul-btn-search' ).on( 'click', onSearch );
$( '#gul-btn-lock'  ).on( 'click', onLock  );
$( '#gul-btn-clear'  ).on( 'click', onClear  );
 
// Allow Enter key in the query field to trigger search
$( '#gul-query' ).on( 'keydown', function ( e ) {
if ( e.key === 'Enter' ) onSearch();
} );
}
 
// Wait for DOM + MW core
$( init );


}() );
}() );
Cookies help us deliver our services. By using our services, you agree to our use of cookies.