r67979 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67978‎ | r67979 | r67980 >
Date:02:42, 14 June 2010
Author:dale
Status:deferred
Tags:
Comment:
gave ajax preview call 60s to complete
Modified paths:
  • /branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/ClipEdit/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/ClipEdit/mw.ClipEdit.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbed.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -2810,7 +2810,7 @@
28112811 $j( _this.target_container ).dialog( 'option', 'title',
28122812 gM( 'mwe-preview_insert_resource', resource.title ) );
28132813
2814 - // Update buttons preview:
 2814+ // Update buttons
28152815 $j( buttonPaneSelector )
28162816 .html(
28172817 $j.btnHtml( gM( 'rsd_do_insert' ), 'preview_do_insert', 'check' ) + ' ' )
@@ -2828,8 +2828,10 @@
28292829 .text( gM('mwe-do-more-modification' ) )
28302830 .click( function() {
28312831 $j( '#rsd_preview_display' ).remove();
 2832+
28322833 // Restore title:
28332834 $j( _this.target_container ).dialog( 'option', 'title', origTitle );
 2835+
28342836 // Restore buttons (from the clipEdit object::)
28352837 _this.clipEdit.updateInsertControlActions();
28362838 return false;
@@ -2841,15 +2843,16 @@
28422844 var pos = $j( _this.target_textbox ).textSelection( 'getCaretPosition' );
28432845 var editWikiText = $j( _this.target_textbox ).val();
28442846 var wikiText = editWikiText.substr(0, pos) + embed_code + editWikiText.substr( pos );
 2847+
28452848 mw.parseWikiText(
28462849 wikiText,
28472850 _this.target_title,
2848 - function( phtml ) {
2849 - $j( '#rsd_preview_display' ).html( phtml );
 2851+ function( previewHtml ) {
 2852+ $j( '#rsd_preview_display' ).html( previewHtml );
28502853 if( mw.documentHasPlayerTags() ) {
28512854 mw.load( 'EmbedPlayer', function() {
28522855 // Update the display of video tag items (if any)
2853 - $j( mw.getConfig( 'rewritePlayerTags' ) ).embedPlayer();
 2856+ $j.embedPlayers();
28542857 });
28552858 }
28562859 }
Index: branches/MwEmbedStandAlone/modules/ClipEdit/loader.js
@@ -18,7 +18,7 @@
1919 [
2020 'mw.ClipEdit',
2121 'mw.style.ClipEdit'
22 - ],
 22+ ],
2323 function(){
2424 callback( 'ClipEdit' );
2525 }
Index: branches/MwEmbedStandAlone/modules/ClipEdit/mw.ClipEdit.js
@@ -700,7 +700,7 @@
701701 } else if ( this.getMediaType() == 'video' ) {
702702 this.applyVideoStartEnd();
703703 }
704 - // copy over the desc text to the resource object
 704+ // copy over the description text to the resource object
705705 _this.resource['inlineDesc'] = $j( '#mv_inline_img_desc' ).val();
706706 },
707707
@@ -960,7 +960,7 @@
961961 /**
962962 * Do the crop Interface
963963 */
964 - doCropInterface:function() {
 964+ doCropInterface: function() {
965965 var _this = this;
966966 $j( '.mw_crop_msg' ).hide();
967967 $j( '.mw_crop_msg_load' ).show();
Index: branches/MwEmbedStandAlone/mwEmbed.js
@@ -808,20 +808,28 @@
809809 * @param {String} title Context title of the content to be parsed
810810 * @param {Function} callback Function called with api parser output
811811 */
812 - mw.parseWikiText = function( wikitext, title, callback ) {
813 - // make sure we have json to decode the resposne
814 - mw.load('JSON', function(){
815 - $j.post( mw.getLocalApiUrl(),
816 - {
817 - 'action': 'parse',
818 - 'format': 'json',
819 - 'title' : title,
820 - 'text': wikitext
821 - }, function( data ) {
822 - var pageData = JSON.parse( data );
823 - callback( pageData.parse.text['*'] );
824 - }
825 - );
 812+ mw.parseWikiText = function( wikitext, title, callback ) {
 813+ $j.ajax({
 814+ type: 'POST',
 815+ url: mw.getLocalApiUrl(),
 816+ // Give the wiki 60 seconds to parse the wiki-text
 817+ timeout : 60000,
 818+ data: {
 819+ 'action': 'parse',
 820+ 'format': 'json',
 821+ 'title' : title,
 822+ 'text': wikitext
 823+ },
 824+ dataType: 'json',
 825+ success: function( data ) {
 826+ // xxx should handle other failures
 827+ callback( data.parse.text['*'] );
 828+ },
 829+ error: function( XMLHttpRequest, textStatus, errorThrown ){
 830+ // xxx should better handle failures
 831+ mw.log( "Error: mw.parseWikiText:" + textStatus );
 832+ callback( "Error: failed to parse wikitext " );
 833+ }
826834 });
827835 }
828836

Status & tagging log