simplify error handling

* less convoluted exception dialogs
* use window.onerror for the majority of exception catching/reporting
* remove most of now useless try/catch blocks
* report stacktrace instead of manually specified error locations
master
Andrew Dolgov 8 years ago
parent e6d66fe55c
commit 1bfe1d7b31

@ -686,16 +686,6 @@ class Pref_Prefs extends Handler_Protected {
print " "; print " ";
/* $checked = $_SESSION["prefs_show_advanced"] ? "checked='1'" : "";
print "<input onclick='toggleAdvancedPrefs()'
id='prefs_show_advanced'
dojoType=\"dijit.form.CheckBox\"
$checked
type=\"checkbox\"></input>
<label for='prefs_show_advanced'>" .
__("Show additional preferences") . "</label>"; */
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION,
"hook_prefs_tab_section", "prefPrefsPrefsOutside"); "hook_prefs_tab_section", "prefPrefsPrefsOutside");

@ -1917,7 +1917,7 @@
$attributes, $include_all_cats = true, $root_id = false, $nest_level = 0) { $attributes, $include_all_cats = true, $root_id = false, $nest_level = 0) {
if (!$root_id) { if (!$root_id) {
print "<select id=\"$id\" name=\"$id\" default=\"$default_id\" onchange=\"catSelectOnChange(this)\" $attributes>"; print "<select id=\"$id\" name=\"$id\" default=\"$default_id\" $attributes>";
} }
if ($root_id) if ($root_id)

@ -1902,7 +1902,7 @@
WHERE owner_uid = '".$_SESSION["uid"]."' ORDER BY caption"); WHERE owner_uid = '".$_SESSION["uid"]."' ORDER BY caption");
print "<select default=\"$value\" name=\"" . htmlspecialchars($name) . print "<select default=\"$value\" name=\"" . htmlspecialchars($name) .
"\" $attributes onchange=\"labelSelectOnChange(this)\" >"; "\" $attributes>";
while ($line = db_fetch_assoc($result)) { while ($line = db_fetch_assoc($result)) {

@ -302,7 +302,7 @@ require(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"]
} }
} }
} catch (e) { } catch (e) {
exception_error("expandParentNodes", e); exception_error(e);
} }
}, },
findNodeParentsAndExpandThem: function(feed, is_cat, root, parents) { findNodeParentsAndExpandThem: function(feed, is_cat, root, parents) {
@ -341,7 +341,7 @@ require(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"]
} }
} }
} catch (e) { } catch (e) {
exception_error("findNodeParentsAndExpandThem", e); exception_error(e);
} }
}, },
selectFeed: function(feed, is_cat) { selectFeed: function(feed, is_cat) {

@ -8,22 +8,16 @@ function selectTableRow(r, do_select) {
} }
function selectTableRowById(elem_id, check_id, do_select) { function selectTableRowById(elem_id, check_id, do_select) {
var row = $(elem_id);
try { if (row) {
selectTableRow(row, do_select);
var row = $(elem_id); }
if (row) {
selectTableRow(row, do_select);
}
var check = $(check_id); var check = $(check_id);
if (check) { if (check) {
check.checked = do_select; check.checked = do_select;
}
} catch (e) {
exception_error("selectTableRowById", e);
} }
} }

@ -8,253 +8,226 @@ var _viewfeed_timeout = false;
var counters_last_request = 0; var counters_last_request = 0;
var _counters_prev = []; var _counters_prev = [];
/*function viewCategory(cat) {
viewfeed({feed: cat, is_cat: true});
return false;
}*/
function resetCounterCache() { function resetCounterCache() {
_counters_prev = []; _counters_prev = [];
} }
function loadMoreHeadlines() { function loadMoreHeadlines() {
try { console.log("loadMoreHeadlines");
console.log("loadMoreHeadlines");
var offset = 0;
var offset = 0;
var view_mode = document.forms["main_toolbar_form"].view_mode.value;
var view_mode = document.forms["main_toolbar_form"].view_mode.value; var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length;
var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length; var num_all = $$("#headlines-frame > div[id*=RROW]").length;
var num_all = $$("#headlines-frame > div[id*=RROW]").length; var num_unread = getFeedUnread(getActiveFeedId(), activeFeedIsCat());
var num_unread = getFeedUnread(getActiveFeedId(), activeFeedIsCat());
// TODO implement marked & published
// TODO implement marked & published
if (view_mode == "marked") {
if (view_mode == "marked") { console.warn("loadMoreHeadlines: marked is not implemented, falling back.");
console.warn("loadMoreHeadlines: marked is not implemented, falling back."); offset = num_all;
offset = num_all; } else if (view_mode == "published") {
} else if (view_mode == "published") { console.warn("loadMoreHeadlines: published is not implemented, falling back.");
console.warn("loadMoreHeadlines: published is not implemented, falling back."); offset = num_all;
offset = num_all; } else if (view_mode == "unread") {
} else if (view_mode == "unread") { offset = unread_in_buffer;
offset = unread_in_buffer; } else if (_search_query) {
} else if (_search_query) { offset = num_all;
offset = num_all; } else if (view_mode == "adaptive" && !(getActiveFeedId() == -1 && !activeFeedIsCat())) {
} else if (view_mode == "adaptive" && !(getActiveFeedId() == -1 && !activeFeedIsCat())) { // ^ starred feed shows both unread & read articles in adaptive mode
// ^ starred feed shows both unread & read articles in adaptive mode offset = num_unread > 0 ? unread_in_buffer : num_all;
offset = num_unread > 0 ? unread_in_buffer : num_all; } else {
} else { offset = num_all;
offset = num_all; }
}
console.log("offset: " + offset); console.log("offset: " + offset);
viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat(), offset: offset, infscroll_req: true}); viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat(), offset: offset, infscroll_req: true});
} catch (e) {
exception_error("viewNextFeedPage", e);
}
} }
function cleanup_memory(root) { function cleanup_memory(root) {
try { var dijits = dojo.query("[widgetid]", dijit.byId(root).domNode).map(dijit.byNode);
var dijits = dojo.query("[widgetid]", dijit.byId(root).domNode).map(dijit.byNode);
dijits.each(function (d) { dijits.each(function (d) {
dojo.destroy(d.domNode); dojo.destroy(d.domNode);
}); });
$$("#" + root + " *").each(function (i) { $$("#" + root + " *").each(function (i) {
i.parentNode ? i.parentNode.removeChild(i) : true; i.parentNode ? i.parentNode.removeChild(i) : true;
}); });
} catch (e) {
console.log("cleanup_memory: exception");
console.log(e);
}
} }
function viewfeed(params) { function viewfeed(params) {
try { var feed = params.feed;
var feed = params.feed; var is_cat = params.is_cat;
var is_cat = params.is_cat; var offset = params.offset;
var offset = params.offset; var background = params.background;
var background = params.background; var infscroll_req = params.infscroll_req;
var infscroll_req = params.infscroll_req; var can_wait = params.can_wait;
var can_wait = params.can_wait; var viewfeed_debug = params.viewfeed_debug;
var viewfeed_debug = params.viewfeed_debug; var method = params.method;
var method = params.method;
if (is_cat == undefined)
if (is_cat == undefined) is_cat = false;
is_cat = false; else
else is_cat = !!is_cat;
is_cat = !!is_cat;
if (offset == undefined) offset = 0;
if (offset == undefined) offset = 0; if (background == undefined) background = false;
if (background == undefined) background = false; if (infscroll_req == undefined) infscroll_req = false;
if (infscroll_req == undefined) infscroll_req = false;
last_requested_article = 0;
last_requested_article = 0;
if (feed != getActiveFeedId() || activeFeedIsCat() != is_cat) {
if (feed != getActiveFeedId() || activeFeedIsCat() != is_cat) { if (!background && _search_query) _search_query = false;
if (!background && _search_query) _search_query = false; }
}
if (!background) {
_viewfeed_last = get_timestamp();
if (getActiveFeedId() != feed || !infscroll_req) { if (!background) {
setActiveArticleId(0); _viewfeed_last = get_timestamp();
_infscroll_disable = 0;
cleanup_memory("headlines-frame"); if (getActiveFeedId() != feed || !infscroll_req) {
_headlines_scroll_offset = 0; setActiveArticleId(0);
} _infscroll_disable = 0;
if (infscroll_req) { cleanup_memory("headlines-frame");
var timestamp = get_timestamp(); _headlines_scroll_offset = 0;
}
if (_infscroll_request_sent && _infscroll_request_sent + 30 > timestamp) { if (infscroll_req) {
//console.log("infscroll request in progress, aborting"); var timestamp = get_timestamp();
return;
}
_infscroll_request_sent = timestamp; if (_infscroll_request_sent && _infscroll_request_sent + 30 > timestamp) {
//console.log("infscroll request in progress, aborting");
return;
} }
_infscroll_request_sent = timestamp;
} }
}
Form.enable("main_toolbar_form"); Form.enable("main_toolbar_form");
var toolbar_query = Form.serialize("main_toolbar_form"); var toolbar_query = Form.serialize("main_toolbar_form");
var query = "?op=feeds&method=view&feed=" + param_escape(feed) + "&" + var query = "?op=feeds&method=view&feed=" + param_escape(feed) + "&" +
toolbar_query; toolbar_query;
if (method) query += "&m=" + param_escape(method); if (method) query += "&m=" + param_escape(method);
if (offset > 0) { if (offset > 0) {
if (current_first_id) { if (current_first_id) {
query = query + "&fid=" + param_escape(current_first_id); query = query + "&fid=" + param_escape(current_first_id);
}
} }
}
if (!background) { if (!background) {
if (_search_query) { if (_search_query) {
force_nocache = true; force_nocache = true;
query = query + "&" + _search_query; query = query + "&" + _search_query;
//_search_query = false; //_search_query = false;
} }
if (offset != 0) { if (offset != 0) {
query = query + "&skip=" + offset; query = query + "&skip=" + offset;
// to prevent duplicate feed titles when showing grouped vfeeds // to prevent duplicate feed titles when showing grouped vfeeds
if (vgroup_last_feed) { if (vgroup_last_feed) {
query = query + "&vgrlf=" + param_escape(vgroup_last_feed); query = query + "&vgrlf=" + param_escape(vgroup_last_feed);
}
} else {
if (!is_cat && feed == getActiveFeedId() && !params.method) {
query = query + "&m=ForceUpdate";
}
} }
} else {
if (!is_cat && feed == getActiveFeedId() && !params.method) {
query = query + "&m=ForceUpdate";
}
}
Form.enable("main_toolbar_form"); Form.enable("main_toolbar_form");
if (!setFeedExpandoIcon(feed, is_cat, if (!setFeedExpandoIcon(feed, is_cat,
(is_cat) ? 'images/indicator_tiny.gif' : 'images/indicator_white.gif')) (is_cat) ? 'images/indicator_tiny.gif' : 'images/indicator_white.gif'))
notify_progress("Loading, please wait...", true); notify_progress("Loading, please wait...", true);
} }
query += "&cat=" + is_cat; query += "&cat=" + is_cat;
console.log(query); console.log(query);
if (can_wait && _viewfeed_timeout) { if (can_wait && _viewfeed_timeout) {
setFeedExpandoIcon(getActiveFeedId(), activeFeedIsCat(), 'images/blank_icon.gif'); setFeedExpandoIcon(getActiveFeedId(), activeFeedIsCat(), 'images/blank_icon.gif');
clearTimeout(_viewfeed_timeout); clearTimeout(_viewfeed_timeout);
} }
setActiveFeedId(feed, is_cat); setActiveFeedId(feed, is_cat);
if (viewfeed_debug) { if (viewfeed_debug) {
window.open("backend.php" + query + "&debug=1&csrf_token=" + getInitParam("csrf_token")); window.open("backend.php" + query + "&debug=1&csrf_token=" + getInitParam("csrf_token"));
} }
timeout_ms = can_wait ? 250 : 0; timeout_ms = can_wait ? 250 : 0;
_viewfeed_timeout = setTimeout(function() { _viewfeed_timeout = setTimeout(function() {
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
try {
setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif'); setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
headlines_callback2(transport, offset, background, infscroll_req); headlines_callback2(transport, offset, background, infscroll_req);
PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]); PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]);
} }); } catch (e) {
}, timeout_ms); // Wait 250ms exception_error(e);
}
} });
}, timeout_ms); // Wait 250ms
} catch (e) {
exception_error("viewfeed", e);
}
} }
function feedlist_init() { function feedlist_init() {
try { console.log("in feedlist init");
console.log("in feedlist init");
loading_set_progress(50); loading_set_progress(50);
document.onkeydown = hotkey_handler; document.onkeydown = hotkey_handler;
setTimeout(hotkey_prefix_timeout, 5*1000); setTimeout(hotkey_prefix_timeout, 5*1000);
if (!getActiveFeedId()) { if (!getActiveFeedId()) {
viewfeed({feed: -3}); viewfeed({feed: -3});
} else { } else {
viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat()}); viewfeed({feed: getActiveFeedId(), is_cat: activeFeedIsCat()});
} }
hideOrShowFeeds(getInitParam("hide_read_feeds") == 1); hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
request_counters(true); request_counters(true);
timeout(); timeout();
} catch (e) {
exception_error("feedlist/init", e);
}
} }
function request_counters(force) { function request_counters(force) {
try { var date = new Date();
var date = new Date(); var timestamp = Math.round(date.getTime() / 1000);
var timestamp = Math.round(date.getTime() / 1000);
if (force || timestamp - counters_last_request > 5) {
console.log("scheduling request of counters...");
counters_last_request = timestamp; if (force || timestamp - counters_last_request > 5) {
console.log("scheduling request of counters...");
var query = "?op=rpc&method=getAllCounters&seq=" + next_seq(); counters_last_request = timestamp;
if (!force) var query = "?op=rpc&method=getAllCounters&seq=" + next_seq();
query = query + "&last_article_id=" + getInitParam("last_article_id");
console.log(query); if (!force)
query = query + "&last_article_id=" + getInitParam("last_article_id");
new Ajax.Request("backend.php", { console.log(query);
parameters: query,
onComplete: function(transport) {
try {
handle_rpc_json(transport);
} catch (e) {
exception_error("request_counters", e);
}
} });
} else { new Ajax.Request("backend.php", {
console.log("request_counters: rate limit reached: " + (timestamp - counters_last_request)); parameters: query,
} onComplete: function(transport) {
handle_rpc_json(transport);
} });
} catch (e) { } else {
exception_error("request_counters", e); console.log("request_counters: rate limit reached: " + (timestamp - counters_last_request));
} }
} }
@ -289,61 +262,56 @@ function counter_is_equal(a, b) {
function parse_counters(elems) { function parse_counters(elems) {
try { for (var l = 0; l < elems.length; l++) {
for (var l = 0; l < elems.length; l++) {
if (_counters_prev[l] && counter_is_equal(elems[l], _counters_prev[l])) { if (_counters_prev[l] && counter_is_equal(elems[l], _counters_prev[l])) {
continue; continue;
} }
var id = elems[l].id; var id = elems[l].id;
var kind = elems[l].kind; var kind = elems[l].kind;
var ctr = parseInt(elems[l].counter); var ctr = parseInt(elems[l].counter);
var error = elems[l].error; var error = elems[l].error;
var has_img = elems[l].has_img; var has_img = elems[l].has_img;
var updated = elems[l].updated; var updated = elems[l].updated;
var auxctr = parseInt(elems[l].auxcounter); var auxctr = parseInt(elems[l].auxcounter);
if (id == "global-unread") {
global_unread = ctr;
updateTitle();
continue;
}
if (id == "subscribed-feeds") { if (id == "global-unread") {
/* feeds_found = ctr; */ global_unread = ctr;
continue; updateTitle();
} continue;
}
/*if (getFeedUnread(id, (kind == "cat")) != ctr || if (id == "subscribed-feeds") {
(kind == "cat")) { /* feeds_found = ctr; */
}*/ continue;
}
setFeedUnread(id, (kind == "cat"), ctr); /*if (getFeedUnread(id, (kind == "cat")) != ctr ||
setFeedValue(id, (kind == "cat"), 'auxcounter', auxctr); (kind == "cat")) {
}*/
if (kind != "cat") { setFeedUnread(id, (kind == "cat"), ctr);
setFeedValue(id, false, 'error', error); setFeedValue(id, (kind == "cat"), 'auxcounter', auxctr);
setFeedValue(id, false, 'updated', updated);
if (id > 0) { if (kind != "cat") {
if (has_img) { setFeedValue(id, false, 'error', error);
setFeedIcon(id, false, setFeedValue(id, false, 'updated', updated);
getInitParam("icons_url") + "/" + id + ".ico");
} else { if (id > 0) {
setFeedIcon(id, false, 'images/blank_icon.gif'); if (has_img) {
} setFeedIcon(id, false,
getInitParam("icons_url") + "/" + id + ".ico");
} else {
setFeedIcon(id, false, 'images/blank_icon.gif');
} }
} }
} }
}
hideOrShowFeeds(getInitParam("hide_read_feeds") == 1); hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
_counters_prev = elems;
} catch (e) { _counters_prev = elems;
exception_error("parse_counters", e);
}
} }
function getFeedUnread(feed, is_cat) { function getFeedUnread(feed, is_cat) {
@ -405,15 +373,10 @@ function getFeedValue(feed, is_cat, key) {
} }
function setFeedUnread(feed, is_cat, unread) { function setFeedUnread(feed, is_cat, unread) {
try { var tree = dijit.byId("feedTree");
var tree = dijit.byId("feedTree");
if (tree && tree.model)
return tree.model.setFeedUnread(feed, is_cat, unread);
} catch (e) { if (tree && tree.model)
exception_error("setFeedUnread", e); return tree.model.setFeedUnread(feed, is_cat, unread);
}
} }
function setFeedValue(feed, is_cat, key, value) { function setFeedValue(feed, is_cat, key, value) {
@ -429,50 +392,31 @@ function setFeedValue(feed, is_cat, key, value) {
} }
function selectFeed(feed, is_cat) { function selectFeed(feed, is_cat) {
try { var tree = dijit.byId("feedTree");
var tree = dijit.byId("feedTree");
if (tree) return tree.selectFeed(feed, is_cat);
} catch (e) { if (tree) return tree.selectFeed(feed, is_cat);
exception_error("selectFeed", e);
}
} }
function setFeedIcon(feed, is_cat, src) { function setFeedIcon(feed, is_cat, src) {
try { var tree = dijit.byId("feedTree");
var tree = dijit.byId("feedTree");
if (tree) return tree.setFeedIcon(feed, is_cat, src);
} catch (e) { if (tree) return tree.setFeedIcon(feed, is_cat, src);
exception_error("setFeedIcon", e);
}
} }
function setFeedExpandoIcon(feed, is_cat, src) { function setFeedExpandoIcon(feed, is_cat, src) {
try { var tree = dijit.byId("feedTree");
var tree = dijit.byId("feedTree");
if (tree) return tree.setFeedExpandoIcon(feed, is_cat, src); if (tree) return tree.setFeedExpandoIcon(feed, is_cat, src);
} catch (e) {
exception_error("setFeedIcon", e);
}
return false; return false;
} }
function getNextUnreadFeed(feed, is_cat) { function getNextUnreadFeed(feed, is_cat) {
try { var tree = dijit.byId("feedTree");
var tree = dijit.byId("feedTree"); var nuf = tree.model.getNextUnreadFeed(feed, is_cat);
var nuf = tree.model.getNextUnreadFeed(feed, is_cat);
if (nuf)
return tree.model.store.getValue(nuf, 'bare_id');
} catch (e) { if (nuf)
exception_error("getNextUnreadFeed", e); return tree.model.store.getValue(nuf, 'bare_id');
}
} }
function catchupCurrentFeed(mode) { function catchupCurrentFeed(mode) {
@ -480,152 +424,138 @@ function catchupCurrentFeed(mode) {
} }
function catchupFeedInGroup(id) { function catchupFeedInGroup(id) {
try { var title = getFeedName(id);
var title = getFeedName(id);
var str = __("Mark all articles in %s as read?").replace("%s", title); var str = __("Mark all articles in %s as read?").replace("%s", title);
if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) {
var rows = $$("#headlines-frame > div[id*=RROW][data-orig-feed-id='"+id+"']"); var rows = $$("#headlines-frame > div[id*=RROW][data-orig-feed-id='"+id+"']");
if (rows.length > 0) { if (rows.length > 0) {
rows.each(function (row) { rows.each(function (row) {
row.removeClassName("Unread"); row.removeClassName("Unread");
if (row.getAttribute("data-article-id") != getActiveArticleId()) { if (row.getAttribute("data-article-id") != getActiveArticleId()) {
new Effect.Fade(row, {duration: 0.5}); new Effect.Fade(row, {duration: 0.5});
} }
});
var feedTitles = $$("#headlines-frame > div[class='cdmFeedTitle']"); });
for (var i = 0; i < feedTitles.length; i++) { var feedTitles = $$("#headlines-frame > div[class='cdmFeedTitle']");
if (feedTitles[i].getAttribute("data-feed-id") == id) {
if (i < feedTitles.length - 1) { for (var i = 0; i < feedTitles.length; i++) {
new Effect.Fade(feedTitles[i], {duration: 0.5}); if (feedTitles[i].getAttribute("data-feed-id") == id) {
}
break; if (i < feedTitles.length - 1) {
new Effect.Fade(feedTitles[i], {duration: 0.5});
} }
}
updateFloatingTitle(true); break;
}
} }
var catchup_query = "?op=rpc&method=catchupFeed&feed_id=" + updateFloatingTitle(true);
id + "&is_cat=false"; }
console.log(catchup_query); var catchup_query = "?op=rpc&method=catchupFeed&feed_id=" +
id + "&is_cat=false";
notify_progress("Loading, please wait...", true); console.log(catchup_query);
new Ajax.Request("backend.php", { notify_progress("Loading, please wait...", true);
parameters: catchup_query,
onComplete: function (transport) {
handle_rpc_json(transport);
}
} );
//return viewCurrentFeed('MarkAllReadGR:' + id); new Ajax.Request("backend.php", {
} parameters: catchup_query,
onComplete: function (transport) {
handle_rpc_json(transport);
}
} );
} catch (e) { //return viewCurrentFeed('MarkAllReadGR:' + id);
exception_error("catchupFeedInGroup", e);
} }
} }
function catchupFeed(feed, is_cat, mode) { function catchupFeed(feed, is_cat, mode) {
try { if (is_cat == undefined) is_cat = false;
if (is_cat == undefined) is_cat = false;
var str = false;
var str = false;
switch (mode) {
switch (mode) { case "1day":
case "1day": str = __("Mark all articles in %s older than 1 day as read?");
str = __("Mark all articles in %s older than 1 day as read?"); break;
break; case "1week":
case "1week": str = __("Mark all articles in %s older than 1 week as read?");
str = __("Mark all articles in %s older than 1 week as read?"); break;
break; case "2week":
case "2week": str = __("Mark all articles in %s older than 2 weeks as read?");
str = __("Mark all articles in %s older than 2 weeks as read?"); break;
break; default:
default: str = __("Mark all articles in %s as read?");
str = __("Mark all articles in %s as read?"); }
}
var fn = getFeedName(feed, is_cat); var fn = getFeedName(feed, is_cat);
str = str.replace("%s", fn); str = str.replace("%s", fn);
if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) { if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
return; return;
} }
var catchup_query = "?op=rpc&method=catchupFeed&feed_id=" + var catchup_query = "?op=rpc&method=catchupFeed&feed_id=" +
feed + "&is_cat=" + is_cat + "&mode=" + mode; feed + "&is_cat=" + is_cat + "&mode=" + mode;
console.log(catchup_query); console.log(catchup_query);
notify_progress("Loading, please wait...", true); notify_progress("Loading, please wait...", true);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: catchup_query, parameters: catchup_query,
onComplete: function(transport) { onComplete: function(transport) {
handle_rpc_json(transport); handle_rpc_json(transport);
var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1"; var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
if (show_next_feed) { if (show_next_feed) {
var nuf = getNextUnreadFeed(feed, is_cat); var nuf = getNextUnreadFeed(feed, is_cat);
if (nuf) { if (nuf) {
viewfeed({feed: nuf, is_cat: is_cat}); viewfeed({feed: nuf, is_cat: is_cat});
}
} else {
if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
viewCurrentFeed();
}
} }
} else {
if (feed == getActiveFeedId() && is_cat == activeFeedIsCat()) {
viewCurrentFeed();
}
}
notify(""); notify("");
} }); } });
} catch (e) {
exception_error("catchupFeed", e);
}
} }
function decrementFeedCounter(feed, is_cat) { function decrementFeedCounter(feed, is_cat) {
try { var ctr = getFeedUnread(feed, is_cat);
var ctr = getFeedUnread(feed, is_cat);
if (ctr > 0) { if (ctr > 0) {
setFeedUnread(feed, is_cat, ctr - 1); setFeedUnread(feed, is_cat, ctr - 1);
global_unread = global_unread - 1; global_unread = global_unread - 1;
updateTitle(); updateTitle();
if (!is_cat) { if (!is_cat) {
var cat = parseInt(getFeedCategory(feed)); var cat = parseInt(getFeedCategory(feed));
if (!isNaN(cat)) { if (!isNaN(cat)) {
ctr = getFeedUnread(cat, true); ctr = getFeedUnread(cat, true);
if (ctr > 0) { if (ctr > 0) {
setFeedUnread(cat, true, ctr - 1); setFeedUnread(cat, true, ctr - 1);
}
} }
} }
} }
} catch (e) {
exception_error("decrement_feed_counter", e);
} }
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -21,108 +21,92 @@ function activeFeedIsCat() {
} }
function getActiveFeedId() { function getActiveFeedId() {
try { return _active_feed_id;
return _active_feed_id;
} catch (e) {
exception_error("getActiveFeedId", e);
}
} }
function setActiveFeedId(id, is_cat) { function setActiveFeedId(id, is_cat) {
try { hash_set('f', id);
hash_set('f', id); hash_set('c', is_cat ? 1 : 0);
hash_set('c', is_cat ? 1 : 0);
_active_feed_id = id; _active_feed_id = id;
_active_feed_is_cat = is_cat; _active_feed_is_cat = is_cat;
$("headlines-frame").setAttribute("feed-id", id); $("headlines-frame").setAttribute("feed-id", id);
$("headlines-frame").setAttribute("is-cat", is_cat ? 1 : 0); $("headlines-frame").setAttribute("is-cat", is_cat ? 1 : 0);
selectFeed(id, is_cat); selectFeed(id, is_cat);
PluginHost.run(PluginHost.HOOK_FEED_SET_ACTIVE, _active_article_id); PluginHost.run(PluginHost.HOOK_FEED_SET_ACTIVE, _active_article_id);
} catch (e) {
exception_error("setActiveFeedId", e);
}
} }
function updateFeedList() { function updateFeedList() {
try {
// $("feeds-holder").innerHTML = "<div id=\"feedlistLoading\">" + Element.show("feedlistLoading");
// __("Loading, please wait...") + "</div>";
Element.show("feedlistLoading"); resetCounterCache();
resetCounterCache();
if (dijit.byId("feedTree")) { if (dijit.byId("feedTree")) {
dijit.byId("feedTree").destroyRecursive(); dijit.byId("feedTree").destroyRecursive();
} }
var store = new dojo.data.ItemFileWriteStore({ var store = new dojo.data.ItemFileWriteStore({
url: "backend.php?op=pref_feeds&method=getfeedtree&mode=2"}); url: "backend.php?op=pref_feeds&method=getfeedtree&mode=2"});
var treeModel = new fox.FeedStoreModel({ var treeModel = new fox.FeedStoreModel({
store: store, store: store,
query: { query: {
"type": getInitParam('enable_feed_cats') == 1 ? "category" : "feed" "type": getInitParam('enable_feed_cats') == 1 ? "category" : "feed"
},
rootId: "root",
rootLabel: "Feeds",
childrenAttrs: ["items"]
});
var tree = new fox.FeedTree({
model: treeModel,
onClick: function (item, node) {
var id = String(item.id);
var is_cat = id.match("^CAT:");
var feed = id.substr(id.indexOf(":")+1);
viewfeed({feed: feed, is_cat: is_cat});
return false;
}, },
openOnClick: false, rootId: "root",
showRoot: false, rootLabel: "Feeds",
persist: true, childrenAttrs: ["items"]
id: "feedTree", });
}, "feedTree");
var tree = new fox.FeedTree({
model: treeModel,
onClick: function (item, node) {
var id = String(item.id);
var is_cat = id.match("^CAT:");
var feed = id.substr(id.indexOf(":")+1);
viewfeed({feed: feed, is_cat: is_cat});
return false;
},
openOnClick: false,
showRoot: false,
persist: true,
id: "feedTree",
}, "feedTree");
/* var menu = new dijit.Menu({id: 'feedMenu'}); /* var menu = new dijit.Menu({id: 'feedMenu'});
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: "Simple menu item" label: "Simple menu item"
})); }));
// menu.bindDomNode(tree.domNode); */ // menu.bindDomNode(tree.domNode); */
var tmph = dojo.connect(dijit.byId('feedMenu'), '_openMyself', function (event) { var tmph = dojo.connect(dijit.byId('feedMenu'), '_openMyself', function (event) {
console.log(dijit.getEnclosingWidget(event.target)); console.log(dijit.getEnclosingWidget(event.target));
dojo.disconnect(tmph); dojo.disconnect(tmph);
}); });
$("feeds-holder").appendChild(tree.domNode); $("feeds-holder").appendChild(tree.domNode);
var tmph = dojo.connect(tree, 'onLoad', function() { var tmph = dojo.connect(tree, 'onLoad', function() {
dojo.disconnect(tmph); dojo.disconnect(tmph);
Element.hide("feedlistLoading"); Element.hide("feedlistLoading");
try {
feedlist_init(); feedlist_init();
// var node = dijit.byId("feedTree")._itemNodesMap['FEED:-2'][0].domNode
// menu.bindDomNode(node);
loading_set_progress(25); loading_set_progress(25);
}); } catch (e) {
exception_error(e);
tree.startup(); }
});
} catch (e) { tree.startup();
exception_error("updateFeedList", e);
}
} }
function catchupAllFeeds() { function catchupAllFeeds() {
@ -218,46 +202,49 @@ function genericSanityCheck() {
function init() { function init() {
try {
//dojo.registerModulePath("fox", "../../js/");
require(["dojo/_base/kernel",
"dojo/ready",
"dojo/parser",
"dojo/_base/loader",
"dojo/_base/html",
"dojo/query",
"dijit/ProgressBar",
"dijit/ColorPalette",
"dijit/Dialog",
"dijit/form/Button",
"dijit/form/ComboButton",
"dijit/form/CheckBox",
"dijit/form/DropDownButton",
"dijit/form/FilteringSelect",
"dijit/form/Form",
"dijit/form/RadioButton",
"dijit/form/Select",
"dijit/form/SimpleTextarea",
"dijit/form/TextBox",
"dijit/form/ComboBox",
"dijit/form/ValidationTextBox",
"dijit/InlineEditBox",
"dijit/layout/AccordionContainer",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dijit/layout/TabContainer",
"dijit/PopupMenuItem",
"dijit/Menu",
"dijit/Toolbar",
"dijit/Tree",
"dijit/tree/dndSource",
"dijit/tree/ForestStoreModel",
"dojo/data/ItemFileWriteStore",
"fox/FeedTree" ], function (dojo, ready, parser) {
ready(function() {
window.onerror = function(message, filename, lineno, colno, error) {
report_error(message, filename, lineno, colno, error);
};
require(["dojo/_base/kernel",
"dojo/ready",
"dojo/parser",
"dojo/_base/loader",
"dojo/_base/html",
"dojo/query",
"dijit/ProgressBar",
"dijit/ColorPalette",
"dijit/Dialog",
"dijit/form/Button",
"dijit/form/ComboButton",
"dijit/form/CheckBox",
"dijit/form/DropDownButton",
"dijit/form/FilteringSelect",
"dijit/form/Form",
"dijit/form/RadioButton",
"dijit/form/Select",
"dijit/form/SimpleTextarea",
"dijit/form/TextBox",
"dijit/form/ComboBox",
"dijit/form/ValidationTextBox",
"dijit/InlineEditBox",
"dijit/layout/AccordionContainer",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dijit/layout/TabContainer",
"dijit/PopupMenuItem",
"dijit/Menu",
"dijit/Toolbar",
"dijit/Tree",
"dijit/tree/dndSource",
"dijit/tree/ForestStoreModel",
"dojo/data/ItemFileWriteStore",
"fox/FeedTree" ], function (dojo, ready, parser) {
ready(function() {
try {
parser.parse(); parser.parse();
if (!genericSanityCheck()) if (!genericSanityCheck())
@ -274,24 +261,25 @@ function init() {
init_hotkey_actions(); init_hotkey_actions();
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: {op: "rpc", method: "sanityCheck", hasAudio: hasAudio, parameters: {
op: "rpc", method: "sanityCheck", hasAudio: hasAudio,
hasMp3: hasMp3, hasMp3: hasMp3,
clientTzOffset: clientTzOffset, clientTzOffset: clientTzOffset,
hasSandbox: hasSandbox}, hasSandbox: hasSandbox
onComplete: function(transport) { },
onComplete: function (transport) {
backend_sanity_check_callback(transport); backend_sanity_check_callback(transport);
} }); }
});
} catch (e) {
}); exception_error(e);
}
});
});
} catch (e) { });
exception_error("init", e);
}
} }
function init_hotkey_actions() { function init_hotkey_actions() {
@ -587,192 +575,177 @@ function init_hotkey_actions() {
} }
function init_second_stage() { function init_second_stage() {
updateFeedList();
closeArticlePanel();
try { if (parseInt(getCookie("ttrss_fh_width")) > 0) {
updateFeedList(); dijit.byId("feeds-holder").domNode.setStyle(
closeArticlePanel(); {width: getCookie("ttrss_fh_width") + "px" });
}
if (parseInt(getCookie("ttrss_fh_width")) > 0) {
dijit.byId("feeds-holder").domNode.setStyle(
{width: getCookie("ttrss_fh_width") + "px" });
}
dijit.byId("main").resize();
var tmph = dojo.connect(dijit.byId('feeds-holder'), 'resize', dijit.byId("main").resize();
function (args) {
if (args && args.w >= 0) {
setCookie("ttrss_fh_width", args.w, getInitParam("cookie_lifetime"));
}
});
var tmph = dojo.connect(dijit.byId('content-insert'), 'resize', var tmph = dojo.connect(dijit.byId('feeds-holder'), 'resize',
function (args) { function (args) {
if (args && args.w >= 0 && args.h >= 0) { if (args && args.w >= 0) {
setCookie("ttrss_ci_width", args.w, getInitParam("cookie_lifetime")); setCookie("ttrss_fh_width", args.w, getInitParam("cookie_lifetime"));
setCookie("ttrss_ci_height", args.h, getInitParam("cookie_lifetime")); }
} });
});
delCookie("ttrss_test"); var tmph = dojo.connect(dijit.byId('content-insert'), 'resize',
function (args) {
if (args && args.w >= 0 && args.h >= 0) {
setCookie("ttrss_ci_width", args.w, getInitParam("cookie_lifetime"));
setCookie("ttrss_ci_height", args.h, getInitParam("cookie_lifetime"));
}
});
var toolbar = document.forms["main_toolbar_form"]; delCookie("ttrss_test");
dijit.getEnclosingWidget(toolbar.view_mode).attr('value', var toolbar = document.forms["main_toolbar_form"];
getInitParam("default_view_mode"));
dijit.getEnclosingWidget(toolbar.order_by).attr('value', dijit.getEnclosingWidget(toolbar.view_mode).attr('value',
getInitParam("default_view_order_by")); getInitParam("default_view_mode"));
feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1; dijit.getEnclosingWidget(toolbar.order_by).attr('value',
getInitParam("default_view_order_by"));
var hash_feed_id = hash_get('f'); feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1;
var hash_feed_is_cat = hash_get('c') == "1";
if (hash_feed_id != undefined) { var hash_feed_id = hash_get('f');
setActiveFeedId(hash_feed_id, hash_feed_is_cat); var hash_feed_is_cat = hash_get('c') == "1";
}
loading_set_progress(50); if (hash_feed_id != undefined) {
setActiveFeedId(hash_feed_id, hash_feed_is_cat);
}
// can't use cache_clear() here because viewfeed might not have initialized yet loading_set_progress(50);
if ('sessionStorage' in window && window['sessionStorage'] !== null)
sessionStorage.clear();
var hotkeys = getInitParam("hotkeys"); // can't use cache_clear() here because viewfeed might not have initialized yet
var tmp = []; if ('sessionStorage' in window && window['sessionStorage'] !== null)
sessionStorage.clear();
for (sequence in hotkeys[1]) { var hotkeys = getInitParam("hotkeys");
filtered = sequence.replace(/\|.*$/, ""); var tmp = [];
tmp[filtered] = hotkeys[1][sequence];
}
hotkeys[1] = tmp; for (sequence in hotkeys[1]) {
setInitParam("hotkeys", hotkeys); filtered = sequence.replace(/\|.*$/, "");
tmp[filtered] = hotkeys[1][sequence];
}
_widescreen_mode = getInitParam("widescreen"); hotkeys[1] = tmp;
switchPanelMode(_widescreen_mode); setInitParam("hotkeys", hotkeys);
console.log("second stage ok"); _widescreen_mode = getInitParam("widescreen");
switchPanelMode(_widescreen_mode);
if (getInitParam("simple_update")) { console.log("second stage ok");
console.log("scheduling simple feed updater...");
window.setTimeout(update_random_feed, 30*1000);
}
} catch (e) { if (getInitParam("simple_update")) {
exception_error("init_second_stage", e); console.log("scheduling simple feed updater...");
window.setTimeout(update_random_feed, 30*1000);
} }
} }
function quickMenuGo(opid) { function quickMenuGo(opid) {
try { switch (opid) {
switch (opid) { case "qmcPrefs":
case "qmcPrefs": gotoPreferences();
gotoPreferences(); break;
break; case "qmcLogout":
case "qmcLogout": gotoLogout();
gotoLogout(); break;
break; case "qmcTagCloud":
case "qmcTagCloud": displayDlg(__("Tag cloud"), "printTagCloud");
displayDlg(__("Tag cloud"), "printTagCloud"); break;
break; case "qmcSearch":
case "qmcSearch": search();
search(); break;
break; case "qmcAddFeed":
case "qmcAddFeed": quickAddFeed();
quickAddFeed(); break;
break; case "qmcDigest":
case "qmcDigest": window.location.href = "backend.php?op=digest";
window.location.href = "backend.php?op=digest"; break;
break; case "qmcEditFeed":
case "qmcEditFeed": if (activeFeedIsCat())
if (activeFeedIsCat()) alert(__("You can't edit this kind of feed."));
alert(__("You can't edit this kind of feed.")); else
else editFeed(getActiveFeedId());
editFeed(getActiveFeedId()); break;
break; case "qmcRemoveFeed":
case "qmcRemoveFeed": var actid = getActiveFeedId();
var actid = getActiveFeedId();
if (activeFeedIsCat()) { if (activeFeedIsCat()) {
alert(__("You can't unsubscribe from the category.")); alert(__("You can't unsubscribe from the category."));
return; return;
} }
if (!actid) { if (!actid) {
alert(__("Please select some feed first.")); alert(__("Please select some feed first."));
return; return;
} }
var fn = getFeedName(actid); var fn = getFeedName(actid);
var pr = __("Unsubscribe from %s?").replace("%s", fn); var pr = __("Unsubscribe from %s?").replace("%s", fn);
if (confirm(pr)) { if (confirm(pr)) {
unsubscribeFeed(actid); unsubscribeFeed(actid);
} }
break; break;
case "qmcCatchupAll": case "qmcCatchupAll":
catchupAllFeeds(); catchupAllFeeds();
break; break;
case "qmcShowOnlyUnread": case "qmcShowOnlyUnread":
toggleDispRead(); toggleDispRead();
break; break;
case "qmcAddFilter": case "qmcAddFilter":
quickAddFilter(); quickAddFilter();
break; break;
case "qmcAddLabel": case "qmcAddLabel":
addLabel(); addLabel();
break; break;
case "qmcRescoreFeed": case "qmcRescoreFeed":
rescoreCurrentFeed(); rescoreCurrentFeed();
break; break;
case "qmcToggleWidescreen": case "qmcToggleWidescreen":
if (!isCdmMode()) { if (!isCdmMode()) {
_widescreen_mode = !_widescreen_mode; _widescreen_mode = !_widescreen_mode;
// reset stored sizes because geometry changed // reset stored sizes because geometry changed
setCookie("ttrss_ci_width", 0); setCookie("ttrss_ci_width", 0);
setCookie("ttrss_ci_height", 0); setCookie("ttrss_ci_height", 0);
switchPanelMode(_widescreen_mode); switchPanelMode(_widescreen_mode);
} else { } else {
alert(__("Widescreen is not available in combined mode.")); alert(__("Widescreen is not available in combined mode."));
}
break;
case "qmcHKhelp":
helpDialog("main");
break;
default:
console.log("quickMenuGo: unknown action: " + opid);
} }
break;
} catch (e) { case "qmcHKhelp":
exception_error("quickMenuGo", e); helpDialog("main");
break;
default:
console.log("quickMenuGo: unknown action: " + opid);
} }
} }
function toggleDispRead() { function toggleDispRead() {
try {
var hide = !(getInitParam("hide_read_feeds") == "1"); var hide = !(getInitParam("hide_read_feeds") == "1");
hideOrShowFeeds(hide); hideOrShowFeeds(hide);
var query = "?op=rpc&method=setpref&key=HIDE_READ_FEEDS&value=" + var query = "?op=rpc&method=setpref&key=HIDE_READ_FEEDS&value=" +
param_escape(hide); param_escape(hide);
setInitParam("hide_read_feeds", hide); setInitParam("hide_read_feeds", hide);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
} }); } });
} catch (e) {
exception_error("toggleDispRead", e);
}
} }
function parse_runtime_info(data) { function parse_runtime_info(data) {
@ -825,18 +798,13 @@ function parse_runtime_info(data) {
} }
function collapse_feedlist() { function collapse_feedlist() {
try { Element.toggle("feeds-holder");
Element.toggle("feeds-holder");
var splitter = $("feeds-holder_splitter"); var splitter = $("feeds-holder_splitter");
Element.visible("feeds-holder") ? splitter.show() : splitter.hide(); Element.visible("feeds-holder") ? splitter.show() : splitter.hide();
dijit.byId("main").resize(); dijit.byId("main").resize();
} catch (e) {
exception_error("collapse_feedlist", e);
}
} }
function viewModeChanged() { function viewModeChanged() {
@ -875,88 +843,83 @@ function rescoreCurrentFeed() {
} }
function hotkey_handler(e) { function hotkey_handler(e) {
try {
if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return; if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
var keycode = false; var keycode = false;
var shift_key = false; var shift_key = false;
var ctrl_key = false; var ctrl_key = false;
var alt_key = false; var alt_key = false;
var meta_key = false; var meta_key = false;
var cmdline = $('cmdline'); var cmdline = $('cmdline');
shift_key = e.shiftKey; shift_key = e.shiftKey;
ctrl_key = e.ctrlKey; ctrl_key = e.ctrlKey;
alt_key = e.altKey; alt_key = e.altKey;
meta_key = e.metaKey; meta_key = e.metaKey;
if (window.event) { if (window.event) {
keycode = window.event.keyCode; keycode = window.event.keyCode;
} else if (e) { } else if (e) {
keycode = e.which; keycode = e.which;
} }
var keychar = String.fromCharCode(keycode); var keychar = String.fromCharCode(keycode);
if (keycode == 27) { // escape if (keycode == 27) { // escape
hotkey_prefix = false; hotkey_prefix = false;
} }
if (keycode == 16) return; // ignore lone shift if (keycode == 16) return; // ignore lone shift
if (keycode == 17) return; // ignore lone ctrl if (keycode == 17) return; // ignore lone ctrl
keychar = keychar.toLowerCase(); keychar = keychar.toLowerCase();
var hotkeys = getInitParam("hotkeys"); var hotkeys = getInitParam("hotkeys");
if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) { if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) {
var date = new Date(); var date = new Date();
var ts = Math.round(date.getTime() / 1000); var ts = Math.round(date.getTime() / 1000);
hotkey_prefix = keychar; hotkey_prefix = keychar;
hotkey_prefix_pressed = ts; hotkey_prefix_pressed = ts;
cmdline.innerHTML = keychar; cmdline.innerHTML = keychar;
Element.show(cmdline); Element.show(cmdline);
return true; return true;
} }
Element.hide(cmdline); Element.hide(cmdline);
var hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")"; var hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")";
// ensure ^*char notation // ensure ^*char notation
if (shift_key) hotkey = "*" + hotkey; if (shift_key) hotkey = "*" + hotkey;
if (ctrl_key) hotkey = "^" + hotkey; if (ctrl_key) hotkey = "^" + hotkey;
if (alt_key) hotkey = "+" + hotkey; if (alt_key) hotkey = "+" + hotkey;
if (meta_key) hotkey = "%" + hotkey; if (meta_key) hotkey = "%" + hotkey;
hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey; hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey;
hotkey_prefix = false; hotkey_prefix = false;
var hotkey_action = false; var hotkey_action = false;
var hotkeys = getInitParam("hotkeys"); var hotkeys = getInitParam("hotkeys");
for (sequence in hotkeys[1]) { for (sequence in hotkeys[1]) {
if (sequence == hotkey) { if (sequence == hotkey) {
hotkey_action = hotkeys[1][sequence]; hotkey_action = hotkeys[1][sequence];
break; break;
}
} }
}
var action = hotkey_actions[hotkey_action]; var action = hotkey_actions[hotkey_action];
if (action != null) {
action();
return false;
}
} catch (e) { if (action != null) {
exception_error("hotkey_handler", e); action();
return false;
} }
} }
@ -965,33 +928,21 @@ function inPreferences() {
} }
function reverseHeadlineOrder() { function reverseHeadlineOrder() {
try {
/* var query_str = "?op=rpc&method=togglepref&key=REVERSE_HEADLINES";
new Ajax.Request("backend.php", {
parameters: query_str,
onComplete: function(transport) {
viewCurrentFeed();
} }); */
var toolbar = document.forms["main_toolbar_form"]; var toolbar = document.forms["main_toolbar_form"];
var order_by = dijit.getEnclosingWidget(toolbar.order_by); var order_by = dijit.getEnclosingWidget(toolbar.order_by);
var value = order_by.attr('value'); var value = order_by.attr('value');
if (value == "date_reverse") if (value == "date_reverse")
value = "default"; value = "default";
else else
value = "date_reverse"; value = "date_reverse";
order_by.attr('value', value); order_by.attr('value', value);
viewCurrentFeed(); viewCurrentFeed();
} catch (e) {
exception_error("reverseHeadlineOrder", e);
}
} }
function handle_rpc_json(transport, scheduled_call) { function handle_rpc_json(transport, scheduled_call) {
@ -1065,99 +1016,79 @@ function handle_rpc_json(transport, scheduled_call) {
else else
notify_error("Communication problem with server."); notify_error("Communication problem with server.");
console.log(e); console.error(e);
//exception_error("handle_rpc_json", e, transport);
} }
return true; return true;
} }
function switchPanelMode(wide) { function switchPanelMode(wide) {
try { if (isCdmMode()) return;
if (isCdmMode()) return;
article_id = getActiveArticleId();
if (wide) { article_id = getActiveArticleId();
dijit.byId("headlines-wrap-inner").attr("design", 'sidebar');
dijit.byId("content-insert").attr("region", "trailing");
dijit.byId("content-insert").domNode.setStyle({width: '50%', if (wide) {
height: 'auto', dijit.byId("headlines-wrap-inner").attr("design", 'sidebar');
borderTopWidth: '0px' }); dijit.byId("content-insert").attr("region", "trailing");
if (parseInt(getCookie("ttrss_ci_width")) > 0) {
dijit.byId("content-insert").domNode.setStyle(
{width: getCookie("ttrss_ci_width") + "px" });
}
$("headlines-frame").setStyle({ borderBottomWidth: '0px' }); dijit.byId("content-insert").domNode.setStyle({width: '50%',
$("headlines-frame").addClassName("wide"); height: 'auto',
borderTopWidth: '0px' });
} else { if (parseInt(getCookie("ttrss_ci_width")) > 0) {
dijit.byId("content-insert").domNode.setStyle(
{width: getCookie("ttrss_ci_width") + "px" });
}
dijit.byId("content-insert").attr("region", "bottom"); $("headlines-frame").setStyle({ borderBottomWidth: '0px' });
$("headlines-frame").addClassName("wide");
dijit.byId("content-insert").domNode.setStyle({width: 'auto', } else {
height: '50%',
borderTopWidth: '0px'});
if (parseInt(getCookie("ttrss_ci_height")) > 0) { dijit.byId("content-insert").attr("region", "bottom");
dijit.byId("content-insert").domNode.setStyle(
{height: getCookie("ttrss_ci_height") + "px" });
}
$("headlines-frame").setStyle({ borderBottomWidth: '1px' }); dijit.byId("content-insert").domNode.setStyle({width: 'auto',
$("headlines-frame").removeClassName("wide"); height: '50%',
borderTopWidth: '0px'});
if (parseInt(getCookie("ttrss_ci_height")) > 0) {
dijit.byId("content-insert").domNode.setStyle(
{height: getCookie("ttrss_ci_height") + "px" });
} }
closeArticlePanel(); $("headlines-frame").setStyle({ borderBottomWidth: '1px' });
$("headlines-frame").removeClassName("wide");
if (article_id) view(article_id); }
new Ajax.Request("backend.php", { closeArticlePanel();
parameters: "op=rpc&method=setpanelmode&wide=" + (wide ? 1 : 0),
onComplete: function(transport) {
console.log(transport.responseText);
} });
if (article_id) view(article_id);
} catch (e) { new Ajax.Request("backend.php", {
exception_error("switchPanelMode", e); parameters: "op=rpc&method=setpanelmode&wide=" + (wide ? 1 : 0),
} onComplete: function(transport) {
console.log(transport.responseText);
} });
} }
function update_random_feed() { function update_random_feed() {
try { console.log("in update_random_feed");
console.log("in update_random_feed");
new Ajax.Request("backend.php", {
parameters: "op=rpc&method=updateRandomFeed",
onComplete: function(transport) {
handle_rpc_json(transport, true);
window.setTimeout(update_random_feed, 30*1000);
} });
} catch (e) { new Ajax.Request("backend.php", {
exception_error("update_random_feed", e); parameters: "op=rpc&method=updateRandomFeed",
} onComplete: function(transport) {
handle_rpc_json(transport, true);
window.setTimeout(update_random_feed, 30*1000);
} });
} }
function hash_get(key) { function hash_get(key) {
try { kv = window.location.hash.substring(1).toQueryParams();
kv = window.location.hash.substring(1).toQueryParams(); return kv[key];
return kv[key];
} catch (e) {
exception_error("hash_get", e);
}
} }
function hash_set(key, value) { function hash_set(key, value) {
try { kv = window.location.hash.substring(1).toQueryParams();
kv = window.location.hash.substring(1).toQueryParams(); kv[key] = value;
kv[key] = value; window.location.hash = $H(kv).toQueryString();
window.location.hash = $H(kv).toQueryString();
} catch (e) {
exception_error("hash_set", e);
}
} }

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save