use multiple classes to mark statuses, JS code cleanup

This commit is contained in:
Andrew Dolgov 2010-11-14 15:55:51 +03:00
parent 7d12b6c8be
commit ca8e3d75f4
9 changed files with 231 additions and 431 deletions

View File

@ -50,8 +50,7 @@ div.cdmFooter {
clear : both; clear : both;
} }
.evenUnreadSelected div.cdmFooter, .oddUnreadSelected div.cdmFooter, .Selected div.cdmFooter {
.evenSelected div.cdmFooter, .oddSelected div.cdmFooter {
background-color : #FFF2BF; background-color : #FFF2BF;
} }

View File

@ -1,8 +1,9 @@
function selectTableRow(r, do_select) { function selectTableRow(r, do_select) {
r.className = r.className.replace("Selected", "");
if (do_select) { if (do_select) {
r.className = r.className + "Selected"; r.addClassName("Selected");
} else {
r.removeClassName("Selected");
} }
} }

View File

@ -243,13 +243,13 @@ function viewfeed(feed, subop, is_cat, offset) {
if (!is_cat) { if (!is_cat) {
var feedr = $("FEEDR-" + feed); var feedr = $("FEEDR-" + feed);
if (feedr && !feedr.className.match("Selected")) { if (feedr && !feedr.hasClassName("Selected")) {
feedr.className = feedr.className + "Selected"; feedr.addClassName("Selected");
} }
} else { } else {
var feedr = $("FCAT-" + feed_id); var feedr = $("FCAT-" + feed_id);
if (feedr && !feedr.className.match("Selected")) { if (feedr && !feedr.hasClassName("Selected")) {
feedr.className = feedr.className + "Selected"; feedr.addClassName("Selected");
} }
} }
@ -384,16 +384,12 @@ function isCatCollapsed(cat) {
function feedlist_dragsorted(ctr) { function feedlist_dragsorted(ctr) {
try { try {
var elem = $("feedList"); var cats = $$("#feedList > li[id*=FCAT-]");
var ordered_cats = [];
var cats = elem.getElementsByTagName("LI"); cats.each(function(cat) {
var ordered_cats = new Array(); ordered_cats.push(cat.id.replace("FCAT-", ""));
});
for (var i = 0; i < cats.length; i++) {
if (cats[i].id && cats[i].id.match("FCAT-")) {
ordered_cats.push(cats[i].id.replace("FCAT-", ""));
}
}
if (ordered_cats.length > 0) { if (ordered_cats.length > 0) {
@ -707,9 +703,9 @@ function parse_counters(reply, scheduled_call) {
if (catctr) { if (catctr) {
catctr.innerHTML = "(" + ctr + ")"; catctr.innerHTML = "(" + ctr + ")";
if (ctr > 0) { if (ctr > 0) {
catctr.className = "catCtrHasUnread"; catctr.addClassName("Unread");
} else { } else {
catctr.className = "catCtrNoUnread"; catctr.removeClassName("Unread");
} }
} }
continue; continue;
@ -778,26 +774,16 @@ function parse_counters(reply, scheduled_call) {
feedu.innerHTML = ctr; feedu.innerHTML = ctr;
if (error) { if (error) {
feedr.className = feedr.className.replace("feed", "error"); feedr.removeClassName("feed");
feedr.addClassName("error");
} else if (id > 0) { } else if (id > 0) {
feedr.className = feedr.className.replace("error", "feed"); feedr.removeClassName("error");
feedr.addClassName("feed");
} }
if (ctr > 0) { if (ctr > 0) {
feedctr.className = "feedCtrHasUnread"; feedctr.addClassName("Unread");
if (!feedr.className.match("Unread")) { feedr.addClassName("Unread");
var is_selected = feedr.className.match("Selected");
feedr.className = feedr.className.replace("Selected", "");
feedr.className = feedr.className.replace("Unread", "");
feedr.className = feedr.className + "Unread";
if (is_selected) {
feedr.className = feedr.className + "Selected";
}
}
if (row_needs_hl && if (row_needs_hl &&
!getInitParam("theme_options").match('no_highlights')) { !getInitParam("theme_options").match('no_highlights')) {
@ -807,8 +793,8 @@ function parse_counters(reply, scheduled_call) {
cache_invalidate("F:" + id); cache_invalidate("F:" + id);
} }
} else { } else {
feedctr.className = "feedCtrNoUnread"; feedctr.removeClassName("Unread");
feedr.className = feedr.className.replace("Unread", ""); feedr.removeClassName("Unread");
} }
} }
} }
@ -883,7 +869,7 @@ function resort_category(node, cat_mode) {
try { try {
console.log("resort_category: " + node + " CM=" + cat_mode); //console.log("resort_category: " + node + " CM=" + cat_mode);
var by_unread = feedsSortByUnread(); var by_unread = feedsSortByUnread();
@ -896,8 +882,8 @@ function resort_category(node, cat_mode) {
var tmp_val = get_feed_entry_unread(list[i]); var tmp_val = get_feed_entry_unread(list[i]);
var cur_val = get_feed_entry_unread(list[j]); var cur_val = get_feed_entry_unread(list[j]);
var tmp_name = get_feed_entry_name(list[i]); var tmp_name = get_feed_entry_name(list[i]).toLowerCase();
var cur_name = get_feed_entry_name(list[j]); var cur_name = get_feed_entry_name(list[j]).toLowerCase();
/* we don't want to match FEEDR-0 - e.g. Archived articles */ /* we don't want to match FEEDR-0 - e.g. Archived articles */
@ -924,13 +910,11 @@ function resort_feedlist() {
if ($("FCATLIST--1")) { if ($("FCATLIST--1")) {
var lists = document.getElementsByTagName("UL"); var lists = $$("#feedList ul[id*=FCATLIST]");
for (var i = 0; i < lists.length; i++) { lists.each(function(list) {
if (lists[i].id && lists[i].id.match("FCATLIST-")) { if (list.id != "FCATLIST--1") resort_category(list, true);
resort_category(lists[i], true); });
}
}
} else { } else {
resort_category($("feedList"), false); resort_category($("feedList"), false);
@ -941,119 +925,64 @@ function hideOrShowFeeds(hide) {
try { try {
//console.log("hideOrShowFeeds: " + hide); if ($("FCATLIST--1")) {
if ($("FCATLIST--1")) { var lists = $$("#feedList ul[id*=FCATLIST]");
var lists = document.getElementsByTagName("UL"); lists.each(function(list) {
hideOrShowFeedsCategory(list.id.replace("FCATLIST-", ""), hide);
});
for (var i = 0; i < lists.length; i++) { } else {
if (lists[i].id && lists[i].id.match("FCATLIST-")) { hideOrShowFeedsCategory(null, hide);
var id = lists[i].id.replace("FCATLIST-", "");
hideOrShowFeedsCategory(id, hide);
}
} }
} else {
hideOrShowFeedsCategory(null, hide);
}
} catch (e) { } catch (e) {
exception_error("hideOrShowFeeds", e); exception_error("hideOrShowFeeds", e);
} }
} }
function hideOrShowFeedsCategory(id, hide) { function hideOrShowFeedsCategory(cat_id, hide) {
try { try {
var node = null; var nodes;
var cat_node = null; var cat_node;
if (id) { if (cat_id) {
node = $("FCATLIST-" + id); nodes = $$("#FCATLIST-" + cat_id + " > li");
cat_node = $("FCAT-" + id); cat_node = $("FCAT-" + cat_id);
} else { } else {
node = $("feedList"); // no categories nodes = $$("#feedList li");
} }
// console.log("hideOrShowFeedsCategory: " + node + " (" + hide + ")");
var cat_unread = 0; var cat_unread = 0;
if (!node) { nodes.each(function(node) {
console.warn("hideOrShowFeeds: passed node is null, aborting");
return;
}
// console.log("cat: " + node.id); var is_unread = node.hasClassName("Unread") ||
(node.hasClassName("virt") &&
getInitParam("hide_read_shows_special")) ||
node.hasClassName("error");
if (node.hasChildNodes() && node.firstChild.nextSibling != false) { if (hide && !is_unread) {
for (i = 0; i < node.childNodes.length; i++) { Effect.Fade(node, {duration : 0.3,
if (node.childNodes[i].nodeName != "LI") { continue; } queue: { position: 'end', scope: 'FFADE-' + node.id, limit: 1 }});
} else {
if (node.childNodes[i].style != undefined) { Element.show(node);
++cat_unread;
var has_unread = (node.childNodes[i].className != "feed" &&
node.childNodes[i].className != "label" &&
!(!getInitParam("hide_read_shows_special") &&
node.childNodes[i].className == "virt") &&
node.childNodes[i].className != "error" &&
node.childNodes[i].className != "tag");
var has_error = node.childNodes[i].className.match("error");
// console.log(node.childNodes[i].id + " --> " + has_unread);
if (hide && !has_unread) {
var id = node.childNodes[i].id;
Effect.Fade(node.childNodes[i], {duration : 0.3,
queue: { position: 'end', scope: 'FFADE-' + id, limit: 1 }});
}
if (!hide) {
Element.show(node.childNodes[i]);
}
if (has_unread) {
Element.show(node.childNodes[i]);
cat_unread++;
}
//if (has_error) Element.hide(node.childNodes[i]);
}
} }
}
// console.log("end cat: " + node.id + " unread " + cat_unread); });
if (cat_node) { if (cat_node) {
if (hide && cat_unread == 0) {
if (cat_unread == 0) { Effect.Fade(cat_node, {duration : 0.3,
if (cat_node.style == undefined) { queue: { position: 'end', scope: 'CFADE-' + cat_node.id, limit: 1 }});
console.log("ERROR: supplied cat_node " + cat_node +
" has no styles. WTF?");
return;
}
if (hide) {
//cat_node.style.display = "none";
Effect.Fade(cat_node, {duration : 0.3,
queue: { position: 'end', scope: 'CFADE-' + node.id, limit: 1 }});
} else {
cat_node.style.display = "list-item";
}
} else { } else {
try { Element.show(cat_node);
cat_node.style.display = "list-item";
} catch (e) {
console.log(e);
}
} }
} }
// console.log("unread for category: " + cat_unread);
} catch (e) { } catch (e) {
exception_error("hideOrShowFeedsCategory", e); exception_error("hideOrShowFeedsCategory", e);
} }
@ -1076,32 +1005,24 @@ function getFeedName(id, is_cat) {
function getNextUnreadCat(id) { function getNextUnreadCat(id) {
try { try {
var rows = $("feedList").getElementsByTagName("LI"); var rows = $$("#feedList li[id*=FCAT]");
var feeds = new Array(); var unread_cats = [];
var unread_only = true; rows.each(function(row) {
var is_cat = true; var cat_id = row.id.replace("FCAT-", "");
for (var i = 0; i < rows.length; i++) { if (Element.visible(row) && get_cat_unread(cat_id) > 0)
if (rows[i].id.match("FCAT-")) { unread_cats.push(parseInt(cat_id));
if (rows[i].id == "FCAT-" + id && is_cat || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) { });
var cat_id = parseInt(rows[i].id.replace("FCAT-", "")); console.log(unread_cats);
if (cat_id >= 0) { var idx = unread_cats.indexOf(id);
if (!unread_only || get_cat_unread(cat_id) > 0) {
feeds.push(cat_id);
}
}
}
}
}
var idx = feeds.indexOf(id); if (idx != -1 && idx < unread_cats.length-1) {
if (idx != -1 && idx < feeds.length) { return unread_cats[idx+1];
return feeds[idx+1];
} else { } else {
return feeds.shift(); return unread_cats[0];
} }
} catch (e) { } catch (e) {
@ -1114,7 +1035,7 @@ function getRelativeFeedId2(id, is_cat, direction, unread_only) {
// alert(id + " IC: " + is_cat + " D: " + direction + " U: " + unread_only); // alert(id + " IC: " + is_cat + " D: " + direction + " U: " + unread_only);
var rows = $("feedList").getElementsByTagName("LI"); var rows = $$("#feedList li");
var feeds = new Array(); var feeds = new Array();
for (var i = 0; i < rows.length; i++) { for (var i = 0; i < rows.length; i++) {
@ -1123,7 +1044,7 @@ function getRelativeFeedId2(id, is_cat, direction, unread_only) {
if (rows[i].id == "FEEDR-" + id && !is_cat || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) { if (rows[i].id == "FEEDR-" + id && !is_cat || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) {
if (!unread_only || if (!unread_only ||
(rows[i].className.match("Unread") || rows[i].id == "FEEDR-" + id)) { (rows[i].hasClassName("Unread") || rows[i].id == "FEEDR-" + id)) {
feeds.push(rows[i].id.replace("FEEDR-", "")); feeds.push(rows[i].id.replace("FEEDR-", ""));
} }
} }
@ -1179,16 +1100,7 @@ function getRelativeFeedId2(id, is_cat, direction, unread_only) {
function clean_feed_selections() { function clean_feed_selections() {
try { try {
var feeds = $("feedList").getElementsByTagName("LI"); $$("#feedList li").invoke('removeClassName', 'Selected');
for (var i = 0; i < feeds.length; i++) {
if (feeds[i].id && feeds[i].id.match("FEEDR-")) {
feeds[i].className = feeds[i].className.replace("Selected", "");
}
if (feeds[i].id && feeds[i].id.match("FCAT-")) {
feeds[i].className = feeds[i].className.replace("Selected", "");
}
}
} catch (e) { } catch (e) {
exception_error("clean_feed_selections", e); exception_error("clean_feed_selections", e);
} }

View File

@ -197,14 +197,6 @@ function notify_info(msg, no_hide) {
notify_real(msg, no_hide, 4); notify_real(msg, no_hide, 4);
} }
function cleanSelected(element) {
var content = $(element);
for (i = 0; i < content.rows.length; i++) {
content.rows[i].className = content.rows[i].className.replace("Selected", "");
}
}
function setCookie(name, value, lifetime, path, domain, secure) { function setCookie(name, value, lifetime, path, domain, secure) {
var d = false; var d = false;
@ -306,48 +298,26 @@ function gotoExportOpml() {
function toggleSelectRowById(sender, id) { function toggleSelectRowById(sender, id) {
var row = $(id); var row = $(id);
return toggleSelectRow(sender, row);
if (sender.checked) {
if (!row.className.match("Selected")) {
row.className = row.className + "Selected";
}
} else {
if (row.className.match("Selected")) {
row.className = row.className.replace("Selected", "");
}
}
} }
function toggleSelectListRow(sender) { function toggleSelectListRow(sender) {
var parent_row = sender.parentNode; var row = sender.parentNode;
return toggleSelectRow(sender, row);
if (sender.checked) {
if (!parent_row.className.match("Selected")) {
parent_row.className = parent_row.className + "Selected";
}
} else {
if (parent_row.className.match("Selected")) {
parent_row.className = parent_row.className.replace("Selected", "");
}
}
} }
function tSR(sender) { function tSR(sender, row) {
return toggleSelectRow(sender); return toggleSelectRow(sender, row);
} }
function toggleSelectRow(sender) { function toggleSelectRow(sender, row) {
var parent_row = sender.parentNode.parentNode;
if (sender.checked) { if (!row) row = sender.parentNode.parentNode;
if (!parent_row.className.match("Selected")) {
parent_row.className = parent_row.className + "Selected"; if (sender.checked && !row.hasClassName('Selected'))
} row.addClassName('Selected');
} else { else
if (parent_row.className.match("Selected")) { row.removeClassName('Selected');
parent_row.className = parent_row.className.replace("Selected", "");
}
}
} }
function checkboxToggleElement(elem, id) { function checkboxToggleElement(elem, id) {
@ -1516,21 +1486,21 @@ function selectTableRows(id, mode) {
} }
if (cb) { if (cb) {
var issel = row.className.match("Selected"); var issel = row.hasClassName("Selected");
if (mode == "all" && !issel) { if (mode == "all" && !issel) {
row.className += "Selected"; row.addClassName("Selected");
cb.checked = true; cb.checked = true;
} else if (mode == "none" && issel) { } else if (mode == "none" && issel) {
row.className = row.className.replace("Selected", ""); row.removeClassName("Selected");
cb.checked = false; cb.checked = false;
} else if (mode == "invert") { } else if (mode == "invert") {
if (issel) { if (issel) {
row.className = row.className.replace("Selected", ""); row.removeClassName("Selected");
cb.checked = false; cb.checked = false;
} else { } else {
row.className += "Selected"; row.addClassName("Selected");
cb.checked = true; cb.checked = true;
} }
} }
@ -1551,7 +1521,7 @@ function getSelectedTableRowIds(id) {
var elem_rows = $(id).rows; var elem_rows = $(id).rows;
for (i = 0; i < elem_rows.length; i++) { for (i = 0; i < elem_rows.length; i++) {
if (elem_rows[i].className.match("Selected")) { if (elem_rows[i].hasClassName("Selected")) {
var bare_id = elem_rows[i].id.replace(/^[A-Z]*?-/, ""); var bare_id = elem_rows[i].id.replace(/^[A-Z]*?-/, "");
rows.push(bare_id); rows.push(bare_id);
} }

View File

@ -1679,7 +1679,7 @@
if (!$feed_title) $feed_title = getFeedTitle($link, $feed_id, false); if (!$feed_title) $feed_title = getFeedTitle($link, $feed_id, false);
if (!$unread) $unread = getFeedUnread($link, $feed_id); if (!$unread) $unread = getFeedUnread($link, $feed_id);
if ($unread > 0) $class .= "Unread"; if ($unread > 0) $class .= " Unread";
if (!$icon_file) $icon_file = getFeedIcon($feed_id); if (!$icon_file) $icon_file = getFeedIcon($feed_id);
@ -1730,9 +1730,9 @@
print "<span $rtl_tag id=\"FEEDN-$feed_id\">$feed</span>"; print "<span $rtl_tag id=\"FEEDN-$feed_id\">$feed</span>";
if ($unread != 0) { if ($unread != 0) {
$fctr_class = "class=\"feedCtrHasUnread\""; $fctr_class = "class=\"feedCtr Unread\"";
} else { } else {
$fctr_class = "class=\"feedCtrNoUnread\""; $fctr_class = "class=\"feedCtr\"";
} }
print " <span $rtl_tag $fctr_class id=\"FEEDCTR-$feed_id\"> print " <span $rtl_tag $fctr_class id=\"FEEDCTR-$feed_id\">
@ -4273,7 +4273,7 @@
$collapse_pic = "cat-collapse.png"; $collapse_pic = "cat-collapse.png";
} }
$catctr_class = ($cat_unread > 0) ? "catCtrHasUnread" : "catCtrNoUnread"; $catctr_class = ($cat_unread > 0) ? "catCtr Unread" : "catCtr";
if ($can_browse) { if ($can_browse) {
$browse_cat_link = "onclick=\"javascript:viewCategory($cat_id)\""; $browse_cat_link = "onclick=\"javascript:viewCategory($cat_id)\"";
@ -4452,7 +4452,7 @@
} }
if ($actid == $feed_id) { if ($actid == $feed_id) {
$class .= "Selected"; $class .= " Selected";
} }
$total_unread += $unread; $total_unread += $unread;
@ -5123,7 +5123,7 @@
} }
if ($line["unread"] == "t" || $line["unread"] == "1") { if ($line["unread"] == "t" || $line["unread"] == "1") {
$class .= "Unread"; $class .= " Unread";
++$num_unread; ++$num_unread;
$is_unread = true; $is_unread = true;
} else { } else {
@ -5313,12 +5313,6 @@
} }
} }
if ($is_unread) {
$add_class = "Unread";
} else {
$add_class = "";
}
$expand_cdm = get_pref($link, 'CDM_EXPANDED'); $expand_cdm = get_pref($link, 'CDM_EXPANDED');
$mouseover_attrs = "onmouseover='postMouseIn($id)' $mouseover_attrs = "onmouseover='postMouseIn($id)'
@ -5344,7 +5338,7 @@
print "</div>"; print "</div>";
print "<input type=\"checkbox\" onclick=\"toggleSelectRowById(this, print "<input type=\"checkbox\" onclick=\"toggleSelectRowById(this,
'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\"/>"; 'RROW-$id')\" id=\"RCHK-$id\"/>";
print "$marked_pic"; print "$marked_pic";
print "$published_pic"; print "$published_pic";

View File

@ -438,7 +438,7 @@
$edit_uid = $_REQUEST["id"]; $edit_uid = $_REQUEST["id"];
if ($subop == "edit" && $uid != $edit_uid) { if ($subop == "edit" && $uid != $edit_uid) {
$class .= "Grayed"; $class .= " Grayed";
$this_row_id = ""; $this_row_id = "";
} else { } else {
$this_row_id = "id=\"UMRR-$uid\""; $this_row_id = "id=\"UMRR-$uid\"";

View File

@ -1111,25 +1111,11 @@ function selectTab(id, noupdate, subop) {
/* clean selection from all tabs */ /* clean selection from all tabs */
var tabs_holder = $("prefTabs"); $$("#prefTabs div").invoke('removeClassName', 'Selected');
var tab = tabs_holder.firstChild;
while (tab) {
if (tab.className && tab.className.match("prefsTabSelected")) {
tab.className = "prefsTab";
}
tab = tab.nextSibling;
}
/* mark new tab as selected */ /* mark new tab as selected */
tab = $(id + "Tab"); $(id + "Tab").addClassName("Selected");
if (tab) {
if (!tab.className.match("Selected")) {
tab.className = tab.className + "Selected";
}
}
active_tab = id; active_tab = id;

View File

@ -149,14 +149,14 @@ ul.feedList span.catTitle:hover {
color : #4684ff; color : #4684ff;
} }
ul.feedList li.feedCatSelected { ul.feedList li.feedCat.Selected {
margin : 0px; margin : 0px;
padding : 3px 0px 3px 0px; padding : 3px 0px 3px 0px;
color : #4684ff; color : #4684ff;
font-size : 12px; font-size : 12px;
} }
ul.feedList li.feedCatSelected span.catTitle { ul.feedList li.feedCat.Selected span.catTitle {
color : #4684ff; color : #4684ff;
cursor : pointer; cursor : pointer;
} }
@ -181,40 +181,40 @@ ul.feedCatList img, ul.feedList img {
vertical-align : bottom; vertical-align : bottom;
} }
li.feedUnread, li.feed.Unread,
li.errorUnread, li.error.Unread,
li.labelUnread, li.label.Unread,
li.virtUnread, li.virt.Unread,
li.tagUnread { li.tag.Unread {
font-weight : bold; font-weight : bold;
} }
li.errorSelected span.feedlink, li.error.Selected span.feedlink,
li.error span.feedlink, li.error span.feedlink,
li.errorUnread span.feedlink, li.error.Unread span.feedlink,
li.errorUnreadSelected span.feedlink { li.error.Unread.Selected span.feedlink {
color : #f04040; color : #f04040;
} }
li.feedSelected span.feedlink, li.feed.Selected span.feedlink,
li.labelSelected span.feedlink, li.label.Selected span.feedlink,
li.virtSelected span.feedlink, li.virt.Selected span.feedlink,
li.tagSelected span.feedlink { li.tag.Selected span.feedlink {
color : #4684ff; color : #4684ff;
} }
li.feedUnreadSelected span.feedlink, li.feed.Unread.Selected span.feedlink,
li.labelUnreadSelected span.feedlink, li.label.Unread.Selected span.feedlink,
li.virtUnreadSelected span.feedlink, li.virt.Unread.Selected span.feedlink,
li.tagUnreadSelected span.feedlink { li.tag.Unread.Selected span.feedlink {
color : #4684ff; color : #4684ff;
} }
li.feedUnreadSelected, li.feed.Unread.Selected,
li.errorUnreadSelected, li.error.Unread.Selected,
li.labelUnreadSelected, li.label.Unread.Selected,
li.virtUnreadSelected, li.virt.Unread.Selected,
li.tagUnreadSelected { li.tag.Unread.Selected {
font-weight : bold; font-weight : bold;
} }
@ -351,8 +351,7 @@ input.editbox {
color : #4684ff; color : #4684ff;
} }
.evenUnreadSelected, .evenSelectedUnread, .evenUnreadSelected td, .even.Unread.Selected, .even.Unread.Selected td {
.evenSelectedUnread td {
background-color : #fff7d5; background-color : #fff7d5;
font-weight : bold; font-weight : bold;
border-width : 0px 0px 1px 0px; border-width : 0px 0px 1px 0px;
@ -360,8 +359,7 @@ input.editbox {
border-color : #e7d796; border-color : #e7d796;
} }
.oddUnreadSelected, .oddSelectedUnread, .oddUnreadSelected td, .odd.Unread.Selected, .odd.Unread.Selected td {
.oddSelectedUnread td {
background-color : #fff7d5; background-color : #fff7d5;
font-weight : bold; font-weight : bold;
border-width : 0px 0px 1px 0px; border-width : 0px 0px 1px 0px;
@ -369,7 +367,7 @@ input.editbox {
border-color : #e7d796; border-color : #e7d796;
} }
.evenSelected, .evenSelected td { .even.Selected, .even.Selected td {
background-color : #fff7d5; background-color : #fff7d5;
border-width : 0px 0px 1px 0px; border-width : 0px 0px 1px 0px;
border-style : solid; border-style : solid;
@ -377,7 +375,7 @@ input.editbox {
border-collapse : collapse; border-collapse : collapse;
} }
.oddSelected, .oddSelected td { .odd.Selected, .odd.Selected td {
background-color : #fff7d5; background-color : #fff7d5;
border-width : 0px 0px 1px 0px; border-width : 0px 0px 1px 0px;
border-style : solid; border-style : solid;
@ -385,7 +383,7 @@ input.editbox {
border-collapse : collapse; border-collapse : collapse;
} }
.evenGrayed, .evenGrayed td { .even.Grayed, .even.Grayed td {
background-color : #f0f0f0; background-color : #f0f0f0;
color : #909090; color : #909090;
border-width : 0px 0px 1px 0px; border-width : 0px 0px 1px 0px;
@ -394,7 +392,7 @@ input.editbox {
border-collapse : collapse; border-collapse : collapse;
} }
.oddGrayed { .odd.Grayed {
color : #909090; color : #909090;
} }
@ -413,7 +411,7 @@ input.editbox {
border-collapse : collapse; border-collapse : collapse;
} }
.evenUnread, .evenUnread td { .even.Unread, .even.Unread td {
background-color : #f0f0f0; background-color : #f0f0f0;
font-weight : bold; font-weight : bold;
border-width : 0px 0px 1px 0px; border-width : 0px 0px 1px 0px;
@ -422,7 +420,7 @@ input.editbox {
border-collapse : collapse; border-collapse : collapse;
} }
.oddUnread, .oddUnread td { .odd.Unread, .odd.Unread td {
font-weight : bold; font-weight : bold;
border-width : 0px 0px 1px 0px; border-width : 0px 0px 1px 0px;
border-style : solid; border-style : solid;
@ -557,7 +555,7 @@ div.prefsTab:hover {
cursor : pointer; cursor : pointer;
} }
div.prefsTabSelected:hover { div.prefsTab.Selected:hover {
cursor : pointer; cursor : pointer;
} }
@ -579,7 +577,7 @@ div.prefsTab {
height : 30px; height : 30px;
} }
div.prefsTabSelected { div.prefsTab.Selected {
float : left; float : left;
border-width : 1px 1px 0px 1px; border-width : 1px 1px 0px 1px;
border-color : #88b0f0; border-color : #88b0f0;
@ -1262,12 +1260,13 @@ div.return a:hover {
right : 2px; right : 2px;
} }
.catCtrHasUnread, .feedCtrHasUnread { .catCtr.Unread, .feedCtr.Unread {
font-weight : bold; font-weight : bold;
color : #707070; color : #707070;
display : inline;
} }
.catCtrNoUnread, .feedCtrNoUnread { .catCtr, .feedCtr {
display : none; display : none;
} }

View File

@ -69,13 +69,13 @@ function headlines_callback2(transport, feed_cur_page) {
if (!is_cat) { if (!is_cat) {
var feedr = $("FEEDR-" + feed_id); var feedr = $("FEEDR-" + feed_id);
if (feedr && !feedr.className.match("Selected")) { if (feedr) {
feedr.className = feedr.className + "Selected"; feedr.addClassName("Selected");
} }
} else { } else {
var feedr = $("FCAT-" + feed_id); var feedr = $("FCAT-" + feed_id);
if (feedr && !feedr.className.match("Selected")) { if (feedr) {
feedr.className = feedr.className + "Selected"; feedr.addClassName("Selected");
} }
} }
@ -254,9 +254,9 @@ function showArticleInHeadlines(id) {
if (!crow) return; if (!crow) return;
var article_is_unread = crow.className.match("Unread"); var article_is_unread = crow.hasClassName("Unread");
crow.className = crow.className.replace("Unread", ""); crow.removeClassName("Unread");
selectArticles('none'); selectArticles('none');
@ -420,7 +420,7 @@ function view(id) {
query = query + "&cids=" + cids_to_request.toString(); query = query + "&cids=" + cids_to_request.toString();
var crow = $("RROW-" + id); var crow = $("RROW-" + id);
var article_is_unread = crow.className.match("Unread"); var article_is_unread = crow.hasClassName("Unread");
active_post_id = id; active_post_id = id;
showArticleInHeadlines(id); showArticleInHeadlines(id);
@ -668,28 +668,16 @@ function toggleSelected(id) {
try { try {
var cb = $("RCHK-" + id); var cb = $("RCHK-" + id);
var row = $("RROW-" + id); var row = $("RROW-" + id);
if (row) { if (row) {
var nc = row.className; if (row.hasClassName('Selected')) {
row.removeClassName('Selected');
if (!nc.match("Selected")) { if (cb) cb.checked = false;
nc = nc + "Selected";
if (cb) {
cb.checked = true;
}
// In CDM basically last selected article == active article
if (isCdmMode()) active_post_id = id;
} else { } else {
nc = nc.replace("Selected", ""); row.addClassName('Selected');
if (cb) { if (cb) cb.checked = true;
cb.checked = false;
}
} }
row.className = nc;
} }
} catch (e) { } catch (e) {
exception_error("toggleSelected", e); exception_error("toggleSelected", e);
@ -712,24 +700,9 @@ function toggleUnread(id, cmode, effect) {
var row = $("RROW-" + id); var row = $("RROW-" + id);
if (row) { if (row) {
var nc = row.className;
var is_selected = row.className.match("Selected");
nc = nc.replace("Unread", "");
nc = nc.replace("Selected", "");
// since we are removing selection from the object, uncheck
// corresponding checkbox
var cb = $("RCHK-" + id);
if (cb) {
cb.checked = false;
}
// NOTE: I'm not sure that resetting selection here is a feature -fox
if (cmode == undefined || cmode == 2) { if (cmode == undefined || cmode == 2) {
if (row.className.match("Unread")) { if (row.hasClassName("Unread")) {
row.className = nc; row.removeClassName("Unread");
if (effect) { if (effect) {
new Effect.Highlight(row, {duration: 1, startcolor: "#fff7d5", new Effect.Highlight(row, {duration: 1, startcolor: "#fff7d5",
@ -738,7 +711,7 @@ function toggleUnread(id, cmode, effect) {
} }
} else { } else {
row.className = nc + "Unread"; row.addClassName("Unread");
} }
if (db) { if (db) {
@ -747,7 +720,8 @@ function toggleUnread(id, cmode, effect) {
} }
} else if (cmode == 0) { } else if (cmode == 0) {
row.className = nc;
row.removeClassName("Unread");
if (effect) { if (effect) {
new Effect.Highlight(row, {duration: 1, startcolor: "#fff7d5", new Effect.Highlight(row, {duration: 1, startcolor: "#fff7d5",
@ -761,7 +735,7 @@ function toggleUnread(id, cmode, effect) {
} }
} else if (cmode == 1) { } else if (cmode == 1) {
row.className = nc + "Unread"; row.addClassName("Unread");
if (db) { if (db) {
db.execute("UPDATE articles SET unread = 1 "+ db.execute("UPDATE articles SET unread = 1 "+
@ -772,9 +746,6 @@ function toggleUnread(id, cmode, effect) {
update_local_feedlist_counters(); update_local_feedlist_counters();
// Disable unmarking as selected for the time being (16.05.08) -fox
if (is_selected) row.className = row.className + "Selected";
if (cmode == undefined) cmode = 2; if (cmode == undefined) cmode = 2;
var query = "?op=rpc&subop=catchupSelected" + var query = "?op=rpc&subop=catchupSelected" +
@ -883,15 +854,11 @@ function selectionToggleUnread(set_state, callback_func, no_error) {
for (i = 0; i < rows.length; i++) { for (i = 0; i < rows.length; i++) {
var row = $("RROW-" + rows[i]); var row = $("RROW-" + rows[i]);
if (row) { if (row) {
var nc = row.className;
nc = nc.replace("Unread", "");
nc = nc.replace("Selected", "");
if (set_state == undefined) { if (set_state == undefined) {
if (row.className.match("Unread")) { if (row.hasClassName("Unread")) {
row.className = nc + "Selected"; row.removeClassName("Unread");
} else { } else {
row.className = nc + "UnreadSelected"; row.addClassName("Unread");
} }
if (db) { if (db) {
db.execute("UPDATE articles SET unread = NOT unread WHERE id = ?", db.execute("UPDATE articles SET unread = NOT unread WHERE id = ?",
@ -900,7 +867,8 @@ function selectionToggleUnread(set_state, callback_func, no_error) {
} }
if (set_state == false) { if (set_state == false) {
row.className = nc + "Selected"; row.removeClassName("Unread");
if (db) { if (db) {
db.execute("UPDATE articles SET unread = 0 WHERE id = ?", db.execute("UPDATE articles SET unread = 0 WHERE id = ?",
[rows[i]]); [rows[i]]);
@ -908,7 +876,8 @@ function selectionToggleUnread(set_state, callback_func, no_error) {
} }
if (set_state == true) { if (set_state == true) {
row.className = nc + "UnreadSelected"; row.addClassName("Unread");
if (db) { if (db) {
db.execute("UPDATE articles SET unread = 1 WHERE id = ?", db.execute("UPDATE articles SET unread = 1 WHERE id = ?",
[rows[i]]); [rows[i]]);
@ -1016,84 +985,65 @@ function selectionTogglePublished() {
} }
function getSelectedArticleIds2() { function getSelectedArticleIds2() {
var sel_articles = new Array();
var children; var rv = [];
var children = $("headlinesInnerContainer").childNodes; $$("#headlinesInnerContainer > div[id*=RROW][class*=Selected]").each(
function(child) {
rv.push(child.id.replace("RROW-", ""));
});
for (i = 0; i < children.length; i++) { return rv;
var child = children[i];
if (child.id && child.id.match("RROW-") && child.className.match("Selected")) {
var c_id = child.id.replace("RROW-", "");
sel_articles.push(c_id);
}
}
return sel_articles;
} }
function getLoadedArticleIds() { function getLoadedArticleIds() {
var sel_articles = new Array(); var rv = [];
var children = $("headlinesInnerContainer").childNodes; var children = $$("#headlinesInnerContainer > div[id*=RROW-]");
if (!children) return sel_articles; children.each(function(child) {
rv.push(child.id.replace("RROW-", ""));
});
for (i = 0; i < children.length; i++) { return rv;
var child = children[i];
if (child.id && child.id.match("RROW-")) {
var c_id = child.id.replace("RROW-", "");
sel_articles.push(c_id);
}
}
return sel_articles;
} }
// mode = all,none,unread,invert // mode = all,none,unread,invert
function selectArticles(mode) { function selectArticles(mode) {
try { try {
var children; var children = $$("#headlinesInnerContainer > div[id*=RROW]");
var children = $("headlinesInnerContainer").childNodes; children.each(function(child) {
var id = child.id.replace("RROW-", "");
for (i = 0; i < children.length; i++) { var cb = $("RCHK-" + id);
var child = children[i];
if (child.id && child.id.match("RROW-")) {
var aid = child.id.replace("RROW-", "");
var cb = $("RCHK-" + aid);
if (mode == "all") {
if (!child.className.match("Selected")) {
child.className = child.className + "Selected";
cb.checked = true;
}
} else if (mode == "unread") {
if (child.className.match("Unread") && !child.className.match("Selected")) {
child.className = child.className + "Selected";
cb.checked = true;
}
} else if (mode == "invert") {
if (child.className.match("Selected")) {
child.className = child.className.replace("Selected", "");
cb.checked = false;
} else {
child.className = child.className + "Selected";
cb.checked = true;
}
if (mode == "all") {
child.addClassName("Selected");
cb.checked = true;
} else if (mode == "unread") {
if (child.hasClassName("Unread")) {
child.addClassName("Selected");
cb.checked = true;
} else { } else {
child.className = child.className.replace("Selected", ""); child.removeClassName("Selected");
cb.checked = false; cb.checked = false;
} }
} else if (mode == "invert") {
if (child.hasClassName("Selected")) {
child.removeClassName("Selected");
cb.checked = false;
} else {
child.addClassName("Selected");
cb.checked = true;
}
} else {
child.removeClassName("Selected");
cb.checked = false;
} }
} });
} catch (e) { } catch (e) {
exception_error("selectArticles", e); exception_error("selectArticles", e);
@ -1349,7 +1299,7 @@ function cdmWatchdog() {
var e = ctr.firstChild; var e = ctr.firstChild;
while (e) { while (e) {
if (e.className && e.className == "cdmArticleUnread" && e.id && if (e.className && e.hasClassName("Unread") && e.id &&
e.id.match("RROW-")) { e.id.match("RROW-")) {
// article fits in viewport OR article is longer than viewport and // article fits in viewport OR article is longer than viewport and
@ -1393,7 +1343,7 @@ function cdmWatchdog() {
for (var i = 0; i < ids.length; i++) { for (var i = 0; i < ids.length; i++) {
var e = $("RROW-" + ids[i]); var e = $("RROW-" + ids[i]);
if (e) { if (e) {
e.className = e.className.replace("Unread", ""); e.removeClassName("Unread");
} }
} }
@ -1817,7 +1767,7 @@ function catchupRelativeToArticle(below) {
if (visible_ids[i] != getActiveArticleId()) { if (visible_ids[i] != getActiveArticleId()) {
var e = $("RROW-" + visible_ids[i]); var e = $("RROW-" + visible_ids[i]);
if (e && e.className.match("Unread")) { if (e && e.hasClassName("Unread")) {
ids_to_mark.push(visible_ids[i]); ids_to_mark.push(visible_ids[i]);
} }
} else { } else {
@ -1829,7 +1779,7 @@ function catchupRelativeToArticle(below) {
if (visible_ids[i] != getActiveArticleId()) { if (visible_ids[i] != getActiveArticleId()) {
var e = $("RROW-" + visible_ids[i]); var e = $("RROW-" + visible_ids[i]);
if (e && e.className.match("Unread")) { if (e && e.hasClassName("Unread")) {
ids_to_mark.push(visible_ids[i]); ids_to_mark.push(visible_ids[i]);
} }
} else { } else {
@ -1847,7 +1797,7 @@ function catchupRelativeToArticle(below) {
for (var i = 0; i < ids_to_mark.length; i++) { for (var i = 0; i < ids_to_mark.length; i++) {
var e = $("RROW-" + ids_to_mark[i]); var e = $("RROW-" + ids_to_mark[i]);
e.className = e.className.replace("Unread", ""); e.removeClassName("Unread");
} }
var query = "?op=rpc&subop=catchupSelected" + var query = "?op=rpc&subop=catchupSelected" +
@ -1958,9 +1908,11 @@ function fixHeadlinesOrder(ids) {
if (e) { if (e) {
if (i % 2 == 0) { if (i % 2 == 0) {
e.className = e.className.replace("even", "odd"); e.removeClassName("even");
e.addClassName("odd");
} else { } else {
e.className = e.className.replace("odd", "even"); e.removeClassName("odd");
e.addClassName("even");
} }
} }
} }
@ -2162,7 +2114,7 @@ function dismissSelectedArticles() {
for (var i = 0; i < ids.length; i++) { for (var i = 0; i < ids.length; i++) {
var elem = $("RROW-" + ids[i]); var elem = $("RROW-" + ids[i]);
if (elem.className && elem.className.match("Selected") && if (elem.className && elem.hasClassName("Selected") &&
ids[i] != active_post_id) { ids[i] != active_post_id) {
new Effect.Fade(elem, {duration : 0.5}); new Effect.Fade(elem, {duration : 0.5});
sel.push(ids[i]); sel.push(ids[i]);
@ -2190,8 +2142,8 @@ function dismissReadArticles() {
for (var i = 0; i < ids.length; i++) { for (var i = 0; i < ids.length; i++) {
var elem = $("RROW-" + ids[i]); var elem = $("RROW-" + ids[i]);
if (elem.className && !elem.className.match("Unread") && if (elem.className && !elem.hasClassName("Unread") &&
!elem.className.match("Selected")) { !elem.hasClassName("Selected")) {
new Effect.Fade(elem, {duration : 0.5}); new Effect.Fade(elem, {duration : 0.5});
} else { } else {
@ -2210,13 +2162,12 @@ function getVisibleArticleIds() {
var ids = []; var ids = [];
try { try {
var tmp = getLoadedArticleIds();
for (var i = 0; i < tmp.length; i++) { getLoadedArticleIds().each(function(id) {
var elem = $("RROW-" + tmp[i]); var elem = $("RROW-" + id);
if (elem && Element.visible(elem)) if (elem && Element.visible(elem))
ids.push(tmp[i]); ids.push(id);
} });
} catch (e) { } catch (e) {
exception_error("getVisibleArticleIds", e); exception_error("getVisibleArticleIds", e);
@ -2238,7 +2189,7 @@ function cdmClicked(event, id) {
var elem = $("RROW-" + id); var elem = $("RROW-" + id);
if (elem) if (elem)
elem.className = elem.className.replace("Unread", ""); elem.removeClassName("Unread");
var upd_img_pic = $("FUPDPIC-" + id); var upd_img_pic = $("FUPDPIC-" + id);
@ -2248,6 +2199,8 @@ function cdmClicked(event, id) {
upd_img_pic.src = "images/blank_icon.gif"; upd_img_pic.src = "images/blank_icon.gif";
} }
active_post_id = id;
var query = "?op=rpc&subop=catchupSelected" + var query = "?op=rpc&subop=catchupSelected" +
"&cmode=0&ids=" + param_escape(id); "&cmode=0&ids=" + param_escape(id);
@ -2351,27 +2304,13 @@ function isCdmMode() {
function markHeadline(id) { function markHeadline(id) {
var row = $("RROW-" + id); var row = $("RROW-" + id);
if (row) { if (row) {
var is_active = false;
if (row.className.match("Active")) {
is_active = true;
}
row.className = row.className.replace("Selected", "");
row.className = row.className.replace("Active", "");
row.className = row.className.replace("Insensitive", "");
if (is_active) {
row.className = row.className = "Active";
}
var check = $("RCHK-" + id); var check = $("RCHK-" + id);
if (check) { if (check) {
check.checked = true; check.checked = true;
} }
row.className = row.className + "Selected"; row.addClassName("Selected");
} }
} }