3 Jappix - An open social platform
4 These are the welcome tool functions for Jappix
6 -------------------------------------------------
10 Last revision: 16/01/12
14 // Opens the welcome tools
15 function openWelcome() {
17 var share_msg = printf(_e("Using Jappix, an open social platform. I am %s!"), getXID());
21 '<div class="top">' + _e("Welcome!") + '</div>' +
24 '<a href="#" class="tab-active" data-step="1">' + _e("Options") + '</a>' +
25 '<a href="#" class="tab-missing" data-step="2">' + _e("Friends") + '</a>' +
26 '<a href="#" class="tab-missing" data-step="3">' + _e("Share") + '</a>' +
29 '<div class="content">' +
30 '<div class="lap-active one-lap welcome1">' +
31 '<div class="infos">' +
32 '<p class="infos-title">' + _e("Welcome on Jappix, your own social cloud!") + '</p>' +
33 '<p>' + _e("Before you start using it, you will have to change some settings, search for friends and complete your profile.") + '</p>' +
36 '<a href="#" class="box enabled" title="' + _e("Click to disable") + '">' +
37 '<span class="option">' + _e("Sounds") + '</span>' +
38 '<span class="description">' + _e("Enable notification sounds") + '</span>' +
39 '<span class="image sound talk-images"></span>' +
40 '<span class="tick talk-images"></span>' +
43 '<a href="#" class="box enabled pep-hidable" title="' + _e("Click to disable") + '">' +
44 '<span class="option">' + _e("Geolocation") + '</span>' +
45 '<span class="description">' + _e("Share your position on the globe") + '</span>' +
46 '<span class="image geolocation talk-images"></span>' +
47 '<span class="tick talk-images"></span>' +
50 '<a href="#" class="box xmpplinks-hidable" title="' + _e("Click to enable") + '">' +
51 '<span class="option">' + _e("XMPP links") + '</span>' +
52 '<span class="description">' + _e("Open XMPP links with Jappix") + '</span>' +
53 '<span class="image xmpp talk-images"></span>' +
54 '<span class="tick talk-images"></span>' +
57 '<a href="#" class="box enabled archives-hidable pref" title="' + _e("Click to enable") + '">' +
58 '<span class="option">' + _e("Message archiving") + '</span>' +
59 '<span class="description">' + _e("Store a history of your chats") + '</span>' +
60 '<span class="image archives talk-images"></span>' +
61 '<span class="tick talk-images"></span>' +
64 '<a href="#" class="box" title="' + _e("Click to enable") + '">' +
65 '<span class="option">' + _e("Offline friends") + '</span>' +
66 '<span class="description">' + _e("Don\'t hide offline friends") + '</span>' +
67 '<span class="image offline talk-images"></span>' +
68 '<span class="tick talk-images"></span>' +
72 '<div class="one-lap welcome2">' +
73 '<div class="infos">' +
74 '<p class="infos-title">' + _e("Friends") + '</p>' +
75 '<p>' + _e("Use this tool to find your friends on the server you are using right now, or add them later.") + '</p>' +
78 '<div class="results welcome-results"></div>' +
81 '<div class="one-lap welcome3">' +
82 '<div class="infos">' +
83 '<p class="infos-title">' + _e("Share") + '</p>' +
84 '<p>' + _e("Great work! Now, you can share Jappix with your friends!") + '</p>' +
85 '<p>' + _e("When you will press the save button, the profile editor will be opened. Happy socializing!") + '</p>' +
88 '<a class="box share first" href="http://www.facebook.com/sharer/sharer.php?u=' + encodeQuotes(generateURL(JAPPIX_LOCATION)) + '" target="_blank">' +
89 '<span class="logo facebook welcome-images"></span>' +
90 '<span class="name">Facebook</span>' +
91 '<span class="description">' + printf(_e("Share Jappix on %s"), 'Facebook') + '</span>' +
92 '<span class="go talk-images"></span>' +
95 '<a class="box share" href="http://twitter.com/intent/tweet?text=' + encodeQuotes(share_msg) + '&url=' + encodeQuotes(generateURL(JAPPIX_LOCATION)) + '" target="_blank">' +
96 '<span class="logo twitter welcome-images"></span>' +
97 '<span class="name">Twitter</span>' +
98 '<span class="description">' + printf(_e("Share Jappix on %s"), 'Twitter') + '</span>' +
99 '<span class="go talk-images"></span>' +
102 '<a class="box share" href="http://www.google.com/buzz/post?message=' + encodeQuotes(share_msg) + '&url=' + encodeQuotes(generateURL(JAPPIX_LOCATION)) + '" target="_blank">' +
103 '<span class="logo buzz welcome-images"></span>' +
104 '<span class="name">Google Buzz</span>' +
105 '<span class="description">' + printf(_e("Share Jappix on %s"), 'Google Buzz') + '</span>' +
106 '<span class="go talk-images"></span>' +
109 '<a class="box share" href="http://identi.ca/index.php?action=newnotice&status_textarea=' + encodeQuotes(share_msg) + ' ' + encodeQuotes(generateURL(JAPPIX_LOCATION)) + '" target="_blank">' +
110 '<span class="logo identica welcome-images"></span>' +
111 '<span class="name">Identi.ca</span>' +
112 '<span class="description">' + printf(_e("Share Jappix on %s"), 'Identi.ca') + '</span>' +
113 '<span class="go talk-images"></span>' +
118 '<div class="bottom">' +
119 '<div class="wait wait-medium"></div>' +
121 '<a href="#" class="finish next">' + _e("Next") + ' ยป</a>' +
122 '<a href="#" class="finish save">' + _e("Save") + '</a>' +
126 createPopup('welcome', html);
128 // Apply the features
129 applyFeatures('welcome');
131 // Associate the events
134 logThis('Welcome assistant opened.');
137 // Closes the welcome tools
138 function closeWelcome() {
140 destroyPopup('welcome');
145 // Switches the welcome tabs
146 function switchWelcome(id) {
148 var welcome = '#welcome ';
149 var content = welcome + '.content .';
150 var tab = welcome + '.tab ';
151 var wait = $(welcome + '.wait');
153 $(content + 'one-lap').hide();
154 $(content + 'welcome' + id).show();
155 $(tab + 'a').removeClass('tab-active');
156 $(tab + 'a[data-step=' + id + ']').addClass('tab-active').removeClass('tab-missing');
158 // Update the "save" button if all is okay
159 if(!exists(tab + '.tab-missing')) {
160 var finish = welcome + '.finish.';
161 $(finish + 'save').show();
162 $(finish + 'next').hide();
165 // If this is ID 2: vJUD search
168 dataForm(HOST_VJUD, 'search', '', '', 'welcome');
177 // Sends the welcome options
178 function sendWelcome(array) {
180 var iq = new JSJaCIQ();
183 var query = iq.setQuery(NS_PRIVATE);
184 var storage = query.appendChild(iq.buildNode('storage', {'xmlns': NS_OPTIONS}));
187 var tags = new Array('sounds', 'geolocation', '', '', 'roster-showall');
189 // Build the XML with the array
191 var value = array[i];
194 if((i != 2) && (i != 3) && tag && value) {
195 storage.appendChild(iq.buildNode('option', {'type': tag, 'xmlns': NS_OPTIONS}, value));
196 setDB('options', tag, value);
202 // If geolocation is enabled
207 // Saves the welcome options
208 var END_WELCOME = false;
210 function saveWelcome() {
211 // Get the new options
212 var array = new Array();
214 $('#welcome a.box').each(function() {
217 if($(this).hasClass('enabled'))
223 // If XMPP links is enabled
227 // If offline buddies showing is enabled
229 showAllBuddies('welcome');
231 // If archiving is supported by the server
232 if(enabledArchives('pref')) {
233 var aEnabled = false;
235 // If archiving is enabled
239 // Send the archives configuration
240 configArchives(aEnabled);
243 // Send the new options
246 // Close the welcome tool
249 // Open the profile editor
257 // Goes to the next welcome step
258 function nextWelcome() {
259 // Check the next step to go to
261 var missing = '#welcome .tab a.tab-missing';
264 next = parseInt($(missing + ':first').attr('data-step'));
266 // Switch to the next step
273 function launchWelcome() {
275 $('#welcome .tab a').click(function() {
276 // Switch to the good tab
277 var key = parseInt($(this).attr('data-step'));
279 return switchWelcome(key);
282 $('#welcome a.box:not(.share)').click(function() {
283 if($(this).hasClass('enabled'))
284 $(this).removeClass('enabled').attr('title', _e("Click to enable"));
286 $(this).addClass('enabled').attr('title', _e("Click to disable"));
291 $('#welcome .bottom .finish').click(function() {
292 if($(this).is('.next'))
293 return nextWelcome();
294 if($(this).is('.save'))
295 return saveWelcome();