[xiph-commits] r3964 - in itext: . javascript skins/schmucker

silvia at svn.annodex.net silvia at svn.annodex.net
Tue Jul 21 00:07:37 PDT 2009


Author: silvia
Date: 2009-07-21 00:07:37 -0700 (Tue, 21 Jul 2009)
New Revision: 3964

Modified:
   itext/
   itext/index.html
   itext/javascript/subtitles.js
   itext/skins/schmucker/tinyvid.js
Log:
Added some more error handling to subtitles.js.
Moved the iText collection handling from tinyvid to subtitles.js.



Property changes on: itext
___________________________________________________________________
Modified: bzr:revision-info
   - timestamp: 2009-07-19 22:08:32.743000031 +1000
committer: Silvia Pfeiffer <silvia.pfeiffer at vquence.com>
properties: 
	branch-nick: silvia

   + timestamp: 2009-07-19 23:04:20.993999958 +1000
committer: Silvia Pfeiffer <silvia.pfeiffer at vquence.com>
properties: 
	branch-nick: silvia

Modified: bzr:file-ids
   - index.html	index.html-20090718094218-d45036mvytq5pecp-3
subtitles/audiodescription.srt	audiodescription.srt-20090718094218-d45036mvytq5pecp-14
subtitles/chapters.srt	chapters.srt-20090718094218-d45036mvytq5pecp-15

   + index.html	index.html-20090718094218-d45036mvytq5pecp-3
javascript/subtitles.js	subtitles.js-20090718094218-d45036mvytq5pecp-10
skins/schmucker/tinyvid.js	tinyvid.js-20090718094218-d45036mvytq5pecp-53

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

   + 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

Modified: bzr:text-parents
   - index.html	silvia.pfeiffer at vquence.com-20090718094222-58zgcmsg9gggbnt1
subtitles/audiodescription.srt	silvia.pfeiffer at vquence.com-20090718094222-58zgcmsg9gggbnt1
subtitles/chapters.srt	silvia.pfeiffer at vquence.com-20090718094222-58zgcmsg9gggbnt1

   + javascript/subtitles.js	silvia.pfeiffer at vquence.com-20090719002119-ekzto9pc7jqs3gw9
skins/schmucker/tinyvid.js	silvia.pfeiffer at vquence.com-20090718123622-xdp52y76dvpem2ya


Modified: itext/index.html
===================================================================
--- itext/index.html	2009-07-21 07:07:28 UTC (rev 3963)
+++ itext/index.html	2009-07-21 07:07:37 UTC (rev 3964)
@@ -79,7 +79,7 @@
 	       src="subtitles/elephant.danish.srt" category="SUB"></itext>
 	<itext id="video_nl" lang="nl" type="text/srt" charset="ISO-8859-1" display="auto"
 	       src="subtitles/elephant.dutch.srt" category="SUB"></itext>   
-	<itext id="video_en" lang="en" type="text/srt" charset="ISO-8859" display="yes"
+	<itext id="video_en" lang="en" type="text/srt" charset="ISO-8859" display="auto"
 	       src="subtitles/elephant.english.srt" category="SUB"></itext>
 	<itext id="video_et" lang="et" type="text/srt" charset="Windows-1252" display="auto"
 	       src="subtitles/elephant.estonian.srt" category="SUB"></itext>  
@@ -125,7 +125,7 @@
 	       src="subtitles/elephant.slovak.srt" category="CC"></itext>
 	<itext id="video_sv" lang="sv" type="text/srt" charset="ISO-8859-1" display="auto"
 	       src="subtitles/elephant.swedish.srt" category="CC"></itext>
-  <itext id="audiodesc" lang="en" type="text/srt" charset="ISO-8859" display="yes"
+  <itext id="audiodesc" lang="en" type="text/srt" charset="ISO-8859" display="auto"
          src="subtitles/audiodescription.srt" category="TAD"></itext>
   <itext id="chapters" lang="en" type="text/srt" charset="ISO-8859" display="yes"
          src="subtitles/chapters.srt" category="CUE"></itext>

Modified: itext/javascript/subtitles.js
===================================================================
--- itext/javascript/subtitles.js	2009-07-21 07:07:28 UTC (rev 3963)
+++ itext/javascript/subtitles.js	2009-07-21 07:07:37 UTC (rev 3964)
@@ -409,6 +409,7 @@
 		this.url = url;
 		handler = null;
 		content = [];
+		error = 0;
 		// choose parsing function
 		if (type == "text/srt") {
 			handler = parseSrt;
@@ -427,12 +428,15 @@
 			url: url,
 			data: {},
 			success: function(data, textStatus) { content = parseSrt(data); },
+			error: function() { error = ITEXT_ERR.NETWORK; },
 			dataType: 'text',
 			async: false,
 			cache: false // REMOVE AFTER TESTING: FIXME
 		});
