mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-13 18:36:54 +00:00
30 lines
853 B
JavaScript
30 lines
853 B
JavaScript
(function (window) {
|
|
'use strict';
|
|
|
|
var TemplateDataSuggestions = {
|
|
init: function() {
|
|
var original = mw.TemplateData.SourceHandler.prototype.extractParametersFromTemplateCode;
|
|
mw.TemplateData.SourceHandler.prototype.extractParametersFromTemplateCode = function( templateCode ) {
|
|
var infobox, source,
|
|
params = original(templateCode),
|
|
infoboxRegex = /<infobox.*?<\/infobox>/gs,
|
|
sourceRegex = /<[^<\/>]*? source="([^"]*)"[^>]*>/g;
|
|
|
|
while( ( infobox = infoboxRegex.exec(templateCode) ) !== null ) {
|
|
while( ( source = sourceRegex.exec(infobox) ) !== null ) {
|
|
if ( $.inArray( source[1], params ) === -1 ) {
|
|
params.push( source[1] );
|
|
}
|
|
}
|
|
}
|
|
|
|
return params;
|
|
}
|
|
}
|
|
}
|
|
|
|
mw.loader.using('ext.templateDataGenerator.data').then(function() {
|
|
TemplateDataSuggestions.init();
|
|
});
|
|
})(window);
|