[xiph-commits] r3965 - in itext: . javascript
silvia at svn.annodex.net
silvia at svn.annodex.net
Tue Jul 21 00:07:44 PDT 2009
Author: silvia
Date: 2009-07-21 00:07:44 -0700 (Tue, 21 Jul 2009)
New Revision: 3965
Modified:
itext/
itext/javascript/subtitles.js
Log:
Cleaned up the itext parsing to create a better two-dim array to go through.
Property changes on: itext
___________________________________________________________________
Modified: bzr:revision-info
- timestamp: 2009-07-19 23:04:20.993999958 +1000
committer: Silvia Pfeiffer <silvia.pfeiffer at vquence.com>
properties:
branch-nick: silvia
+ timestamp: 2009-07-20 16:54:54.084000111 +1000
committer: Silvia Pfeiffer <silvia.pfeiffer at vquence.com>
properties:
branch-nick: silvia
Modified: bzr:file-ids
- index.html index.html-20090718094218-d45036mvytq5pecp-3
javascript/subtitles.js subtitles.js-20090718094218-d45036mvytq5pecp-10
skins/schmucker/tinyvid.js tinyvid.js-20090718094218-d45036mvytq5pecp-53
+ javascript/subtitles.js subtitles.js-20090718094218-d45036mvytq5pecp-10
Modified: bzr:revision-id:v4
- 1 silvia.pfeiffer at vquence.com-20090713110521-cz7evclxohf4rbs2
2 silvia.pfeiffer at vquence.com-20090714003359-apmpuor2ttarph5n
3 silvia.pfeiffer at vquence.com-20090714143931-q6j8ritt91jn5rhu
4 silvia.pfeiffer at vquence.com-20090718094222-58zgcmsg9gggbnt1
5 silvia.pfeiffer at vquence.com-20090718094708-wb83p9u6jr1xlhm6
6 silvia.pfeiffer at vquence.com-20090718095409-p6en5qufj62m8w3h
7 silvia.pfeiffer at vquence.com-20090718113424-9s8cmt1guxj6qoky
8 silvia.pfeiffer at vquence.com-20090718113445-n0q9c14w4i11pe36
9 silvia.pfeiffer at vquence.com-20090718123622-xdp52y76dvpem2ya
10 silvia.pfeiffer at vquence.com-20090718131644-69y0zml0ccbwc5er
11 silvia.pfeiffer at vquence.com-20090719002119-ekzto9pc7jqs3gw9
12 silvia.pfeiffer at vquence.com-20090719120832-srm8qemvr5jjy67w
13 silvia.pfeiffer at vquence.com-20090719130420-s7xjh35zrfj8117x
+ 1 silvia.pfeiffer at vquence.com-20090713110521-cz7evclxohf4rbs2
2 silvia.pfeiffer at vquence.com-20090714003359-apmpuor2ttarph5n
3 silvia.pfeiffer at vquence.com-20090714143931-q6j8ritt91jn5rhu
4 silvia.pfeiffer at vquence.com-20090718094222-58zgcmsg9gggbnt1
5 silvia.pfeiffer at vquence.com-20090718094708-wb83p9u6jr1xlhm6
6 silvia.pfeiffer at vquence.com-20090718095409-p6en5qufj62m8w3h
7 silvia.pfeiffer at vquence.com-20090718113424-9s8cmt1guxj6qoky
8 silvia.pfeiffer at vquence.com-20090718113445-n0q9c14w4i11pe36
9 silvia.pfeiffer at vquence.com-20090718123622-xdp52y76dvpem2ya
10 silvia.pfeiffer at vquence.com-20090718131644-69y0zml0ccbwc5er
11 silvia.pfeiffer at vquence.com-20090719002119-ekzto9pc7jqs3gw9
12 silvia.pfeiffer at vquence.com-20090719120832-srm8qemvr5jjy67w
13 silvia.pfeiffer at vquence.com-20090719130420-s7xjh35zrfj8117x
14 silvia.pfeiffer at vquence.com-20090720065454-m2g8tcjgpgw8aetr
Modified: bzr:text-parents
- javascript/subtitles.js silvia.pfeiffer at vquence.com-20090719002119-ekzto9pc7jqs3gw9
skins/schmucker/tinyvid.js silvia.pfeiffer at vquence.com-20090718123622-xdp52y76dvpem2ya
+
Modified: itext/javascript/subtitles.js
===================================================================
--- itext/javascript/subtitles.js 2009-07-21 07:07:37 UTC (rev 3964)
+++ itext/javascript/subtitles.js 2009-07-21 07:07:44 UTC (rev 3965)
@@ -387,7 +387,7 @@
// This is where the implementation of iText starts
// list of potential errors created with iText parsing
-ITEXT_ERR = {
+var ITEXT_ERR = {
ABORTED: 1, // fetching aborted
NETWORK: 2, // network error
PARSE: 3, // parsing error of itext resource
@@ -526,7 +526,6 @@
$.extend(ItextCollection.prototype, {
video: null,
tracks: [],
- categories: [],
primary_lang: -1,
init: function(vid) {
@@ -534,51 +533,51 @@
this.load();
},
load: function() {
- // parse the itext elements
- tracks = [];
- categories = [];
- primary_lang = -1;
- secondary_lang = -1;
+ // parse the itext elements and remember which tracks to fetch
+ categories = {};
+ primary_lang = [];
+ secondary_lang = [];
+
+ // go through each itext track, parse it and add it to categories[]
tracks_tmp = this.video.find('itext');
tracks_tmp.each(function(i){
- // create the text track
- tracks[i]=new ItextTrack(this);
- // check for appropriate language in this track
- if (tracks[i].display=="auto") {
- if (tracks[i].lang == window.navigator.language) {
- primary_lang = i;
- } else if (tracks[i].lang == window.navigator.language.substr(0,2)) {
- secondary_lang = i;
+
+ // create the text track and add to the categories double assoc array
+ track = new ItextTrack(this);
+ if (categories[track.category] == null) categories[track.category] = {};
+ categories[track.category][track.lang] = track;
+
+ // check for appropriate language in this track for later fetching
+ if (!primary_lang[track.category]) primary_lang[track.category] = null;
+ if (!secondary_lang[track.category]) secondary_lang[track.category] = null;
+ if (track.display == "auto") {
+ if (track.lang == window.navigator.language) {
+ primary_lang[track.category] = track; // complete lang match
+ } else if (track.lang == window.navigator.language.substr(0,2)) {
+ secondary_lang[track.category] = track; // only main lang match
}
}
- // create list of categories encountered
- cat_exist = false;
- for (var j = 0; j < categories.length; j++) {
- if (tracks[i].category == categories[j]) {
- cat_exist = true;
- }
- }
- if (!cat_exist) categories.push(tracks[i].category);
});
- this.tracks = tracks;
- this.categories = categories;
- // load track of appropriate language
- if (primary_lang < 0) primary_lang = secondary_lang;
- if (primary_lang >= 0) {
- this.tracks[primary_lang].fetch(this.tracks[primary_lang].src);
- this.tracks[primary_lang].enabled = true;
+ // load track of appropriate language in each category
+ for (i in categories) {
+ if (!primary_lang[i]) primary_lang[i] = secondary_lang[i];
+ if (primary_lang[i] && !primary_lang[i].fetched) {
+ primary_lang[i].fetch(primary_lang[i].src);
+ primary_lang[i].enabled = true;
+ }
}
+
+ // double assoc array is created
+ this.tracks = categories;
},
itextMenu: function(baseEl) {
var appendText = '<div class="itextMenu">\n';
appendText += '<ul class="catMenu">\n';
- for (var i = 0; i < this.categories.length; i++) {
- appendText += '<li> < ' + categoryName(categories[i]) + '\n';
+ for (i in this.tracks) {
+ appendText += '<li> < ' + i + '\n';
appendText += '<ul class="langMenu">\n';
- for (var j = 0; j < this.tracks.length; j++) {
- if (this.tracks[j].category == categories[i]) {
- appendText += '<li><a href="#" onclick="playerControllers[0].itexts.tracks['+j+'].enable();return false;">' + tracks[j].langName + '</a></li>\n';
- }
+ for (j in this.tracks[i]) {
+ appendText += '<li><a href="#" onclick="playerControllers[0].itexts.tracks[\''+i+'\'][\''+j+'\'].enable();return false;">' + this.tracks[i][j].langName + '</a></li>\n';
}
appendText += '</ul>\n</li>\n';
}
@@ -589,10 +588,12 @@
},
show: function(currentTime) {
var content = "";
- for (var i=0; i < this.tracks.length; i++) {
- if (this.tracks[i].enabled) {
- if (this.tracks[i].currentText(currentTime)) {
- content += this.tracks[i].currentText(currentTime);
+ for (i in this.tracks) {
+ for (j in this.tracks[i]) {
+ if (this.tracks[i][j].enabled) {
+ if (text = this.tracks[i][j].currentText(currentTime)) {
+ content += text;
+ }
}
}
}
More information about the commits
mailing list