Make “follow”, “unfollow”, “block” and “unblock” buttons dynamic.
[Sone.git] / src / main / resources / templates / include / head.html
1 <div id="sone">
2
3         <div id="formPassword"><% formPassword|html></div>
4
5         <script src="javascript/jquery-1.4.2.js" language="javascript"></script>
6         <script src="javascript/sone.js" language="javascript"></script>
7
8         <script language="javascript">
9                 /* this initializes the status update input field. */
10                 $(document).ready(function() {
11                         registerInputTextareaSwap("#sone #update-status .status-input", "WebInterface.DefaultText.StatusUpdate", "text", false);
12                 });
13         </script>
14
15         <script language="javascript">
16                 /* these functions are necessary for updating Sone statuses. */
17                 $(document).ready(function() {
18                         $("#sone .sone").each(function() {
19                                 watchSone($(this).find(".id").text());
20                         });
21                 });
22         </script>
23
24         <script language="javascript">
25                 /* this initializes all reply input fields. */
26                 $(document).ready(function() {
27                         registerInputTextareaSwap("#sone input.reply-input", "WebInterface.DefaultText.Reply", "text", false);
28                         addCommentLinks();
29                 });
30         </script>
31
32         <script language="javascript">
33                 /* replace all “delete” buttons with javascript. */
34                 $(document).ready(function() {
35                         $("#sone .post").each(function() {
36                                 postId = $(this).attr("id");
37                                 enhanceDeletePostButton("#sone .post#" + postId + " > .status-line .delete button", postId);
38                                 (function(postId) {
39                                         $("#sone .post#" + postId + " .reply").each(function() {
40                                                 replyId = $(this).attr("id");
41                                                 (function(postId, reply, replyId) {
42                                                         reply.find(".delete button").each(function() {
43                                                                 enhanceDeleteReplyButton("#sone .post#" + postId + " .reply#" + replyId + " .delete button", replyId);
44                                                         })
45                                                 })(postId, $(this), replyId);
46                                         });
47                                 })(postId);
48                         });
49                 });
50         </script>
51
52         <script language="javascript">
53                 /* convert all “follow”, “unfollow”, “block”, and “unblock” links to something nicer. */
54                 $(document).ready(function() {
55                         $("#sone .follow").submit(function() {
56                                 var followElement = this;
57                                 $.getJSON("ajax/followSone.ajax", { "sone": getSoneId(this), "formPassword": getFormPassword() }, function() {
58                                         $(followElement).addClass("hidden");
59                                         $(followElement).parent().find(".unfollow").removeClass("hidden");
60                                 });
61                                 return false;
62                         });
63                         $("#sone .unfollow").submit(function() {
64                                 var unfollowElement = this;
65                                 $.getJSON("ajax/unfollowSone.ajax", { "sone": getSoneId(this), "formPassword": getFormPassword() }, function() {
66                                         $(unfollowElement).addClass("hidden");
67                                         $(unfollowElement).parent().find(".follow").removeClass("hidden");
68                                 });
69                                 return false;
70                         });
71                         $("#sone .block").submit(function() {
72                                 var blockElement = this;
73                                 $.getJSON("ajax/blockSone.ajax", { "sone": getSoneId(this), "formPassword": getFormPassword() }, function() {
74                                         $(blockElement).addClass("hidden");
75                                         $(blockElement).parent().find(".unblock").removeClass("hidden");
76                                 });
77                                 return false;
78                         });
79                         $("#sone .unblock").submit(function() {
80                                 var unblockElement = this;
81                                 $.getJSON("ajax/unblockSone.ajax", { "sone": getSoneId(this), "formPassword": getFormPassword() }, function() {
82                                         $(unblockElement).addClass("hidden");
83                                         $(unblockElement).parent().find(".block").removeClass("hidden");
84                                 });
85                                 return false;
86                         });
87                 });
88         </script>
89
90         <div id="main">
91
92                 <div id="profile" class="<%ifnull currentSone>offline<%else>online<%/if>">
93                         <a class="picture" href="index.html">&nbsp;</a>
94                         <%ifnull ! currentSone>
95                                 <div id="home-sone">
96                                         <% currentSone|store key=sone>
97                                         <%include include/viewSone.html>
98                                         <%include include/updateStatus.html>
99                                 </div>
100                         <%/if>
101                 </div>