]> git.wh0rd.org - tt-rss.git/blobdiff - functions.js
notifier: fix icons; support single-user mode
[tt-rss.git] / functions.js
index f0135f76a5b62bef04650fb0ade8ceb894f07520..ff35961e86e76cef96b158dec850170d81af5260 100644 (file)
@@ -162,13 +162,13 @@ function notify_real(msg, no_hide, n_type) {
                n.className = "notify";
        } else if (n_type == 2) {
                n.className = "notifyProgress";
-               msg = "<img src='images/indicator_white.gif'> " + msg;
+               msg = "<img src='"+getInitParam("sign_progress")+"'> " + msg;
        } else if (n_type == 3) {
                n.className = "notifyError";
-               msg = "<img src='images/sign_excl.gif'> " + msg;
+               msg = "<img src='"+getInitParam("sign_excl")+"'> " + msg;
        } else if (n_type == 4) {
                n.className = "notifyInfo";
-               msg = "<img src='images/sign_info.gif'> " + msg;
+               msg = "<img src='"+getInitParam("sign_info")+"'> " + msg;
        }
 
 //     msg = "<img src='images/live_com_loading.gif'> " + msg;
@@ -356,39 +356,6 @@ function getCookie(name) {
        return unescape(dc.substring(begin + prefix.length, end));
 }
 
-function disableContainerChildren(id, disable, doc) {
-
-       if (!doc) doc = document;
-
-       var container = $(id);
-
-       if (!container) {
-               //alert("disableContainerChildren: element " + id + " not found");
-               return;
-       }
-
-       for (var i = 0; i < container.childNodes.length; i++) {
-               var child = container.childNodes[i];
-
-               try {
-                       child.disabled = disable;
-               } catch (E) {
-
-               }
-
-               if (disable) {
-                       if (child.className && child.className.match("button")) {
-                               child.className = "disabledButton";
-                       }
-               } else {
-                       if (child.className && child.className.match("disabledButton")) {
-                               child.className = "button";
-                       }
-               } 
-       }
-
-}
-
 function gotoPreferences() {
        document.location.href = "prefs.php";
 }
@@ -526,7 +493,8 @@ function parse_counters(reply, scheduled_call) {
                                                
                                        }
 
-                                       if (row_needs_hl) { 
+                                       if (row_needs_hl && 
+                                                       !getInitParam("theme_options").match('no_highlights')) { 
                                                new Effect.Highlight(feedr, {duration: 1, startcolor: "#fff7d5",
                                                        queue: { position:'end', scope: 'EFQ-' + id, limit: 1 } } );
 
@@ -1115,7 +1083,6 @@ function getRelativeFeedId2(id, is_cat, direction, unread_only) {
        }
 }
 
-
 function getRelativeFeedId(list, id, direction, unread_only) { 
        var rows = list.getElementsByTagName("LI");
        var feeds = new Array();
@@ -1265,7 +1232,7 @@ function closeInfoBox(cleanup) {
                        Element.hide("dialog_overlay");
                        Element.hide("infoBoxShadow");
 
-                       if (cleanup) $("infoBoxShadow").innerHTML = "&nbsp;";
+                       if (cleanup) $("infoBox").innerHTML = "&nbsp;";
                }
        } catch (e) {
                exception_error("closeInfoBox", e);
@@ -1860,130 +1827,9 @@ function remove_splash() {
        }
 }
 
-function addLabelExample() {
-       try {
-               var form = document.forms["label_edit_form"];
-
-               var text = form.sql_exp;
-               var op = form.label_fields[form.label_fields.selectedIndex];
-               var p = form.label_fields_param;
-
-               if (op) {
-                       op = op.value;
-
-                       var tmp = "";
-
-                       if (text.value != "") {                 
-                               if (text.value.substring(text.value.length-3, 3).toUpperCase() != "AND") {
-                                       tmp = " AND ";
-                               } else {
-                                       tmp = " ";
-                               }
-                       }
-
-                       if (op == "unread") {
-                               tmp = tmp + "unread = true";
-                       }
-
-                       if (op == "updated") {
-                               tmp = tmp + "last_read is null and unread = false";
-                       }
-
-                       if (op == "kw_title") {
-                               if (p.value == "") {
-                                       alert("This action requires a parameter.");
-                                       return false;
-                               }
-                               tmp = tmp + "ttrss_entries.title like '%"+p.value+"%'";
-                       }
-
-                       if (op == "kw_content") {
-                               if (p.value == "") {
-                                       alert("This action requires a parameter.");
-                                       return false;
-                               }
-
-                               tmp = tmp + "ttrss_entries.content like '%"+p.value+"%'";
-                       }
-
-                       if (op == "scoreE") {
-                               if (isNaN(parseInt(p.value))) {
-                                       alert("This action expects numeric parameter.");
-                                       return false;
-                               }
-                               tmp = tmp + "score = " + p.value;
-                       }
-
-                       if (op == "scoreG") {
-                               if (isNaN(parseInt(p.value))) {
-                                       alert("This action expects numeric parameter.");
-                                       return false;
-                               }
-                               tmp = tmp + "score > " + p.value;
-                       }
-
-                       if (op == "scoreL") {
-                               if (isNaN(parseInt(p.value))) {
-                                       alert("This action expects numeric parameter.");
-                                       return false;
-                               }
-                               tmp = tmp + "score < " + p.value;
-                       }
-
-                       if (op == "newerD") {
-                               if (isNaN(parseInt(p.value))) {
-                                       alert("This action expects numeric parameter.");
-                                       return false;
-                               }
-                               tmp = tmp + "updated > NOW() - INTERVAL '"+parseInt(p.value)+" days'";
-                       }
-
-                       if (op == "newerH") {
-                               if (isNaN(parseInt(p.value))) {
-                                       alert("This action expects numeric parameter.");
-                                       return false;
-                               }
-
-                               tmp = tmp + "updated > NOW() - INTERVAL '"+parseInt(p.value)+" hours'";
-                       }
-
-                       text.value = text.value + tmp;
-
-                       p.value = "";
-
-               }
-               
-       } catch (e) {
-               exception_error("addLabelExample", e);
-       }
-
-       return false;
-}
-
-function labelFieldsCheck(elem) {
-       try {
-               var op = elem[elem.selectedIndex].value;
-
-               var p = document.forms["label_edit_form"].label_fields_param;
-
-               if (op == "kw_title" || op == "kw_content" || op == "scoreL" || 
-                               op == "scoreG" ||       op == "scoreE" || op == "newerD" ||
-                               op == "newerH" ) {
-                       Element.show(p);
-               } else {
-                       Element.hide(p);
-               }
-
-       } catch (e) {
-               exception_error("labelFieldsCheck", e);
-
-       }
-}
-
 function getSelectedFeedsFromBrowser() {
 
        var list = $("browseFeedList");
-       if (!list) list = $("browseBigFeedList");
 
        var selected = new Array();
        
@@ -2040,28 +1886,6 @@ function updateFeedBrowser() {
 
 }
 
-function browseFeeds(limit) {
-
-       try {
-
-/*             var query = "?op=ialog&subop=browse";
-
-               notify_progress("Loading, please wait...", true);
-
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) { 
-                               infobox_callback2(transport);
-                       } }); */
-
-               displayDlg('feedBrowser');
-
-               return false;
-       } catch (e) {
-               exception_error("browseFeeds", e);
-       }
-}
-
 function transport_error_check(transport) {
        try {
                if (transport.responseXML) {
@@ -2093,43 +1917,6 @@ function truncate_string(s, length) {
        return tmp;
 }
 
-/*
-function switchToFlash(e) {
-       try {
-               var targ = e;
-               if (!e) var e = window.event;
-               if (e.target) targ = e.target;
-               else if (e.srcElement) targ = e.srcElement;
-               if (targ.nodeType == 3) // defeat Safari bug
-                       targ = targ.parentNode;
-               
-               //targ is the link that was clicked
-               var audioTag=targ;
-               do {
-                       audioTag=audioTag.previousSibling;
-               } while(audioTag && audioTag.nodeType != 1)
-               
-               var flashPlayer = audioTag.getElementsByTagName('span')[0];
-               targ.parentNode.insertBefore(flashPlayer,targ);
-               targ.parentNode.removeChild(targ);
-               audioTag.parentNode.removeChild(audioTag);
-
-               return false;
-       } catch (e) {
-               exception_error("switchToFlash", e);
-       }
-}
-
-function html5AudioOrFlash(type) {
-       var audioTag = document.createElement('audio');
-       if(! audioTag.canPlayType || audioTag.canPlayType(type) == "no" ||
-                       audioTag.canPlayType(type) == ""){
-               if($('switchToFlashLink')){
-                       switchToFlash($('switchToFlashLink'));
-               }
-       }
-} */
-
 function hotkey_prefix_timeout() {
        try {
 
@@ -2248,15 +2035,56 @@ function feedArchiveRemove() {
        }
 }
 
-function uploadIconHandler(iframe) {
+function uploadIconHandler(rc) {
        try {
-               notify_info("Icon changed!");
+               switch (rc) {
+                       case 0:
+                               notify_info("Upload complete.");
+                               if (inPreferences()) {
+                                       updateFeedList();
+                               } else {
+                                       setTimeout('updateFeedList(false, false)', 50);
+                               }
+                               break;
+                       case 1:
+                               notify_error("Upload failed: icon is too big.");
+                               break;
+                       case 2:
+                               notify_error("Upload failed.");
+                               break;
+               }
 
-               alert("Icon changed, blah blah");
+       } catch (e) {
+               exception_error("uploadIconHandler", e);
+       }
+}
+
+function removeFeedIcon(id) {
+
+       try {
+
+               if (confirm(__("Remove stored feed icon?"))) {
+                       var query = "backend.php?op=pref-feeds&subop=removeicon&feed_id=" + param_escape(id);
+
+                       debug(query);
 
+                       notify_progress("Removing feed icon...", true);
+
+                       new Ajax.Request("backend.php", {
+                               parameters: query,
+                               onComplete: function(transport) { 
+                                       notify_info("Feed icon removed.");
+                                       if (inPreferences()) {
+                                               updateFeedList();
+                                       } else {
+                                               setTimeout('updateFeedList(false, false)', 50);
+                                       }
+                               } }); 
+               }
 
+               return false;
        } catch (e) {
-               exception_error("uploadIconHandler", e);
+               exception_error("uploadFeedIcon", e);
        }
 }
 
@@ -2268,14 +2096,93 @@ function uploadFeedIcon() {
 
                if (file.value.length == 0) {
                        alert(__("Please select an image file to upload."));
-                       return false;
                } else {
-                       notify_progress("Uploading, please wait...", true);
-                       return true;
+                       if (confirm(__("Upload new icon for this feed?"))) {
+                               notify_progress("Uploading, please wait...", true);
+                               return true;
+                       }
                }
 
+               return false;
+
        } catch (e) {
                exception_error("uploadFeedIcon", e);
        }
 }
 
+function addLabel() {
+
+       try {
+
+               var caption = prompt(__("Please enter label caption:"), "");
+
+               if (caption != undefined) {
+       
+                       if (caption == "") {
+                               alert(__("Can't create label: missing caption."));
+                               return false;
+                       }
+
+                       var query = "?op=pref-labels&subop=add&caption=" + 
+                               param_escape(caption);
+
+                       notify_progress("Loading, please wait...", true);
+
+                       if (inPreferences()) active_tab = "labelConfig";
+
+                       new Ajax.Request("backend.php", {
+                               parameters: query,
+                               onComplete: function(transport) { 
+                                       if (inPreferences()) {
+                                               infobox_submit_callback2(transport);
+                                       } else {
+                                               updateFeedList();
+                                       }
+                       } });
+
+               }
+
+       } catch (e) {
+               exception_error("addLabel", e);
+       }
+}
+
+function quickAddFeed() {
+       displayDlg('quickAddFeed', '',
+          function () {$('feed_url').focus();});
+}
+
+function quickAddFilter() {
+       displayDlg('quickAddFilter', '',
+          function () {document.forms['filter_add_form'].reg_exp.focus();});
+}
+
+function unsubscribeFeed(feed_id, title) {
+
+       var msg = __("Unsubscribe from %s?").replace("%s", title);
+
+       if (title == undefined || confirm(msg)) {
+               notify_progress("Removing feed...");
+
+               var query = "?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id;
+
+               new Ajax.Request("backend.php", {
+                       parameters: query,
+                       onComplete: function(transport) {
+
+                                       closeInfoBox();
+
+                                       if (inPreferences()) {
+                                               updateFeedList();                               
+                                       } else {
+                                               dlg_frefresh_callback(transport, feed_id);
+                                       }
+
+                               } });
+       }
+
+       return false;
+}
+
+
+