/* Jappix - An open social platform These are the welcome tool functions for Jappix ------------------------------------------------- License: AGPL Author: Vanaryon Last revision: 16/01/12 */ // Opens the welcome tools function openWelcome() { // Share message var share_msg = printf(_e("Using Jappix, an open social platform. I am %s!"), getXID()); // Popup HTML content var html = '
' + _e("Welcome!") + '
' + '
' + '' + _e("Options") + '' + '' + _e("Friends") + '' + '' + _e("Share") + '' + '
' + '
' + '
' + '
' + '

' + _e("Welcome on Jappix, your own social cloud!") + '

' + '

' + _e("Before you start using it, you will have to change some settings, search for friends and complete your profile.") + '

' + '
' + '' + '' + _e("Sounds") + '' + '' + _e("Enable notification sounds") + '' + '' + '' + '' + '' + '' + _e("Geolocation") + '' + '' + _e("Share your position on the globe") + '' + '' + '' + '' + '' + '' + _e("XMPP links") + '' + '' + _e("Open XMPP links with Jappix") + '' + '' + '' + '' + '' + '' + _e("Message archiving") + '' + '' + _e("Store a history of your chats") + '' + '' + '' + '' + '' + '' + _e("Offline friends") + '' + '' + _e("Don\'t hide offline friends") + '' + '' + '' + '' + '
' + '
' + '
' + '

' + _e("Friends") + '

' + '

' + _e("Use this tool to find your friends on the server you are using right now, or add them later.") + '

' + '
' + '
' + '
' + '
' + '
' + '

' + _e("Share") + '

' + '

' + _e("Great work! Now, you can share Jappix with your friends!") + '

' + '

' + _e("When you will press the save button, the profile editor will be opened. Happy socializing!") + '

' + '
' + '' + '' + '' + '' + '
' + '
' + '
' + '
' + '' + '' + _e("Save") + '' + '
'; // Create the popup createPopup('welcome', html); // Apply the features applyFeatures('welcome'); // Associate the events launchWelcome(); logThis('Welcome assistant opened.'); } // Closes the welcome tools function closeWelcome() { // Destroy the popup destroyPopup('welcome'); return false; } // Switches the welcome tabs function switchWelcome(id) { // Path to var welcome = '#welcome '; var content = welcome + '.content .'; var tab = welcome + '.tab '; var wait = $(welcome + '.wait'); $(content + 'one-lap').hide(); $(content + 'welcome' + id).show(); $(tab + 'a').removeClass('tab-active'); $(tab + 'a[data-step=' + id + ']').addClass('tab-active').removeClass('tab-missing'); // Update the "save" button if all is okay if(!exists(tab + '.tab-missing')) { var finish = welcome + '.finish.'; $(finish + 'save').show(); $(finish + 'next').hide(); } // If this is ID 2: vJUD search if(id == 2) { wait.show(); dataForm(HOST_VJUD, 'search', '', '', 'welcome'); } else wait.hide(); return false; } // Sends the welcome options function sendWelcome(array) { // Sends the options var iq = new JSJaCIQ(); iq.setType('set'); var query = iq.setQuery(NS_PRIVATE); var storage = query.appendChild(iq.buildNode('storage', {'xmlns': NS_OPTIONS})); // Value array var tags = new Array('sounds', 'geolocation', '', '', 'roster-showall'); // Build the XML with the array for(i in array) { var value = array[i]; var tag = tags[i]; if((i != 2) && (i != 3) && tag && value) { storage.appendChild(iq.buildNode('option', {'type': tag, 'xmlns': NS_OPTIONS}, value)); setDB('options', tag, value); } } con.send(iq); // If geolocation is enabled if(array[1] == '1') geolocate(); } // Saves the welcome options var END_WELCOME = false; function saveWelcome() { // Get the new options var array = new Array(); $('#welcome a.box').each(function() { var current = '0'; if($(this).hasClass('enabled')) current = '1'; array.push(current); }); // If XMPP links is enabled if(array[2] == '1') xmppLinksHandler(); // If offline buddies showing is enabled if(array[4] == '1') showAllBuddies('welcome'); // If archiving is supported by the server if(enabledArchives('pref')) { var aEnabled = false; // If archiving is enabled if(array[3] == '1') aEnabled = true; // Send the archives configuration configArchives(aEnabled); } // Send the new options sendWelcome(array); // Close the welcome tool closeWelcome(); // Open the profile editor openVCard(); END_WELCOME = true; return false; } // Goes to the next welcome step function nextWelcome() { // Check the next step to go to var next = 1; var missing = '#welcome .tab a.tab-missing'; if(exists(missing)) next = parseInt($(missing + ':first').attr('data-step')); // Switch to the next step switchWelcome(next); return false; } // Addon launcher function launchWelcome() { // Click events $('#welcome .tab a').click(function() { // Switch to the good tab var key = parseInt($(this).attr('data-step')); return switchWelcome(key); }); $('#welcome a.box:not(.share)').click(function() { if($(this).hasClass('enabled')) $(this).removeClass('enabled').attr('title', _e("Click to enable")); else $(this).addClass('enabled').attr('title', _e("Click to disable")); return false; }); $('#welcome .bottom .finish').click(function() { if($(this).is('.next')) return nextWelcome(); if($(this).is('.save')) return saveWelcome(); return false; }); }