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