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