Skip to content

Instantly share code, notes, and snippets.

@ferclaverino
Created September 11, 2012 23:38
Show Gist options
  • Save ferclaverino/3703042 to your computer and use it in GitHub Desktop.
Save ferclaverino/3703042 to your computer and use it in GitHub Desktop.
BookmarkInMemory
(function () {
"use strict";
var bookmarks = [];
function init() {
}
var instanceMembers = {
addNews: function (news) {
bookmarks.push(news);
},
hasNews: function (idArticulo) {
var result = bookmarks.filter(function (item) {
return (item.IdArticulo == idArticulo);
});
return (result.length > 0);
},
removeNews: function (idArticulo) {
for (var i = 0; i < bookmarks.length; i++) {
if (bookmarks[i].IdArticulo == idArticulo) {
bookmarks.splice(i, 1);
return;
}
}
},
getAllNews: function () {
return bookmarks;
},
};
var staticMembers = {};
var BookmarkInMemory = WinJS.Class.define(init, instanceMembers, staticMembers);
// add to namespace
WinJS.Namespace.define("Repositories",
{
BookmarkInMemory: BookmarkInMemory
}
);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment