[xiph-commits] r4052 - in itext: javascript styles

silvia at svn.annodex.net silvia at svn.annodex.net
Thu Oct 29 02:03:07 PDT 2009


Author: silvia
Date: 2009-10-29 02:03:06 -0700 (Thu, 29 Oct 2009)
New Revision: 4052

Modified:
   itext/javascript/lrc.js
   itext/javascript/srt.js
   itext/javascript/subtitles.js
   itext/styles/subtitles.css
Log:
More white space fixes.


Modified: itext/javascript/lrc.js
===================================================================
--- itext/javascript/lrc.js	2009-10-29 09:02:58 UTC (rev 4051)
+++ itext/javascript/lrc.js	2009-10-29 09:03:06 UTC (rev 4052)
@@ -41,39 +41,39 @@
 
 // Function to parse lrc file
 function parseLrc(data) {
-	var lrc = data.replace(/\r+/g, ''); // remove dos newlines
-	lrc = lrc.replace(/\n+/g, '\n'); // remove empty lines
-	lrc = lrc.replace(/^\s+|\s+$/g, ''); // trim white space start and end
+    var lrc = data.replace(/\r+/g, ''); // remove dos newlines
+    lrc = lrc.replace(/\n+/g, '\n'); // remove empty lines
+    lrc = lrc.replace(/^\s+|\s+$/g, ''); // trim white space start and end
     lrc = lrc.replace(/<[a-zA-Z\/][^>]*>/g, ''); // remove all html tags for security reasons
-	// this last one also removes karaoke style time markup (ok for now)
+    // this last one also removes karaoke style time markup (ok for now)
 
     // get lyrics lines
     var lines = [];
-	var start, end, content;
-	content = null;
-	lrclist = lrc.split('\n');
-	for (var i = 0; i < lrclist.length; i=i+1) {
-    		var line = lrclist[i];
-		// parse [xx] from rest of line
-		var m = line.match(/\[([^\]]+)\](.*)/);
-		var s = m[1].match(/(\d+):(\d+)(?:\.(\d+))?/);
-		if (s) { // ignore header strings and broken time codes
-        	  end =
-              	    (parseInt(s[1], 10) * 60) +
-          	    (parseInt(s[2], 10)) +
-          	    (parseInt(s[3], 10) / 100);
+    var start, end, content;
+    content = null;
+    lrclist = lrc.split('\n');
+    for (var i = 0; i < lrclist.length; i=i+1) {
+            var line = lrclist[i];
+        // parse [xx] from rest of line
+        var m = line.match(/\[([^\]]+)\](.*)/);
+        var s = m[1].match(/(\d+):(\d+)(?:\.(\d+))?/);
+        if (s) { // ignore header strings and broken time codes
+              end =
+                      (parseInt(s[1], 10) * 60) +
+                  (parseInt(s[2], 10)) +
+                  (parseInt(s[3], 10) / 100);
 
-	    	  // write previous line if there is content from before
-	    	  if (content) {
-        	    lines.push({start: start, end: end, content: content});
-		  }
-		  start = end;
-		  content = m[2];
-		}
-    	}
-	// write last line if it has content
-	if (content) {
-    	  lines.push({start: start, end: null, content: content});
-	}
+              // write previous line if there is content from before
+              if (content) {
+                lines.push({start: start, end: end, content: content});
+          }
+          start = end;
+          content = m[2];
+        }
+        }
+    // write last line if it has content
+    if (content) {
+          lines.push({start: start, end: null, content: content});
+    }
     return lines;
 }

