author | amit |
Fri, 15 Oct 2010 15:59:28 +0530 | |
changeset 2 | f5e18f8ed036 |
parent 0 | 54f784230511 |
permissions | -rw-r--r-- |
0
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
1 |
function qid(id) { |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
2 |
return id.replace(/([.:])/g, "\\$1"); |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
3 |
} |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
4 |
|
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
5 |
function beforeComment(formData, jqForm, options) { |
2
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
6 |
var form=jqForm[0]; |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
7 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
8 |
if (form.comment.textLength.toString()=='0') { |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
9 |
$("span.comment_error").empty().append( |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
10 |
"<span class=\"comment_error\"> Your comment is empty</span>"); |
0
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
11 |
return false; |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
12 |
} |
2
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
13 |
if (form.name.textLength.toString()=='0') { |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
14 |
$("span.comment_error").empty().append( |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
15 |
"<span class=\"comment_error\"> Please provide a name</span>"); |
0
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
16 |
return false; |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
17 |
} |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
18 |
$(options.target + " span.comment_error").empty().after( |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
19 |
"<img src=\"/support/icons/throbber.gif\" style=\"vertical-align: middle\"/>"); |
2
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
20 |
$("input[@name=submit]").attr("disabled", true); |
0
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
21 |
} |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
22 |
|
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
23 |
function ajaxifyForm(id) { |
2
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
24 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
25 |
// $('#form_func_1').replaceWith('something'); |
0
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
26 |
|
2
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
27 |
var substring=id.substr(9); |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
28 |
$('#form_'+substring).ajaxForm({beforeSubmit: beforeComment, |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
29 |
success: function(){ loadComments(id);} |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
30 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
31 |
});} |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
32 |
|
0
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
33 |
|
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
34 |
function toggleComment(id) { |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
35 |
$("#toggle_" + qid(id)).nextAll().toggle(); |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
36 |
return false; |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
37 |
} |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
38 |
|
2
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
39 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
40 |
function loadComments(id) |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
41 |
{ |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
42 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
43 |
var substring=id.substr(9); |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
44 |
$('#comments_'+substring).load("http://127.0.0.1:8000/single/"+ substring +'/',function() { ajaxifyForm(id);} |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
45 |
); |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
46 |
|
0
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
47 |
} |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
48 |
|
2
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
49 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
50 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
51 |
|
0
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
52 |
function loadAllComments() { |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
53 |
$("a.commenttoggle").each(function() { |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
54 |
var id = $(this).attr("pid"); |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
55 |
if (id) { |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
56 |
loadComments(id); |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
57 |
} |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
58 |
}); |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
59 |
} |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
60 |
|
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
61 |
|
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
62 |
|
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
63 |
$(document).ready(function() { |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
64 |
function loading(id) { |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
65 |
return " <span id=\"comments_" + id + "\" class=\"comment\">" + |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
66 |
"<span pid=\"" + id + "\" class=\"commenttoggle\"><p>Loading...." + |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
67 |
"</span>"; |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
68 |
} |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
69 |
|
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
70 |
$("p[@id]").each(function() { |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
71 |
$(this).append(loading($(this).attr("id"))); |
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
72 |
}); |
2
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
73 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
74 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
75 |
var url_string=window.location.pathname; |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
76 |
var temp = new Array(); |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
77 |
temp = url_string.split('/'); |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
78 |
var chap_name=temp[temp.length-1].split('.')[0]; |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
79 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
80 |
jQuery.getJSON("http://127.0.0.1:8000/count/"+chap_name, function(data) { |
0
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
81 |
|
2
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
82 |
$("span.comment").each(function(data_val) { |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
83 |
var id = $(this).attr("id"); |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
84 |
var substring=id.substr(9); |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
85 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
86 |
$(this).replaceWith("<span class='comment'" + ' id='+ id+ " <a + href=javascript:loadComments('"+id+"');>" + data.count[substring] +' comments'+ "</a>"); |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
87 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
88 |
}); |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
89 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
90 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
91 |
}); |
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
92 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
93 |
}); |
0
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
94 |
|
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
95 |
|
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
96 |
|
2
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
97 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
98 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
99 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
100 |
|
0
54f784230511
Initial commit of django based commenting system for sphinx. Already has
amit
parents:
diff
changeset
|
101 |
|
2
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
102 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
103 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
104 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
105 |
|
f5e18f8ed036
Changes to account for a new way of keeping ids ... Uses the whole path rather than just file name
amit
parents:
0
diff
changeset
|
106 |