MediaWiki:Gadget-codeBacklinks.js

var PCM = mw.config.get( "wgTitle" ).substr(mw.config.get( "wgTitle" ).lastIndexOf(".")); if(PCM === ".js"){ PCM = "javascript"; }else if(PCM === ".css"){ PCM = "css"; } $("pre.source-" + PCM).find("span.co1, span.coMULTI").not("span.co1, span.coMULTI").each(function{	var codeComment = $(this).html.substr($(this).html.indexOf(""));	var wikiLink = "";	while(codeComment.indexOf("[[") !== -1 && codeComment.indexOf("") !== -1){		wikiLink = codeComment.slice(codeComment.indexOf("") +2, codeComment.indexOf(""));		codeComment = codeComment.substr(codeComment.indexOf("]]") +2); console.log("codeComment:\n\t %s\nHas link to:\n\t %s", codeComment, wikiLink);	} });

// single line no link // single line single link // single line double unspaced linkssingle line double unspaced links // single line double spaced links -- single line double spaced links /* multi line no link */ /* multi-line multi-line single link */ /* multi-line double unspaced links multi-line double unspaced linksmulti-line double unspaced links */ /* multi-line multi-line double spaced links -- multi-line double spaced links */ /* multi-line //no link around single line */ /* multi-line //multi-line single link around single line around single line */ /* multi-line //double unspaced links around single linedouble unspaced links around single line around single line */ /* multi-line //double spaced links around single line -- double spaced links around single line around single line */ // single line in front of multi-line /* no link */ // single line in front of multi-line single link /* single line in front of multi-line single link */ // single line in front of multi-line double unspaced links /* single line in front of multi-line double unspaced linkssingle line in front of multi-line double unspaced links */ // single line in front of multi-line double spaced links /* single line in front of multi-line double spaced links -- single line in front of multi-line double spaced links */