Modified: itext/javascript/srt.js
===================================================================
--- itext/javascript/srt.js	2009-10-29 09:02:58 UTC (rev 4051)
+++ itext/javascript/srt.js	2009-10-29 09:03:06 UTC (rev 4052)
@@ -50,10 +50,10 @@
     var captions = [];
     var caplist = srt.split('\n\n');
     for (var i = 0; i < caplist.length; i=i+1) {
-		var caption = "";
+        var caption = "";
         var content, start, end, s;
-		caption = caplist[i];
-		s = caption.split(/\n/);
+        caption = caplist[i];
+        s = caption.split(/\n/);
         if (s[0].match(/^\d+$/) && s[1].match(/\d+:\d+:\d+/)) {
             // ignore caption number in s[0]
             // parse time string

Modified: itext/javascript/subtitles.js
===================================================================
--- itext/javascript/subtitles.js	2009-10-29 09:02:58 UTC (rev 4051)
+++ itext/javascript/subtitles.js	2009-10-29 09:03:06 UTC (rev 4052)
@@ -40,17 +40,17 @@
 // Function to convert language code to language name
 // should be available inside the browser
 function languageName(abbrev) {
-	// see http://www.iana.org/assignments/language-subtag-registry
-	// no sign languages included right now
-	var langHash = {
-		"aa": "Afar",
-		"ab": "Abkhazian",
-		"ae": "Avestan",
-	    "af": "Africaans",
-		"ak": "Akan",
+    // see http://www.iana.org/assignments/language-subtag-registry
+    // no sign languages included right now
+    var langHash = {
+        "aa": "Afar",
+        "ab": "Abkhazian",
+        "ae": "Avestan",
+        "af": "Africaans",
+        "ak": "Akan",
         "am": "Amharic",
         "an": "Aragonese",
-		"anp": "Angika",
+        "anp": "Angika",
         "ar": "Arabic",
         "ar-ae": "Arabic (U.A.E.)",
         "ar-bh": "Arabic (Bahrain)",
@@ -68,20 +68,20 @@
         "ar-sy": "Arabic (Syria)",
         "ar-tn": "Arabic (Tunisia)",
         "ar-ye": "Arabic (Yemen)",
-		"as": "Assamese",
+        "as": "Assamese",
         "ast": "Asturian",
-		"av": "Avaric",
-		"ay": "Aymara",
+        "av": "Avaric",
+        "ay": "Aymara",
         "az": "Azerbaijani",
-		"ba": "Bashkir",
+        "ba": "Bashkir",
         "be": "Belarusian",
         "bg": "Bulgarian",
         "bg-bg": "Bulgarian (Bulgaria)",
-		"bh": "Bihari",
-		"bi": "Bislama",
-		"bm": "Bambara",
-		"bn": "Bengali",
-		"bo": "Tibetan",
+        "bh": "Bihari",
+        "bi": "Bislama",
+        "bm": "Bambara",
+        "bn": "Bengali",
+        "bo": "Tibetan",
         "br": "Breton",
         "bs": "Bosnian",
         "ca": "Catalan",
@@ -89,10 +89,10 @@
         "ce": "Chechen",
         "ch": "Chamorro",
         "co": "Corsican",
-		"cr": "Cree",
+        "cr": "Cree",
         "cs": "Czech",
         "cs-cz": "Czech (Czech Republic)",
-		"cu": "Church Slavic",
+        "cu": "Church Slavic",
         "cv": "Cuvash",
         "cy": "Welsh",
         "da": "Danish",
@@ -103,9 +103,9 @@
         "de-de": "German (Germany)",
         "de-li": "Deutsch (Lichtenstein)",
         "de-lu": "Deutsch (Luxemburg)",
-		"dv": "Divehi",
-		"dz": "Dzongkha",
-		"ee": "Ewe",
+        "dv": "Divehi",
+        "dz": "Dzongkha",
+        "ee": "Ewe",
         "el": "Greek",
         "en": "English",
         "en-au": "English (Australia)",
@@ -145,10 +145,10 @@
         "et": "Estonian",
         "eu": "Basque",
         "fa": "Persian",
-		"ff": "Fulah",
+        "ff": "Fulah",
         "fi": "Finnish",
         "fj": "Fijian",
-		"fo": "Faroese",
+        "fo": "Faroese",
         "fr": "French",
         "fr-be": "French (Belgium)",
         "fr-ca": "French (Canada)",
@@ -156,155 +156,155 @@
         "fr-fr": "French (France)",
         "fr-lu": "French (Luxemburg)",
         "fr-mc": "French (Mexico)",
-		"frr": "Frisian",
+        "frr": "Frisian",
         "fy": "Western Frisian",
         "ga": "Irish",
-		"gd": "Gaelic",
-		"gl": "Galician",
-		"gn": "Guarani",
-		"gu": "Gujarati",
-		"gv": "Manx",
-		"ha": "Hausa",
+        "gd": "Gaelic",
+        "gl": "Galician",
+        "gn": "Guarani",
+        "gu": "Gujarati",
+        "gv": "Manx",
+        "ha": "Hausa",
         "he": "Hebrew",
-		"hi": "Hindi",
-		"ho": "Hiri Motu",
+        "hi": "Hindi",
+        "ho": "Hiri Motu",
         "hr": "Croatian",
         "hsb": "High Sorbian",
         "ht": "Haitian",
         "hu": "Hungarian",
         "hy": "Armenian",
-		"hz": "Herero",
-		"ia": "Interlingua",
+        "hz": "Herero",
+        "ia": "Interlingua",
         "id": "Indonesian",
-		"ie": "Interlingue",
-		"ig": "Igbo",
-		"ii": "Sichuan Yi",
-		"ik": "Inupiaq",
-		"in": "Indonesian",
-		"io": "Ido",
+        "ie": "Interlingue",
+        "ig": "Igbo",
+        "ii": "Sichuan Yi",
+        "ik": "Inupiaq",
+        "in": "Indonesian",
+        "io": "Ido",
         "is": "Icelandic",
         "it": "Italian",
         "it-ch": "Italian (Swiss)",
         "iu": "Inuktitut",
-		"iw": "Hebrew",
+        "iw": "Hebrew",
         "ja": "Japanese",
-		"ji": "Yiddish",
-		"jv": "Javanese",
+        "ji": "Yiddish",
+        "jv": "Javanese",
         "ka": "Georian",
-		"kg": "Kongo",
-		"ki": "Kikuyu",
-		"kj": "Kuanyama",
+        "kg": "Kongo",
+        "ki": "Kikuyu",
+        "kj": "Kuanyama",
         "kk": "Kasakh",
-		"kl": "Kalaallisut",
-		"km": "Central Khmer",
-		"kn": "Kannada",
+        "kl": "Kalaallisut",
+        "km": "Central Khmer",
+        "kn": "Kannada",
         "ko": "Korean",
         "ko-kp": "Korean (North Korea)",
         "ko-kr": "Korean (South Korea)",
-		"kr": "Kanuri",
-		"ks": "Kashmiri",
-		"ku": "Kurdish",
-		"kv": "Komi",
-		"kw": "Cornish",
+        "kr": "Kanuri",
+        "ks": "Kashmiri",
+        "ku": "Kurdish",
+        "kv": "Komi",
+        "kw": "Cornish",
         "ky": "Kyrgyz",
         "la": "Latin",
         "lb": "Luxembourgish",
-		"lg": "Ganda",
-		"li": "Limburgan",
-		"ln": "Lingala",
-		"lo": "Lao",
+        "lg": "Ganda",
+        "li": "Limburgan",
+        "ln": "Lingala",
+        "lo": "Lao",
         "lt": "Lithuanian",
-		"lu": "Luba-Katanga",
+        "lu": "Luba-Katanga",
         "lv": "Latvian",
-		"mg": "Malagasy",
-		"mh": "Marshallese",
-		"mi": "Maori",
-		"mk": "Macedonian",
+        "mg": "Malagasy",
+        "mh": "Marshallese",
+        "mi": "Maori",
+        "mk": "Macedonian",
         "mk-mk": "Macedonian (F.J.R. Macedonia)",
-		"ml": "Malayalam",
-		"mn": "Mongolian",
+        "ml": "Malayalam",
+        "mn": "Mongolian",
         "mo": "Moldavian",
         "mr": "Marathi",
         "ms": "Malay",
-		"mt": "Maltese",
-		"my": "Burmese",
-		"na": "Nauru",
+        "mt": "Maltese",
+        "my": "Burmese",
+        "na": "Nauru",
         "nb": "Nowegian Bokm&#xE5;l",
-		"nd": "North Ndebele",
+        "nd": "North Ndebele",
         "ne": "Nepali",
-		"ng": "Ndonga",
+        "ng": "Ndonga",
         "nl": "Dutch",
         "nl-be": "Dutch (Belgium)",
         "nn": "Nowegian Nynorsk",
         "no": "Nowegian",
-		"nr": "South Ndebele",
+        "nr": "South Ndebele",
         "nv": "Navajo",
-		"ny": "Chichewa",
+        "ny": "Chichewa",
         "oc": "Occitan",
-		"oj": "Ojibwa",
+        "oj": "Ojibwa",
         "om": "Oromo",
-		"or": "Oriya",
-		"os": "Ossetian",
-		"pa": "Panjabi",
-		"pi": "Pali",
+        "or": "Oriya",
+        "os": "Ossetian",
+        "pa": "Panjabi",
+        "pi": "Pali",
         "pl": "Polish",
-		"ps": "Pushto",
+        "ps": "Pushto",
         "pt": "Portuguese",
         "pt-br": "Portuguese (Brasil)",
         "qu": "Quechua",
-		"rm": "Romansh",
-		"rn": "Rundi",
+        "rm": "Romansh",
+        "rn": "Rundi",
         "ro": "Romanian",
         "ru": "Russian",
-		"rw": "Kinyarwanda",
+        "rw": "Kinyarwanda",
         "sa": "Sanskit",
         "sc": "Sardinian",
         "sd": "Sindhi",
-		"se": "Northern Sami",
+        "se": "Northern Sami",
         "sg": "Sango",
-		"sh": "Serbo-Croatian",
-		"si": "Sinhala",
+        "sh": "Serbo-Croatian",
+        "si": "Sinhala",
         "sk": "Slovak",
         "sl": "Slovenian",
-		"sm": "Samoan",
-		"sn": "Shona",
+        "sm": "Samoan",
+        "sn": "Shona",
         "so": "Somali",
         "sq": "Albanian",
         "sr": "Serbian",
-		"ss": "Swati",
-		"st": "Southern Sotho",
-		"su": "Sundanese",
+        "ss": "Swati",
+        "st": "Southern Sotho",
+        "su": "Sundanese",
         "sv": "Swedish",
         "sv-fi": "Swedisch (Finnland)",
         "sw": "Swahili",
         "ta": "Tamil",
-		"te": "Telugu",
-		"tg": "Tajik",
+        "te": "Telugu",
+        "tg": "Tajik",
         "th": "Thai",
-		"ti": "Tigrinya",
+        "ti": "Tigrinya",
         "tk": "Turkmen",
-		"tl": "Tagalog",
-		"tn": "Tswana",
-		"to": "Tonga",
+        "tl": "Tagalog",
+        "tn": "Tswana",
+        "to": "Tonga",
         "tr": "Turkish",
-		"ts": "Tsonga",
-		"tt": "Tatar",
-		"tw": "Twi",
-		"ty": "Tahitian",
-		"ug": "Uighur",
+        "ts": "Tsonga",
+        "tt": "Tatar",
+        "tw": "Twi",
+        "ty": "Tahitian",
+        "ug": "Uighur",
         "uk": "Ukrainian",
-		"ur": "Urdu",
-		"uz": "Uzbek",
+        "ur": "Urdu",
+        "uz": "Uzbek",
         "ve": "Venda",
         "vi": "Vietnamese",
         "vo": "Volap&#xFC;k",
         "wa": "Walloon",
-		"wo": "Wolof",
+        "wo": "Wolof",
         "xh": "Xhosa",
         "yi": "Yiddish",
-		"yo": "Yoruba",
-		"za": "Zhuang",
-		"zh": "Chinese",
+        "yo": "Yoruba",
+        "za": "Zhuang",
+        "zh": "Chinese",
         "zh-chs": "Chinese (Simplified)",
         "zh-cht": "Chinese (Traditional)",
         "zh-cn": "Chinese (People's Republic of China)",
@@ -318,17 +318,17 @@
         "zu": "Zulu"
     };
     if (langHash[abbrev]) {
-		return langHash[abbrev];
-	} else {
-		return null;
-	}
+        return langHash[abbrev];
+    } else {
+        return null;
+    }
 }
 
 // Function to convert category code to category name
 function categoryName(abbrev) {
-	// see http://www.iana.org/assignments/language-subtag-registry
-	var catHash = {
-		"CC":  "Captions",
+    // see http://www.iana.org/assignments/language-subtag-registry
+    var catHash = {
+        "CC":  "Captions",
         "SUB": "Subtitles",
         "TAD": "Audio Description",
         "KTV": "Karaoke",
@@ -342,154 +342,154 @@
         "CUE": "Cue Points"
     };
     if (catHash[abbrev]) {
-		return catHash[abbrev];
-	} else {
-		return null;
-	}
+        return catHash[abbrev];
+    } else {
+        return null;
+    }
 }
 
 
 // This is where the implementation of iText starts
 // list of potential errors created with iText parsing
 var ITEXT_ERR = {
-	ABORTED: 1, // fetching aborted
-	NETWORK: 2, // network error
-	PARSE: 3,   // parsing error of itext resource
-	SRC_NOT_SUPPORTED: 4, // unsuitable itext resource
-	LANG: 5    // language mismatch
+    ABORTED: 1, // fetching aborted
+    NETWORK: 2, // network error
+    PARSE: 3,   // parsing error of itext resource
+    SRC_NOT_SUPPORTED: 4, // unsuitable itext resource
+    LANG: 5    // language mismatch
 };
 
 
 // class to load a file, call the right parsing function,
 // and keep the parsed text segments
 var LoadFile = function (url, charset, type) {
-	this.load(url, charset, type);
+    this.load(url, charset, type);
 };
 LoadFile.prototype = {
-	url: null,
-	textElements: [],
-	error: 0,
-	load: function (url, charset, type) {
-		this.url = url;
-		var handler = null;
-		var content = [];
-		var error = 0;
-		// 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;
-		}
-		// set the character encoding before the ajax request
-		jQuery.ajaxSetup({
-			'beforeSend' : function (xhr) {
-				xhr.overrideMimeType("text/text; charset=" + charset);
-			}
-		});
-		jQuery.ajax({
-			type: "GET",
-			url: url,
-			data: {},
-			success: function (data, textStatus) {
-				content = handler(data);
-			},
-			error: function () {
-				error = ITEXT_ERR.NETWORK;
-			},
-			dataType: 'text',
-			async: false,
-			cache: false // REMOVE AFTER TESTING: FIXME
-		});
-		if (!error && !content) {
-			this.error = ITEXT_ERR.PARSE;
-		} else if (error) {
-			this.error = error;
-		}
-		this.textElements = content;
-	}
+    url: null,
+    textElements: [],
+    error: 0,
+    load: function (url, charset, type) {
+        this.url = url;
+        var handler = null;
+        var content = [];
+        var error = 0;
+        // 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;
+        }
+        // set the character encoding before the ajax request
+        jQuery.ajaxSetup({
+            'beforeSend' : function (xhr) {
+                xhr.overrideMimeType("text/text; charset=" + charset);
+            }
+        });
+        jQuery.ajax({
+            type: "GET",
+            url: url,
+            data: {},
+            success: function (data, textStatus) {
+                content = handler(data);
+            },
+            error: function () {
+                error = ITEXT_ERR.NETWORK;
+            },
+            dataType: 'text',
+            async: false,
+            cache: false // REMOVE AFTER TESTING: FIXME
+        });
+        if (!error && !content) {
+            this.error = ITEXT_ERR.PARSE;
+        } else if (error) {
+            this.error = error;
+        }
+        this.textElements = content;
+    }
 };
 
 
 // class to hold an itext track
 var ItextTrack = function (track) {
-	this.init(track);
+    this.init(track);
 };
