Merge "MimeAnalyzer: Detect magic bytes for mp3"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / mw.rcfilters.js
1 ( function ( mw ) {
2 mw.rcfilters = {
3 dm: {},
4 ui: {},
5 utils: {
6 addArrayElementsUnique: function ( arr, elements ) {
7 elements = Array.isArray( elements ) ? elements : [ elements ];
8
9 elements.forEach( function ( element ) {
10 if ( arr.indexOf( element ) === -1 ) {
11 arr.push( element );
12 }
13 } );
14
15 return arr;
16 },
17 normalizeParamOptions: function ( givenOptions, legalOptions ) {
18 var result = [];
19
20 if ( givenOptions.indexOf( 'all' ) > -1 ) {
21 // If anywhere in the values there's 'all', we
22 // treat it as if only 'all' was selected.
23 // Example: param=valid1,valid2,all
24 // Result: param=all
25 return [ 'all' ];
26 }
27
28 // Get rid of any dupe and invalid parameter, only output
29 // valid ones
30 // Example: param=valid1,valid2,invalid1,valid1
31 // Result: param=valid1,valid2
32 givenOptions.forEach( function ( value ) {
33 if (
34 legalOptions.indexOf( value ) > -1 &&
35 result.indexOf( value ) === -1
36 ) {
37 result.push( value );
38 }
39 } );
40
41 return result;
42 }
43 }
44 };
45 }( mediaWiki ) );