diff --git a/desktop/apps/desktop.login/desktop.login.js b/desktop/apps/desktop.login/desktop.login.js index adbb2f9..34876ec 100644 --- a/desktop/apps/desktop.login/desktop.login.js +++ b/desktop/apps/desktop.login/desktop.login.js @@ -79,7 +79,7 @@ desktop.app.login.load = function loadDesktopLogin (params, next) { // token is valid, show client login success buddypond.qtokenid = localToken; buddypond.me = me; - desktop.app.login.success(); + desktop.app.login.success({ source: 'localToken' }); } if (location.hash) { desktop.routeFromHash(); @@ -137,7 +137,7 @@ desktop.app.login.auth = function authDesktop (buddyname, password) { localStorage.setItem('qtokenid', data.qtokenid); localStorage.setItem('me', buddypond.me); buddypond.qtokenid = data.qtokenid; - desktop.app.login.success(); + desktop.app.login.success({ source: 'serverToken' }); } else { if (data.banned) { alert(data.message); @@ -158,14 +158,14 @@ desktop.app.login.auth = function authDesktop (buddyname, password) { }); }; -desktop.app.login.success = function desktopLoginSuccess () { +desktop.app.login.success = function desktopLoginSuccess (params) { $('#me_title').html('Welcome - ' + buddypond.me); $('.me').html(buddypond.me); desktop.play('WELCOME.wav', Infinity); $('.logoutLink').show(); $('.loginLink').hide(); // $('.qtokenid').val(data); - $('#window_login').hide(); + desktop.ui.closeWindow('login'); $('.buddy_pond_not_connected').hide(); $('#login_desktop_icon').hide(); $('#profile_desktop_icon').show(); @@ -209,22 +209,29 @@ desktop.app.login.success = function desktopLoginSuccess () { }, 1000); // TODO: route default view based on query string - let params = desktop.utils.parseQueryString(document.location.search); - if (params.pond) { + let queryParams = desktop.utils.parseQueryString(document.location.search); + if (queryParams.pond) { desktop.ui.openWindow('pond', { - context: params.pond + context: queryParams.pond }); } else { - $('#window_buddylist').show(); - desktop.ui.openWindow('buddylist'); - desktop.ui.openWindow('pond'); - desktop.ui.openWindow('pond', { - context: 'Lily' - }); - // anounce all new buddies when they join + // is the source of the login is a serverToken, this indicates a fresh login + // for fresh logins, show the buddy list and join the default Lily Pond + // if params.source === 'localToken', this indicates that localStorage remembered the session + // and that the desktop should rely on localStorage desktop.settings.windows_open + if (params.source === 'serverToken') { + $('#window_buddylist').show(); + desktop.ui.openWindow('buddylist'); + desktop.ui.openWindow('pond'); + desktop.ui.openWindow('pond', { + context: 'Lily' + }); + } + // anounce all new anonymous buddies when they join if (buddypond.me === 'anonymous') { buddypond.pondSendMessage('Lily', 'Hello, I am anonymous.', function (err, data) { }); + // TODO: show Merlin welcome message } } @@ -241,7 +248,7 @@ desktop.app.login.success = function desktopLoginSuccess () { desktop.app.login.openWindow = function desktopLoginOpenWindow () { $('.desktopConnected').hide(); $('.logoutLink').hide(); - $('#window_login').addClass('window_stack').show(); + // $('#window_login').addClass('window_stack').show(); $('#window_login').css('width', '74vw'); $('#window_login').css('height', '75vh'); $('#window_login').css('left', '22vw'); diff --git a/desktop/apps/desktop.mtv/data/mtv.js b/desktop/apps/desktop.mtv/data/mtv.js index 1f8f4ac..faae48f 100644 --- a/desktop/apps/desktop.mtv/data/mtv.js +++ b/desktop/apps/desktop.mtv/data/mtv.js @@ -111,6 +111,9 @@ desktop.app.ytPlaylist = [ 'itRWssMSuvw', 'mV-qGna_4Eo', 'RISWXReh-QI', - 'EtC8WxPt7d8' + 'EtC8WxPt7d8', + 'ALZHF5UqnU4', + 'K5KAc5CoCuk', + 'VHoT4N43jK8' ]; diff --git a/desktop/assets/js/jquery.desktop.x.js b/desktop/assets/js/jquery.desktop.x.js index 707f366..f575f32 100755 --- a/desktop/assets/js/jquery.desktop.x.js +++ b/desktop/assets/js/jquery.desktop.x.js @@ -397,17 +397,20 @@ JQDX.window_resize = function window_resize (el) { // Bring window to front. JQDX.window_flat(); win.addClass('window_stack'); - - desktop.ui.openWindows[win.attr('id')] = { + /* TODO: windows_open should remember if window min or max + let openWindows = desktop.settings.windows_open || {}; + openWindows[win.attr('id')] = { open: true, - app: appName, + app: win.data('app'), + context: win.data('context'), width: win.css('width'), height: win.css('height'), top: win.css('top'), left: win.css('left') } - + desktop.ui.openWindows = openWindows; desktop.set('windows_open', desktop.ui.openWindows); + */ }; @@ -495,6 +498,15 @@ JQDX.bindDocumentEventHandlers = function bindDocumentEventHandlers () { return false; }); + /* TODO: remove help with single click + d.on('click', '.help', function (ev) { + // Remark It's not code yet, it's "coode" + let holder = $(this).parent(); + holder.hide(); + return false; + }); + */ + d.on('click', 'tr.openApp', function (ev) { let appName = $(this).data('app'); desktop.ui.openWindow(appName); @@ -726,10 +738,12 @@ JQDX.bindDocumentEventHandlers = function bindDocumentEventHandlers () { // desktop.ui.getDesktopIconPositions(); let win = $(this); let windowId = '#' + win.attr('id'); - let appName = windowId.replace('#window_', ''); + let appName = win.data('app'); + let context = win.data('context'); desktop.ui.openWindows[windowId] = { open: true, app: appName, + context: context, width: win.css('width'), height: win.css('height'), top: win.css('top'), @@ -848,6 +862,7 @@ JQDX.loadWindow = function loadWindow (appName, params, callback) { }); */ if (desktop.app[appName] && desktop.app[appName].depends_on && desktop.app[appName].depends_on.length > 0) { + // TODO: can we remove this and just use call load.remoteJS() from inside the app.load ( like other deps ) let depName = desktop.app[appName].depends_on[0]; desktop.log('Loading: App.' + depName); desktop.load.remoteJS([ `desktop/apps/desktop.${depName}/desktop.${desktop.app[appName].depends_on[0]}.js` ], function () { @@ -906,6 +921,9 @@ JQDX.showWindow = function showWindow (appName, params) { JQDX.window_flat(); $(appWindow).addClass('window_stack').show(); + $(appWindow).data('app', appName); + $(appWindow).data('context', params.context); + if (desktop.ui.view === 'Mobile') { JQDX.window_maximize($(appWindow)); } @@ -925,7 +943,8 @@ JQDX.showWindow = function showWindow (appName, params) { let win = $(appWindow); desktop.ui.openWindows[appWindow] = { open: true, - app: appName, + app: win.data('app'), + context: win.data('context'), width: win.css('width'), height: win.css('height'), top: win.css('top'), @@ -1383,12 +1402,11 @@ desktop.ui.toggleDisplayMode = function toggleDisplayMode () { } } -desktop.ui.openSavedWindows = function openSavedWindows () { - return; +desktop.ui.openWindowsFromSavedSettings = function openWindowsFromSavedSettings () { let previouslyOpenWindows = desktop.get('windows_open'); for (let key in previouslyOpenWindows) { let win = previouslyOpenWindows[key]; - desktop.ui.openWindow(win.app, {}, function(){ + desktop.ui.openWindow(win.app, { context: win.context }, function(){ $(key).css('top', win.top); $(key).css('left', win.left); $(key).css('width', win.width); diff --git a/index.html b/index.html index 5f0321f..b9117a3 100755 --- a/index.html +++ b/index.html @@ -307,7 +307,9 @@ // never gonna work due to: // Refused to display 'https://www.google.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. // desktop.ui.openWindow('console'); - // desktop.ui.openSavedWindows(); + + // re-opens previously opened windows + desktop.ui.openWindowsFromSavedSettings(); }); });