-ItextTrack.prototype = {	
-	category: null,
+ItextTrack.prototype = {    
+    category: null,
     src: null,
-	lang: null,
-	langName: null,
+    lang: null,
+    langName: null,
     type: "text/srt",
     charset: null,
     display: "no",
-	fetched: false,
-	enabled: false,
-	error: 0,
-	delayBy: 0, // FIXME: TODO
-	allText: [],
-	init: function (itext) {
-		this.category = jQuery(itext).attr("category");
-		this.src = jQuery(itext).attr("src");
-		this.lang = jQuery(itext).attr("lang");
-		this.langName = languageName(this.lang);
-		this.type = (jQuery(itext).attr("type") || "text/srt");
-		this.charset = jQuery(itext).attr("charset");
-		this.display = (jQuery(itext).attr("display") || "no");
-		if (this.display === "yes") {
-			this.fetch(this.src);
-			this.enabled = true;
-		}
-	},
-	fetch: function (src) {
-		if (src) {
-			this.src = src;
-			if (this.type === "text/srt" || this.type === "text/lrc") {
-				var file = new LoadFile(src, this.charset, this.type);
-				this.error = file.error;
-				this.allText = file.textElements;
-				this.fetched = true;
-			} else {
-				this.error = ITEXT_ERR.SRC_NOT_SUPPORTED;
-			}
-		}
-	},
-	currentText: function (currentTime) {
-	    var lines = [];
-		for (var i = 0; i < this.allText.length; i++) {
-			if (this.allText[i].end) {
-				if (currentTime >= this.allText[i].start && currentTime < this.allText[i].end) {
-	        		lines.push('<div class="text">' + this.allText[i].content + '</div>');
-				}
-			} else {
-				if (currentTime >= this.allText[i].start) {
-	        		lines.push('<div class="text">' + this.allText[i].content + '</div>');
-				}
-			}
-		}
-		// produce output
-	    var content;
-	    if (lines.length === 0) {
-	    	content = null;
-	    } else {
-	    	content = lines.join("<br>\n");
-	    }
-	    return content;
-	},
-	enable: function () {
-		this.enabled = true;
-		if (!this.fetched) {
-			this.fetch(this.src);
-		}
-	},
-	disable: function () {
-		this.enabled = false;
-	},
-	delay: function (seconds) {
-		this.delayBy = seconds;
-	}
+    fetched: false,
+    enabled: false,
+    error: 0,
+    delayBy: 0, // FIXME: TODO
+    allText: [],
+    init: function (itext) {
+        this.category = jQuery(itext).attr("category");
+        this.src = jQuery(itext).attr("src");
+        this.lang = jQuery(itext).attr("lang");
+        this.langName = languageName(this.lang);
+        this.type = (jQuery(itext).attr("type") || "text/srt");
+        this.charset = jQuery(itext).attr("charset");
+        this.display = (jQuery(itext).attr("display") || "no");
+        if (this.display === "yes") {
+            this.fetch(this.src);
+            this.enabled = true;
+        }
+    },
+    fetch: function (src) {
+        if (src) {
+            this.src = src;
+            if (this.type === "text/srt" || this.type === "text/lrc") {
+                var file = new LoadFile(src, this.charset, this.type);
+                this.error = file.error;
+                this.allText = file.textElements;
+                this.fetched = true;
+            } else {
+                this.error = ITEXT_ERR.SRC_NOT_SUPPORTED;
+            }
+        }
+    },
+    currentText: function (currentTime) {
+        var lines = [];
+        for (var i = 0; i < this.allText.length; i++) {
+            if (this.allText[i].end) {
+                if (currentTime >= this.allText[i].start && currentTime < this.allText[i].end) {
+                    lines.push('<div class="text">' + this.allText[i].content + '</div>');
+                }
+            } else {
+                if (currentTime >= this.allText[i].start) {
+                    lines.push('<div class="text">' + this.allText[i].content + '</div>');
+                }
+            }
+        }
+        // produce output
+        var content;
+        if (lines.length === 0) {
+            content = null;
+        } else {
+            content = lines.join("<br>\n");
+        }
+        return content;
+    },
+    enable: function () {
+        this.enabled = true;
+        if (!this.fetched) {
+            this.fetch(this.src);
+        }
+    },
+    disable: function () {
+        this.enabled = false;
+    },
+    delay: function (seconds) {
+        this.delayBy = seconds;
+    }
 };
 
 
@@ -497,149 +497,150 @@
 // would need to be implemented inside Browser as default
 // but does not need javascript API exposure
 var ItextCollection = function (video, div_id) {
-	this.init(video, div_id);
+    this.init(video, div_id);
 };
 ItextCollection.prototype = {
-	video: null,
-	div_id: null,
-	tracks: [],
-	primary_lang: -1,
-	
-	init: function (vid, div) {
-		this.video = vid;
-		this.div_id = div;
-		this.load();
-		// set up display divs for each category
-		for (var i in this.tracks) {
-			jQuery("#" + this.div_id).append("<div class='itext_" + i + "'></div>");
-		}
-	},
-	load: function () {
-		// parse the itext elements and remember which tracks to fetch
-		var categories = {};
-		var primary_lang = [];
-		var secondary_lang = [];
+    video: null,
+    div_id: null,
+    tracks: [],
+    primary_lang: -1,
+    
+    init: function (vid, div) {
+        this.video = vid;
+        this.div_id = div;
+        this.load();
+        // set up display divs for each category
+        for (var i in this.tracks) {
+            jQuery("#" + this.div_id).append("<div class='itext_" + i + "'></div>");
+        }
+    },
+    load: function () {
+        // parse the itext elements and remember which tracks to fetch
+        var categories = {};
+        var primary_lang = [];
+        var secondary_lang = [];
 
-		// go through each itext track, parse it and add it to categories[]
-    	var tracks_tmp = this.video.find('itext');
-		tracks_tmp.each(function (i) {
-		
-			// create the text track and add to the categories double assoc array
-	    	var track = new ItextTrack(this);
-			if (!(track.category in categories)) {
-				categories[track.category] = {};
-			}
-			categories[track.category][track.lang] = track;
+        // go through each itext track, parse it and add it to categories[]
+        var tracks_tmp = this.video.find('itext');
+console.log(this.video);
+        tracks_tmp.each(function (i) {
+        
+            // create the text track and add to the categories double assoc array
+            var track = new ItextTrack(this);
+            if (!(track.category in categories)) {
+                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
-				}
-			}
-		});
-		
-		// load track of appropriate language in each category
-		for (var 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;
-	    	}
-		}
+            // 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
+                }
+            }
+        });
+        
+        // load track of appropriate language in each category
+        for (var 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;
+        // double assoc array is created
+        this.tracks = categories;
     },
