/[drupal]/contributions/modules/commentify/commentify.js
ViewVC logotype

Contents of /contributions/modules/commentify/commentify.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1.1.1 - (show annotations) (download) (as text) (vendor branch)
Sat Mar 15 22:13:18 2008 UTC (20 months, 1 week ago) by chrisyates
Branch: DRUPAL-5, MAIN
CVS Tags: start, DRUPAL-5--1-1, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/javascript
Initial import of commentify.module
1 function commentify(site, fid) {
2 var stylepath = 'http://dev1.lowcountrynewspapers.com/sites/dev1.lowcountrynewspapers.com/modules/commentify/';
3 var imagepath = 'http://dev1.lowcountrynewspapers.com/sites/dev1.lowcountrynewspapers.com/modules/commentify/images/';
4
5 // Some customization is required here. Change the first element to your target for displaying the comments list
6 $("#commentcontainer").append('<div id="comments"><span><img id="togglecomments" src="' + imagepath + 'minus.png" title="show/hide comments"/> Comment on this</span></div>');
7 $("head").append('<link rel="stylesheet" href="' + stylepath + 'comments.css" type="text/css" media="screen" title="no title" charset="utf-8" />');
8 $.getJSON(site + "/" + fid + "&callback=?",
9 function(data){
10
11 $.each(data.comments, function(i,comment){
12 var box = $("<div></div>").appendTo("#comments");
13 $('<p></p>').text(comment.comment.replace(/(<([^>]+)>)/ig,"")).appendTo(box);
14 $('<div class="subj"></div>').text((i+1) + ") " + comment.subject).prependTo(box.find("p"));
15 var cdate = new Date();
16 cdate.setTime(comment.timestamp*1000);
17 $('<div></div>').html('Posted by <a href="' + data.url.replace(/story.*/,"user/") + comment.name + '">' + comment.name + '</a>, ' + cdate.toLocaleString() ).addClass("info").appendTo(box);
18 });
19
20 // Uncomment the following if you have jquery cookie plugin
21
22 // if($.cookie('showinlinecomments') == 0){
23 // $("#comments > *:gt(0)").hide();
24 // $("#comments span img").attr("src",imagepath + "plus.png");
25 // }
26
27 // Again with the changes. #commentcounter element is where to display count
28 $("<a>").attr('href','#comments').text('(0) Comments').appendTo("#commentcounter");
29
30 if (data.count > 0) {
31 $("#comments span").append(" (Showing " + data.comments.length + " of " + data.count +")");
32 $("#commentcounter a").text('('+data.count+') Comments');
33 $("#comments").append('<div class="tools"><a href="' + data.url.replace(/node/,"comment/reply") + '">Add your own comment</a> (Free Registration Required) | <a href="' + data.url + '">View all</a></div>');
34 } else {
35 $("#comments").append('<div class="tools"><a href="javascript:document.commentform.submit();">No comments yet, be the first</a></div>');
36 }
37 }
38 );
39 $('#comments span').toggle(
40 function(){
41 $("#comments > *:gt(0)").slideUp();
42 $("#comments span img").attr("src",imagepath + "plus.png");
43 // $.cookie('showinlinecomments',0,{ expires: 365 });
44 },
45 function(){
46 $("#comments > *:gt(0)").slideDown();
47 $("#comments span img").attr("src",imagepath + "minus.png");
48 // $.cookie('showinlinecomments',1,{ expires: 365 });
49 }
50 );
51
52 }

  ViewVC Help
Powered by ViewVC 1.1.2