[xiph-commits] r4009 - in itext: . javascript

silvia at svn.annodex.net silvia at svn.annodex.net
Mon Sep 14 06:50:06 PDT 2009


Author: silvia
Date: 2009-09-14 06:50:06 -0700 (Mon, 14 Sep 2009)
New Revision: 4009

Modified:
   itext/
   itext/javascript/srt.js
   itext/javascript/subtitles.js
Log:
Beautification of srt.js.
Proper handling of handler function pointer - now with lyrics added.



Property changes on: itext
___________________________________________________________________
Modified: bzr:revision-info
   - timestamp: 2009-09-14 22:17:06.125999928 +1000
committer: Silvia Pfeiffer <silvia.pfeiffer at vquence.com>
properties: 
	branch-nick: silvia

   + timestamp: 2009-09-14 22:18:15.828000069 +1000
committer: Silvia Pfeiffer <silvia.pfeiffer at vquence.com>
properties: 
	branch-nick: silvia

Modified: bzr:file-ids
   - elephant_no_skin.html	elephant_no_skin.htm-20090802130343-dlzxqj7cts3o0n1v-1

   + javascript/srt.js	srt.js-20090801090342-quzbpyzxle8bmzy3-1
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
14 silvia.pfeiffer at vquence.com-20090720065454-m2g8tcjgpgw8aetr
15 silvia.pfeiffer at vquence.com-20090720131039-ivpstebztd7u3vwx
16 silvia.pfeiffer at vquence.com-20090720190949-r4ahzq2regl7opf1
17 silvia.pfeiffer at vquence.com-20090720210510-i54efp8a9sem4g6g
18 silvia.pfeiffer at vquence.com-20090721063829-4pvft92pnt7k966p
19 silvia.pfeiffer at vquence.com-20090721065410-0miir37pbb73k35r
20 silvia.pfeiffer at vquence.com-20090721065911-9ngk00aeujudpw8p
21 silvia.pfeiffer at vquence.com-20090721121059-uthu2kmvu74zjv06
22 silvia.pfeiffer at vquence.com-20090721125735-lwwo9ivbdhj0jdhp
23 silvia.pfeiffer at vquence.com-20090721130655-sdqdgbs0lexyrwh5
24 silvia.pfeiffer at vquence.com-20090721143346-065b9v0rr1tcmyg0
25 silvia.pfeiffer at vquence.com-20090722010421-9sx8ynfzcoxh1eai
26 silvia.pfeiffer at vquence.com-20090722014433-yrqaapi0kmfec1oh
27 silvia.pfeiffer at vquence.com-20090722062945-586zxe3smxv1gdcw
28 silvia.pfeiffer at vquence.com-20090727123838-lcxe2fb7n2111ipd
29 silvia.pfeiffer at vquence.com-20090728151700-ai24t8itvj8hxs0c
30 silvia.pfeiffer at vquence.com-20090728210031-2n53wzpuledyqg9w
31 silvia.pfeiffer at vquence.com-20090730034353-pcrnaae01i2q5430
32 silvia.pfeiffer at vquence.com-20090731122706-nrrle33ore1cjl87
33 silvia.pfeiffer at vquence.com-20090801092101-zyu1s0ntmio5bihb
34 silvia.pfeiffer at vquence.com-20090801092534-5pvl2ehkqi87p9le
35 silvia.pfeiffer at vquence.com-20090801233833-xa51k548ng1tqxso
36 silvia.pfeiffer at vquence.com-20090802130400-k998eftqulgcrp04
37 silvia.pfeiffer at vquence.com-20090802143005-c1sm52ru0kfed912
38 silvia.pfeiffer at vquence.com-20090827061919-ejpm51zs89ekbd56
39 silvia.pfeiffer at vquence.com-20090827061950-6fu26p80jdvdh50c
40 silvia.pfeiffer at vquence.com-20090901040002-3qs6tqiqcod3cda2
41 silvia.pfeiffer at vquence.com-20090901040227-o491w2qkp79a2a3r
42 silvia.pfeiffer at vquence.com-20090901040449-3xtimieabhw7fu7o
43 silvia.pfeiffer at vquence.com-20090901051757-h9l9753jy47x87zy
44 silvia.pfeiffer at vquence.com-20090901132958-3i65nroyeciazei3
45 silvia.pfeiffer at vquence.com-20090901230635-adfp1v5h24nvg30q
46 silvia.pfeiffer at vquence.com-20090902004049-ssqjbhtpz737oc90
47 silvia.pfeiffer at vquence.com-20090902022932-omg01n8yn6gg853c
48 silvia.pfeiffer at vquence.com-20090903010501-3vehjdbaxv2gyzzf
49 silvia.pfeiffer at vquence.com-20090912064418-3jw90gm7r0d2jjzk
50 silvia.pfeiffer at vquence.com-20090912065734-rx0kxsolg43lssa3
51 silvia.pfeiffer at vquence.com-20090912144329-yanfydw2pkoaxytw
52 silvia.pfeiffer at vquence.com-20090912152710-r2ga9oa451rmxgym
53 silvia.pfeiffer at vquence.com-20090912152945-l5voojx7ripnzono
54 silvia.pfeiffer at vquence.com-20090914014851-pt8aboskjyfhwecd
55 silvia.pfeiffer at vquence.com-20090914113345-t47n88dsqglme076
56 silvia.pfeiffer at vquence.com-20090914121706-2psey2lbp8tb70b6

   + 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