-	itextMenu: function (baseEl, elstring) {
-		var appendText = '<div class="itextMenu" role="presentation">\n';
-		appendText += '<ul class="catMenu" role="presentation">\n';
-		for (var i in this.tracks) {
-			appendText += '<li role="menuitem" aria-haspopup="true" tabindex="0"> &lt; &nbsp;' + categoryName(i) + '\n';
-			appendText += '<ul class="langMenu" role="menu" >\n';
-			for (var j in this.tracks[i]) {
-				appendText += '<li role="menuitemradio" tabindex="0"';
-				if (this.tracks[i].display) {
-				  appendText += ' aria-checked="true"';
-				} else {
-				  appendText += ' aria-checked="false"';
-				}
-				appendText += '><a href="#" onclick="'+elstring+'.itexts.tracks[\'' + i + '\'][\'' + j + '\'].enable();jQuery(\'.catMenu\').css(\'visibility\', \'hidden\');return false;">' + this.tracks[i][j].langName + '</a></li>\n';
-			}
-			appendText += '</ul>\n</li>\n';
-		}
-		appendText += '</ul></div>\n';
-		jQuery(baseEl).append(appendText);
-		var videoHeight = jQuery(this.video).css("height").substr(0, jQuery(this.video).css("height").length - 2);
-		jQuery(".langMenu").css("height", "240px");
-		jQuery(".catMenu").css("visibility", "hidden");
-	},
-	show: function (currentTime) {
-		// get content per category
-		var content = [];
-		for (var i in this.tracks) {
-			content[i] = null;
-			for (var j in this.tracks[i]) {
-				if (this.tracks[i][j].enabled) {
-					content[i] = this.tracks[i][j].currentText(currentTime);
-				}
-			}
-		}
-		
-	    // add to correct content container
-		var mc_width = jQuery('.mc').css("width").substr(0, jQuery('.mc').css("width").length - 2);
+    itextMenu: function (baseEl, elstring) {
+        var appendText = '<div class="itextMenu" role="presentation">\n';
+        appendText += '<ul class="catMenu" role="presentation">\n';
+        for (var i in this.tracks) {
+            appendText += '<li role="menuitem" aria-haspopup="true" tabindex="0"> &lt; &nbsp;' + categoryName(i) + '\n';
+            appendText += '<ul class="langMenu" role="menu" >\n';
+            for (var j in this.tracks[i]) {
+                appendText += '<li role="menuitemradio" tabindex="0"';
+                if (this.tracks[i].display) {
+                  appendText += ' aria-checked="true"';
+                } else {
+                  appendText += ' aria-checked="false"';
+                }
+                appendText += '><a href="#" onclick="'+elstring+'.itexts.tracks[\'' + i + '\'][\'' + j + '\'].enable();jQuery(\'.catMenu\').css(\'visibility\', \'hidden\');return false;">' + this.tracks[i][j].langName + '</a></li>\n';
+            }
+            appendText += '</ul>\n</li>\n';
+        }
+        appendText += '</ul></div>\n';
+        jQuery(baseEl).append(appendText);
+        var videoHeight = jQuery(this.video).css("height").substr(0, jQuery(this.video).css("height").length - 2);
+        jQuery(".langMenu").css("height", "240px");
+        jQuery(".catMenu").css("visibility", "hidden");
+    },
+    show: function (currentTime) {
+        // get content per category
+        var content = [];
+        for (var i in this.tracks) {
+            content[i] = null;
+            for (var j in this.tracks[i]) {
+                if (this.tracks[i][j].enabled) {
+                    content[i] = this.tracks[i][j].currentText(currentTime);
+                }
+            }
+        }
+        
+        // add to correct content container
+        var mc_width = jQuery('.mc').css("width").substr(0, jQuery('.mc').css("width").length - 2);
 
-	    for (i in content) {
-			if (content[i]) {
-				// replace content of itext div
-				if (jQuery("#" + this.div_id + " > .itext_" + i).html() !== content[i]) {
-					jQuery("#" + this.div_id + " > .itext_" + i).html(content[i]);
-					if (i === "CUE") {
-						jQuery("#" + this.div_id + " > .itext_" + i + " > .text").prepend("Chapter: ");
-					}
-					if (i === "TAD")	{
-						jQuery("#" + this.div_id + " > .itext_TAD").attr("aria-live", "assertive");
-						jQuery("#" + this.div_id + " > .itext_TAD").css("max-width", (mc_width) + "px");
-						jQuery("#" + this.div_id + " > .itext_TAD").css("bottom", "5px");
-					}
-					if (i === "LRC") {
-						jQuery("#" + this.div_id + " > .itext_LRC").css("max-width", mc_width + "px");
-						jQuery("#" + this.div_id + " > .itext_LRC").css("bottom", "38px");					
-						// somehow the setting of "left" encourages the correct width to be calculated
-						// if I don't do that, the width calculation in text_half_length is too short on some elements
-						jQuery("#" + this.div_id + " > .itext_" + i).css("left",5);
-						var text_half_length = jQuery("#" + this.div_id + " > .itext_LRC > .text").css("width").substr(0, jQuery("#" + this.div_id + " > .itext_LRC > .text").css("width").length - 2) / 2;
-						jQuery("#" + this.div_id + " > .itext_LRC").css("left", ((mc_width / 2) - text_half_length - 7) + "px");
-					}
-					jQuery("#" + this.div_id + " > .itext_" + i).css("visibility", "visible");
-					if (i === "CC" ||
-		      			i === "SUB" ||
-		      			i === "KTV" ||
-		      			i === "TRX" ||
-		      			i === "LIN") {
-						// anyone with a better idea for how to place the captions bottom center, please speak up
-						jQuery("#" + this.div_id + " > .itext_" + i).css("max-width", mc_width + "px");
-						jQuery("#" + this.div_id + " > .itext_" + i).css("bottom", "23px");
-						// somehow the setting of "left" encourages the correct width to be calculated
-						// if I don't do that, the width calculation in text_half_length is too short on some elements
-						jQuery("#" + this.div_id + " > .itext_" + i).css("left",5);
-						var text_half_length = jQuery("#" + this.div_id + " > .itext_" + i + " > .text").css("width").substr(0, jQuery("#" + this.div_id + " > .itext_" + i + " > .text").css("width").length - 2) / 2;
-						jQuery("#" + this.div_id + " > .itext_" + i).css("left", ((mc_width / 2) - text_half_length - 7) + "px");
-					}
-				}
-			} else {
-				jQuery("#" + this.div_id + " > .itext_" + i).css("visibility", "hidden");
-			}
-		}
-	}
+        for (i in content) {
+            if (content[i]) {
+                // replace content of itext div
+                if (jQuery("#" + this.div_id + " > .itext_" + i).html() !== content[i]) {
+                    jQuery("#" + this.div_id + " > .itext_" + i).html(content[i]);
+                    if (i === "CUE") {
+                        jQuery("#" + this.div_id + " > .itext_" + i + " > .text").prepend("Chapter: ");
+                    }
+                    if (i === "TAD")    {
+                        jQuery("#" + this.div_id + " > .itext_TAD").attr("aria-live", "assertive");
+                        jQuery("#" + this.div_id + " > .itext_TAD").css("max-width", (mc_width) + "px");
+                        jQuery("#" + this.div_id + " > .itext_TAD").css("bottom", "5px");
+                    }
+                    if (i === "LRC") {
+                        jQuery("#" + this.div_id + " > .itext_LRC").css("max-width", mc_width + "px");
+                        jQuery("#" + this.div_id + " > .itext_LRC").css("bottom", "38px");                    
+                        // somehow the setting of "left" encourages the correct width to be calculated
+                        // if I don't do that, the width calculation in text_half_length is too short on some elements
+                        jQuery("#" + this.div_id + " > .itext_" + i).css("left",5);
+                        var text_half_length = jQuery("#" + this.div_id + " > .itext_LRC > .text").css("width").substr(0, jQuery("#" + this.div_id + " > .itext_LRC > .text").css("width").length - 2) / 2;
+                        jQuery("#" + this.div_id + " > .itext_LRC").css("left", ((mc_width / 2) - text_half_length - 7) + "px");
+                    }
+                    jQuery("#" + this.div_id + " > .itext_" + i).css("visibility", "visible");
+                    if (i === "CC" ||
+                          i === "SUB" ||
+                          i === "KTV" ||
+                          i === "TRX" ||
+                          i === "LIN") {
+                        // anyone with a better idea for how to place the captions bottom center, please speak up
+                        jQuery("#" + this.div_id + " > .itext_" + i).css("max-width", mc_width + "px");
+                        jQuery("#" + this.div_id + " > .itext_" + i).css("bottom", "23px");
+                        // somehow the setting of "left" encourages the correct width to be calculated
+                        // if I don't do that, the width calculation in text_half_length is too short on some elements
+                        jQuery("#" + this.div_id + " > .itext_" + i).css("left",5);
+                        var text_half_length = jQuery("#" + this.div_id + " > .itext_" + i + " > .text").css("width").substr(0, jQuery("#" + this.div_id + " > .itext_" + i + " > .text").css("width").length - 2) / 2;
+                        jQuery("#" + this.div_id + " > .itext_" + i).css("left", ((mc_width / 2) - text_half_length - 7) + "px");
+                    }
+                }
+            } else {
+                jQuery("#" + this.div_id + " > .itext_" + i).css("visibility", "hidden");
+            }
+        }
+    }
 };

