]> git.wh0rd.org - tt-rss.git/blobdiff - functions.js
notifier: fix icons; support single-user mode
[tt-rss.git] / functions.js
index 7a43212dce3c76dad0fe1765b723453fd913ff40..ff35961e86e76cef96b158dec850170d81af5260 100644 (file)
@@ -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,8 +493,8 @@ function parse_counters(reply, scheduled_call) {
                                                
                                        }
 
-                                       if (row_needs_hl && getInitParam("theme") != 'neon' &&
-                                                       getInitParam("theme") != 'lejla') { 
+                                       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 } } );
 
@@ -1116,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();
@@ -1266,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);
@@ -1861,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();
        
@@ -2041,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) {
@@ -2094,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 {
 
@@ -2324,3 +2110,79 @@ function uploadFeedIcon() {
        }
 }
 
+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;
+}
+
+
+