]> git.wh0rd.org Git - tt-rss.git/blob - feedlist.js
cc36587a2eb288bbbdb3fdb99b74e8ea244950f8
[tt-rss.git] / feedlist.js
1 //var xmlhttp = Ajax.getTransport();
2
3 function viewCategory(cat) {
4         active_feed_is_cat = true;
5         viewfeed(cat, '', true);
6 }
7
8 function feedlist_callback() {
9         if (xmlhttp.readyState == 4) {
10                 debug("feedlist_callback");
11                 var f = document.getElementById("feeds-frame");
12                 f.innerHTML = xmlhttp.responseText;
13                 feedlist_init();
14         }
15 }
16
17 function viewfeed(feed, subop, is_cat, subop_param) {
18         try {
19
20                 enableHotkeys();
21
22                 var toolbar_query = Form.serialize("main_toolbar_form");
23                 var toolbar_form = document.forms["main_toolbar_form"];
24
25                 if (document.forms["main_toolbar_form"].query) {
26                         toolbar_form.query.value = "";
27                 }
28
29                 storeInitParam("toolbar_limit", 
30                         toolbar_form.limit[toolbar_form.limit.selectedIndex].value);
31
32                 storeInitParam("toolbar_view_mode", 
33                         toolbar_form.view_mode[toolbar_form.view_mode.selectedIndex].value); 
34
35                 var query = "backend.php?op=viewfeed&feed=" + feed + "&" +
36                         toolbar_query + "&subop=" + param_escape(subop);
37
38                 if (document.getElementById("search_form")) {
39                         var search_query = Form.serialize("search_form");
40                         query = query + "&" + search_query;
41                         closeInfoBox(true);
42                 }
43
44                 debug("IS_CAT_STORED: " + activeFeedIsCat() + ", IS_CAT: " + is_cat);
45
46                 var fe = document.getElementById("FEEDR-" + getActiveFeedId());
47
48                 if (fe) {
49                         fe.className = fe.className.replace("Selected", "");
50                 }
51
52                 setActiveFeedId(feed);
53         
54                 if (is_cat != undefined) {
55                         active_feed_is_cat = is_cat;
56                 }
57
58                 if (subop == "MarkAllRead") {
59
60                         var feedlist = document.getElementById('feedList');
61                         
62                         var next_unread_feed = getRelativeFeedId(feedlist,
63                                         getActiveFeedId(), "next", true);
64
65                         var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
66
67                         if (next_unread_feed && show_next_feed && !activeFeedIsCat()) {
68                                 query = query + "&nuf=" + param_escape(next_unread_feed);
69                                 setActiveFeedId(next_unread_feed);
70                         }
71                 }
72
73                 if (activeFeedIsCat()) {
74                         query = query + "&cat=1";
75                 }
76
77                 if (navigator.userAgent.match("Opera")) {
78                         var date = new Date();
79                         var timestamp = Math.round(date.getTime() / 1000);
80                         query = query + "&ts=" + timestamp
81                 }
82
83                 if (!activeFeedIsCat()) {
84                         var feedr = document.getElementById("FEEDR-" + getActiveFeedId());
85                         if (feedr && !feedr.className.match("Selected")) {      
86                                 feedr.className = feedr.className + "Selected";
87                         } 
88                 }
89                 
90                 disableContainerChildren("headlinesToolbar", false);
91                 Form.enable("main_toolbar_form");
92
93                 debug(query);
94
95 /*              var container = document.getElementById("headlines-frame");
96
97                 container.innerHTML = "<div class=\"loadingPrompt\"><img src=\"images/indicator_white.gif\">&nbsp;" +
98                         "Loading, please wait...</div>"; */
99
100                 notify("Loading, please wait...", true);
101
102                 xmlhttp.abort();
103
104                 if (xmlhttp_ready(xmlhttp)) {
105                         xmlhttp.open("GET", query, true);
106                         xmlhttp.onreadystatechange=headlines_callback;
107                         xmlhttp.send(null);
108                 } else {
109                         debug("xmlhttp busy (@feeds)");
110                 }  
111
112         } catch (e) {
113                 exception_error("viewfeed", e);
114         }               
115 }
116
117 function toggleCollapseCat(cat) {
118         try {
119                 if (!xmlhttp_ready(xmlhttp)) {
120                         printLockingError();
121                         return;
122                 }
123         
124                 var cat_elem = document.getElementById("FCAT-" + cat);
125                 var cat_list = document.getElementById("FCATLIST-" + cat).parentNode;
126                 var caption = document.getElementById("FCAP-" + cat);
127                 
128                 if (cat_list.className.match("invisible")) {
129                         cat_list.className = "";
130                         caption.innerHTML = caption.innerHTML.replace("...", "");
131                         if (cat == 0) {
132                                 setCookie("ttrss_vf_uclps", "0");
133                         }
134                 } else {
135                         cat_list.className = "invisible";
136                         caption.innerHTML = caption.innerHTML + "...";
137                         if (cat == 0) {
138                                 setCookie("ttrss_vf_uclps", "1");
139                         }
140                 }
141
142                 new Ajax.Request("backend.php?op=feeds&subop=collapse&cid=" + 
143                         param_escape(cat));
144
145         } catch (e) {
146                 exception_error("toggleCollapseCat", e);
147         }
148 }
149
150 function feedlist_init() {
151         try {
152 //              if (arguments.callee.done) return;
153 //              arguments.callee.done = true;           
154                 
155                 debug("in feedlist init");
156                 
157                 hideOrShowFeeds(document, getInitParam("hide_read_feeds") == 1);
158                 document.onkeydown = hotkey_handler;
159                 setTimeout("timeout()", 0);
160
161                 debug("about to remove splash, OMG!");
162
163                 var o = document.getElementById("overlay");
164
165                 if (o) {
166                         o.style.display = "none";
167                         debug("removed splash!");
168                 }
169
170                 if (typeof correctPNG != 'undefined') {
171                         correctPNG();
172                 }
173
174         } catch (e) {
175                 exception_error("feedlist/init", e);
176         }
177 }