User:Quarenon/quickpreview.js

/** * Original script: User:Sander_Säde/quickpreview.js * Ported to use jQuery and Monaco for Wikia */

if (wgAction == 'edit' || wgAction == 'submit') { $(document).ready(function {		var attrs = {			value: 'Quick preview',			type: 'button',			tabindex: 6,			accesskey: 'g',			id: 'dlQuickPreview',			title: 'Preview your changes'		};		var $button = $(' ').attr(attrs).click(function { $(this).attr({value: 'Getting preview', disabled: 'disabled'});

var f = document.editform; $.ajax({				data: {					'wpMinoredit': f.wpMinoredit.checked,					'wpWatchthis': f.wpWatchthis.checked,					'wpStarttime': f.wpStarttime.value,					'wpEdittime': f.wpEdittime.value,					'wpAutoSummary': f.wpAutoSummary.value,					'wpEditToken': f.wpEditToken.value,					'wpSummary': 'Quick preview',					'wpTextbox1': f.wpTextbox1.value				},				dataType: 'text',				type: 'POST',				url: document.location.href.replace('&action=edit', '&action=submit') + '&wpPreview=true&live=true',				success: function(response) {					$('#wikiPreview').css('display', 'block').html(unescape(response.replace(/&gt;/g, '>').replace(/&lt;/g, '<').replace(/&amp;/g, '&').replace(/&quot;/g, '"')));					$('#dlQuickPreview').attr({value: 'Quick preview', disabled: null});				}			});		});		var $li = $(' ').append($button);		$('#edit_enhancements_toolbar li').eq(2).after($li);	}); }