15 silvia.pfeiffer at vquence.com-20090720131039-ivpstebztd7u3vwx
16 silvia.pfeiffer at vquence.com-20090720190949-r4ahzq2regl7opf1
17 silvia.pfeiffer at vquence.com-20090720210510-i54efp8a9sem4g6g
18 silvia.pfeiffer at vquence.com-20090721063829-4pvft92pnt7k966p
19 silvia.pfeiffer at vquence.com-20090721065410-0miir37pbb73k35r
20 silvia.pfeiffer at vquence.com-20090721065911-9ngk00aeujudpw8p
21 silvia.pfeiffer at vquence.com-20090721121059-uthu2kmvu74zjv06
22 silvia.pfeiffer at vquence.com-20090721125735-lwwo9ivbdhj0jdhp
23 silvia.pfeiffer at vquence.com-20090721130655-sdqdgbs0lexyrwh5
24 silvia.pfeiffer at vquence.com-20090721143346-065b9v0rr1tcmyg0
25 silvia.pfeiffer at vquence.com-20090722010421-9sx8ynfzcoxh1eai
26 silvia.pfeiffer at vquence.com-20090722014433-yrqaapi0kmfec1oh
27 silvia.pfeiffer at vquence.com-20090722062945-586zxe3smxv1gdcw
28 silvia.pfeiffer at vquence.com-20090727123838-lcxe2fb7n2111ipd
29 silvia.pfeiffer at vquence.com-20090728151700-ai24t8itvj8hxs0c
30 silvia.pfeiffer at vquence.com-20090728210031-2n53wzpuledyqg9w
31 silvia.pfeiffer at vquence.com-20090730034353-pcrnaae01i2q5430
32 silvia.pfeiffer at vquence.com-20090731122706-nrrle33ore1cjl87
33 silvia.pfeiffer at vquence.com-20090801092101-zyu1s0ntmio5bihb
34 silvia.pfeiffer at vquence.com-20090801092534-5pvl2ehkqi87p9le
35 silvia.pfeiffer at vquence.com-20090801233833-xa51k548ng1tqxso
36 silvia.pfeiffer at vquence.com-20090802130400-k998eftqulgcrp04
37 silvia.pfeiffer at vquence.com-20090802143005-c1sm52ru0kfed912
38 silvia.pfeiffer at vquence.com-20090827061919-ejpm51zs89ekbd56
39 silvia.pfeiffer at vquence.com-20090827061950-6fu26p80jdvdh50c
40 silvia.pfeiffer at vquence.com-20090901040002-3qs6tqiqcod3cda2
41 silvia.pfeiffer at vquence.com-20090901040227-o491w2qkp79a2a3r
42 silvia.pfeiffer at vquence.com-20090901040449-3xtimieabhw7fu7o
43 silvia.pfeiffer at vquence.com-20090901051757-h9l9753jy47x87zy
44 silvia.pfeiffer at vquence.com-20090901132958-3i65nroyeciazei3
45 silvia.pfeiffer at vquence.com-20090901230635-adfp1v5h24nvg30q
46 silvia.pfeiffer at vquence.com-20090902004049-ssqjbhtpz737oc90
47 silvia.pfeiffer at vquence.com-20090902022932-omg01n8yn6gg853c
48 silvia.pfeiffer at vquence.com-20090903010501-3vehjdbaxv2gyzzf
49 silvia.pfeiffer at vquence.com-20090912064418-3jw90gm7r0d2jjzk
50 silvia.pfeiffer at vquence.com-20090912065734-rx0kxsolg43lssa3
51 silvia.pfeiffer at vquence.com-20090912144329-yanfydw2pkoaxytw
52 silvia.pfeiffer at vquence.com-20090912152710-r2ga9oa451rmxgym
53 silvia.pfeiffer at vquence.com-20090912152945-l5voojx7ripnzono
54 silvia.pfeiffer at vquence.com-20090914014851-pt8aboskjyfhwecd
55 silvia.pfeiffer at vquence.com-20090914113345-t47n88dsqglme076
56 silvia.pfeiffer at vquence.com-20090914121706-2psey2lbp8tb70b6
57 silvia.pfeiffer at vquence.com-20090914121815-f09keijembthe6ug

Modified: bzr:text-parents
   - 
   + javascript/srt.js	silvia.pfeiffer at vquence.com-20090801092101-zyu1s0ntmio5bihb
