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(mw, $) {   // @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' ];           var styles = [ 'jquery.nodetree.css', 'ext.parserPlayground.css' ];           var messages = { 'vis-edit-source-ok': 'Ok', 'vis-edit-source-cancel': 'Cancel' };

var $head = $('head'); for (var key in messages) { if (messages.hasOwnProperty(key)) { var text = messages[key]; mw.messages.set(key, text); }           }            $.each(styles, function(i, style) {                var url = moduleBase + '/' + style;                $(' ')                    .attr('rel', 'stylesheet')                    .attr('href', url)                    .attr('type', 'text/css')                    .appendTo($head);            }); $.each(scripts, function(i, script) {               var url = moduleBase + '/' + script;                $(' ')                    .attr('src', url)                    .appendTo($head);            }); });   } })(mediaWiki, jQuery);