Modified: itext/styles/subtitles.css
===================================================================
--- itext/styles/subtitles.css	2009-10-29 09:02:58 UTC (rev 4051)
+++ itext/styles/subtitles.css	2009-10-29 09:03:06 UTC (rev 4052)
@@ -35,85 +35,85 @@
  * ***** END LICENSE BLOCK ***** */
 
 div.itextMenu {
-	float: right;
+    float: right;
 }
 
 div.itextMenu ul {
-	bottom: 0;
-	position: absolute;
-	list-style-type: none;
-	margin: 0;
-	padding: 0;
-	right: 0;
-	border: 1px;
-	z-index: 500;
+    bottom: 0;
+    position: absolute;
+    list-style-type: none;
+    margin: 0;
+    padding: 0;
+    right: 0;
+    border: 1px;
+    z-index: 500;
 }
 
 ul.catMenu > li {
-	margin-right: 14px;
-	width: 100px;
-	background-color: white;
+    margin-right: 14px;
+    width: 100px;
+    background-color: white;
     opacity:0.8;
-	padding: 5px 0px 0px 5px;
-	border: 1px solid black;
+    padding: 5px 0px 0px 5px;
+    border: 1px solid black;
 }
 
 ul.catMenu > li > ul {
-	right: 121px;
-	border: 1px solid black;
-	background-color: white;
-	visibility: hidden;
-	overflow: auto; 
+    right: 121px;
+    border: 1px solid black;
+    background-color: white;
+    visibility: hidden;
+    overflow: auto; 
 }
 
 ul.catMenu > li:hover > ul {
-	visibility: visible;
-	width: 150px;
+    visibility: visible;
+    width: 150px;
 }
 
 ul.langMenu li {
-	padding: 5px 0px 0px 5px;
+    padding: 5px 0px 0px 5px;
 }
 
 ul.langMenu a {
-	display: block;
+    display: block;
 }
 
 div.itext_CC, div.itext_SUB, div.itext_KTV, div.itext_TRX, div.itext_LRC, div.itext_LIN {
-	background-color: #333333;
+    background-color: #333333;
     opacity:0.8;
-/*	padding: 7px 7px 4px 7px; */
-	visibility: hidden;
-	bottom: 0;
+/*    padding: 7px 7px 4px 7px; */
+    visibility: hidden;
+    bottom: 0;
     position: absolute;
-	z-index: 1;
+    z-index: 1;
 }
 
 div.itext_TAD {
-	background-color: #333333;
-	visibility: hidden;
-	float: left;
-	margin: 0;
-	padding: 0;
-	width: 0
-	height: 0;
-	bottom: 0;
-	position: absolute;
-	z-index: -100;
+    background-color: #333333;
+    visibility: hidden;
+    float: left;
+    margin: 0;
+    padding: 0;
+    width: 0
+    height: 0;
+    bottom: 0;
+    position: absolute;
+    z-index: -100;
 }
 
 div.itext_CUE {
-	background-color: #333333;
-	visibility: hidden;
-	margin: 0;
-	padding: 0;
-	width: 0
-	height: 0;
-	z-index: -200;
+    background-color: #333333;
+    visibility: hidden;
+    margin: 0;
+    padding: 0;
+    width: 0
+    height: 0;
+    z-index: -200;
 }
 
 div.text {
-	color: white;
-	opacity: 100%;
-	text-align: center;
+    color: white;
+    opacity: 100%;
+    text-align: center;
 }



More information about the commits mailing list