javascript/subtitles.js	silvia.pfeiffer at vquence.com-20090912152710-r2ga9oa451rmxgym


Modified: itext/javascript/srt.js
===================================================================
--- itext/javascript/srt.js	2009-09-14 13:49:58 UTC (rev 4008)
+++ itext/javascript/srt.js	2009-09-14 13:50:06 UTC (rev 4009)
@@ -35,47 +35,49 @@
  * ***** END LICENSE BLOCK ***** */
 
 // Stop JSLint whinging about globals //
-/*global jQuery: true, window: true, ITEXT_ERR: true, ItextCollection: true, ItextTrack: true, LoadFile: true, categoryName: true, languageName: true, parseInt: true, parseSrt: true */
+/*global jQuery: true, window: true, parseInt: true, parseSrt: true */
 
 // SRT specification from http://forum.doom9.org/archive/index.php/t-73953.html
 // but without the formatting, which is just interpreted as text
 
 // Function to parse srt file
 function parseSrt(data) {
-        var srt = data.replace(/\r+/g, ''); // remove dos newlines
+    var srt = data.replace(/\r+/g, ''); // remove dos newlines
     srt = srt.replace(/^\s+|\s+$/g, ''); // trim white space start and end
-        srt = srt.replace(/<[a-zA-Z\/][^>]*>/g, ''); // remove all html tags for security reasons
-        // get captions
-        var captions = [];
-        jQuery.each(srt.split('\n\n'), function (i, caption) {
-            var s = caption.split(/\n/);
-            var content, start, end;
-            if (s[0].match(/^\d+$/) && s[1].match(/\d+:\d+:\d+/)) {
-                        // ignore caption number in s[0]
-                        // parse time string
-                        var m = s[1].match(/(\d+):(\d+):(\d+)(?:,(\d+))?\s*--?>\s*(\d+):(\d+):(\d+)(?:,(\d+))?/);
-                if (m) {
-                        start =
-                          (parseInt(m[1], 10) * 60 * 60) +
-                          (parseInt(m[2], 10) * 60) +
-                          (parseInt(m[3], 10)) +
-                          (parseInt(m[4], 10) / 1000);
-                        end =
-                          (parseInt(m[5], 10) * 60 * 60) +
-                          (parseInt(m[6], 10) * 60) +
-                          (parseInt(m[7], 10)) +
-                          (parseInt(m[8], 10) / 1000);
-                } else {
-                        // Unrecognized timestring
-                        return;
-                }
-                        // concatenate text lines to html text
-                        content = s.slice(2).join("<br>");
+    srt = srt.replace(/<[a-zA-Z\/][^>]*>/g, ''); // remove all html tags for security reasons
+
+    // get captions
+    var captions = [];
+    jQuery.each(srt.split('\n\n'), function (i, caption) {
+        var s = caption.split(/\n/);
+        var content, start, end;
+        if (s[0].match(/^\d+$/) && s[1].match(/\d+:\d+:\d+/)) {
+            // ignore caption number in s[0]
+            // parse time string
+            var m = s[1].match(/(\d+):(\d+):(\d+)(?:,(\d+))?\s*--?>\s*(\d+):(\d+):(\d+)(?:,(\d+))?/);
+            if (m) {
+                start =
+                  (parseInt(m[1], 10) * 60 * 60) +
+                  (parseInt(m[2], 10) * 60) +
+                  (parseInt(m[3], 10)) +
+                  (parseInt(m[4], 10) / 1000);
+                end =
+                  (parseInt(m[5], 10) * 60 * 60) +
+                  (parseInt(m[6], 10) * 60) +
+                  (parseInt(m[7], 10)) +
+                  (parseInt(m[8], 10) / 1000);
             } else {
-                        // file format error
+                // Unrecognized timestring
                 return;
             }
-            captions.push({start: start, end: end, content: content});
-        });
-        return captions;
+            // concatenate text lines to html text
+            content = s.slice(2).join("<br>");
+        } else {
+            // file format error
+            return;
+        }
+        captions.push({start: start, end: end, content: content});
+    });
+
+    return captions;
 }

Modified: itext/javascript/subtitles.js
===================================================================
--- itext/javascript/subtitles.js	2009-09-14 13:49:58 UTC (rev 4008)
+++ itext/javascript/subtitles.js	2009-09-14 13:50:06 UTC (rev 4009)
@@ -376,6 +376,8 @@
 		// choose parsing function
 		if (type === "text/srt") {
 			handler = parseSrt;
+		} else if (type === "text/lrc") {
+			handler = parseLrc;
 		} else {
 			// no handler for given file type
 			this.error = ITEXT_ERR.SRC_NOT_SUPPORTED;
@@ -391,7 +393,7 @@
 			url: url,
 			data: {},
 			success: function (data, textStatus) {
-				content = parseSrt(data);
+				content = handler(data);
 			},
 			error: function () {
 				error = ITEXT_ERR.NETWORK;



More information about the commits mailing list