Permalink
Browse files

discussion2 upgrade for loading/complete handlers

  • Loading branch information...
1 parent 725b7dd commit fcc0093650c048712c2d8e951bd064d093107fdb @pudge pudge committed Apr 20, 2006
View
@@ -1833,7 +1833,7 @@ sub _hard_dispComment {
subject_only => 1,
}, 1);
}
- $comment_to_display .= qq'<div id="comment_shrunk_$comment->{cid}" class="shrunk">$link</div>';
+ $comment_to_display .= qq'<div id="comment_shrunk_$comment->{cid}" class="commentshrunk">$link</div>';
}
$time_to_display = timeCalc($comment->{date});
@@ -1947,6 +1947,7 @@ EOT2
my $return = <<EOT;
<li id="tree_$comment->{cid}" class="comment">
+<div id="comment_status_$comment->{cid}" class="commentstatus"></div>
<div id="comment_$comment->{cid}"$classattr>
<div class="commentTop">
<div class="title">
@@ -236,7 +236,14 @@ ()
sub readRest {
my($slashdb, $constants, $user, $form) = @_;
my $cid = $form->{cid} or return;
- return $slashdb->getCommentText($cid);
+
+ my $comment = $slashdb->getComment($cid) or return;
+ my $texts = $slashdb->getCommentTextCached(
+ { $cid => $comment },
+ [ $cid ],
+ { cid => $cid }
+ ) or return;
+ return $texts->{$cid} || '';
}
@@ -266,83 +266,30 @@ function tagsCreateForUrl(id) {
}
// helper functions
-function ajax_eval(params, onsucc, onfail, url) {
+function ajax_update(params, onsucc, options, url) {
var h = $H(params);
- if (!url) {
+
+ if (!url)
url = '/ajax.pl';
- }
-
- var ajax = new Ajax.Updater(
- {
- success: onsucc,
- failure: onfail
- },
- url,
- {
- method: 'post',
- parameters: h.toQueryString(),
- evalScripts: 1
- }
- );
-}
+ if (!options)
+ options = {};
+
+ options.method = 'post';
+ options.parameters = h.toQueryString();
-function ajax_update(params, onsucc, onfail, url) {
- var h = $H(params);
- if (!url) {
- url = '/ajax.pl';
- }
-
var ajax = new Ajax.Updater(
- {
- success: onsucc,
- failure: onfail
- },
+ { success: onsucc },
url,
- {
- method: 'post',
- parameters: h.toQueryString()
- }
+ options
);
}
-// function ajax_update_sync(params, onsucc, onfail, url) {
-// var h = $H(params);
-// if (!url) {
-// url = '/ajax.pl';
-// }
-//
-// var ajax = new Ajax.Updater(
-// {
-// success: onsucc,
-// failure: onfail
-// },
-// url,
-// {
-// method: 'post',
-// parameters: h.toQueryString(),
-// asynchronous: false
-// }
-// );
-// }
-
-function ajax_periodic_update(secs, params, onsucc, onfail, url) {
- var h = $H(params);
- if (!url) {
- url = '/ajax.pl';
- }
-
- var ajax = new Ajax.PeriodicalUpdater(
- {
- success: onsucc,
- failure: onfail
- },
- url,
- {
- method: 'post',
- parameters: h.toQueryString(),
- frequency: secs
- }
- );
-}
+function ajax_periodic_update(secs, params, onsucc, options, url) {
+ if (!options)
+ options = {};
+
+ options.frequency = secs;
+ ajax_update(params, onsucc, options, url);
+}
@@ -79,7 +79,8 @@ html > body .commentwrap table {
padding: .3em;
}
-.shrunk { font-weight: bold }
+.commentshrunk { font-weight: bold }
+.commentstatus { font-weight: bold }
#commentlisting {
@@ -164,9 +164,14 @@ function refreshCommentDisplays() {
function setFocusComment(cid) {
var abscid = Math.abs(cid);
+ var statusdiv = $('comment_status_' + abscid);
+ statusdiv.innerHTML = 'Working ...';
+
refreshDisplayModes(cid);
updateCommentTree(abscid);
+ statusdiv.innerHTML = '';
+
var comment_y = getOffsetTop($("comment_"+abscid));
var newcomment_y = getOffsetTop($("comment_"+abscid));
if (comment_y != newcomment_y) {
@@ -234,25 +239,30 @@ function viewWindowBottom() {
function readRest(cid) {
- var sigdiv = $('comment_sig_' + cid);
- if (sigdiv) {
- sigdiv.className = 'sig';
- }
-
var shrunkdiv = $('comment_shrunk_' + cid);
- if (shrunkdiv) {
- shrunkdiv.innerHTML = '';
- } else {
+ if (!shrunkdiv) {
return false; // seems we shouldn't be here ...
}
var params = [];
params['op'] = 'comments_read_rest';
params['cid'] = cid;
- ajax_update(params, 'comment_body_' + cid);
+ var handlers = {
+ onLoading: function() {
+ shrunkdiv.innerHTML = 'Loading...';
+ },
+ onComplete: function() {
+ shrunkdiv.innerHTML = '';
+ var sigdiv = $('comment_sig_' + cid);
+ if (sigdiv) {
+ sigdiv.className = 'sig'; // show
+ }
+ }
+ };
+
+ ajax_update(params, 'comment_body_' + cid, handlers);
return false;
}
-
@@ -239,7 +239,7 @@ function getComments(sid, element) {
var params = [];
params['op'] = 'get_comments';
params['sid'] = sid;
- ajax_eval(params, '', '', 'http://use.perl.org/ajax.pl');
+ ajax_update(params, '', { evalScripts: 1 }, 'http://use.perl.org/ajax.pl');
}
function randomizeBehaviors(ctype) {
@@ -24,6 +24,7 @@ dispComment
__template__
[% discussion2 = user.discussion2 && (user.discussion2 == "slashdot" || user.discussion2 == "uofm") %]
<li id="tree_[% cid %]" class="comment">
+<div id="comment_status_[% cid %]" class="commentstatus"></div>
<div id="comment_[% cid %]"[% IF discussion2 %] class="[% class %]"[% END %]>
<div class="commentTop">
<div class="title">
@@ -82,7 +83,7 @@ __template__
subject_only => 1
}, 1);
END %]
- <div id="comment_shrunk_[% cid %]" class="shrunk">[% linkComment %]</div>
+ <div id="comment_shrunk_[% cid %]" class="commentshrunk">[% linkComment %]</div>
[% END %]
</div>
[% PROCESS dispLinkComment %]

0 comments on commit fcc0093

Please sign in to comment.