r75187 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75186‎ | r75187 | r75188 >
Date:12:12, 22 October 2010
Author:hartman
Status:deferred
Tags:
Comment:
mwEmbed: Repair generation of Languages menu.
Modified paths:
  • /branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js
@@ -773,9 +773,11 @@
774774 getLanguageMenu: function() {
775775 var _this = this;
776776
777 - // See if we have categories to worry about:
 777+ // See if we have categories to worry about
 778+ // associative array of SUB etc categories. Each category contains an array of textSources.
 779+ var catSourceList = {};
 780+ var catSourceCount = 0;
778781
779 - var catSourceList = [ ];
780782 // ( All sources should have a category (depreciate )
781783 var sourcesWithoutCategory = [ ];
782784 for( var i=0; i < this.textSources.length; i++ ) {
@@ -786,6 +788,7 @@
787789 if( !catSourceList[ catKey ] ) {
788790 // Set up catList pointer:
789791 catSourceList[ catKey ] = [ ];
 792+ catSourceCount++;
790793 }
791794 // Append to the source category key menu item:
792795 catSourceList[ catKey ].push(
@@ -797,10 +800,10 @@
798801 }
799802 var $langMenu = $j('<ul>');
800803 // Check if we have multiple categories ( if not just list them under the parent menu item)
801 - if( catSourceList.length > 1 ) {
802 - for(var catKey=0; catKey < catSourceList.length; catKey++) {
 804+ if( catSourceCount > 1 ) {
 805+ for(var catKey in catSourceList) {
803806 $catChildren = $j('<ul>');
804 - for(var i in catSourceList[ catKey ]) {
 807+ for(var i=0; i < catSourceList[ catKey ].length; i++) {
805808 $catChildren.append(
806809 catSourceList[ catKey ][i]
807810 );
@@ -813,8 +816,8 @@
814817 );
815818 }
816819 } else {
817 - for(var catKey=0; catKey < catSourceList.length; catKey++) {
818 - for(var i in catSourceList[ catKey ]) {
 820+ for(var catKey in catSourceList) {
 821+ for(var i=0 i < catSourceList[ catKey ].length; i++) {
819822 $langMenu.append(
820823 catSourceList[ catKey ][i]
821824 );
@@ -1086,7 +1089,7 @@
10871090 var startIndex = 0;
10881091 }
10891092 // Start looking for the text via time, return first match:
1090 - for( var i = startIndex ; i < this.captions.length; i ++ ) {
 1093+ for( var i = startIndex ; i < this.captions.length; i++ ) {
10911094 caption = this.captions[ i ];
10921095 if( time >= caption.start &&
10931096 time <= caption.end ) {
@@ -1188,7 +1191,7 @@
11891192 // Get captions
11901193 var captions = [];
11911194 var caplist = srt.split('\n\n');
1192 - for (var i = 0; i < caplist.length; i=i+1) {
 1195+ for (var i = 0; i < caplist.length; i++) {
11931196 var caption = "";
11941197 var content, start, end, s;
11951198 caption = caplist[i];

Follow-up revisions

RevisionCommit summaryAuthorDate
r75189Followup to r75187. Missing ; in for loophartman12:38, 22 October 2010

Status & tagging log