MediaWiki:Gadget-ParserPlayground.js

/** * MediaWiki:Gadget-ParserPlayground.js * Stub to load Extension:ParserPlayground as a gadget. * * Requires enhanced editing toolbar (WikiEditor extension); integrates with toolbar. * * Gadget stub CC-BY-SA 2 * (c) 2011 Brion Vibber  * * Extension:ParserPlayground JS bits are GPLv2 or compat -- http://www.mediawiki.org/wiki/Extension:ParserPlayground */ ( function($) {   // @fixme need an SSL alternative    mw.config.set('wgParserPlaygroundAssetsPath', 'http://toolserver.org/~brion/extensions');    var moduleBase = mw.config.get('wgParserPlaygroundAssetsPath') + '/ParserPlayground/modules';    var $box = $('#wpTextbox1');    if ($box.length) {        $(function { var scripts = [ 'lib.jsdiff.js', 'lib.pegjs.js', 'jquery.nodetree.js', 'ext.parserPlayground.hashMap.js', 'ext.parserPlayground.classicParser.js', 'ext.parserPlayground.serializer.js', 'ext.parserPlayground.renderer.js', 'ext.parserPlayground.pegParser.js', 'ext.parserPlayground.js' ],           styles = [ 'jquery.nodetree.css', 'ext.parserPlayground.css' ],           $head = $('head');

mw.messages.set({               'vis-edit-source-ok': 'Ok',                'vis-edit-source-cancel': 'Cancel'            });

$.each(styles, function(i, style) {               var $link = $(' ')                    .attr('rel', 'stylesheet')                    .attr('href', moduleBase + '/' + style)                    .attr('type', 'text/css');                $head.append($link);            }); $.each(scripts, function(i, script) {               var $script = $(' ').attr('src', moduleBase + '/' + script);                $head.append($script);            }); });   } })(jQuery);