summaryrefslogtreecommitdiffstats
path: root/js/service
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-19 16:00:08 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-19 16:00:08 +0200
commit274034a63374434298204db21e6d6513690e6eaf (patch)
tree7dcda9aebb41120fc2619248f4609e4df5912fd3 /js/service
parent11f0246acd0daab1067eb32099fa26f05a26ea21 (diff)
put models into seperate folder
Diffstat (limited to 'js/service')
-rw-r--r--js/service/Feed.js20
-rw-r--r--js/service/Folder.js20
-rw-r--r--js/service/Item.js44
-rw-r--r--js/service/Model.js88
4 files changed, 0 insertions, 172 deletions
diff --git a/js/service/Feed.js b/js/service/Feed.js
deleted file mode 100644
index 9223ca6e7..000000000
--- a/js/service/Feed.js
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * ownCloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright Bernhard Posselt 2014
- */
-app.factory('Feed', function (Model) {
- 'use strict';
-
- var Feed = function () {
- Model.call(this, 'url');
- };
-
- Feed.prototype = Object.create(Model.prototype);
-
- return new Feed();
-}); \ No newline at end of file
diff --git a/js/service/Folder.js b/js/service/Folder.js
deleted file mode 100644
index 101b8ec66..000000000
--- a/js/service/Folder.js
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * ownCloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright Bernhard Posselt 2014
- */
-app.factory('Folder', function (Model) {
- 'use strict';
-
- var Folder = function () {
- Model.call(this, 'name');
- };
-
- Folder.prototype = Object.create(Model.prototype);
-
- return new Folder();
-}); \ No newline at end of file
diff --git a/js/service/Item.js b/js/service/Item.js
deleted file mode 100644
index ec3512f22..000000000
--- a/js/service/Item.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * ownCloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright Bernhard Posselt 2014
- */
-app.factory('Item', function (Model) {
- 'use strict';
-
- var Item = function () {
- Model.call(this, 'id');
- };
-
- Item.prototype = Object.create(Model.prototype);
-
- Item.prototype.receive = function (value, channel) {
- switch (channel) {
-
- case 'newestItemId':
- this.newestItemId = value;
- break;
-
- case 'starred':
- this.starredCount = value;
- break;
- default:
- Model.prototype.receive.call(this, value, channel);
- }
- };
-
- Item.prototype.getNewestItemId = function () {
- return this.newestItemId;
- };
-
- Item.prototype.getStarredCount = function () {
- return this.starredCount;
- };
-
-
- return new Item();
-}); \ No newline at end of file
diff --git a/js/service/Model.js b/js/service/Model.js
deleted file mode 100644
index dddede788..000000000
--- a/js/service/Model.js
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * ownCloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright Bernhard Posselt 2014
- */
-app.factory('Model', function () {
- 'use strict';
-
- var Model = function (id) {
- this.id = id;
- this.values = [];
- this.hashMap = {};
- };
-
- Model.prototype = {
- receive: function (values) {
- var self = this;
- values.forEach(function (value) {
- self.add(value);
- });
- },
-
- add: function (value) {
- var key,
- existing;
-
- existing = this.hashMap[value[this.id]];
-
- if (existing === undefined) {
- this.values.push(value);
- this.hashMap[value[this.id]] = value;
- } else {
- // copy values from new to old object if it exists already
- for (key in value) {
- if (value.hasOwnProperty(key)) {
- existing[key] = value[key];
- }
- }
- }
- },
-
- size: function () {
- return this.values.length;
- },
-
- get: function (id) {
- return this.hashMap[id];
- },
-
- delete: function (id) {
- // find index of object that should be deleted
- var i,
- deleteAtIndex;
-
- for (i = 0; i < this.values.length; i += 1) {
- if (this.values[i][this.id] === id) {
- deleteAtIndex = i;
- break;
- }
- }
-
- if (deleteAtIndex !== undefined) {
- this.values.splice(deleteAtIndex, 1);
- }
-
- 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;
-}); \ No newline at end of file