From fa1a56e7d5331f8d034c4bec79613f6779c80654 Mon Sep 17 00:00:00 2001 From: ScottDowne Date: Tue, 22 Jun 2010 08:53:59 -0400 Subject: [PATCH] added support for SS:FF and SS --- popcorn.js | 14 +++++++++++--- xml/webMadeMovies.xml | 30 +++++++++++++++--------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/popcorn.js b/popcorn.js index 6eed955..09c74fb 100644 --- a/popcorn.js +++ b/popcorn.js @@ -57,9 +57,17 @@ }; // Simple function to convert 0:05 to 0.5 in seconds - var to_secs = function(time) { + var toSeconds = function(time) { var t = time.split(":"); - return parseInt(t[0] * 60, 10) + parseInt(t[1], 10); + if (t.length === 1) { + return parseFloat(t[0], 10); + } else if (t.length === 2) { + return parseFloat(t[0], 10) + parseFloat(t[1] / 30, 10); + } else if (t.length === 3) { + return parseInt(t[0] * 60, 10) + parseFloat(t[1], 10) + parseFloat(t[2] / 30, 10); + } else if (t.length === 4) { + return parseInt(t[0] * 3600, 10) + parseInt(t[1] * 60, 10) + parseFloat(t[2], 10) + parseFloat(t[3] / 30, 10); + } }; //////////////////////////////////////////////////////////////////////////// @@ -81,7 +89,7 @@ var key = params[i].item(j).nodeName, data = params[i].item(j).nodeValue; if (key === "in" || key === "out") { - this.params[key] = to_secs(data); + this.params[key] = toSeconds(data); } else { this.params[key] = data; } diff --git a/xml/webMadeMovies.xml b/xml/webMadeMovies.xml index da74059..9135cc2 100644 --- a/xml/webMadeMovies.xml +++ b/xml/webMadeMovies.xml @@ -1,23 +1,23 @@ - Hello! My name is Celine Celine - And I help the Internet be easier - by making things easier - My name is Mona Kasra - and I'm building a better internet + Hello! My name is Celine Celine + And I help the Internet be easier + by making things easier + My name is Mona Kasra + and I'm building a better internet - Celine Celine - Bryan - Mona Kasra - Caleb - Dave - Noah - Celine Celine + Celine Celine + Bryan + Mona Kasra + Caleb + Dave + Noah + Celine Celine - - - + + + -- 2.43.0