Commit c182b8ef by Christina Roberts

Merge pull request #1145 from MITx/feature/dhm/cms-settings

Feature/dhm/cms settings
parents 62f54447 9cc1b348
......@@ -56,6 +56,7 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({
for (var i=0; i<videos.length; i++) {
// doesn't call parseFloat or Number b/c they stop on first non parsable and return what they have
if (!isFinite(videos[i].speed)) vid_errors.push(videos[i].speed + " is not a valid speed.");
else if (!videos[i].key) vid_errors.push(videos[i].speed + " does not have a video id");
// can't use get from client to test if video exists b/c of CORS (crossbrowser get not allowed)
// GET "http://gdata.youtube.com/feeds/api/videos/" + videokey
}
......@@ -76,7 +77,7 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({
// the below is lax to enable validation
_videospeedparse : /[^:]*/g, // /\d+\.?\d*(?=:)/g,
_videokeyparse : /([^,\/]+)/g,
_videonosuffix : /[^\"]+/g,
_videonosuffix : /[^\"\/\>]+/g,
_getNextMatch : function (regex, string, cursor) {
regex.lastIndex = cursor;
var result = regex.exec(string);
......@@ -141,12 +142,13 @@ CMS.Models.Settings.CourseDetails = Backbone.Model.extend({
cursor = 0;
// parsed to "fff:kkk,fff:kkk"
var result = new Array();
if (!videostring || videostring.length == 0) return result;
while (cursor < videostring.length) {
var speed = this._getNextMatch(this._videospeedparse, videostring, cursor);
if (speed) cursor = this._videospeedparse.lastIndex + 1;
else return result;
var key = this._getNextMatch(this._videokeyparse, videostring, cursor);
cursor = this._videokeyparse.lastIndex + 1;
if (key) cursor = this._videokeyparse.lastIndex + 1;
// See the WTF above
if (_.isArray(key)) key = key[0];
result.push({speed: speed, key: key});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment