]> git.mxchange.org Git - friendica-addons.git/blob - jappixmini/jappix/js/board.js
jappixmini: include jappix source
[friendica-addons.git] / jappixmini / jappix / js / board.js
1 /*
2
3 Jappix - An open social platform
4 These are the notification board JS script for Jappix
5
6 -------------------------------------------------
7
8 License: AGPL
9 Author: Vanaryon
10 Last revision: 12/03/11
11
12 */
13
14 // Creates a board panel
15 function createBoard(type, id) {
16         // Text var
17         var text = '';
18         
19         // Info
20         if(type == 'info') {
21                 switch(id) {
22                         // Password change
23                         case 1:
24                                 text = _e("Your password has been changed, now you can connect to your account with your new login data.");
25                                 
26                                 break;
27                         
28                         // Account deletion
29                         case 2:
30                                 text = _e("Your XMPP account has been removed, bye!");
31                                 
32                                 break;
33                         
34                         // Account logout
35                         case 3:
36                                 text = _e("You have been logged out of your XMPP account, have a nice day!");
37                                 
38                                 break;
39                         
40                         // Groupchat join
41                         case 4:
42                                 text = _e("The room you joined seems not to exist. You should create it!");
43                                 
44                                 break;
45                         
46                         // Groupchat removal
47                         case 5:
48                                 text = _e("The groupchat has been removed, now someone else will be able to recreate it.");
49                                 
50                                 break;
51                         
52                         // Non-existant groupchat user
53                         case 6:
54                                 text = _e("The user that you want to reach is not present in the room.");
55                                 
56                                 break;
57                 }
58         }
59         
60         // Error
61         else {
62                 switch(id) {
63                         // Custom error
64                         case 1:
65                                 text = '<b>' + _e("Error") + '</b> &raquo; <span></span>';
66                                 
67                                 break;
68                         
69                         // Network error
70                         case 2:
71                                 text = _e("Jappix has been interrupted by a network issue, a bug or bad login (check that you entered the right credentials), sorry for the inconvenience.");
72                                 
73                                 break;
74                         
75                         // List retrieving error
76                         case 3:
77                                 text = _e("The element list on this server could not be obtained!");
78                                 
79                                 break;
80                         
81                         // Attaching error
82                         case 4:
83                                 text = printf(_e("An error occured while uploading your file: maybe it is too big (%s maximum) or forbidden!"), JAPPIX_MAX_UPLOAD);
84                                 
85                                 break;
86                 }
87         }
88         
89         // No text?
90         if(!text)
91                 return false;
92         
93         // Append the content
94         $('#board').append('<div class="one-board ' + type + '" data-id="' + id + '">' + text + '</div>');
95         
96         // Events (click and auto-hide)
97         $('#board .one-board.' + type + '[data-id=' + id + ']')
98         
99         .click(function() {
100                 closeThisBoard(this);
101         })
102         
103         .oneTime('5s', function() {
104                 closeThisBoard(this);
105         })
106         
107         .slideDown();
108         
109         return true;
110 }
111
112 // Destroys the existing board notifications
113 function destroyBoard() {
114         $('#board').empty();
115 }
116
117 // Executes a given action on the notification board
118 function actionBoard(id, type) {
119         // In a first, we destroy other boards
120         destroyBoard();
121         
122         // Then we display the board
123         createBoard(type, id);
124 }
125
126 // Opens a given error ID
127 function openThisError(id) {
128         actionBoard(id, 'error');
129 }
130
131 // Opens a given info ID
132 function openThisInfo(id) {
133         actionBoard(id, 'info');
134 }
135
136 // Closes a given board
137 function closeThisBoard(board) {
138         $(board).slideUp('normal', function() {
139                 $(this).remove();
140         });
141 }