js: code cleanup

This commit is contained in:
Andrew Dolgov 2010-11-14 01:41:27 +03:00
parent 0526ffdd4c
commit 4ad8c93b95
3 changed files with 31 additions and 100 deletions

View File

@ -637,27 +637,22 @@ function init() {
} }
} }
function toggle_mark(mark_img, id) { function toggle_mark(img, id) {
try { try {
var query = "?op=rpc&id=" + id + "&subop=mark"; var query = "?op=rpc&id=" + id + "&subop=mark";
query = query + "&afid=" + _active_feed_id; if (!img) return;
query = query + "&omode=c";
if (!mark_img) return; if (img.src.match("mark_unset")) {
img.src = img.src.replace("mark_unset", "mark_set");
if (mark_img.src.match("mark_unset")) { img.alt = __("Unstar article");
mark_img.src = mark_img.src.replace("mark_unset", "mark_set");
mark_img.alt = __("Unstar article");
query = query + "&mark=1"; query = query + "&mark=1";
} else { } else {
mark_img.alt = __("Please wait..."); img.src = img.src.replace("mark_set", "mark_unset");
img.alt = __("Star article");
query = query + "&mark=0"; query = query + "&mark=0";
mark_img.src = mark_img.src.replace("mark_set", "mark_unset");
mark_img.alt = __("Star article");
} }
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
@ -671,35 +666,29 @@ function toggle_mark(mark_img, id) {
} }
} }
function toggle_pub(mark_img, id, note) { function toggle_pub(img, id, note) {
try { try {
var query = "?op=rpc&id=" + id + "&subop=publ"; var query = "?op=rpc&id=" + id + "&subop=publ";
query = query + "&afid=" + _active_feed_id;
if (note != undefined) { if (note != undefined) {
query = query + "&note=" + param_escape(note); query = query + "&note=" + param_escape(note);
} else { } else {
query = query + "&note=undefined"; query = query + "&note=undefined";
} }
query = query + "&omode=c"; if (!img) return;
if (!mark_img) return; if (img.src.match("pub_unset") || note != undefined) {
img.src = img.src.replace("pub_unset", "pub_set");
if (mark_img.src.match("pub_unset") || note != undefined) { img.alt = __("Unpublish article");
mark_img.src = mark_img.src.replace("pub_unset", "pub_set");
mark_img.alt = __("Unpublish article");
query = query + "&pub=1"; query = query + "&pub=1";
} else { } else {
mark_img.alt = __("Please wait..."); img.src = img.src.replace("pub_set", "pub_unset");
img.alt = __("Publish article");
query = query + "&pub=0"; query = query + "&pub=0";
mark_img.src = mark_img.src.replace("pub_set", "pub_unset");
mark_img.alt = __("Publish article");
} }
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {

View File

@ -210,14 +210,6 @@ function viewfeed(feed, subop, is_cat, offset) {
Form.enable("main_toolbar_form"); Form.enable("main_toolbar_form");
// for piggybacked counters
if (tagsAreDisplayed()) {
query = query + "&omode=lt";
} else {
query = query + "&omode=flc";
}
console.log(query); console.log(query);
var container = $("headlinesInnerContainer"); var container = $("headlinesInnerContainer");

View File

@ -417,14 +417,6 @@ function view(id) {
console.log("additional ids: " + cids_to_request.toString()); console.log("additional ids: " + cids_to_request.toString());
/* additional info for piggyback counters */
if (tagsAreDisplayed()) {
query = query + "&omode=lt";
} else {
query = query + "&omode=flc";
}
query = query + "&cids=" + cids_to_request.toString(); query = query + "&cids=" + cids_to_request.toString();
var crow = $("RROW-" + id); var crow = $("RROW-" + id);
@ -513,30 +505,17 @@ function tPub_afh_off(effect) {
} }
} }
function toggleMark(id, client_only, no_effects) { function toggleMark(id, client_only) {
try { try {
var query = "?op=rpc&id=" + id + "&subop=mark"; var query = "?op=rpc&id=" + id + "&subop=mark";
query = query + "&afid=" + getActiveFeedId(); var img = $("FMPIC-" + id);
if (tagsAreDisplayed()) { if (!img) return;
query = query + "&omode=tl";
} else {
query = query + "&omode=flc";
}
var mark_img = $("FMPIC-" + id); if (img.src.match("mark_unset")) {
img.src = img.src.replace("mark_unset", "mark_set");
if (!mark_img) return; img.alt = __("Unstar article");
var vfeedu = $("FEEDU--1");
var crow = $("RROW-" + id);
if (mark_img.src.match("mark_unset")) {
mark_img.src = mark_img.src.replace("mark_unset", "mark_set");
mark_img.alt = __("Unstar article");
query = query + "&mark=1"; query = query + "&mark=1";
if (db) { if (db) {
@ -544,29 +523,23 @@ function toggleMark(id, client_only, no_effects) {
} }
} else { } else {
mark_img.alt = __("Please wait..."); img.src = img.src.replace("mark_set", "mark_unset");
img.alt = __("Star article");
query = query + "&mark=0"; query = query + "&mark=0";
mark_img.src = mark_img.src.replace("mark_set", "mark_unset");
mark_img.alt = __("Star article");
if (db) { if (db) {
db.execute("UPDATE articles SET marked = 0 WHERE id = ?", [id]); db.execute("UPDATE articles SET marked = 0 WHERE id = ?", [id]);
} }
} }
if (!no_effects) update_local_feedlist_counters(); update_local_feedlist_counters();
if (!client_only) { if (!client_only) {
//console.log(query);
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
handle_rpc_reply(transport); handle_rpc_reply(transport);
} }); } });
} }
} catch (e) { } catch (e) {
@ -575,44 +548,29 @@ function toggleMark(id, client_only, no_effects) {
} }
function togglePub(id, client_only, no_effects, note) { function togglePub(id, client_only, no_effects, note) {
try { try {
var query = "?op=rpc&id=" + id + "&subop=publ"; var query = "?op=rpc&id=" + id + "&subop=publ";
query = query + "&afid=" + getActiveFeedId();
if (note != undefined) { if (note != undefined) {
query = query + "&note=" + param_escape(note); query = query + "&note=" + param_escape(note);
} else { } else {
query = query + "&note=undefined"; query = query + "&note=undefined";
} }
if (tagsAreDisplayed()) { var img = $("FPPIC-" + id);
query = query + "&omode=tl";
} else {
query = query + "&omode=flc";
}
var mark_img = $("FPPIC-" + id); if (!img) return;
if (!mark_img) return; if (img.src.match("pub_unset") || note != undefined) {
img.src = img.src.replace("pub_unset", "pub_set");
var vfeedu = $("FEEDU--2"); img.alt = __("Unpublish article");
var crow = $("RROW-" + id);
if (mark_img.src.match("pub_unset") || note != undefined) {
mark_img.src = mark_img.src.replace("pub_unset", "pub_set");
mark_img.alt = __("Unpublish article");
query = query + "&pub=1"; query = query + "&pub=1";
} else { } else {
mark_img.alt = __("Please wait..."); img.src = img.src.replace("pub_set", "pub_unset");
img.alt = __("Publish article");
query = query + "&pub=0"; query = query + "&pub=0";
mark_img.src = mark_img.src.replace("pub_set", "pub_unset");
mark_img.alt = __("Publish article");
} }
if (!client_only) { if (!client_only) {
@ -1012,10 +970,6 @@ function selectionToggleMarked() {
var query = "?op=rpc&subop=markSelected&ids=" + var query = "?op=rpc&subop=markSelected&ids=" +
param_escape(rows.toString()) + "&cmode=2"; param_escape(rows.toString()) + "&cmode=2";
query = query + "&afid=" + getActiveFeedId();
query = query + "&omode=lc";
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {
@ -1048,10 +1002,6 @@ function selectionTogglePublished() {
var query = "?op=rpc&subop=publishSelected&ids=" + var query = "?op=rpc&subop=publishSelected&ids=" +
param_escape(rows.toString()) + "&cmode=2"; param_escape(rows.toString()) + "&cmode=2";
query = query + "&afid=" + getActiveFeedId();
query = query + "&omode=lc";
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: query, parameters: query,
onComplete: function(transport) { onComplete: function(transport) {