-		if (!content) {
+		if (!error && !content) {
 			this.error = ITEXT_ERR.PARSE;
+		} else if (error) {
+			this.error = error;
 		}
 		this.textElements = content;
 	}
@@ -513,3 +517,97 @@
 		this.delay=seconds;
 	}
 });
+
+
+// class to handle all itexts
+var ItextCollection=function(video) {
+	this.init(video);
+};
+$.extend(ItextCollection.prototype, {
+	video: null,
+	tracks: [],
+	categories: [],
+	primary_lang: -1,
+	
+	init: function(vid) {
+	  this.video = vid;
+	  this.load();
+	},
+	load: function() {
+	  // parse the itext elements
+	  tracks = [];
+	  categories = [];
+	  primary_lang = -1;
+	  secondary_lang = -1;
+      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 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;
+	  }
+    },
+	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> &lt; &nbsp;' + categoryName(categories[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';
+				}
+			}
+			appendText += '</ul>\n</li>\n';
+		}
+		appendText += '</ul></div>\n';
+		$(baseEl).append(appendText);
+		$(".langMenu").css("height",$(this.video).css("height"));
+		$(".catMenu").css("visibility", "hidden");
+	},
+	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);
+				}
+			}
+		}
+		if (content) {
+			// replace content of caption div
+			$(".captioncontainer").html(content);
+			$(".captioncontainer").css("visibility", "visible");
+			// anyone with a better idea for how to place the captions bottom center, please speak up
+			mc_width = $('.mc').css("width").substr(0,$('.mc').css("width").length-2)
+			$(".captioncontainer").css("max-width", (mc_width-14)+"px");
+			$(".captioncontainer").css("left", (mc_width/2+7)+"px");
+			text_half_length = $('.text').css("width").substr(0,$('.text').css("width").length-2)/2*(-1)+"px";
+			$(".captioncontainer").css("margin-left", text_half_length);
+		} else {
+			$(".captioncontainer").css("visibility", "hidden");			
+		}
+	}
+});

Modified: itext/skins/schmucker/tinyvid.js
===================================================================
--- itext/skins/schmucker/tinyvid.js	2009-07-21 07:07:28 UTC (rev 3963)
+++ itext/skins/schmucker/tinyvid.js	2009-07-21 07:07:37 UTC (rev 3964)
@@ -28,7 +28,6 @@
 };
 
 
-
 /*====== ThrobberHandle ======*/
 var ThrobberHandle=function(element, interactiveReference,onInteract){
 	this.setValue=das.hardScope(this.setValue,this);
@@ -170,101 +169,7 @@
 	mouseUpListener:null
 };
 
-// class to handle itexts
-var ItextCollection=function(video) {
-	this.init(video);
-};
-$.extend(ItextCollection.prototype, {
-	video: null,
-	tracks: [],
-	categories: [],
-	primary_lang: -1,
-	
-	init: function(vid) {
-	  this.video = vid;
-	  this.load();
-	},
-	load: function() {
-	  // parse the itext elements
-	  tracks = [];
-	  categories = [];
-	  primary_lang = -1;
-	  secondary_lang = -1;
-      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 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;
-	  }
-    },
-	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> &lt; &nbsp;' + categoryName(categories[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';
-				}
-			}
-			appendText += '</ul>\n</li>\n';
-		}
-		appendText += '</ul></div>\n';
-		$(baseEl).append(appendText);
-		$(".langMenu").css("height",$(this.video).css("height"));
-		$(".catMenu").css("visibility", "hidden");
-	},
-	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);
-				}
-			}
-		}
-		if (content) {
-			// replace content of caption div
-			$(".captioncontainer").html(content);
-			$(".captioncontainer").css("visibility", "visible");
-			// anyone with a better idea for how to place the captions bottom center, please speak up
-			mc_width = $('.mc').css("width").substr(0,$('.mc').css("width").length-2)
-			$(".captioncontainer").css("max-width", (mc_width-14)+"px");
-			$(".captioncontainer").css("left", (mc_width/2+7)+"px");
-			text_half_length = $('.text').css("width").substr(0,$('.text').css("width").length-2)/2*(-1)+"px";
-			$(".captioncontainer").css("margin-left", text_half_length);
-		} else {
-			$(".captioncontainer").css("visibility", "hidden");			
-		}
-	}
-});
 
-
-
 /*====== PlayerController ======*/
 var PlayerController=function(el){
 	this.play=das.hardScope(this.play,this);



More information about the commits mailing list