Welcome to mirror list, hosted at ThFree Co, Russian Federation.

talk.js « javascripts « app - github.com/jappix/jappix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c157f95280a31f9073418fa5141cfc325b3c8c5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
/*

Jappix - An open social platform
These are the talkpage JS scripts for Jappix

-------------------------------------------------

License: AGPL
Author: Valérian Saliou

*/

// Bundle
var Talk = (function () {

    /**
     * Alias of this
     * @private
     */
    var self = {};


    /**
     * Creates the talkpage events
     * @public
     * @return {undefined}
     */
    self.events = function() {

        try {
            // Launch all associated bundles
            Microblog.instance();
            Roster.instance();
            Presence.instance();
            PEP.instance();
            Notification.instance();
            Music.instance();
        } catch(e) {
            Console.error('Talk.events', e);
        }

    };


    /**
     * Creates the talkpage code
     * @public
     * @return {boolean}
     */
    self.create = function() {

        try {
            // Talkpage exists?
            if(Common.exists('#talk')) {
                return false;
            }

            // Anonymous detector
            var anonymous = Utils.isAnonymous();

            // Generate the HTML code
            var html =
            '<div id="talk" class="removable">' +
                '<div id="top-content">' +
                    '<div class="tools tools-logo talk-images"></div>' +

                    '<div class="tools tools-all">';

                        if(!anonymous) html +=
                        '<a href="#" onclick="return Inbox.open();" class="inbox-hidable">' + Common._e("Messages") +  '</a>' +
                        '<a href="#" onclick="return vCard.open();" class="vcard">' + Common._e("Profile") +  '</a>' +
                        '<a href="#" onclick="return Options.open();" class="options-hidable">' + Common._e("Options") +  '</a>' +
                        '<a href="#" onclick="return Connection.normalQuit();" class="quit">' + Common._e("Disconnect") +  '</a>';

                        else html +=
                        '<a href="./">' + Common._e("Disconnect") +  '</a>';

                    html +=
                    '</div>';

                    if(!anonymous && document.createElement('audio').canPlayType) html +=
                    '<div class="tools-all ibubble">' +
                        '<div class="tools music talk-images" onclick="return Music.open();"></div>' +

                        '<div class="music-content tools-content bubble hidable">' +
                            '<div class="tools-content-subarrow talk-images"></div>' +

                            '<div class="tools-content-subitem">' +
                                '<div class="player">' +
                                    '<a href="#" class="stop talk-images" onclick="return Music.action(\'stop\');"></a>' +
                                '</div>' +

                                '<div class="list">' +
                                    '<p class="no-results">' + Common._e("No result!") +  '</p>' +
                                '</div>' +

                                '<div class="search">' +
                                    '<input type="text" />' +
                                '</div>' +
                            '</div>' +
                        '</div>' +
                    '</div>';

                    if(!anonymous) html +=
                    '<div class="tools-all ibubble">' +
                        '<div class="tools notifications talk-images" onclick="return Bubble.show(\'.notifications-content\');"></div>' +

                        '<div class="notifications-content tools-content bubble hidable">' +
                            '<div class="tools-content-subarrow talk-images"></div>' +

                            '<div class="tools-content-subitem">' +
                                '<a class="empty" href="#" onclick="return Notification.clear();">' + Common._e("Empty") +  '</a>' +
                                '<p class="nothing">' + Common._e("No notifications.") +  '</p>' +
                            '</div>' +
                        '</div>' +
                    '</div>';

                    if(!anonymous) html +=
                    '<div class="tools-all">' +
                        '<div class="tools call talk-images" onclick="return Call.open();">' +
                            '<span class="streaming-items">' +
                                '<span class="counter" data-default="00:00:00">00:00:00</span>' +
                                '<a class="stop" href="#" onclick="return Call.stop();">' + Common._e("Stop") + '</a>' +
                            '</span>' +
                        '</div>' +

                        '<div class="call-content tools-content">' +
                            '<div class="tools-content-subarrow talk-images"></div>' +

                            '<div class="tools-content-subitem"></div>' +
                        '</div>' +
                    '</div>';

                html +=
                '</div>' +

                '<div id="main-content">' +
                    '<div id="left-content">';
                        if(!anonymous) html +=
                        '<div id="roster">' +
                            '<div class="content"></div>' +

                            '<div class="filter">' +
                                '<input type="text" placeholder="' + Common._e("Filter") +  '" />' +
                                '<a href="#">x</a>' +
                            '</div>' +

                            '<div class="foot ibubble">' +
                                '<div class="roster-add roster-icon">' +
                                    '<a href="#" class="add talk-images" title="' + Common._e("Add a friend") +  '"></a>' +
                                '</div>' +

                                '<div class="roster-join roster-icon">' +
                                    '<a href="#" class="join talk-images" title="' + Common._e("Join a chat") +  '"></a>' +
                                '</div>' +

                                '<div class="roster-groupchat roster-icon">' +
                                    '<a href="#" class="groupchat talk-images" title="' + Common._e("Your groupchats") +  '"></a>' +
                                '</div>' +

                                '<div class="roster-muji roster-icon muji-hidable">' +
                                    '<a href="#" class="muji talk-images" title="' + Common._e("Audio/video conference") +  '"></a>' +
                                '</div>' +

                                '<div class="roster-more roster-icon">' +
                                    '<a href="#" class="more talk-images" title="' + Common._e("More stuff") +  '"></a>' +
                                '</div>' +

                                '<div style="clear: both;"></div>' +
                            '</div>' +
                        '</div>';

                        html +=
                        '<div id="my-infos">' +
                            '<div class="content">' +
                                '<div class="element f-presence ibubble">' +
                                    '<a href="#" class="icon picker disabled" data-value="available">' +
                                        '<span class="talk-images"></span>' +
                                    '</a>' +

                                    '<input id="presence-status" type="text" placeholder="' + Common._e("Status") + '" disabled="" />' +
                                '</div>';

                                if(!anonymous) html +=
                                '<div class="element f-mood pep-hidable ibubble">' +
                                    '<a href="#" class="icon picker" data-value="happy">' +
                                        '<span class="talk-images"></span>' +
                                    '</a>' +

                                    '<input id="mood-text" type="text" placeholder="' + Common._e("Mood") + '" />' +
                                '</div>' +

                                '<div class="element f-activity pep-hidable ibubble">' +
                                    '<a href="#" class="icon picker" data-value="exercising">' +
                                        '<span class="talk-images activity-exercising"></span>' +
                                    '</a>' +

                                    '<input id="activity-text" type="text" placeholder="' + Common._e("Activity") + '" />' +
                                '</div>';

                            html +=
                            '</div>' +
                        '</div>' +
                    '</div>' +

                    '<div id="right-content">' +
                        '<div id="page-switch">' +
                            '<div class="chans">';
                                if(!anonymous) html +=
                                '<div class="channel switcher activechan" onclick="return Interface.switchChan(\'channel\');">' +
                                    '<div class="icon talk-images"></div>' +

                                    '<div class="name">' + Common._e("Channel") +  '</div>' +
                                '</div>';

                            html +=
                            '</div>';

                            if(anonymous) html +=
                                '<div class="join ibubble">' +
                                    '<div class="join-button talk-images" onclick="return Interface.loadJoinGroupchat();" title="' + Common._e("Join groupchat") +  '"></div>' +
                                '</div>';

                            html +=
                            '<div class="more ibubble">' +
                                '<div class="more-button talk-images" onclick="return Interface.loadChatSwitch();" title="' + Common._e("All tabs") +  '"></div>' +
                            '</div>' +
                        '</div>' +

                        '<div id="page-engine">';
                            if(!anonymous) html +=
                            '<div id="channel" class="page-engine-chan" style="display: block;">' +
                                '<div class="top mixed ' + hex_md5(Common.getXID()) + '">' +
                                    '<div class="avatar-container">' +
                                        '<img class="avatar" src="' + './images/others/default-avatar.png' + '" alt="" />' +
                                    '</div>' +

                                    '<div class="update">' +
                                        '<p>' + Common._e("What\'s up with you?") +  '</p>' +

                                        '<div class="microblog-body">' +
                                            '<input class="focusable" type="text" name="microblog_body" placeholder="' + Common._e("Type something you want to share with your friends...") + '" disabled="" />' +
                                        '</div>' +

                                        '<div class="one-microblog-icon ibubble">' +
                                            '<a href="#" onclick="return Bubble.show(\'#attach\');" title="' + Common._e("Attach a file") +  '" class="postit attach talk-images"></a>' +

                                            '<form id="attach" class="bubble hidable" action="./server/file-share.php" method="post" enctype="multipart/form-data">' +
                                                '<div class="attach-subarrow talk-images"></div>' +

                                                '<div class="attach-subitem">' +
                                                    '<p class="attach-p">' + Common._e("Attach a file") +  '</p>' +
                                                    Interface.generateFileShare() +
                                                '</div>' +
                                            '</form>' +
                                        '</div>' +
                                    '</div>' +
                                '</div>' +

                                '<div class="content mixed"></div>' +

                                '<div class="footer">' +
                                    '<div class="sync talk-images">' + Common._e("You are synchronized with your network.") +  '</div>' +

                                    '<div class="unsync talk-images">' + Common._e("Cannot send anything: you can only receive notices!") +  '</div>' +

                                    '<div class="fetch wait-small">' + Common._e("Fetching the social channel...") +  '</div>' +
                                '</div>' +
                            '</div>';

                        html +=
                        '</div>' +
                    '</div>' +
                '</div>' +
            '</div>';

            // Create the HTML code
            $('body').prepend(html);

            // Adapt the roster size
            Roster.adapt();

            // Create JS events
            self.events();

            // Start the auto idle functions
            Presence.liveIdle();

            return true;
        } catch(e) {
            Console.error('Talk.create', e);
        }

    };


    /**
     * Destroys the talkpage code
     * @public
     * @return {undefined}
     */
    self.destroy = function() {

        try {
            // Reset our database
            DataStore.resetDB();

            // Reset some vars
            STANZA_ID = 1;
            Roster.blist_all = false;
            Presence.first_sent = false;
            Search.search_filtered = false;
            Avatar.pending = [];
            Groupchat.join_suggest = [];

            // Kill all timers, exept the board ones
            $('*:not(#board .one-board)').stopTime();

            // Kill the auto idle functions
            Presence.dieIdle();

            // We renitalise the html markup as its initiale look
            $('.removable').remove();
            Interface.title('home');

            // Finally we show the homepage
            $('#home').show();
        } catch(e) {
            Console.error('Talk.destroy', e);
        }

    };


    /**
     * Return class scope
     */
    return self;

})();