code cleanup

master
Andrew Dolgov 14 years ago
parent 102cfe73c6
commit 9c99281f20

@ -162,7 +162,6 @@
case "feeds":
$print_exec_time = true;
$tags = $_REQUEST["tags"];
$subop = $_REQUEST["subop"];
@ -207,7 +206,7 @@
}
print json_encode(outputFeedList($link, $tags));
print json_encode(outputFeedList($link));
break; // feeds

@ -224,61 +224,13 @@ function viewfeed(feed, subop, is_cat, offset) {
} else {
// if (!page_offset) {
var feedr;
if (is_cat) {
feedr = $('FCAP-' + feed);
} else {
feedr = $('FEEDR-' + feed);
}
if (feedr && !$('FLL-' + feed)) {
var img = $('FIMG-' + feed);
if (!is_cat && img) {
var cat_list = feedr.parentNode;
if (!cat_list || Element.visible(cat_list)) {
if (!img.src.match("indicator_white")) {
img.alt = img.src;
img.src = getInitParam("sign_progress");
}
} else if (cat_list) {
feed_cat_id = cat_list.id.replace("FCATLIST-", "");
if (!$('FLL-' + feed_cat_id)) {
var ll = document.createElement('img');
ll.src = getInitParam("sign_progress_tiny");
ll.className = 'hlLoading';
ll.id = 'FLL-' + feed;
$("FCAP-" + feed_cat_id).appendChild(ll);
}
}
} else {
if (!$('FLL-' + feed)) {
var ll = document.createElement('img');
ll.src = getInitParam("sign_progress_tiny");
ll.className = 'hlLoading';
ll.id = 'FLL-' + feed;
feedr.appendChild(ll);
}
}
}
// }
if (!is_cat)
setFeedExpandoIcon(feed, is_cat, 'images/indicator_white.gif');
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
headlines_callback2(transport, page_offset);
} });
}
@ -406,11 +358,7 @@ function request_counters_real() {
var query = "?op=rpc&subop=getAllCounters&seq=" + next_seq();
if (tagsAreDisplayed()) {
query = query + "&omode=tl";
} else {
query = query + "&omode=flc";
}
new Ajax.Request("backend.php", {
parameters: query,
@ -892,6 +840,7 @@ function setFeedUnread(feed, is_cat, unread) {
function setFeedValue(feed, is_cat, key, value) {
try {
if (!value) value = '';
if (!treeModel) return;
if (is_cat)
treeItem = treeModel.store._itemsByIdentity['CAT:' + feed];
@ -952,3 +901,24 @@ function setFeedIcon(feed, is_cat, src) {
exception_error("setFeedIcon", e);
}
}
function setFeedExpandoIcon(feed, is_cat, src) {
try {
var tree = dijit.byId("feedTree");
if (!tree) return;
if (is_cat)
treeNode = tree._itemNodesMap['CAT:' + feed];
else
treeNode = tree._itemNodesMap['FEED:' + feed];
if (treeNode) {
treeNode = treeNode[0];
treeNode.expandoNode.src = src;
}
} catch (e) {
exception_error("setFeedIcon", e);
}
}

@ -1672,82 +1672,6 @@
}
}
function printFeedEntry($feed_id, $class, $feed_title, $unread, $icon_file, $link,
$rtl_content = false, $last_updated = false, $last_error = false,
$fg_content = false, $bg_content = false) {
if (!$feed_title) $feed_title = getFeedTitle($link, $feed_id, false);
if (!$unread) $unread = getFeedUnread($link, $feed_id);
if ($unread > 0) $class .= " Unread";
if (!$icon_file) $icon_file = getFeedIcon($feed_id);
if (strpos($icon_file, "images") !== false) {
$icon_file = theme_image($link, $icon_file);
}
if (file_exists($icon_file) && filesize($icon_file) > 0) {
$feed_icon = "<img id=\"FIMG-$feed_id\" src=\"$icon_file\">";
} else {
$feed_icon = "<img id=\"FIMG-$feed_id\" src=\"images/blank_icon.gif\">";
}
if ($rtl_content) {
$rtl_tag = "dir=\"rtl\"";
} else {
$rtl_tag = "dir=\"ltr\"";
}
$error_notify_msg = "";
if ($last_error) {
$link_title = "Error: $last_error ($last_updated)";
$error_notify_msg = "(Error)";
} else if ($last_updated) {
$link_title = "Updated: $last_updated";
}
$feed_title = truncate_string($feed_title, 30);
$feed = "<span class='feedlink' title=\"$link_title\" id=\"FEEDL-$feed_id\" href=\"#\"
onclick=\"viewfeed('$feed_id');\">$feed_title</span>";
/* if ($feed_id < -10) {
$bg_color = "#00ccff";
$fg_color = "white";
}
if ($fg_color || $bg_color) {
$color_str = "<div class='labelColorIndicator'
style='color : $fg_color; background-color : $bg_color'>l</div>";
}
print $color_str; */
print "<li id=\"FEEDR-$feed_id\" class=\"$class\">";
print "$feed_icon";
print "<span $rtl_tag id=\"FEEDN-$feed_id\">$feed</span>";
if ($unread != 0) {
$fctr_class = "class=\"feedCtr Unread\"";
} else {
$fctr_class = "class=\"feedCtr\"";
}
print " <span $rtl_tag $fctr_class id=\"FEEDCTR-$feed_id\">
(<span id=\"FEEDU-$feed_id\">$unread</span>)</span>";
if (get_pref($link, "EXTENDED_FEEDLIST")) {
$total = getFeedArticles($link, $feed_id);
print "<div class=\"feedExtInfo\">
<span id=\"FLUPD-$feed_id\">$last_updated ($total total) $error_notify_msg</span></div>";
}
print "</li>";
}
function getmicrotime() {
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
@ -4147,47 +4071,6 @@
print " ";
/* print "<span
onmouseover=\"enable_selection(false)\"
onmouseout=\"enable_selection(true)\"
onclick=\"toggleHeadlineActions()\" id=\"headlineActionsDrop\">".
__("Actions...") . "&nbsp;&nbsp;<img width='11' height'7'
src=\"images/down_arrow.png\">
</span>";
print "<ul id=\"headlineActionsBody\" style=\"display : none\">";
print "<li class=\"insensitive\">".__('Selection toggle:')."</li>
<li onclick=\"$tog_unread_link\">&nbsp;&nbsp;".__('Unread')."</li>
<li onclick=\"$tog_marked_link\">&nbsp;&nbsp;".__('Starred')."</li>
<li onclick=\"$tog_published_link\">&nbsp;&nbsp;".__('Published')."</li>
<li class=\"insensitive\">".__('Selection:')."</li>
<li onclick=\"$catchup_sel_link\">&nbsp;&nbsp;".__('Mark as read')."</li>";
// print "<li onclick=\"$catchup_feed_link\">&nbsp;&nbsp;".__('Entire feed').
// "</li>";
if ($feed_id != "0") {
print "<li onclick=\"$archive_sel_link\">&nbsp;&nbsp;".__('Archive')."</li>";
} else {
print "<li onclick=\"$archive_sel_link\">&nbsp;&nbsp;".__('Move back')."</li>";
print "<li onclick=\"$delete_sel_link\">&nbsp;&nbsp;".__('Delete')."</li>";
}
print "<li onclick=\"emailArticle(false)\">&nbsp;&nbsp;".
__('Forward by email')."</li>";
//print "<li><span class=\"insensitive\">--------</span></li>";
print "<li class=\"insensitive\">".__('Assign label:')."</li>";
print_labels_headlines_dropdown($link, $feed_id);
print "<li class=\"insensitive\">".__('Feed:')."</li>";
print "<li onclick=\"displayDlg('generatedFeed', '$feed_id:$is_cat:$rss_link')\">&nbsp;&nbsp;".__('View as RSS')."</li>";
print "</ul>"; */
print "<select dojoType=\"dijit.form.Select\"
onchange=\"headlineActionsChange(this)\">";
print "<option value=\"\">".__('Actions...')."</option>";
@ -4293,62 +4176,7 @@
}
function printCategoryHeader($link, $cat_id, $hidden = false, $can_browse = true,
$title_override = false) {
if (!$title_override)
$tmp_category = getCategoryTitle($link, $cat_id);
else
$tmp_category = $title_override;
if ($cat_id > 0) {
$cat_unread = ccache_find($link, $cat_id, $_SESSION["uid"], true);
} else if ($cat_id == 0 || $cat_id == -2) {
$cat_unread = getCategoryUnread($link, $cat_id);
}
if ($hidden) {
$holder_style = "display:none;";
$ellipsis = "…";
$collapse_pic = "cat-uncollapse.png";
} else {
$holder_style = "";
$ellipsis = "";
$collapse_pic = "cat-collapse.png";
}
$catctr_class = ($cat_unread > 0) ? "catCtr Unread" : "catCtr";
if ($can_browse) {
$browse_cat_link = "onclick=\"javascript:viewCategory($cat_id)\"";
$inner_title_class = "catTitle";
} else {
$browse_cat_link = "";
$inner_title_class = "catTitleNL";
}
$cat_class = "feedCat";
print "<li class=\"$cat_class\" id=\"FCAT-$cat_id\">
<img onclick=\"toggleCollapseCat($cat_id)\" class=\"catCollapse\"
title=\"".__('Click to collapse category')."\"
src=\"images/$collapse_pic?\"><span class=\"$inner_title_class\"
id=\"FCATN-$cat_id\" $browse_cat_link/>$tmp_category</span>";
print "<span id=\"FCAP-$cat_id\">";
print " <span id=\"FCATCTR-$cat_id\"
class=\"$catctr_class\">($cat_unread)</span> $ellipsis";
print "</span>";
//print "</li>";
print "<ul class=\"feedCatList\" id=\"FCATLIST-$cat_id\" style='$holder_style'>";
}
function outputFeedList($link, $tags = false) {
function outputFeedList($link) {
$feedlist = array();
@ -4379,8 +4207,6 @@
$feedlist['items'] = array_merge($feedlist['items'], $cat['items']);
}
if (!$tags) {
$result = db_query($link, "SELECT * FROM
ttrss_labels2 WHERE owner_uid = '$owner_uid' ORDER by caption");
@ -4489,69 +4315,6 @@
$feedlist['items'] = array_merge($feedlist['items'], $cat['items']);
}
/* if (db_num_rows($result) == 0) {
if (!get_pref($link, 'ENABLE_FEED_CATS')) {
print "<li style='text-align : center'><a href=\"#\"
onclick=\"quickAddFeed()\">".
__('Subscribe to feed...')."</a></li>";
} else {
printCategoryHeader($link, -1, false, false, "Feeds");
print "<li><a href=\"#\"
onclick=\"quickAddFeed()\">".
__('Subscribe to feed...')."</a></li>";
print "</ul>";
}
} */
} else {
// tags
if (get_pref($link, 'ENABLE_FEED_CATS')) {
# print "<li class=\"feedCat\">".__('Tags')."</li>";
# print "<ul class=\"feedCatList\">";
}
$age_qpart = getMaxAgeSubquery();
$result = db_query($link, "SELECT tag_name,SUM((SELECT COUNT(int_id)
FROM ttrss_user_entries,ttrss_entries WHERE int_id = post_int_id
AND ref_id = id AND $age_qpart
AND unread = true)) AS count FROM ttrss_tags
WHERE owner_uid = ".$_SESSION['uid']." GROUP BY tag_name
ORDER BY count DESC LIMIT 50");
$tags = array();
while ($line = db_fetch_assoc($result)) {
$tags[$line["tag_name"]] += $line["count"];
}
foreach (array_keys($tags) as $tag) {
$unread = $tags[$tag];
$class = "tag";
# printFeedEntry($tag, $class, $tag, $unread, "images/tag.png", $link);
}
if (db_num_rows($result) == 0) {
# print "<li>No tags to display.</li>";
}
if (get_pref($link, 'ENABLE_FEED_CATS')) {
# print "</ul>";
}
}
# print "</ul>";
return $feedlist;
}

@ -635,8 +635,8 @@
print "<title>".__('Tag Cloud')."</title>";
print "<content><![CDATA[";
print __("Showing most popular tags ")." (<a
href='javascript:toggleTags(true)'>".__('more tags')."</a>):<br/>";
# print __("Showing most popular tags ")." (<a
# href='javascript:toggleTags(true)'>".__('more tags')."</a>):<br/>";
print "<div class=\"tagCloudContainer\">";

@ -211,22 +211,6 @@ input.editbox {
cursor : pointer;
}
#dispSwitch {
font-size : 12px;
font-family : "Lucida Grande", Arial, sans-serif;
text-align : right;
float : right;
margin : 5px 5px 0px 0px;
}
#dispSwitch a {
color : gray;
}
#dispSwitch a:hover {
color : #4684ff;
}
.even.Unread.Selected, .even.Unread.Selected td {
background-color : #fff7d5;
font-weight : bold;
@ -1519,3 +1503,9 @@ img.feedIcon {
max-width : 16px;
max-height : 16px;
}
div#feedlistLoading {
text-align : center;
padding : 5px;
color : gray;
}

