User:Ameobea/monaco.js

/** * Original script: User:Sander_Säde/quickpreview.js * Ported to use jQuery and Wikia compatibility */ if (wgAction == 'edit' || wgAction == 'submit') { $(document).ready(function {		var attrs = {			tabindex: 6,			accesskey: 'g',			id: 'dlQuickPreview',			title: 'Preview your changes'		};		var $button = $(' ').val('Quick preview').attr(attrs).click(function { $(this).val('Getting preview').attr('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: wgScript + document.location.search.replace('&action=edit', '&action=submit') + '&wpPreview=true&live=true',				success: function(response) {					$('#wikiPreview').css('display', 'block').html(response.replace(/&gt;/g, '>').replace(/&lt;/g, '<').replace(/&amp;/g, '&').replace(/&quot;/g, '"'));					$('#dlQuickPreview').val('Quick preview').prop('disabled', false);				}			});		});		if (skin == 'monobook') {			// Monobook			$('#editOptions .editButtons input').eq(1).after($button);		} else {			// Monaco/Oasis $('#edit_enhancements_toolbar li').eq(2).after($(' ').append($button)); }			}); }