r58719 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58718‎ | r58719 | r58720 >
Date:17:44, 7 November 2009
Author:dale
Status:deferred
Tags:
Comment:
* fixed subtitles language msg
Modified paths:
  • /trunk/phase3/js2/mwEmbed/libTimedText/mvTextInterface.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/php/languages/mwEmbed.i18n.php (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/php/languages/mwEmbed.i18n.php
@@ -49,6 +49,8 @@
5050 'mwe-improve_transcript' => 'Improve',
5151 'mwe-no_text_tracks_found' => 'No text tracks were found',
5252 'mwe-subtitles' => '$1 subtitles',
 53+ 'mwe-no_text_tracks_found' => 'No text subtitles found',
 54+ 'mwe-add-edit-subs' => 'Add/edit subtitles',
5355
5456 /*
5557 * js file: /libSequencer/mvTimedEffectsEdit.js
Index: trunk/phase3/js2/mwEmbed/libTimedText/mvTextInterface.js
@@ -4,7 +4,8 @@
55 "mwe-auto_scroll" : "auto scroll",
66 "mwe-close" : "close",
77 "mwe-improve_transcript" : "Improve",
8 - "mwe-no_text_tracks_found" : "No text tracks were found"
 8+ "mwe-no_text_tracks_found" : "No text subtitles found",
 9+ "mwe-add-edit-subs" : "Add/edit subtitles"
910 })
1011 // text interface object (for inline display captions)
1112 var mvTextInterface = function( parentEmbed ){
@@ -18,6 +19,11 @@
1920 autoscroll:true,
2021 add_to_end_on_this_pass:false,
2122 scrollTimerId:0,
 23+ found_tracks: false,
 24+ suportedMime:{
 25+ 'srt': 'text/x-srt',
 26+ 'cmml': 'text/cmml'
 27+ },
2228 init:function( parentEmbed ){
2329 //init a new availableTracks obj:
2430 this.availableTracks={};
@@ -28,7 +34,7 @@
2935 },
3036 //@@todo separate out data loader & data display
3137 getTimedTextTracks:function(){
32 - js_log("load timed text from roe: "+ this.pe.roe);
 38+ //js_log("load timed text from roe: "+ this.pe.roe);
3339 var _this = this;
3440 var apiUrl = mwGetLocalApiUrl();
3541 //if roe not yet loaded do load it:
@@ -39,13 +45,12 @@
4046 if(_this.pe.roe){
4147 do_request( _this.pe.roe, function(data)
4248 {
43 - //continue
4449 _this.pe.media_element.addROE(data);
4550 _this.getParseTimedText_rowReady();
4651 });
4752 }else if( _this.pe.wikiTitleKey ){
4853 do_api_req({
49 - 'url': apiUrl,
 54+ 'url' : apiUrl,
5055 'data': {
5156 'list' : 'allpages',
5257 'apprefix' : 'TimedText:' + _this.pe.wikiTitleKey
@@ -68,11 +73,8 @@
6974 var langKey = subPage.title.split('.');
7075 var extension = langKey.pop();
7176 langKey = langKey.pop();
72 - var mimeTypes = {
73 - 'srt': 'text/x-srt',
74 - 'cmml': 'text/cmml'
75 - }
76 - if( !mimeTypes[ extension ] ){
 77+
 78+ if( ! _this.suportedMime[ extension ] ){
7779 js_log('Error: unknown extension:'+ extension);
7880 continue;
7981 }
@@ -84,14 +86,15 @@
8587 $j(textElm).attr({
8688 'category' : 'SUB',
8789 'lang' : langKey,
88 - 'type' : mimeTypes[ extension ],
 90+ 'type' : _this.suportedMime[ extension ],
8991 'title' : langData[ langKey],
9092 'src' : wgServer + wgScript + '?title=' + subPage.title + '&action=raw'
9193 });
92 - _this.pe.media_element.tryAddSource( textElm );
93 - _this.getParseTimedText_rowReady();
 94+ _this.pe.media_element.tryAddSource( textElm );
9495 }
9596 }
 97+ //after all text loaded:
 98+ _this.getParseTimedText_rowReady();
9699 }); //do_api_req({
97100 }); //function( subData ) {
98101 }
@@ -107,15 +110,12 @@
108111 }
109112 }
110113 },
111 - getParseTimedText_rowReady: function (){
112 - var _this = this;
113 - //create timedTextObj
114 - var default_found=false;
 114+ getParseTimedText_rowReady: function (){
 115+ var _this = this;
 116+ //create timedTextObj
115117 js_log("mv_txt_load_:SHOW mv_txt_load_");
116118 $j('#mv_txt_load_'+_this.pe.id).show(); //show the loading icon
117 -
118119 $j.each( this.pe.media_element.sources, function(inx, source){
119 -
120120 if( typeof source.id == 'undefined' || source.id == null ){
121121 source.id = 'tt_' + inx;
122122 }
@@ -128,7 +128,7 @@
129129 //display if requested:
130130 if( source['default'] == "true" ){
131131 //we did set at least one track by default tag
132 - default_found=true;
 132+ _this.found_tracks=true;
133133 js_log('do load timed text: ' + source.id );
134134 _this.loadAndDisplay( source.id );
135135 }else{
@@ -136,22 +136,15 @@
137137 }
138138 }
139139 });
140 -
141140 //no default clip found take the first_id
142 - if(!default_found){
 141+ if(!_this.found_tracks){
143142 $j.each( _this.availableTracks, function(inx, sourceTrack){
144143 _this.loadAndDisplay( sourceTrack.id );
145 - default_found=true;
146 - //retun after loading first available
 144+ _this.found_tracks=true;
 145+ //return after loading first available
147146 return false;
148147 });
149148 }
150 -
151 - //if nothing found anywhere update the loading icon to say no tracks found
152 - if(!default_found)
153 - $j('#mv_txt_load_'+_this.pe.id).html( gM('mwe-no_text_tracks_found') );
154 -
155 -
156149 },
157150 loadAndDisplay: function ( track_id){
158151 var _this = this;
@@ -299,7 +292,7 @@
300293 applyTsSelect:function(){
301294 var _this = this;
302295 //update availableTracks
303 - $j('#mvtsel_'+this.pe.id+' .mvTsSelect').each(function(){
 296+ $j('#mvtsel_' + this.pe.id + ' .mvTsSelect').each(function(){
304297 if(this.checked){
305298 var track_id = this.name;
306299 //if not yet loaded now would be a good time
@@ -394,13 +387,23 @@
395388 },
396389 getMenu:function(){
397390 var out='';
 391+ var _this = this;
398392 //add in loading icon:
399393 var as_checked = (this.autoscroll)?'checked':'';
400 - out+= '<div id="tt_mmenu_'+this.pe.id+'" class="ui-widget-header" style="font-size:.6em;position:absolute;top:0;height:30px;left:0px;right:0px;">' +
401 - $j.btnHtml(gM('mwe-select_transcript_set'), 'tt-select', 'shuffle');
402 - if(this.pe.media_element.linkback){
403 - out+=' ' + $j.btnHtml(gM('mwe-improve_transcript'), 'tt-improve', 'document', {href:this.pe.media_element.linkback, target:'_new'});
 394+ out += '<div id="tt_mmenu_'+this.pe.id+'" class="ui-widget-header" style="font-size:.6em;position:absolute;top:0;height:30px;left:0px;right:0px;">';
 395+ out += $j.btnHtml( gM('mwe-select_transcript_set'), 'tt-select', 'shuffle');
 396+
 397+ _this.editlink = '';
 398+
 399+ if( this.pe.media_element.linkback ){
 400+ _this.editlink = this.pe.media_element.linkback;
 401+ }else if(this.pe.wikiTitleKey && wgServer && wgScript) { //check for wikiTitleKey (for edit linkback)
 402+ //only local:
 403+ _this.editlink = wgServer + wgScript + '?title=TimedText:' + this.pe.wikiTitleKey +'.'+ wgContentLanguage + '.srt&action=edit';
404404 }
 405+ if(_this.editlink!='')
 406+ out+=' ' + $j.btnHtml(gM('mwe-improve_transcript'), 'tt-improve', 'document', {href:_this.editlink, target:'_new'});
 407+
405408 out+='<input onClick="document.getElementById(\''+this.pe.id+'\').textInterface.setAutoScroll(this.checked);return false;" ' +
406409 'type="checkbox" '+as_checked +'>'+gM('mwe-auto_scroll') + ' ' +
407410 $j.btnHtml(gM('mwe-close'), 'tt-close', 'circle-close');
@@ -420,6 +423,15 @@
421424 });
422425 //use hard-coded link:
423426 $j(mt + ' .tt-improve').btnBind();
 427+
 428+ //dobule check we have sublties (else add default missing msg)
 429+ //if nothing found anywhere update the loading icon to say no tracks found
 430+ if(!_this.found_tracks){
 431+ $j( '#mmbody_' + _this.pe.id).html( ''+
 432+ '<h3>' + gM('mwe-no_text_tracks_found') + '</h3>' +
 433+ '<a href="' + _this.editlink + '">'+ gM('mwe-add-edit-subs') + '</a>'
 434+ );
 435+ }
424436 }
425437 }
426438

Status & tagging log