code cleanups

master
Andrew Dolgov 18 years ago
parent eb58af8d65
commit 0feab655ba

@ -1,7 +1,7 @@
//var xmlhttp = Ajax.getTransport(); //var xmlhttp = Ajax.getTransport();
function viewCategory(cat) { function viewCategory(cat) {
getMainContext().active_feed_is_cat = true; active_feed_is_cat = true;
viewfeed(cat, '', true); viewfeed(cat, '', true);
} }
@ -52,7 +52,7 @@ function viewfeed(feed, subop, is_cat, subop_param) {
setActiveFeedId(feed); setActiveFeedId(feed);
if (is_cat != undefined) { if (is_cat != undefined) {
getMainContext().active_feed_is_cat = is_cat; active_feed_is_cat = is_cat;
} }
if (subop == "MarkAllRead") { if (subop == "MarkAllRead") {

@ -169,30 +169,25 @@ function hotkey_handler(e) {
keycode = e.which; keycode = e.which;
} }
var m_ctx = getMainContext();
var f_ctx = getFeedsContext();
var h_ctx = getHeadlinesContext();
if (keycode == 82) { // r if (keycode == 82) { // r
return m_ctx.scheduleFeedUpdate(true); return scheduleFeedUpdate(true);
} }
if (keycode == 83) { // r if (keycode == 83) { // r
return m_ctx.displayDlg("search", getActiveFeedId()); return displayDlg("search", getActiveFeedId());
} }
if (keycode == 85) { // u if (keycode == 85) { // u
if (getActiveFeedId()) { if (getActiveFeedId()) {
return f_ctx.viewfeed(getActiveFeedId(), "ForceUpdate"); return viewfeed(getActiveFeedId(), "ForceUpdate");
} }
} }
if (keycode == 65) { // a if (keycode == 65) { // a
return m_ctx.toggleDispRead(); return toggleDispRead();
} }
var f_doc = document; var feedlist = document.getElementById('feedList');
var feedlist = f_doc.getElementById('feedList');
if (keycode == 74) { // j if (keycode == 74) { // j
var feed = getActiveFeedId(); var feed = getActiveFeedId();
@ -207,14 +202,14 @@ function hotkey_handler(e) {
} }
if (keycode == 78 || keycode == 40) { // n, down if (keycode == 78 || keycode == 40) { // n, down
if (typeof h_ctx.moveToPost != 'undefined') { if (typeof moveToPost != 'undefined') {
return h_ctx.moveToPost('next'); return moveToPost('next');
} }
} }
if (keycode == 80 || keycode == 38) { // p, up if (keycode == 80 || keycode == 38) { // p, up
if (typeof h_ctx.moveToPost != 'undefined') { if (typeof moveToPost != 'undefined') {
return h_ctx.moveToPost('prev'); return moveToPost('prev');
} }
} }
@ -445,22 +440,22 @@ function gotoExportOpml() {
function getActiveFeedId() { function getActiveFeedId() {
// return getCookie("ttrss_vf_actfeed"); // return getCookie("ttrss_vf_actfeed");
try { try {
debug("gAFID: " + getMainContext().active_feed_id); debug("gAFID: " + active_feed_id);
return getMainContext().active_feed_id; return active_feed_id;
} catch (e) { } catch (e) {
exception_error("getActiveFeedId", e); exception_error("getActiveFeedId", e);
} }
} }
function activeFeedIsCat() { function activeFeedIsCat() {
return getMainContext().active_feed_is_cat; return active_feed_is_cat;
} }
function setActiveFeedId(id) { function setActiveFeedId(id) {
// return setCookie("ttrss_vf_actfeed", id); // return setCookie("ttrss_vf_actfeed", id);
try { try {
debug("sAFID(" + id + ")"); debug("sAFID(" + id + ")");
getMainContext().active_feed_id = id; active_feed_id = id;
} catch (e) { } catch (e) {
exception_error("setActiveFeedId", e); exception_error("setActiveFeedId", e);
} }
@ -468,8 +463,6 @@ function setActiveFeedId(id) {
function parse_counters(reply, scheduled_call) { function parse_counters(reply, scheduled_call) {
try { try {
var f_document = document;
var title_obj = this.window;
var feeds_found = 0; var feeds_found = 0;
@ -478,8 +471,6 @@ function parse_counters(reply, scheduled_call) {
reply = reply.firstChild; reply = reply.firstChild;
} }
debug("F_DOC: " + f_document + ", T_OBJ: " + title_obj);
for (var l = 0; l < reply.childNodes.length; l++) { for (var l = 0; l < reply.childNodes.length; l++) {
if (!reply.childNodes[l] || if (!reply.childNodes[l] ||
typeof(reply.childNodes[l].getAttribute) == "undefined") { typeof(reply.childNodes[l].getAttribute) == "undefined") {
@ -495,8 +486,8 @@ function parse_counters(reply, scheduled_call) {
var updated = reply.childNodes[l].getAttribute("updated"); var updated = reply.childNodes[l].getAttribute("updated");
if (id == "global-unread") { if (id == "global-unread") {
title_obj.global_unread = ctr; global_unread = ctr;
title_obj.updateTitle(); updateTitle();
continue; continue;
} }
@ -506,19 +497,19 @@ function parse_counters(reply, scheduled_call) {
} }
if (t == "category") { if (t == "category") {
var catctr = f_document.getElementById("FCATCTR-" + id); var catctr = document.getElementById("FCATCTR-" + id);
if (catctr) { if (catctr) {
catctr.innerHTML = "(" + ctr + " unread)"; catctr.innerHTML = "(" + ctr + " unread)";
} }
continue; continue;
} }
var feedctr = f_document.getElementById("FEEDCTR-" + id); var feedctr = document.getElementById("FEEDCTR-" + id);
var feedu = f_document.getElementById("FEEDU-" + id); var feedu = document.getElementById("FEEDU-" + id);
var feedr = f_document.getElementById("FEEDR-" + id); var feedr = document.getElementById("FEEDR-" + id);
var feed_img = f_document.getElementById("FIMG-" + id); var feed_img = document.getElementById("FIMG-" + id);
var feedlink = f_document.getElementById("FEEDL-" + id); var feedlink = document.getElementById("FEEDL-" + id);
var feedupd = f_document.getElementById("FLUPD-" + id); var feedupd = document.getElementById("FLUPD-" + id);
if (updated && feedlink) { if (updated && feedlink) {
if (error) { if (error) {
@ -572,15 +563,14 @@ function parse_counters(reply, scheduled_call) {
} }
} }
hideOrShowFeeds(getFeedsContext().document, hideOrShowFeeds(document, getInitParam("hide_read_feeds") == 1);
getInitParam("hide_read_feeds") == 1);
var feeds_stored = getMainContext().number_of_feeds; var feeds_stored = number_of_feeds;
debug("Feed counters, C: " + feeds_found + ", S:" + feeds_stored); debug("Feed counters, C: " + feeds_found + ", S:" + feeds_stored);
if (feeds_stored != feeds_found) { if (feeds_stored != feeds_found) {
getMainContext().number_of_feeds = feeds_found; number_of_feeds = feeds_found;
if (feeds_stored != 0) { if (feeds_stored != 0) {
debug("Subscribed feed number changed, refreshing feedlist"); debug("Subscribed feed number changed, refreshing feedlist");
@ -612,7 +602,7 @@ function all_counters_callback() {
var runtime = counters.nextSibling; var runtime = counters.nextSibling;
if (runtime) { if (runtime) {
getMainContext().parse_runtime_info(runtime); parse_runtime_info(runtime);
} }
if (getInitParam("feeds_sort_by_unread") == 1) { if (getInitParam("feeds_sort_by_unread") == 1) {
@ -675,7 +665,7 @@ function resort_category(doc, node) {
function resort_feedlist() { function resort_feedlist() {
debug("resort_feedlist"); debug("resort_feedlist");
var fd = getFeedsContext().document; var fd = document;
if (fd.getElementById("feedCatHolder")) { if (fd.getElementById("feedCatHolder")) {
@ -754,7 +744,7 @@ function hideOrShowFeeds(doc, hide) {
debug("hideOrShowFeeds: " + doc + ", " + hide); debug("hideOrShowFeeds: " + doc + ", " + hide);
var fd = getFeedsContext().document; var fd = document;
var list = fd.getElementById("feedList"); var list = fd.getElementById("feedList");
@ -1259,7 +1249,7 @@ function qafAdd() {
closeInfoBox(); closeInfoBox();
var feeds_doc = getFeedsContext().document; var feeds_doc = document;
// feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait..."; // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
@ -1299,7 +1289,6 @@ function getContentContext() {
return this.window; return this.window;
} }
function getHeadlinesContext() { function getHeadlinesContext() {
return this.window; return this.window;
} }
@ -1307,15 +1296,14 @@ function getHeadlinesContext() {
var debug_last_class = "even"; var debug_last_class = "even";
function debug(msg) { function debug(msg) {
var ctx = getMainContext();
if (ctx.debug_last_class == "even") { if (debug_last_class == "even") {
ctx.debug_last_class = "odd"; debug_last_class = "odd";
} else { } else {
ctx.debug_last_class = "even"; debug_last_class = "even";
} }
var c = ctx.document.getElementById('debug_output'); var c = document.getElementById('debug_output');
if (c && c.style.display == "block") { if (c && c.style.display == "block") {
while (c.lastChild != 'undefined' && c.childNodes.length > 100) { while (c.lastChild != 'undefined' && c.childNodes.length > 100) {
c.removeChild(c.lastChild); c.removeChild(c.lastChild);
@ -1324,7 +1312,7 @@ function debug(msg) {
var d = new Date(); var d = new Date();
var ts = leading_zero(d.getHours()) + ":" + leading_zero(d.getMinutes()) + var ts = leading_zero(d.getHours()) + ":" + leading_zero(d.getMinutes()) +
":" + leading_zero(d.getSeconds()); ":" + leading_zero(d.getSeconds());
c.innerHTML = "<li class=\"" + ctx.debug_last_class + "\"><span class=\"debugTS\">[" + ts + "]</span> " + c.innerHTML = "<li class=\"" + debug_last_class + "\"><span class=\"debugTS\">[" + ts + "]</span> " +
msg + "</li>" + c.innerHTML; msg + "</li>" + c.innerHTML;
} }
} }

@ -45,9 +45,6 @@ function view(id, feed_id) {
try { try {
debug("loading article: " + id + "/" + feed_id); debug("loading article: " + id + "/" + feed_id);
var f_document = getFeedsContext().document;
var m_document = document;
enableHotkeys(); enableHotkeys();
var crow = document.getElementById("RROW-" + id); var crow = document.getElementById("RROW-" + id);
@ -65,7 +62,7 @@ function view(id, feed_id) {
active_post_id = id; active_post_id = id;
setActiveFeedId(feed_id); setActiveFeedId(feed_id);
var content = m_document.getElementById("content-frame"); var content = document.getElementById("content-frame");
selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false); selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', false);
markHeadline(active_post_id); markHeadline(active_post_id);
@ -88,8 +85,6 @@ function view(id, feed_id) {
function toggleMark(id) { function toggleMark(id) {
var f_document = document;
if (!xmlhttp_ready(xmlhttp_rpc)) { if (!xmlhttp_ready(xmlhttp_rpc)) {
printLockingError(); printLockingError();
return; return;
@ -98,7 +93,7 @@ function toggleMark(id) {
var query = "backend.php?op=rpc&id=" + id + "&subop=mark"; var query = "backend.php?op=rpc&id=" + id + "&subop=mark";
var mark_img = document.getElementById("FMARKPIC-" + id); var mark_img = document.getElementById("FMARKPIC-" + id);
var vfeedu = f_document.getElementById("FEEDU--1"); var vfeedu = document.getElementById("FEEDU--1");
var crow = document.getElementById("RROW-" + id); var crow = document.getElementById("RROW-" + id);
if (mark_img.alt != "Reset mark") { if (mark_img.alt != "Reset mark") {
@ -121,8 +116,8 @@ function toggleMark(id) {
} }
var vfeedctr = f_document.getElementById("FEEDCTR--1"); var vfeedctr = document.getElementById("FEEDCTR--1");
var vfeedr = f_document.getElementById("FEEDR--1"); var vfeedr = document.getElementById("FEEDR--1");
if (vfeedu && vfeedctr) { if (vfeedu && vfeedctr) {
if ((+vfeedu.innerHTML) > 0) { if ((+vfeedu.innerHTML) > 0) {
@ -401,35 +396,10 @@ function labelFromSearch(search, search_mode, match_on, feed_id, is_cat) {
debug("LFS: " + query); debug("LFS: " + query);
xmlhttp_rpc.open("GET", query, true); xmlhttp_rpc.open("GET", query, true);
xmlhttp_rpc.onreadystatechange=getMainContext().dlg_frefresh_callback; xmlhttp_rpc.onreadystatechange=dlg_frefresh_callback;
xmlhttp_rpc.send(null); xmlhttp_rpc.send(null);
} }
} }
/*
function headlines_init() {
if (arguments.callee.done) return;
arguments.callee.done = true;
if (parent.frames["feeds-frame"]) {
document.onkeydown = hotkey_handler;
}
var hl = document.getElementById("headlinesList");
if (!hl) {
hl = document.getElementById("headlinesContainer");
}
var hw = hl.scrollHeight;
var pw = parent.document.getElementById("headlines").scrollHeight;
if (hw >= pw) {
var bt = document.getElementById("headlineActionsBottom");
bt.className = "headlinesSubToolbar";
}
}
*/

Loading…
Cancel
Save