Палсеич— (lusever) wrote in changelog,
Палсеич—
lusever
changelog

[livejournal] r19059: LJSUP-8748: FriendsTimes: update page na...

Committer: pkornilov
LJSUP-8748: FriendsTimes: update page navigation
U   trunk/htdocs/js/journal.js
Modified: trunk/htdocs/js/journal.js
===================================================================
--- trunk/htdocs/js/journal.js	2011-05-13 08:59:23 UTC (rev 19058)
+++ trunk/htdocs/js/journal.js	2011-05-13 10:29:02 UTC (rev 19059)
@@ -129,6 +129,55 @@
 	}
 }
 
+// Friends Times
+jQuery(function($) {
+	$("#friendstimes").each(function() {
+		var last_unreaded = +$(".b-friendstimes-f5 b").text() || 0,
+			$window = $(window)
+		setInterval(function() {
+			$.getJSON(LiveJournal.getAjaxUrl("ft_unreaded"), {
+				after: Site.server_time
+			}, function(data) {
+				if (data.unreaded) {
+					$(".b-friendstimes-f5")
+						.show()
+						.find("b").text(data.unreaded);
+				}
+			});
+		}, 5000);
+
+		var more_node = $(".b-friendstimes-loading"),
+			skip = +LiveJournal.parseGetArgs(location.search) || 0;
+		function loading_more() {
+			if (more_node.offset().top <= ($window.scrollTop() + $window.height())) {
+				$window.unbind("scroll", loading_more);
+				jQuery.ajax({
+					url: LiveJournal.getAjaxUrl("ft_more"),
+					data: {
+						skip: skip + 20
+					},
+					dataType: 'html',
+					success: function(html) {
+						if (html) {
+							skip += 20;
+							more_node.before(html);
+							$window.scroll(loading_more);
+						} else {
+							more_node.remove();
+						}
+					},
+					error: function() {
+						// retry
+						setTimeout(loading_more, 5000);
+					}
+				});
+			}
+		}
+		
+		$window.scroll(loading_more);
+	});
+});
+
 // Share at some S2 styles
 jQuery(document).click(function(e)
 {

Tags: js, livejournal, lusever
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments