]> git.wh0rd.org Git - tt-rss.git/commitdiff
js: code cleanup
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 18 Nov 2010 13:00:00 +0000 (16:00 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 18 Nov 2010 13:00:00 +0000 (16:00 +0300)
feedlist.js
tt-rss.js

index e96aa63d4c4f1352514ced77ba7391c57996aca7..f3332477be2ed58a18c9c3332af3a3723f1b890e 100644 (file)
@@ -352,7 +352,11 @@ function parse_counters(reply, scheduled_call) {
 
 function getFeedUnread(feed, is_cat) {
        try {
-               return parseInt(getFeedValue(feed, is_cat, 'unread'));
+               var tree = dijit.byId("feedTree");
+
+               if (tree && tree.model) 
+                       return tree.model.getFeedUnread(feed, is_cat);
+
        } catch (e) {
                //
        }
@@ -372,30 +376,32 @@ function hideOrShowFeeds(hide) {
 }
 
 function getFeedName(feed, is_cat) {   
-       return getFeedValue(feed, is_cat, 'name');
+       var tree = dijit.byId("feedTree");
+
+       if (tree && tree.model) 
+               return tree.model.getFeedValue(feed, is_cat, 'name');
 }
 
 function getFeedValue(feed, is_cat, key) {     
-
        try {
-               if (is_cat) 
-                       treeItem = treeModel.store._itemsByIdentity['CAT:' + feed];
-               else
-                       treeItem = treeModel.store._itemsByIdentity['FEED:' + feed];
-
-               if (treeItem)
-                       return treeModel.store.getValue(treeItem, key);
+               var tree = dijit.byId("feedTree");
 
+               if (tree && tree.model) 
+                       return tree.model.getFeedValue(feed, is_cat, key);
+       
        } catch (e) {
                //
        }
-
        return '';
 }
 
 function setFeedUnread(feed, is_cat, unread) {
        try {
-               setFeedValue(feed, is_cat, 'unread', parseInt(unread));
+               var tree = dijit.byId("feedTree");
+
+               if (tree && tree.model) 
+                       return tree.model.setFeedUnread(feed, is_cat, unread);
+
        } catch (e) {
                exception_error("setFeedUnread", e);
        }
@@ -403,19 +409,13 @@ function setFeedUnread(feed, is_cat, unread) {
 
 function setFeedValue(feed, is_cat, key, value) {
        try {
-               if (!value) value = '';
-
-               if (is_cat) 
-                       treeItem = treeModel.store._itemsByIdentity['CAT:' + feed];
-               else
-                       treeItem = treeModel.store._itemsByIdentity['FEED:' + feed];
+               var tree = dijit.byId("feedTree");
 
-               if (treeItem)
-                       treeModel.store.setValue(treeItem, key, value);
+               if (tree && tree.model) 
+                       return tree.model.setFeedValue(feed, is_cat, key, value);
 
        } catch (e) {
-               console.log(e);
-               //exception_error("setFeedValue", e);
+               //
        }
 }
 
@@ -423,18 +423,7 @@ function selectFeed(feed, is_cat) {
        try {
                var tree = dijit.byId("feedTree");
 
-               if (!tree) return;
-
-               if (is_cat) 
-                       treeNode = tree._itemNodesMap['CAT:' + feed];
-               else
-                       treeNode = tree._itemNodesMap['FEED:' + feed];
-
-               if (treeNode) {
-                       treeNode = treeNode[0];
-                       if (!is_cat) tree._expandNode(treeNode);
-                       tree._selectNode(treeNode);
-               }
+               if (tree) return tree.selectFeed(feed, is_cat);
 
        } catch (e) {
                exception_error("selectFeed", e);
@@ -445,17 +434,7 @@ function setFeedIcon(feed, is_cat, src) {
        try {
                var tree = dijit.byId("feedTree");
 
-               if (!tree) return;
-
-               if (is_cat) 
-                       treeNode = tree._itemNodesMap['CAT:' + feed];
-               else
-                       treeNode = tree._itemNodesMap['FEED:' + feed];
-
-               if (treeNode) {
-                       treeNode = treeNode[0];
-                       treeNode.iconNode.src = src;
-               }
+               if (tree) return tree.setFeedIcon(feed, is_cat, src);
 
        } catch (e) {
                exception_error("setFeedIcon", e);
@@ -466,18 +445,7 @@ function setFeedExpandoIcon(feed, is_cat, src) {
        try {
                var tree = dijit.byId("feedTree");
 
-               if (!tree) return;
-
-               if (is_cat) 
-                       treeNode = tree._itemNodesMap['CAT:' + feed];
-               else
-                       treeNode = tree._itemNodesMap['FEED:' + feed];
-
-               if (treeNode) {
-                       treeNode = treeNode[0];
-                       treeNode.expandoNode.src = src;
-                       return true;
-               }
+               if (tree) return tree.setFeedExpandoIcon(feed, is_cat, src);
 
        } catch (e) {
                exception_error("setFeedIcon", e);
index b9e93e1bfa024de24d9a4383cea25d35c5efbc27..4ad6ca2f4d8f1065730238ef94b1dfa0aecc0d9f 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -9,7 +9,6 @@ var hotkey_prefix_pressed = false;
 var init_params = {};
 var _force_scheduled_update = false;
 var last_scheduled_update = false;
-var treeModel;
 
 var _rpc_seq = 0;
 
@@ -75,7 +74,7 @@ function updateFeedList() {
                var store = new dojo.data.ItemFileWriteStore({
          url: "backend.php?op=feeds"});
 
-               treeModel = new fox.FeedStoreModel({
+               var treeModel = new fox.FeedStoreModel({
                        store: store,
                        query: {
                                "type": "feed"