Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5976515
ext.abuseFilter.examine.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ext.abuseFilter.examine.js
View Options
/**
* Check a filter against a change
*
* @author John Du Hart
* @author Marius Hoch <hoo@online.de>
*/
(
function
()
{
'use strict'
;
// @var {jQuery} Syntax result div
var
$syntaxResult
;
/**
* Processes the results of the filter test
*
* @param {Object} data The response of the API request
*/
function
examinerTestProcess
(
data
)
{
$
.
removeSpinner
(
'filter-check'
);
var
msg
,
exClass
;
if
(
data
.
abusefiltercheckmatch
.
result
)
{
exClass
=
'mw-abusefilter-examine-match'
;
msg
=
'abusefilter-examine-match'
;
}
else
{
exClass
=
'mw-abusefilter-examine-nomatch'
;
msg
=
'abusefilter-examine-nomatch'
;
}
$syntaxResult
.
attr
(
'class'
,
exClass
)
// Messages listed above
// eslint-disable-next-line mediawiki/msg-doc
.
text
(
mw
.
msg
(
msg
)
)
.
show
();
}
/**
* Processes the results of the filter test in case of an error
*
* @param {string} error Error code returned from the AJAX request
* @param {Object} details Details about the error
*/
function
examinerTestProcessFailure
(
error
,
details
)
{
$
.
removeSpinner
(
'filter-check'
);
var
msg
;
if
(
error
===
'badsyntax'
)
{
$syntaxResult
.
attr
(
'class'
,
'mw-abusefilter-syntaxresult-error'
);
msg
=
'abusefilter-examine-syntaxerror'
;
}
else
if
(
error
===
'nosuchrcid'
||
error
===
'nosuchlogid'
)
{
msg
=
'abusefilter-examine-notfound'
;
}
else
if
(
error
===
'permissiondenied'
)
{
// The 'abusefilter-modify' or 'abusefilter-view-private' right is needed
// to use this API
msg
=
'abusefilter-mustviewprivateoredit'
;
}
else
if
(
error
===
'http'
)
{
msg
=
'abusefilter-http-error'
;
}
else
{
msg
=
'unknown-error'
;
}
$syntaxResult
// Messages listed above
// eslint-disable-next-line mediawiki/msg-doc
.
text
(
mw
.
msg
(
msg
,
details
&&
details
.
exception
)
)
.
show
();
}
/**
* Tests the filter against an rc event or abuse log entry.
*
* @this HTMLElement
* @param {jQuery.Event} e The event fired when the function is called
*/
function
examinerTestFilter
()
{
var
filter
=
$
(
'#wpFilterRules'
).
val
(),
examine
=
mw
.
config
.
get
(
'abuseFilterExamine'
),
params
=
{
action
:
'abusefiltercheckmatch'
,
filter
:
filter
};
$
(
this
).
injectSpinner
(
{
id
:
'filter-check'
,
size
:
'large'
}
);
params
[
examine
.
type
===
'rc'
?
'rcid'
:
'logid'
]
=
examine
.
id
;
// Use post due to the rather large amount of data
new
mw
.
Api
().
post
(
params
)
.
done
(
examinerTestProcess
)
.
fail
(
examinerTestProcessFailure
);
}
$
(
function
initialize
()
{
$syntaxResult
=
$
(
'#mw-abusefilter-syntaxresult'
);
$
(
'#mw-abusefilter-examine-test'
).
on
(
'click'
,
examinerTestFilter
);
}
);
}()
);
File Metadata
Details
Attached
Mime Type
text/x-asm
Expires
Sat, Oct 3, 19:12 (2 d, 36 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
12/48/99de433b2a42b14e9b382673ec83
Default Alt Text
ext.abuseFilter.examine.js (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment