summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-02-07 12:16:47 +0100
committerBernhard Posselt <nukeawhale@gmail.com>2013-02-07 12:16:47 +0100
commit33219e2211b9a91c0436902771eb83e1e9f5964b (patch)
treedb22f1a75a49d3fd390302c7a9a57c32819f5c6c /js
parentd962dc1d58cfcdf294c7a304d857f0984ef6fd49 (diff)
fixed grunt compile errors in .4
Diffstat (limited to 'js')
-rw-r--r--js/app.js2087
1 files changed, 1032 insertions, 1055 deletions
diff --git a/js/app.js b/js/app.js
index fe4b04f5f..7308db3df 100644
--- a/js/app.js
+++ b/js/app.js
@@ -9,16 +9,15 @@
*
*/
-(function(angular, $, OC, oc_requesttoken){
-
-
/*
# ownCloud
#
# @author Bernhard Posselt
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
-# This file is licensed under the Affero General Public License version 3 or later.
+# This file is licensed under the Affero General Public License version 3 or
+# later.
+#
# See the COPYING-README file
#
*/
@@ -53,7 +52,59 @@
# @author Bernhard Posselt
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
- # This file is licensed under the Affero General Public License version 3 or later.
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.
+ #
+ # See the COPYING-README file
+ #
+ */
+
+
+ /*
+ # Used for properly distributing received model data from the server
+ */
+
+
+ angular.module('OC').factory('_Publisher', function() {
+ var Publisher;
+ Publisher = (function() {
+
+ function Publisher() {
+ this.subscriptions = {};
+ }
+
+ Publisher.prototype.subscribeModelTo = function(model, name) {
+ var _base;
+ (_base = this.subscriptions)[name] || (_base[name] = []);
+ return this.subscriptions[name].push(model);
+ };
+
+ Publisher.prototype.publishDataTo = function(data, name) {
+ var subscriber, _i, _len, _ref, _results;
+ _ref = this.subscriptions[name] || [];
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ subscriber = _ref[_i];
+ _results.push(subscriber.handle(data));
+ }
+ return _results;
+ };
+
+ return Publisher;
+
+ })();
+ return Publisher;
+ });
+
+ /*
+ # ownCloud
+ #
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.
+ #
# See the COPYING-README file
#
*/
@@ -165,313 +216,473 @@
# @author Bernhard Posselt
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
- # This file is licensed under the Affero General Public License version 3 or later.
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.
+ #
# See the COPYING-README file
#
*/
- angular.module('OC').factory('_Model', function() {
- var Model;
- Model = (function() {
+ /*
+ # Inject router into angular to make testing easier
+ */
- function Model() {
- this.foreignKeys = {};
- this.data = [];
- this.ids = {};
+
+ angular.module('OC').factory('Router', function() {
+ return OC.Router;
+ });
+
+}).call(this);
+
+
+/*
+# ownCloud news app
+#
+# @author Alessandro Cosentino
+# @author Bernhard Posselt
+# Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
+# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+#
+# This file is licensed under the Affero General Public License version 3 or
+# later.
+#
+# See the COPYING-README file
+#
+*/
+
+
+(function() {
+ var app, markingRead, scrolling,
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ app = angular.module('News', []).config(function($provide) {
+ var config;
+ config = {
+ MarkReadTimeout: 500,
+ ScrollTimeout: 500,
+ initialLoadedItemsNr: 20,
+ FeedUpdateInterval: 6000000
+ };
+ return $provide.value('Config', config);
+ });
+
+ app.run([
+ 'PersistenceNews', function(PersistenceNews) {
+ return PersistenceNews.loadInitial();
+ }
+ ]);
+
+ $(document).ready(function() {
+ $(this).keyup(function(e) {
+ if ((e.which === 116) || (e.which === 82 && e.ctrlKey)) {
+ document.location.reload(true);
+ return false;
}
+ });
+ return $('#browselink').click(function() {
+ return $('#file_upload_start').trigger('click');
+ });
+ });
- Model.prototype.handle = function(data) {
- var item, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results;
- if (data['create'] !== void 0) {
- _ref = data['create'];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- item = _ref[_i];
- this.create(item);
- }
+ /*
+ # ownCloud news app
+ #
+ # @author Alessandro Cosentino
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.
+ #
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('_ActiveFeed', function() {
+ var ActiveFeed;
+ ActiveFeed = (function() {
+
+ function ActiveFeed() {
+ this.id = 0;
+ this.type = 3;
+ }
+
+ ActiveFeed.prototype.handle = function(data) {
+ this.id = data.id;
+ return this.type = data.type;
+ };
+
+ return ActiveFeed;
+
+ })();
+ return ActiveFeed;
+ });
+
+ /*
+ # ownCloud news app
+ #
+ # @author Alessandro Cosentino
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.
+ #
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('_Cache', function() {
+ var Cache;
+ Cache = (function() {
+
+ function Cache(feedType, feedModel, folderModel) {
+ this.feedType = feedType;
+ this.feedModel = feedModel;
+ this.folderModel = folderModel;
+ this.clear();
+ }
+
+ Cache.prototype.clear = function() {
+ this.feedCache = [];
+ this.folderCache = {};
+ this.folderCacheLastModified = 0;
+ this.importantCache = [];
+ this.highestId = 0;
+ this.lowestId = 0;
+ this.highestTimestamp = 0;
+ this.lowestTimestamp = 0;
+ this.highestIds = {};
+ this.lowestIds = {};
+ this.highestTimestamps = {};
+ return this.lowestTimestamps = {};
+ };
+
+ Cache.prototype.add = function(item) {
+ if (!this.feedCache[item.feedId]) {
+ this.feedCache[item.feedId] = [];
}
- if (data['update'] !== void 0) {
- _ref1 = data['update'];
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
- item = _ref1[_j];
- this.update(item);
- }
+ this.feedCache[item.feedId].push(item);
+ if (this.highestTimestamp < item.date) {
+ this.highestTimestamp = item.date;
}
- if (data['delete'] !== void 0) {
- _ref2 = data['delete'];
- _results = [];
- for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
- item = _ref2[_k];
- _results.push(this["delete"](item));
- }
- return _results;
+ if (this.lowestTimestamp > item.date) {
+ this.lowestTimestamp = item.date;
+ }
+ if (this.highestId < item.id) {
+ this.highestId = item.id;
+ }
+ if (this.lowestId > item.id) {
+ this.lowestId = item.id;
+ }
+ if (item.isImportant) {
+ this.importantCache.push(item);
+ }
+ if (this.highestTimestamps[item.feedId] === void 0 || item.id > this.highestTimestamps[item.feedId]) {
+ this.highestTimestamps[item.feedId] = item.date;
+ }
+ if (this.lowestTimestamps[item.feedId] === void 0 || item.id > this.lowestTimestamps[item.feedId]) {
+ this.lowestTimestamps[item.feedId] = item.date;
+ }
+ if (this.highestIds[item.feedId] === void 0 || item.id > this.highestIds[item.feedId]) {
+ this.highestIds[item.feedId] = item.id;
}
+ if (this.lowestIds[item.feedId] === void 0 || item.id > this.lowestIds[item.feedId]) {
+ return this.lowestIds[item.feedId] = item.id;
+ }
+ };
+
+ Cache.prototype.getItemsOfFeed = function(feedId) {
+ return this.feedCache[feedId];
};
- Model.prototype.hasForeignKey = function(name) {
- return this.foreignKeys[name] = {};
+ Cache.prototype.getFeedIdsOfFolder = function(folderId) {
+ this.buildFolderCache(folderId);
+ return this.folderCache[folderId];
};
- Model.prototype.create = function(data) {
- var id, ids, name, _base, _ref, _results;
- if (this.ids[data.id] !== void 0) {
- return this.update(data);
- } else {
- this.data.push(data);
- this.ids[data.id] = data;
- _ref = this.foreignKeys;
+ Cache.prototype.getImportantItems = function() {
+ return this.importantCache;
+ };
+
+ Cache.prototype.buildFolderCache = function(id) {
+ var feed, _i, _len, _ref, _results;
+ if (this.folderCacheLastModified !== this.feedModel.getLastModified()) {
+ this.folderCache = {};
+ this.folderCacheLastModified = this.feedModel.getLastModified();
+ }
+ if (this.folderCache[id] === void 0) {
+ this.folderCache[id] = [];
+ _ref = this.feedModel.getItems();
_results = [];
- for (name in _ref) {
- ids = _ref[name];
- id = data[name];
- (_base = this.foreignKeys[name])[id] || (_base[id] = []);
- _results.push(this.foreignKeys[name][id].push(data));
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ feed = _ref[_i];
+ if (feed.folderId === id) {
+ _results.push(this.folderCache[id].push(feed.id));
+ } else {
+ _results.push(void 0);
+ }
}
return _results;
}
};
- Model.prototype.update = function(item) {
- var currentItem, key, value, _results;
- currentItem = this.ids[item.id];
- _results = [];
- for (key in item) {
- value = item[key];
- if (this.foreignKeys[key] !== void 0) {
- if (value !== currentItem[key]) {
- this._updateForeignKeyCache(key, currentItem, item);
- }
- }
- if (key !== 'id') {
- _results.push(currentItem[key] = value);
- } else {
- _results.push(void 0);
- }
- }
- return _results;
+ Cache.prototype.getFeedsOfFolderId = function(id) {
+ this.buildFolderCache(id);
+ return this.folderCache[id];
};
- Model.prototype["delete"] = function(item) {
- if (this.getById(item.id) !== void 0) {
- return this.removeById(item.id);
+ Cache.prototype.removeItemInArray = function(id, array) {
+ var counter, element, removeItemIndex, _i, _len;
+ removeItemIndex = null;
+ counter = 0;
+ for (_i = 0, _len = array.length; _i < _len; _i++) {
+ element = array[_i];
+ if (element.id === id) {
+ removeItemIndex = counter;
+ break;
+ }
+ counter += 1;
+ }
+ if (removeItemIndex !== null) {
+ return array.splice(removeItemIndex, 1);
}
};
- Model.prototype._updateForeignKeyCache = function(name, currentItem, toItem) {
- var foreignKeyItems, fromValue, toValue;
- fromValue = currentItem[name];
- toValue = toItem[name];
- foreignKeyItems = this.foreignKeys[name][fromValue];
- this._removeForeignKeyCacheItem(foreignKeyItems, currentItem);
- return this.foreignKeys[name][toValue].push(item);
+ Cache.prototype.remove = function(item) {
+ this.removeItemInArray(item.id, this.feedCache[item.feedId]);
+ return this.removeItemInArray(item.id, this.importantCache);
};
- Model.prototype._removeForeignKeyCacheItem = function(foreignKeyItems, item) {
- var fkItem, index, _i, _len, _results;
- _results = [];
- for (index = _i = 0, _len = foreignKeyItems.length; _i < _len; index = ++_i) {
- fkItem = foreignKeyItems[index];
- if (fkItem.id === id) {
- _results.push(this.foreignKeys[key][item[key]].splice(index, 1));
- } else {
- _results.push(void 0);
- }
+ Cache.prototype.setImportant = function(item, isImportant) {
+ if (isImportant) {
+ return this.importantCache.push(item);
+ } else {
+ return this.removeItemInArray(item.id, this.importantCache);
}
- return _results;
};
- Model.prototype.removeById = function(id) {
- var foreignKeyItems, ids, index, item, key, _i, _len, _ref, _ref1;
- item = this.getById(id);
- _ref = this.foreignKeys;
- for (key in _ref) {
- ids = _ref[key];
- foreignKeyItems = ids[item[key]];
- this._removeForeignKeyCacheItem(foreignKeyItems, item);
+ Cache.prototype.getHighestId = function(type, id) {
+ if (this.isFeed(type)) {
+ return this.highestIds[id] || 0;
+ } else {
+ return this.highestId;
}
- _ref1 = this.data;
- for (index = _i = 0, _len = _ref1.length; _i < _len; index = ++_i) {
- item = _ref1[index];
- if (item.id === id) {
- this.data.splice(index, 1);
- }
+ };
+
+ Cache.prototype.getHighestTimestamp = function(type, id) {
+ if (this.isFeed(type)) {
+ return this.highestTimestamps[id] || 0;
+ } else {
+ return this.highestTimestamp;
}
- return delete this.ids[id];
};
- Model.prototype.getById = function(id) {
- return this.ids[id];
+ Cache.prototype.getLowestId = function(type, id) {
+ if (this.isFeed(type)) {
+ return this.lowestIds[id] || 0;
+ } else {
+ return this.lowestId;
+ }
};
- Model.prototype.getAll = function() {
- return this.data;
+ Cache.prototype.getLowestTimestamp = function(type, id) {
+ if (this.isFeed(type)) {
+ return this.lowestTimestamps[id] || 0;
+ } else {
+ return this.lowestTimestamp;
+ }
};
- Model.prototype.getAllOfForeignKeyWithId = function(foreignKeyName, foreignKeyId) {
- return this.foreignKeys[foreignKeyName][foreignKeyId];
+ Cache.prototype.isFeed = function(type) {
+ return type === this.feedType.Feed;
};
- return Model;
+ return Cache;
})();
- return Model;
+ return Cache;
});
/*
- # ownCloud
+ # ownCloud news app
#
+ # @author Alessandro Cosentino
# @author Bernhard Posselt
+ # Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
- # This file is licensed under the Affero General Public License version 3 or later.
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.
+ #
# See the COPYING-README file
#
*/
- /*
- # Inject router into angular to make testing easier
- */
+ angular.module('News').factory('_FeedModel', [
+ 'Model', function(Model) {
+ var FeedModel;
+ FeedModel = (function(_super) {
+
+ __extends(FeedModel, _super);
+ function FeedModel() {
+ FeedModel.__super__.constructor.call(this);
+ }
- angular.module('OC').factory('Router', function() {
- return OC.Router;
- });
+ FeedModel.prototype.add = function(item) {
+ return FeedModel.__super__.add.call(this, this.bindAdditional(item));
+ };
+
+ FeedModel.prototype.bindAdditional = function(item) {
+ if (item.icon === "url()") {
+ item.icon = 'url(' + OC.imagePath('news', 'rss.svg') + ')';
+ }
+ return item;
+ };
+
+ return FeedModel;
+
+ })(Model);
+ return FeedModel;
+ }
+ ]);
/*
- # ownCloud
+ # ownCloud news app
#
+ # @author Alessandro Cosentino
# @author Bernhard Posselt
+ # Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
- # This file is licensed under the Affero General Public License version 3 or later.
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.
+ #
# See the COPYING-README file
#
*/
+ angular.module('News').factory('FeedType', function() {
+ var feedType;
+ return feedType = {
+ Feed: 0,
+ Folder: 1,
+ Starred: 2,
+ Subscriptions: 3,
+ Shared: 4
+ };
+ });
+
/*
- # Used for properly distributing received model data from the server
+ # ownCloud news app
+ #
+ # @author Alessandro Cosentino
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.
+ #
+ # See the COPYING-README file
+ #
*/
- angular.module('OC').factory('_Publisher', function() {
- var Publisher;
- Publisher = (function() {
-
- function Publisher() {
- this.subscriptions = {};
- }
+ angular.module('News').factory('_FolderModel', [
+ 'Model', function(Model, $rootScope) {
+ var FolderModel;
+ FolderModel = (function(_super) {
- Publisher.prototype.subscribeModelTo = function(model, name) {
- var _base;
- (_base = this.subscriptions)[name] || (_base[name] = []);
- return this.subscriptions[name].push(model);
- };
+ __extends(FolderModel, _super);
- Publisher.prototype.publishDataTo = function(data, name) {
- var subscriber, _i, _len, _ref, _results;
- _ref = this.subscriptions[name] || [];
- _results = [];
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
- subscriber = _ref[_i];
- _results.push(subscriber.handle(data));
+ function FolderModel() {
+ FolderModel.__super__.constructor.call(this);
}
- return _results;
- };
-
- return Publisher;
-
- })();
- return Publisher;
- });
-
-}).call(this);
-
-
-/*
-# ownCloud - News app
-#
-# @author Bernhard Posselt
-# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
-#
-# This file is licensed under the Affero General Public License version 3 or later.
-# See the COPYING-README file
-#
-*/
+ return FolderModel;
-(function() {
- var app, markingRead, scrolling,
- __hasProp = {}.hasOwnProperty,
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
-
- app = angular.module('News', []).config(function($provide) {
- var config;
- config = {
- MarkReadTimeout: 500,
- ScrollTimeout: 500,
- initialLoadedItemsNr: 20,
- FeedUpdateInterval: 6000000
- };
- return $provide.value('Config', config);
- });
-
- app.run([
- 'PersistenceNews', function(PersistenceNews) {
- return PersistenceNews.loadInitial();
+ })(Model);
+ return FolderModel;
}
]);
- $(document).ready(function() {
- $(this).keyup(function(e) {
- if ((e.which === 116) || (e.which === 82 && e.ctrlKey)) {
- document.location.reload(true);
- return false;
- }
- });
- return $('#browselink').click(function() {
- return $('#file_upload_start').trigger('click');
- });
- });
-
/*
- # ownCloud - News app
+ # ownCloud news app
#
+ # @author Alessandro Cosentino
# @author Bernhard Posselt
+ # Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
- # This file is licensed under the Affero General Public License version 3 or later.
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.
+ #
# See the COPYING-README file
#
*/
- angular.module('News').factory('_ShowAll', function() {
- var ShowAll;
- ShowAll = (function() {
+ angular.module('News').factory('_GarbageRegistry', function() {
+ var GarbageRegistry;
+ GarbageRegistry = (function() {
- function ShowAll() {
- this.showAll = false;
+ function GarbageRegistry(itemModel) {
+ this.itemModel = itemModel;
+ this.registeredItemIds = {};
}
- ShowAll.prototype.handle = function(data) {
- return this.showAll = data;
+ GarbageRegistry.prototype.register = function(item) {
+ var itemId;
+ itemId = item.id;
+ return this.registeredItemIds[itemId] = item;
};
- return ShowAll;
+ GarbageRegistry.prototype.unregister = function(item) {
+ var itemId;
+ itemId = item.id;
+ return delete this.registeredItemIds[itemId];
+ };
+
+ GarbageRegistry.prototype.clear = function() {
+ var id, item, _ref;
+ _ref = this.registeredItemIds;
+ for (id in _ref) {
+ item = _ref[id];
+ if (!item.keptUnread) {
+ this.itemModel.removeById(parseInt(id, 10));
+ }
+ item.keptUnread = false;
+ }
+ return this.registeredItemIds = {};
+ };
+
+ return GarbageRegistry;
})();
- return ShowAll;
+ return GarbageRegistry;
});
/*
- # ownCloud - News app
+ # ownCloud news app
#
+ # @author Alessandro Cosentino
# @author Bernhard Posselt
+ # Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
- # This file is licensed under the Affero General Public License version 3 or later.
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.
+ #
# See the COPYING-README file
#
*/
@@ -581,12 +792,151 @@
]);
/*
- # ownCloud - News app
+ # ownCloud news app
+ #
+ # @author Alessandro Cosentino
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.
+ #
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('_Loading', function() {
+ var Loading;
+ return Loading = (function() {
+
+ function Loading() {
+ this.loading = 0;
+ }
+
+ return Loading;
+
+ })();
+ });
+
+ /*
+ # ownCloud news app
+ #
+ # @author Alessandro Cosentino
+ # @author Bernhard Posselt
+ # Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
+ # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ #
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.
+ #
+ # See the COPYING-README file
+ #
+ */
+
+
+ angular.module('News').factory('Model', function() {
+ var Model;
+ Model = (function() {
+
+ function Model() {
+ this.clearCache();
+ }
+
+ Model.prototype.handle = function(data) {
+ var item, _i, _len, _results;
+ _results = [];
+ for (_i = 0, _len = data.length; _i < _len; _i++) {
+ item = data[_i];
+ _results.push(this.add(item));
+ }
+ return _results;
+ };
+
+ Model.prototype.clearCache = function() {
+ this.items = [];
+ this.itemIds = {};
+ return this.markAccessed();
+ };
+
+ Model.prototype.markAccessed = function() {
+ return this.lastAccessed = new Date().getTime();
+ };
+
+ Model.prototype.getLastModified = function() {
+ return this.lastAccessed;
+ };
+
+ Model.prototype.add = function(item) {
+ if (this.itemIds[item.id] === void 0) {
+ this.items.push(item);
+ this.itemIds[item.id] = item;
+ this.markAccessed();
+ return true;
+ } else {
+ this.update(item);
+ return false;
+ }
+ };
+
+ Model.prototype.update = function(item) {
+ var key, updatedItem, value;
+ updatedItem = this.itemIds[item.id];
+ for (key in item) {
+ value = item[key];
+ if (key !== 'id') {
+ updatedItem[key] = value;
+ }
+ }
+ return this.markAccessed();
+ };
+
+ Model.prototype.removeById = function(id) {
+ var counter, item, removeItemIndex, _i, _len, _ref;
+ removeItemIndex = null;
+ counter = 0;
+ _ref = this.items;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ item = _ref[_i];
+ if (item.id === id) {
+ removeItemIndex = counter;
+ break;
+ }
+ counter += 1;
+ }
+ if (removeItemIndex !== null) {
+ this.items.splice(removeItemIndex, 1);
+ delete this.itemIds[id];
+ }
+ return this.markAccessed();
+ };
+
+ Model.prototype.getItemById = function(id) {
+ return this.itemIds[id];
+ };
+
+ Model.prototype.getItems = function() {
+ return this.items;
+ };
+
+ return Model;
+
+ })();
+ return Model;
+ });
+
+ /*
+ # ownCloud news app
#
+ # @author Alessandro Cosentino
# @author Bernhard Posselt
+ # Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
- # This file is licensed under the Affero General Public License version 3 or later.
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.
+ #
# See the COPYING-README file
#
*/
@@ -681,146 +1031,16 @@
});
/*
- # ownCloud - News app
- #
- # @author Bernhard Posselt
- # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
- #
- # This file is licensed under the Affero General Public License version 3 or later.
- # See the COPYING-README file
- #
- */
-
-
- angular.module('News').factory('Loading', [
- '_Loading', function(_Loading) {
- return new _Loading();
- }
- ]);
-
- angular.module('News').factory('ActiveFeed', [
- '_ActiveFeed', 'Publisher', function(_ActiveFeed, Publisher) {
- var model;
- model = new _ActiveFeed();
- Publisher.subscribeTo('activeFeed', model);
- return model;
- }
- ]);
-
- angular.module('News').factory('ShowAll', [
- '_ShowAll', 'Publisher', function(_ShowAll, Publisher) {
- var model;
- model = new _ShowAll();
- Publisher.subscribeTo('showAll', model);
- return model;
- }
- ]);
-
- angular.module('News').factory('StarredCount', [
- '_StarredCount', 'Publisher', function(_StarredCount, Publisher) {
- var model;
- model = new _StarredCount();
- Publisher.subscribeTo('starredCount', model);
- return model;
- }
- ]);
-
- angular.module('News').factory('FeedModel', [
- '_FeedModel', 'Publisher', function(_FeedModel, Publisher) {
- var model;
- model = new _FeedModel();
- Publisher.subscribeTo('feeds', model);
- return model;
- }
- ]);
-
- angular.module('News').factory('FolderModel', [
- '_FolderModel', 'Publisher', function(_FolderModel, Publisher) {
- var model;
- model = new _FolderModel();
- Publisher.subscribeTo('folders', model);
- return model;
- }
- ]);
-
- angular.module('News').factory('ItemModel', [
- '_ItemModel', 'Publisher', 'Cache', 'FeedType', function(_ItemModel, Publisher, Cache, FeedType) {
- var model;
- model = new _ItemModel(Cache, FeedType);
- Publisher.subscribeTo('items', model);
- return model;
- }
- ]);
-
- angular.module('News').factory('Cache', [
- '_Cache', 'FeedType', 'FeedModel', 'FolderModel', function(_Cache, FeedType, FeedModel, FolderModel) {
- return new _Cache(FeedType, FeedModel, FolderModel);
- }
- ]);
-
- angular.module('News').factory('PersistenceNews', [
- '_PersistenceNews', '$http', '$rootScope', 'Loading', 'Publisher', function(_PersistenceNews, $http, $rootScope, Loading, Publisher) {
- return new _PersistenceNews($http, $rootScope, Loading, Publisher);
- }
- ]);
-
- angular.module('News').factory('GarbageRegistry', [
- '_GarbageRegistry', 'ItemModel', function(_GarbageRegistry, ItemModel) {
- return new _GarbageRegistry(ItemModel);
- }
- ]);
-
- angular.module('News').factory('Publisher', [
- '_Publisher', function(_Publisher) {
- return new _Publisher();
- }
- ]);
-
- angular.module('News').factory('OPMLParser', [
- '_OPMLParser', function(_OPMLParser) {
- return new _OPMLParser();
- }
- ]);
-
- /*
- # ownCloud - News app
+ # ownCloud news app
#
+ # @author Alessandro Cosentino
# @author Bernhard Posselt
+ # Copyright (c) 2012 - Alessandro Cosentino <cosenal@gmail.com>
# Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
#
- # This file is licensed under the Affero General Public License version 3 or later.
- # See the COPYING-README file
- #
- */
-
-
- angular.module('News').factory('_ActiveFeed', function() {
- var ActiveFeed;
- ActiveFeed = (function() {
-
- function ActiveFeed() {
- this.id = 0;
- this.type = 3;
- }
-
- ActiveFeed.prototype.handle = function(data) {
- this.id = data.id;
- return this.type = data.type;
- };
-
- return ActiveFeed;
-
- })();
- return ActiveFeed;
- });
-
- /*
- # ownCloud - News app
- #
- # @author Bernhard Posselt
- # Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com>
+ # This file is licensed under the Affero General Public License version 3 or
+ # later.