Author: ygrego Date: 2015-05-18 07:39:47 +0000 (Mon, 18 May 2015) New Revision: 1348 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1348 Log: -This class extends "Collection". -The properties name and values are initialized in constructor. -Addition of methods: "_additionnalProcessing", "_addRatingValue" and "_addSeveralRatingValues". Modified: oipf/js/impl/model/ParentalRatingScheme.js Modified: oipf/js/impl/model/ParentalRatingScheme.js =================================================================== --- oipf/js/impl/model/ParentalRatingScheme.js 2015-05-15 13:49:51 UTC (rev 1347) +++ oipf/js/impl/model/ParentalRatingScheme.js 2015-05-18 07:39:47 UTC (rev 1348) @@ -17,16 +17,25 @@ * collections, the ParentalRatingScheme class supports the additional * properties and methods defined below. */ -var ParentalRatingScheme = Array.extend({ +var ParentalRatingScheme = Collection.extend({ name: null, threshold: null, - init: function() { - this._iconUri = []; + /* + * + * FIXME: + * - Yannis 15/05/2015 Initialization of property threshold must be bone, + * when name unequal to "dvb-si" but i don't know with what values. + */ + init: function(name, values) { + this._iconUri = []; + this.name = name; + this._additionnalProcessing(name, values); + }, - + /* * Description: * Return the index of the rating represented by attribute ratingValue @@ -62,6 +71,28 @@ */ iconUri: function(index) { return this._iconUri[index]; + }, + + _additionnalProcessing: function(name, values) { + switch (name) { + case "dvb-si": + break; + + default: + var ratingValues = values.split(","); + ratingValues && this._addSeveralRatingValues(ratingValues); + } + }, + + _addRatingValue: function(ratingValue) { + this.push(ratingValue); + }, + + _addSeveralRatingValues: function(ratingValues) { + for (var i = 0, li = ratingValues.length; i < li; i++) { + var currentRatingValue = ratingValues[i]; + this.addRatingValue(currentRatingValue); + } } });