Author: ygrego Date: 2015-04-27 14:39:00 +0000 (Mon, 27 Apr 2015) New Revision: 1265 Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1265 Log: Implementation of "BookmarkCollection". Added: oipf/js/impl/model/BookmarkCollection.js Added: oipf/js/impl/model/BookmarkCollection.js =================================================================== --- oipf/js/impl/model/BookmarkCollection.js (rev 0) +++ oipf/js/impl/model/BookmarkCollection.js 2015-04-27 14:39:00 UTC (rev 1265) @@ -0,0 +1,48 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + +var BookmarkCollection = Collection.extend({ + + init: function() { + this.super.init.apply(this, arguments); + }, + + /* + * Description: + * Add a new bookmark to the collection. If the bookmark cannot be added + * (e.g. because the value given for time lies outside + * the length of the recording), this method SHALL return null. + * + * Argument: + * - time: The time at which the bookmark is set, in seconds since + * the start of the recording. + * + * - name: The name of the bookmark. + */ + addBookmark: function(time, name) { + var newBookmark = new Bookmark(time, name); + this.push(newBookmark); + + }, + + /* + * Description: + * Remove a bookmark from the collection. + * + * Argument: + * - bookmark: The bookmark to be removed. + */ + removeBookmark: function(bookmark) { + var indexOfBookmark = this.indexOf(bookmark); + var lastBookmark = this[this.length-1]; + + if (indexOfBookmark) { + this[indexOfBookmark] = lastBookmark; + this.pop(); + } + } + +});