User:Tyilo/quickpreview.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, '"'));					var holder = loadedScripts;					loadedScripts = {};					$('head:eq(0)').append($('[src*="gen=js"]:eq(0)').clone);					loadedScripts = holder;					$('#dlQuickPreview').val('Quick preview').removeAttr('disabled'); }			});		});		if (skin == 'monobook') { // Monobook $('#editOptions .editButtons input').eq(1).after($button); } else { // Monaco/Oasis $('#edit_enhancements_toolbar li').eq(2).after($(' ').append($button)); }			}); }