@ -1,5 +1,4 @@
var total_unread = 0;
var display_tags = false;
var global_unread = -1;
var firsttime_update = true;
var _active_feed_id = 0;
@ -57,35 +56,7 @@ function isFeedlistSortable() {
}
function tagsAreDisplayed() {
return display_tags;
}
function toggleTags(show_all) {
try {
console.log("toggleTags: " + show_all + "; " + display_tags);
var p = $("dispSwitchPrompt");
if (!show_all && !display_tags) {
displayDlg("printTagCloud");
} else if (show_all) {
closeInfoBox();
display_tags = true;
p.innerHTML = __("display feeds");
notify_progress("Loading, please wait...", true);
updateFeedList();
} else if (display_tags) {
display_tags = false;
p.innerHTML = __("tag cloud");
notify_progress("Loading, please wait...", true);
updateFeedList();
}
} catch (e) {
exception_error("toggleTags", e);
}
return false;
}
function dlg_frefresh_callback(transport, deleted_feed) {
@ -100,6 +71,11 @@ function dlg_frefresh_callback(transport, deleted_feed) {
function updateFeedList() {
try {
// $("feeds-holder").innerHTML = "<div id=\"feedlistLoading\">" +
// __("Loading, please wait...") + "</div>";
Element.show("feedlistLoading");
if (dijit.byId("feedTree")) {
dijit.byId("feedTree").destroyRecursive();
}
@ -176,6 +152,11 @@ function updateFeedList() {
$("feeds-holder").appendChild(tree.domNode);
var tmph = dojo.connect(tree, 'onLoad', function() {
dojo.disconnect(tmph);
Element.hide("feedlistLoading");
});
tree.startup();
} catch (e) {
@ -234,13 +215,9 @@ function timeout() {
if (firsttime_update && !navigator.userAgent.match("Opera")) {
firsttime_update = false;
omode = "T";
} else {
if (display_tags) {
omode = "tl";
} else {
omode = "flc";
}
}
query_str = query_str + "&omode=" + omode;
@ -379,6 +356,10 @@ function quickMenuGo(opid) {
gotoPreferences();
}
if (opid == "qmcTagCloud") {
displayDlg("printTagCloud");
}
if (opid == "qmcSearch") {
displayDlg("search", getActiveFeedId() + ":" + activeFeedIsCat(),
function() {
@ -452,7 +433,7 @@ function quickMenuGo(opid) {
alert("Function not implemented");
}
if (opid == "qmcToggleReorder") {
/* if (opid == "qmcToggleReorder") {
feedlist_sortable_enabled = !feedlist_sortable_enabled;
if (feedlist_sortable_enabled) {
@ -462,7 +443,7 @@ function quickMenuGo(opid) {
notify_info("Category reordering disabled");
toggle_sortable_feedlist(false);
}
}
} */
if (opid == "qmcResetCats") {
@ -475,7 +456,7 @@ function quickMenuGo(opid) {
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
window.setTimeout('updateFeedList(false, false)', 50);
window.setTimeout('updateFeedList()', 50);
} });
}
}
@ -587,7 +568,7 @@ function editFeedDlg(feed) {
return;
}
if ((feed <= 0) || activeFeedIsCat() || tagsAreDisplayed()) {
if ((feed <= 0) || activeFeedIsCat()) {
alert(__("You can't edit this kind of feed."));
return;
}
@ -705,7 +686,7 @@ function rescoreCurrentFeed() {
var actid = getActiveFeedId();
if (activeFeedIsCat() || actid < 0 || tagsAreDisplayed()) {
if (activeFeedIsCat() || actid < 0) {
alert(__("You can't rescore this kind of feed."));
return;
}

@ -120,11 +120,10 @@
</div>
<div id="feeds-holder" dojoType="dijit.layout.ContentPane" region="leading" style="width : 20%" splitter="true">
<div id="dispSwitch">
<a id="dispSwitchPrompt"
href="javascript:toggleTags()"><?php echo __("tag cloud") ?></a>
</div>
<div id="feeds-frame"><div id="feedTree"></div></div>
<div id="feedlistLoading">
<img src='images/indicator_tiny.gif'>
<?php echo __("Loading, please wait..."); ?></div>
<div id="feedTree"></div>
</div>
<div dojoType="dijit.layout.BorderContainer" region="center" id="content-wrap">
@ -180,12 +179,13 @@
</optgroup>
<optgroup label="<?php echo __('Categories:') ?>">
<option value="qmcToggleReorder"><?php echo __('Toggle reordering mode') ?></option>
<!-- <option value="qmcToggleReorder"><?php echo __('Toggle reordering mode') ?></option> -->
<option value="qmcResetCats"><?php echo __('Reset order') ?></option>
</optgroup>
<optgroup label="<?php echo __('Other actions:') ?>">
<option value="qmcTagCloud"><?php echo __('Show tag cloud...') ?></option>
<option value="qmcAddLabel"><?php echo __('Create label...') ?></option>
<option value="qmcAddFilter"><?php echo __('Create filter...') ?></option>
<option value="qmcResetUI"><?php echo __('Reset UI layout') ?></option>

@ -2,9 +2,6 @@ var active_post_id = false;
var last_article_view = false;
var active_real_feed_id = false;
// FIXME: kludges, needs proper implementation
var _reload_feedlist_after_view = false;
var _cdm_wd_timeout = false;
var _cdm_wd_vishist = new Array();
@ -60,29 +57,6 @@ function headlines_callback2(transport, feed_cur_page) {
update_btn.disabled = !(feed_id >= 0 && !is_cat);
var ll = $('FLL-' + feed_id);
if (ll && ll.parentNode)
ll.parentNode.removeChild(ll);
if (!is_cat) {
var feedr = $("FEEDR-" + feed_id);
if (feedr) {
feedr.addClassName("Selected");
}
} else {
var feedr = $("FCAT-" + feed_id);
if (feedr) {
feedr.addClassName("Selected");
}
}
var img = $('FIMG-' + feed_id);
if (img && !is_cat) {
img.src = img.alt;
}
try {
if (feed_cur_page == 0) {
$("headlines-frame").scrollTop = 0;
@ -128,7 +102,7 @@ function headlines_callback2(transport, feed_cur_page) {
$("headlines-toolbar").innerHTML = headlines_toolbar.firstChild.nodeValue;
dojo.parser.parse("headlines-toolbar");
dijit.byId("main").resize();
//dijit.byId("main").resize();
var cache_prefix = "";
@ -326,11 +300,6 @@ function article_callback2(transport, id) {
if (!transport_error_check(transport)) return;
/* var ll = $('LL-' + id);
var content = $('HLC-' + id);
if (ll && content) content.removeChild(ll); */
var upic = $('FUPDPIC-' + id);
if (upic) {
@ -375,12 +344,7 @@ function article_callback2(transport, id) {
var date = new Date();
last_article_view = date.getTime() / 1000;
if (_reload_feedlist_after_view) {
setTimeout('updateFeedList(false, false)', 50);
_reload_feedlist_after_view = false;
} else {
request_counters();
}
notify("");
} catch (e) {
@ -1172,10 +1136,6 @@ function editTagsSave() {
closeInfoBox();
notify("");
if (tagsAreDisplayed()) {
_reload_feedlist_after_view = true;
}
if (transport.responseXML) {
var tags_str = transport.responseXML.getElementsByTagName("tags-str")[0];

Loading…
Cancel
Save