// [[User:Quarl/imdb_canonicalize.js]] - canonicalizes IMDB external links
// Example: [http://www.imdb.com/title/tt0403832/ IMDB Entry] becomes
// {{imdb title|id=0403832|title=Quarl/imdb canonicalize.js}}
// requires: wikipage.js, util.js, addlilink.js
// quarl 2006-02-06 initial version
//<pre><nowiki>
imdbz = new autoedit(
'imdbz',
'ImdbZ',
'ca-imdbz',
'Canonicalize IMDB links',
'IMDB canonicalization');
imdbz.buildRegExp = function() {
return new RegExp(
'\\[http://(?:www\\.)?imdb\\.com/(title|name)/(?:tt|nm)([0-9]+)/?[^\\]]*\\]');
}
imdbz.replaceRegExp = function(d, m)
{
var type = m[1];
var idnum = m[2];
if (type == 'name') {
return '{{imdb name|id='+idnum+'|name={{subst:PAGENAME}}}}';
} else if (type == 'title') {
return '{{imdb title|id='+idnum+'|name={{subst:PAGENAME}}}}';
}
alert ("## internal error 781cea49-9cb7-44b1-8656-368608c5457c");
return null;
}
imdbz._load = function() {
imdbz.addTab();
}
$(imdbz._load);
//</nowiki></pre>