summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-02-28 09:37:52 +0400
committerAndrew Dolgov <[email protected]>2013-02-28 09:37:52 +0400
commit271edfa6f9ac8ad387f98693a6c09496ddf72f1f (patch)
treebe105dbcf4c8316c24931de5263b4d7c48d21a0a
parent81d5b6e9ef3c7912e157d9338ae7b07133b57539 (diff)
parent350e3944d49ad26802e27e64057212d88c4d0bf9 (diff)
Merge branch 'master' of github.com:gothfox/Tiny-Tiny-RSS
-rw-r--r--backend.php2
-rw-r--r--classes/backend.php35
-rw-r--r--classes/feeds.php4
-rw-r--r--classes/pref/feeds.php2
-rw-r--r--classes/pref/prefs.php5
-rw-r--r--include/functions.php13
-rw-r--r--js/feedlist.js2
-rw-r--r--js/tt-rss.js6
-rw-r--r--js/viewfeed.js57
-rw-r--r--public.php2
10 files changed, 82 insertions, 46 deletions
diff --git a/backend.php b/backend.php
index 98b76450f..41481a963 100644
--- a/backend.php
+++ b/backend.php
@@ -47,7 +47,7 @@
startup_gettext();
- $script_started = getmicrotime();
+ $script_started = microtime(true);
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
diff --git a/classes/backend.php b/classes/backend.php
index 0b6e6bd30..d9a7a9fec 100644
--- a/classes/backend.php
+++ b/classes/backend.php
@@ -23,16 +23,10 @@ class Backend extends Handler {
$imap = get_hotkeys_map($this->link);
$omap = array();
- // :(
- $tinycharmap = array(
- "(9)" => "{TAB}",
- "(191)" => "?");
-
foreach ($imap[1] as $sequence => $action) {
- if (!isset($omap[$action])) {
- $omap[$action] = isset($tinycharmap[$sequence]) ? $tinycharmap[$sequence] :
- $sequence;
- }
+ if (!isset($omap[$action])) $omap[$action] = array();
+
+ array_push($omap[$action], $sequence);
}
print "<ul class='helpKbList' id='helpKbList'>";
@@ -44,18 +38,21 @@ class Backend extends Handler {
print "<li><h3>" . $section . "</h3></li>";
foreach ($hotkeys as $action => $description) {
- if (strpos($omap[$action], "|") !== FALSE) {
- $omap[$action] = substr($omap[$action],
- strpos($omap[$action], "|")+1,
- strlen($omap[$action]));
- }
- print "<li>";
- print "<span class='hksequence'>" . $omap[$action] . "</span>";
- print $description;
- print "</li>";
- }
+ foreach ($omap[$action] as $sequence) {
+ if (strpos($sequence, "|") !== FALSE) {
+ $sequence = substr($sequence,
+ strpos($sequence, "|")+1,
+ strlen($sequence));
+ }
+
+ print "<li>";
+ print "<span class='hksequence'>$sequence</span>";
+ print $description;
+ print "</li>";
+ }
+ }
}
print "</ul>";
diff --git a/classes/feeds.php b/classes/feeds.php
index de001d568..886470e90 100644
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -152,7 +152,7 @@ class Feeds extends Handler_Protected {
$reply = array();
- $timing_info = getmicrotime();
+ $timing_info = microtime(true);
$topmost_article_ids = array();
@@ -750,7 +750,7 @@ class Feeds extends Handler_Protected {
}
function view() {
- $timing_info = getmicrotime();
+ $timing_info = microtime(true);
$reply = array();
diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php
index da8d68ba1..2ed7b1b24 100644
--- a/classes/pref/feeds.php
+++ b/classes/pref/feeds.php
@@ -437,6 +437,8 @@ class Pref_Feeds extends Handler_Protected {
}
function uploadicon() {
+ header("Content-type: text/html");
+
$icon_file = $_FILES['icon_file']['tmp_name'];
$feed_id = db_escape_string($_REQUEST["feed_id"]);
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php
index eb84bde99..810b1e164 100644
--- a/classes/pref/prefs.php
+++ b/classes/pref/prefs.php
@@ -824,7 +824,10 @@ class Pref_Prefs extends Handler_Protected {
}
function setplugins() {
- $plugins = join(",", $_REQUEST["plugins"]);
+ if (is_array($_REQUEST["plugins"]))
+ $plugins = join(",", $_REQUEST["plugins"]);
+ else
+ $plugins = "";
set_pref($this->link, "_ENABLED_PLUGINS", $plugins);
}
diff --git a/include/functions.php b/include/functions.php
index d6c73343e..8db72f56d 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -478,11 +478,6 @@
print "</select>";
}
- function getmicrotime() {
- list($usec, $sec) = explode(" ",microtime());
- return ((float)$usec + (float)$sec);
- }
-
function print_radio($id, $default, $true_is, $values, $attributes = "") {
foreach ($values as $v) {
@@ -1864,6 +1859,8 @@
"prev_feed" => __("Open previous feed"),
"next_article" => __("Open next article"),
"prev_article" => __("Open previous article"),
+ "next_article_noscroll" => __("Open next article (don't scroll long articles)"),
+ "prev_article_noscroll" => __("Open previous article (don't scroll long articles)"),
"search_dialog" => __("Show search dialog")),
__("Article") => array(
"toggle_mark" => __("Toggle starred"),
@@ -1924,6 +1921,8 @@
"p" => "prev_article",
"(38)|up" => "prev_article",
"(40)|down" => "next_article",
+ "^(38)|Ctrl-up" => "prev_article_noscroll",
+ "^(40)|Ctrl-down" => "next_article_noscroll",
"(191)|/" => "search_dialog",
// "article" => array(
"s" => "toggle_mark",
@@ -2796,7 +2795,7 @@
$id = 'AUDIO-' . uniqid();
- $entry .= "<audio id=\"$id\"\" controls>
+ $entry .= "<audio id=\"$id\"\" controls style='display : none'>
<source type=\"$ctype\" src=\"$url\"></source>
</audio>";
@@ -3065,7 +3064,7 @@
}
function print_checkpoint($n, $s) {
- $ts = getmicrotime();
+ $ts = microtime(true);
echo sprintf("<!-- CP[$n] %.4f seconds -->", $ts - $s);
return $ts;
}
diff --git a/js/feedlist.js b/js/feedlist.js
index 282e64b37..b2aadab62 100644
--- a/js/feedlist.js
+++ b/js/feedlist.js
@@ -227,7 +227,7 @@ function request_counters(force) {
var date = new Date();
var timestamp = Math.round(date.getTime() / 1000);
- if (force || timestamp - counters_last_request > 15) {
+ if (force || timestamp - counters_last_request > 5) {
console.log("scheduling request of counters...");
counters_last_request = timestamp;
diff --git a/js/tt-rss.js b/js/tt-rss.js
index 530cb2931..7462d933d 100644
--- a/js/tt-rss.js
+++ b/js/tt-rss.js
@@ -604,6 +604,12 @@ function hotkey_handler(e) {
case "prev_article":
moveToPost('prev');
return false;
+ case "next_article_noscroll":
+ moveToPost('next', true);
+ return false;
+ case "prev_article_noscroll":
+ moveToPost('prev', true);
+ return false;
case "search_dialog":
search();
return ;
diff --git a/js/viewfeed.js b/js/viewfeed.js
index 1cdfdba3f..b8dc05aed 100644
--- a/js/viewfeed.js
+++ b/js/viewfeed.js
@@ -325,7 +325,8 @@ function article_callback2(transport, id) {
Element.show(dijit.byId("net-alert").domNode);
}
- request_counters();
+ var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
+ request_counters(unread_in_buffer == 0);
headlines_scroll_handler($("headlines-frame"));
@@ -513,7 +514,7 @@ function togglePub(id, client_only, no_effects, note) {
}
}
-function moveToPost(mode) {
+function moveToPost(mode, noscroll) {
try {
@@ -548,13 +549,23 @@ function moveToPost(mode) {
}
if (mode == "next") {
- if (next_id) {
+ if (next_id || active_post_id) {
if (isCdmMode()) {
- cdmExpandArticle(next_id);
- cdmScrollToArticleId(next_id);
+ var article = $("RROW-" + active_post_id);
+ var ctr = $("headlines-frame");
- } else {
+ if (!noscroll && article && article.offsetTop + article.offsetHeight >
+ ctr.scrollTop + ctr.offsetHeight) {
+
+ scrollArticle(ctr.offsetHeight/2);
+
+ } else if (next_id) {
+ cdmExpandArticle(next_id);
+ cdmScrollToArticleId(next_id);
+ }
+
+ } else if (next_id) {
correctHeadlinesOffset(next_id);
view(next_id, getActiveFeedId());
}
@@ -562,11 +573,24 @@ function moveToPost(mode) {
}
if (mode == "prev") {
- if (prev_id) {
+ if (prev_id || active_post_id) {
if (isCdmMode()) {
- cdmExpandArticle(prev_id);
- cdmScrollToArticleId(prev_id);
- } else {
+
+ var article = $("RROW-" + active_post_id);
+ var prev_article = $("RROW-" + prev_id);
+ var ctr = $("headlines-frame");
+
+ if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
+ scrollArticle(-ctr.offsetHeight/2);
+ } else if (!noscroll && prev_article &&
+ prev_article.offsetTop < ctr.scrollTop) {
+ cdmExpandArticle(prev_id);
+ scrollArticle(-ctr.offsetHeight/2);
+ } else if (prev_id) {
+ cdmExpandArticle(prev_id);
+ cdmScrollToArticleId(prev_id);
+ }
+ } else if (prev_id) {
correctHeadlinesOffset(prev_id);
view(prev_id, getActiveFeedId());
}
@@ -1131,7 +1155,11 @@ function cdmScrollToArticleId(id) {
if (!e || !ctr) return;
- ctr.scrollTop = e.offsetTop;
+ if (e.offsetTop+e.offsetHeight > (ctr.scrollTop+ctr.offsetHeight) ||
+ e.offsetTop < ctr.scrollTop) {
+
+ ctr.scrollTop = e.offsetTop;
+ }
} catch (e) {
exception_error("cdmScrollToArticleId", e);
@@ -1330,12 +1358,12 @@ function cdmExpandArticle(id) {
Element.hide("CEXC-" + id);
}
- var new_offset = $("RROW-" + id).offsetTop;
+ /* var new_offset = $("RROW-" + id).offsetTop;
$("headlines-frame").scrollTop += (new_offset-old_offset);
if ($("RROW-" + id).offsetTop != old_offset)
- $("headlines-frame").scrollTop = new_offset;
+ $("headlines-frame").scrollTop = new_offset; */
toggleUnread(id, 0, true);
toggleSelected(id);
@@ -1550,7 +1578,8 @@ function cdmClicked(event, id) {
openArticleInNewWindow(id);
}
- request_counters();
+ var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
+ request_counters(unread_in_buffer == 0);
} catch (e) {
exception_error("cdmClicked");
diff --git a/public.php b/public.php
index 7138b3d81..dccd77f43 100644
--- a/public.php
+++ b/public.php
@@ -28,7 +28,7 @@
startup_gettext();
- $script_started = getmicrotime();
+ $script_started = microtime(true);
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);