Created
September 11, 2012 23:38
-
-
Save ferclaverino/3703042 to your computer and use it in GitHub Desktop.
BookmarkInMemory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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