mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-14 19:31:44 +00:00
Override extracting paramters in ext.templateData.data resource module
This commit is contained in:
parent
df30141d1f
commit
98d379c464
|
@ -42,8 +42,33 @@
|
|||
}
|
||||
};
|
||||
|
||||
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.hook('wikipage.content').add(function($content) {
|
||||
MediaCollection.init($content);
|
||||
CollapsibleGroup.init($content);
|
||||
});
|
||||
mw.loader.using('ext.templateDataGenerator.data').then(function() {
|
||||
TemplateDataSuggestions.init();
|
||||
});
|
||||
})(window, jQuery);
|
||||
|
|
Loading…
Reference in a new issue