Index: branches/MwEmbedStandAlone/modules/TimedText/mw.TimedText.js |
— | — | @@ -773,9 +773,11 @@ |
774 | 774 | getLanguageMenu: function() { |
775 | 775 | var _this = this; |
776 | 776 | |
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; |
778 | 781 | |
779 | | - var catSourceList = [ ]; |
780 | 782 | // ( All sources should have a category (depreciate ) |
781 | 783 | var sourcesWithoutCategory = [ ]; |
782 | 784 | for( var i=0; i < this.textSources.length; i++ ) { |
— | — | @@ -786,6 +788,7 @@ |
787 | 789 | if( !catSourceList[ catKey ] ) { |
788 | 790 | // Set up catList pointer: |
789 | 791 | catSourceList[ catKey ] = [ ]; |
| 792 | + catSourceCount++; |
790 | 793 | } |
791 | 794 | // Append to the source category key menu item: |
792 | 795 | catSourceList[ catKey ].push( |
— | — | @@ -797,10 +800,10 @@ |
798 | 801 | } |
799 | 802 | var $langMenu = $j('<ul>'); |
800 | 803 | // 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) { |
803 | 806 | $catChildren = $j('<ul>'); |
804 | | - for(var i in catSourceList[ catKey ]) { |
| 807 | + for(var i=0; i < catSourceList[ catKey ].length; i++) { |
805 | 808 | $catChildren.append( |
806 | 809 | catSourceList[ catKey ][i] |
807 | 810 | ); |
— | — | @@ -813,8 +816,8 @@ |
814 | 817 | ); |
815 | 818 | } |
816 | 819 | } 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++) { |
819 | 822 | $langMenu.append( |
820 | 823 | catSourceList[ catKey ][i] |
821 | 824 | ); |
— | — | @@ -1086,7 +1089,7 @@ |
1087 | 1090 | var startIndex = 0; |
1088 | 1091 | } |
1089 | 1092 | // 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++ ) { |
1091 | 1094 | caption = this.captions[ i ]; |
1092 | 1095 | if( time >= caption.start && |
1093 | 1096 | time <= caption.end ) { |
— | — | @@ -1188,7 +1191,7 @@ |
1189 | 1192 | // Get captions |
1190 | 1193 | var captions = []; |
1191 | 1194 | 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++) { |
1193 | 1196 | var caption = ""; |
1194 | 1197 | var content, start, end, s; |
1195 | 1198 | caption = caplist[i]; |