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
This commit is contained in:
Andrew Dolgov 2017-03-04 14:34:44 +03:00
parent e6d66fe55c
commit 1bfe1d7b31
10 changed files with 3791 additions and 4593 deletions

View File

@ -686,16 +686,6 @@ class Pref_Prefs extends Handler_Protected {
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,
"hook_prefs_tab_section", "prefPrefsPrefsOutside");

View File

@ -1917,7 +1917,7 @@
$attributes, $include_all_cats = true, $root_id = false, $nest_level = 0) {
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)

View File

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

View File

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

View File

@ -8,22 +8,16 @@ function selectTableRow(r, 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);
var check = $(check_id);
if (row) {
selectTableRow(row, do_select);
}
var check = $(check_id);
if (check) {
check.checked = do_select;
}
} catch (e) {
exception_error("selectTableRowById", e);
if (check) {
check.checked = do_select;
}
}

View File

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

View File

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

File diff suppressed because it is too large Load Diff