]> git.mxchange.org Git - friendica-addons.git/blob - jappixmini/jappix/js/talk.js
529de6c7b2bb1a0d05ade4f7ba08022cc362ce2d
[friendica-addons.git] / jappixmini / jappix / js / talk.js
1 /*
2
3 Jappix - An open social platform
4 These are the talkpage JS scripts for Jappix
5
6 -------------------------------------------------
7
8 License: AGPL
9 Author: Vanaryon
10 Last revision: 06/05/11
11
12 */
13
14 // Creates the talkpage events
15 function eventsTalkPage() {
16         // Launch all associated addons
17         launchMicroblog();
18         launchRoster();
19         launchPresence();
20         launchPEP();
21         launchNotifications();
22         launchMusic();
23 }
24
25 // Creates the talkpage code
26 function createTalkPage() {
27         // Talkpage exists?
28         if(exists('#talk'))
29                 return false;
30         
31         // Anonymous detector
32         var anonymous = isAnonymous();
33         
34         // Generate the HTML code
35         var html = 
36         '<div id="talk" class="removable">' + 
37                 '<div id="top-content">' + 
38                         '<div class="tools tools-logo talk-images"></div>' + 
39                         
40                         '<div class="tools tools-all">';
41                                 
42                                 if(!anonymous) html += 
43                                 '<a href="#" onclick="return openInbox();" class="inbox-hidable">' + _e("Messages") +  '</a>' + 
44                                 '<a href="#" onclick="return openVCard();">' + _e("Profile") +  '</a>' + 
45                                 '<a href="#" onclick="return optionsOpen();" class="options-hidable">' + _e("Options") +  '</a>' + 
46                                 '<a href="#" onclick="return normalQuit();">' + _e("Disconnect") +  '</a>';
47                                 
48                                 else html +=
49                                 '<a href="./">' + _e("Disconnect") +  '</a>';
50                         
51                         html +=
52                         '</div>';
53                         
54                         if(!anonymous && document.createElement('audio').canPlayType) html += 
55                         '<div class="tools-all ibubble">' + 
56                                 '<div class="tools music talk-images" onclick="return openMusic();"></div>' + 
57                                 
58                                 '<div class="music-content tools-content bubble hidable">' + 
59                                         '<div class="tools-content-subarrow talk-images"></div>' + 
60                                         
61                                         '<div class="tools-content-subitem">' + 
62                                                 '<div class="player">' + 
63                                                         '<a href="#" class="stop talk-images" onclick="return actionMusic(\'stop\');"></a>' + 
64                                                 '</div>' + 
65                                                 
66                                                 '<div class="list">' + 
67                                                         '<p class="no-results">' + _e("No result!") +  '</p>' + 
68                                                 '</div>' + 
69                                                 
70                                                 '<div class="search">' + 
71                                                         '<input type="text" />' + 
72                                                 '</div>' + 
73                                         '</div>' + 
74                                 '</div>' + 
75                         '</div>';
76                         
77                         if(!anonymous) html += 
78                         '<div class="tools-all ibubble">' + 
79                                 '<div class="tools notifications talk-images" onclick="return showBubble(\'.notifications-content\');"></div>' + 
80                                 
81                                 '<div class="notifications-content tools-content bubble hidable">' + 
82                                         '<div class="tools-content-subarrow talk-images"></div>' + 
83                                         
84                                         '<div class="tools-content-subitem">' + 
85                                                 '<a class="empty" href="#" onclick="return clearNotifications();">' + _e("Empty") +  '</a>' + 
86                                                 '<p class="nothing">' + _e("No notifications.") +  '</p>' + 
87                                         '</div>' + 
88                                 '</div>' + 
89                         '</div>';
90                 
91                 html +=
92                 '</div>' + 
93                 
94                 '<div id="main-content">' + 
95                         '<div id="left-content">';
96                                 if(!anonymous) html += 
97                                 '<div id="buddy-list">' + 
98                                         '<div class="content"></div>' + 
99                                         
100                                         '<div class="filter">' + 
101                                                 '<input type="text" placeholder="' + _e("Filter") +  '" />' + 
102                                                 '<a href="#">x</a>' + 
103                                         '</div>' + 
104                                         
105                                         '<div class="foot ibubble">' + 
106                                                 '<div class="buddy-list-add buddy-list-icon">' + 
107                                                         '<a href="#" class="add talk-images" title="' + _e("Add a friend") +  '"></a>' + 
108                                                 '</div>' + 
109                                                 
110                                                 '<div class="buddy-list-join buddy-list-icon">' + 
111                                                         '<a href="#" class="join talk-images" title="' + _e("Join a chat") +  '"></a>' + 
112                                                 '</div>' + 
113                                                 
114                                                 '<div class="buddy-list-groupchat buddy-list-icon">' + 
115                                                         '<a href="#" class="groupchat talk-images" title="' + _e("Your groupchats") +  '"></a>' + 
116                                                 '</div>' + 
117                                                 
118                                                 '<div class="buddy-list-more buddy-list-icon">' + 
119                                                         '<a href="#" class="more talk-images" title="' + _e("More stuff") +  '"></a>' + 
120                                                 '</div>' + 
121                                                 
122                                                 '<div style="clear: both;"></div>' + 
123                                         '</div>' + 
124                                 '</div>';
125                                 
126                                 html +=
127                                 '<div id="my-infos">' + 
128                                         '<div class="content">' + 
129                                                 '<div class="element f-presence ibubble">' + 
130                                                         '<a href="#" class="icon picker disabled" data-value="available">' + 
131                                                                 '<span class="talk-images"></span>' + 
132                                                         '</a>' + 
133                                                         
134                                                         '<input id="presence-status" type="text" placeholder="' + _e("Status") + '" disabled="" />' + 
135                                                 '</div>';
136                                                 
137                                                 if(!anonymous) html += 
138                                                 '<div class="element f-mood pep-hidable ibubble">' + 
139                                                         '<a href="#" class="icon picker" data-value="happy">' + 
140                                                                 '<span class="talk-images"></span>' + 
141                                                         '</a>' + 
142                                                         
143                                                         '<input id="mood-text" type="text" placeholder="' + _e("Mood") + '" />' + 
144                                                 '</div>' + 
145                                                 
146                                                 '<div class="element f-activity pep-hidable ibubble">' + 
147                                                         '<a href="#" class="icon picker" data-value="exercising">' + 
148                                                                 '<span class="talk-images activity-exercising"></span>' + 
149                                                         '</a>' + 
150                                                         
151                                                         '<input id="activity-text" type="text" placeholder="' + _e("Activity") + '" />' + 
152                                                 '</div>';
153                                         
154                                         html +=
155                                         '</div>' + 
156                                 '</div>' + 
157                         '</div>' + 
158                         
159                         '<div id="right-content">' + 
160                                 '<div id="page-switch">' + 
161                                         '<div class="chans">';
162                                                 if(!anonymous) html += 
163                                                 '<div class="channel switcher activechan" onclick="return switchChan(\'channel\');">' + 
164                                                         '<div class="icon talk-images"></div>' + 
165                                                 
166                                                         '<div class="name">' + _e("Channel") +  '</div>' + 
167                                                 '</div>';
168                                         
169                                         html +=
170                                         '</div>' + 
171                                         
172                                         '<div class="more ibubble">' + 
173                                                 '<div class="more-button talk-images" onclick="return loadChatSwitch();" title="' + _e("All tabs") +  '"></div>' + 
174                                         '</div>' + 
175                                 '</div>' + 
176                                 
177                                 '<div id="page-engine">';
178                                         if(!anonymous) html += 
179                                         '<div id="channel" class="page-engine-chan" style="display: block;">' + 
180                                                 '<div class="top mixed ' + hex_md5(getXID()) + '">' + 
181                                                         '<div class="avatar-container">' + 
182                                                                 '<img class="avatar" src="' + './img/others/default-avatar.png' + '" alt="" />' + 
183                                                         '</div>' + 
184                                                         
185                                                         '<div class="update">' + 
186                                                                 '<p>' + _e("What\'s up with you?") +  '</p>' + 
187                                                                 
188                                                                 '<div class="microblog-body">' + 
189                                                                         '<input class="focusable" type="text" name="microblog_body" placeholder="' + _e("Type something you want to share with your friends...") + '" disabled="" />' + 
190                                                                 '</div>' + 
191                                                                 
192                                                                 '<div class="one-microblog-icon ibubble">' + 
193                                                                         '<a href="#" onclick="return showBubble(\'#attach\');" title="' + _e("Attach a file") +  '" class="postit attach talk-images"></a>' + 
194                                                                         
195                                                                         '<form id="attach" class="bubble hidable" action="./php/file-share.php" method="post" enctype="multipart/form-data">' + 
196                                                                                 '<div class="attach-subarrow talk-images"></div>' + 
197                                                                                 
198                                                                                 '<div class="attach-subitem">' + 
199                                                                                         '<p class="attach-p">' + _e("Attach a file") +  '</p>' + 
200                                                                                         generateFileShare() + 
201                                                                                 '</div>' + 
202                                                                         '</form>' + 
203                                                                 '</div>' + 
204                                                         '</div>' + 
205                                                 '</div>' + 
206                                                 
207                                                 '<div class="content mixed"></div>' + 
208                                                 
209                                                 '<div class="footer">' + 
210                                                         '<div class="sync talk-images">' + _e("You are synchronized with your network.") +  '</div>' + 
211                                                         
212                                                         '<div class="unsync talk-images">' + _e("Cannot send anything: you can only receive notices!") +  '</div>' + 
213                                                         
214                                                         '<div class="fetch wait-small">' + _e("Fetching the social channel...") +  '</div>' + 
215                                                 '</div>' + 
216                                         '</div>';
217                                 
218                                 html +=
219                                 '</div>' + 
220                         '</div>' + 
221                 '</div>' + 
222         '</div>';
223         
224         // Create the HTML code
225         $('body').prepend(html);
226         
227         // Adapt the buddy-list size
228         adaptRoster();
229         
230         // Create JS events
231         eventsTalkPage();
232         
233         // Start the auto idle functions
234         liveIdle();
235         
236         return true;
237 }
238
239 // Destroys the talkpage code
240 function destroyTalkPage() {
241         // Reset our database
242         resetDB();
243         
244         // Reset some vars
245         STANZA_ID = 1;
246         BLIST_ALL = false;
247         FIRST_PRESENCE_SENT = false;
248         SEARCH_FILTERED = false;
249         AVATAR_PENDING = [];
250         
251         // Kill all timers, exept the board ones
252         $('*:not(#board .one-board)').stopTime();
253         
254         // Kill the auto idle functions
255         dieIdle();
256         
257         // We renitalise the html markup as its initiale look
258         $('.removable').remove();
259         pageTitle('home');
260         
261         // Finally we show the homepage
262         $('#home').show();
263 }