summaryrefslogtreecommitdiffstats
path: root/js/build/app.js
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-18 22:49:30 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-18 22:49:30 +0200
commit2459002dcc070dcb66b2a44c237b87e8a1b8e968 (patch)
tree5a668fa1aead7269a1979e8706405d8dbf3226f3 /js/build/app.js
parente2e9a79aa3acb0d3a02d81ddbfbdcacc676db2d2 (diff)
add models
Diffstat (limited to 'js/build/app.js')
-rw-r--r--js/build/app.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/js/build/app.js b/js/build/app.js
index 206114cd4..8c5835c06 100644
--- a/js/build/app.js
+++ b/js/build/app.js
@@ -54,6 +54,39 @@ app.run([
});
}
]);
+app.factory('Feed', [
+ 'Model',
+ function (Model) {
+ 'use strict';
+ var Feed = function () {
+ Model.call(this, 'url');
+ };
+ Feed.prototype = Object.create(Model.prototype);
+ return new Feed();
+ }
+]);
+app.factory('Folder', [
+ 'Model',
+ function (Model) {
+ 'use strict';
+ var Folder = function () {
+ Model.call(this, 'name');
+ };
+ Folder.prototype = Object.create(Model.prototype);
+ return new Folder();
+ }
+]);
+app.factory('Item', [
+ 'Model',
+ function (Model) {
+ 'use strict';
+ var Item = function () {
+ Model.call(this, 'id');
+ };
+ Item.prototype = Object.create(Model.prototype);
+ return new Item();
+ }
+]);
app.service('Loading', function () {
'use strict';
this.loading = {
@@ -117,6 +150,15 @@ app.factory('Model', function () {
if (this.hashMap[id] !== undefined) {
delete this.hashMap[id];
}
+ },
+ clear: function () {
+ this.hashMap = {};
+ // http://stackoverflow.com/questions/1232040/how-to-empty-an-array-in-javascript
+ // this is the fastes way to empty an array when you want to keep the
+ // reference around
+ while (this.values.length > 0) {
+ this.values.pop();
+ }
}
};
return Model;
@@ -133,6 +175,14 @@ app.service('Publisher', function () {
}
};
};
+ this.publishAll = function (values) {
+ var key;
+ for (key in values) {
+ if (values.hasOwnProperty(key)) {
+ this.publish(values[key]).onChannel(key);
+ }
+ }
+ };
this.publish = function (value) {
return {
onChannel: function (channel) {