Hide all replies but the last two.
[Sone.git] / src / main / resources / templates / include / head.html
1 <div id="sone" class="<%ifnull ! currentSone>online<%else>offline<%/if>">
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, 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, 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 + " > .inner-part > .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                 /* hides all replies but the latest two. */
54                 $(document).ready(function() {
55                         $("#sone .post .replies").each(function() {
56                                 allReplies = $(this).find(".reply");
57                                 if (allReplies.length > 2) {
58                                         for (replyIndex = 0; replyIndex < (allReplies.length - 2); ++replyIndex) {
59                                                 $(allReplies[replyIndex]).addClass("hidden");
60                                         }
61                                         clickToShowElement = $("<div></div>").addClass("click-to-show");
62                                         (function(clickToShowElement, allReplies) {
63                                                 getTranslation("WebInterface.ClickToShow.Replies", function(text) {
64                                                         clickToShowElement.text(text);
65                                                 });
66                                                 clickToShowElement.click(function() {
67                                                         allReplies.removeClass("hidden");
68                                                         clickToShowElement.addClass("hidden");
69                                                 });
70                                         })(clickToShowElement, allReplies);
71                                         $(allReplies[0]).before(clickToShowElement);
72                                 }
73                         });
74                 });
75         </script>
76
77         <script language="javascript">
78                 /* convert all “follow”, “unfollow”, “block”, and “unblock” links to something nicer. */
79                 $(document).ready(function() {
80                         $("#sone .follow").submit(function() {
81                                 var followElement = this;
82                                 $.getJSON("ajax/followSone.ajax", { "sone": getSoneId(this), "formPassword": getFormPassword() }, function() {
83                                         $(followElement).addClass("hidden");
84                                         $(followElement).parent().find(".unfollow").removeClass("hidden");
85                                 });
86                                 return false;
87                         });
88                         $("#sone .unfollow").submit(function() {
89                                 var unfollowElement = this;
90                                 $.getJSON("ajax/unfollowSone.ajax", { "sone": getSoneId(this), "formPassword": getFormPassword() }, function() {
91                                         $(unfollowElement).addClass("hidden");
92                                         $(unfollowElement).parent().find(".follow").removeClass("hidden");
93                                 });
94                                 return false;
95                         });
96                         $("#sone .block").submit(function() {
97                                 var blockElement = this;
98                                 $.getJSON("ajax/blockSone.ajax", { "sone": getSoneId(this), "formPassword": getFormPassword() }, function() {
99                                         $(blockElement).addClass("hidden");
100                                         $(blockElement).parent().find(".unblock").removeClass("hidden");
101                                 });
102                                 return false;
103                         });
104                         $("#sone .unblock").submit(function() {
105                                 var unblockElement = this;
106                                 $.getJSON("ajax/unblockSone.ajax", { "sone": getSoneId(this), "formPassword": getFormPassword() }, function() {
107                                         $(unblockElement).addClass("hidden");
108                                         $(unblockElement).parent().find(".block").removeClass("hidden");
109                                 });
110                                 return false;
111                         });
112                         $("#sone .blacklist").submit(function() {
113                                 var blacklistElement = this;
114                                 $.getJSON("ajax/blacklistSone.ajax", { "sone" : getSoneId(this), "formPassword" : getFormPassword() }, function() {
115                                         $(getSoneElement(blacklistElement)).slideUp();
116                                 });
117                                 return false;
118                         });
119                         $("#sone .unblacklist").submit(function() {
120                                 var unblacklistElement = this;
121                                 $.getJSON("ajax/unblacklistSone.ajax", { "sone" : getSoneId(this), "formPassword" : getFormPassword() }, function() {
122                                         $(getSoneElement(unblacklistElement)).slideUp();
123                                 });
124                                 return false;
125                         });
126                 });
127         </script>
128
129         <script language="javascript">
130                 /* convert all “like” buttons to javascript functions. */
131                 $(document).ready(function() {
132                         $("#sone .post > .inner-part > .status-line .like").submit(function() {
133                                 likePost(getPostId(this));
134                                 return false;
135                         });
136                         $("#sone .post > .inner-part > .status-line .unlike").submit(function() {
137                                 unlikePost(getPostId(this));
138                                 return false;
139                         });
140                         $("#sone .post .reply .status-line .like").submit(function() {
141                                 likeReply(getReplyId(this));
142                                 return false;
143                         });
144                         $("#sone .post .reply .status-line .unlike").submit(function() {
145                                 unlikeReply(getReplyId(this));
146                                 return false;
147                         });
148                 });
149         </script>
150
151         <div id="main">
152
153                 <%if !webInterface.core.identityManager.connected>
154                         <div id="plugin-warning">
155                                 <%= Warning.PluginNotConnected.Text|l10n|html|replace needle="{link}" replacement="<a href=\"/plugins/\">"|replace needle="{/link}" replacement="</a>">
156                         </div>
157                 <%/if>
158
159                 <div id="profile" class="<%ifnull currentSone>offline<%else>online<%/if>">
160                         <a class="picture" href="index.html">
161                                 <%ifnull !currentSone>
162                                         <img src="/WoT/GetIdenticon?identity=<% currentSone.id|html>&amp;width=80&amp;height=80" width="80" height="80" alt="Profile Avatar" />
163                                 <%else>
164                                         <img src="images/sone.png" width="80" height="80" alt="Sone is offline" />
165                                 <%/if>
166                         </a>
167                         <%ifnull ! currentSone>
168                                 <div id="home-sone">
169                                         <% currentSone|store key=sone>
170                                         <%include include/viewSone.html>
171                                         <%include include/updateStatus.html>
172                                 </div>
173                         <%/if>
174                 </div>