From c7f5115e26a6cdc7e6e33649c475ff7f39550105 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 3 May 2017 16:38:25 -0700 Subject: [PATCH 1/6] Move help text to above buttons --- scripts/system/html/css/SnapshotReview.css | 4 ++-- scripts/system/html/js/SnapshotReview.js | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/system/html/css/SnapshotReview.css b/scripts/system/html/css/SnapshotReview.css index 29c5f465d7..bd9bb81fdc 100644 --- a/scripts/system/html/css/SnapshotReview.css +++ b/scripts/system/html/css/SnapshotReview.css @@ -158,7 +158,7 @@ input[type=button].naked:active { align-items: flex-end; height: 40px; width: calc(100% - 60px); - margin-bottom: 25px; + margin-bottom: -24px; margin-left: 0; } .shareButtons img { @@ -178,7 +178,7 @@ input[type=button].naked:active { height: 25px; line-height: 25px; position: absolute; - bottom: 0; + bottom: 40px; left: 73px; right: 0; font-family: Raleway-Regular; diff --git a/scripts/system/html/js/SnapshotReview.js b/scripts/system/html/js/SnapshotReview.js index 6365c2be18..a8a73b62bc 100644 --- a/scripts/system/html/js/SnapshotReview.js +++ b/scripts/system/html/js/SnapshotReview.js @@ -134,7 +134,8 @@ function createShareBar(parentID, isGif, blastButtonDisabled, hifiButtonDisabled shareBar.id = parentID + "shareBar"; shareBar.className = "shareControls"; - var shareBarInnerHTML = '
' + + var shareBarInnerHTML = '' + + '
' + '' + '' + '' + @@ -151,8 +152,6 @@ function createShareBar(parentID, isGif, blastButtonDisabled, hifiButtonDisabled shareBar.innerHTML = shareBarInnerHTML; - shareBar.innerHTML += ''; - // Add onclick handler to parent DIV's img to toggle share buttons document.getElementById(parentID + 'img').onclick = function () { selectImageToShare(parentID, true); }; From b01bff061e7a6f0122eb3b6562e6f162628ff787 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 4 May 2017 10:06:33 -0700 Subject: [PATCH 2/6] Hover lock when uploading --- scripts/system/html/js/SnapshotReview.js | 99 +++++++++++++----------- 1 file changed, 52 insertions(+), 47 deletions(-) diff --git a/scripts/system/html/js/SnapshotReview.js b/scripts/system/html/js/SnapshotReview.js index a8a73b62bc..4aede9e3bc 100644 --- a/scripts/system/html/js/SnapshotReview.js +++ b/scripts/system/html/js/SnapshotReview.js @@ -261,6 +261,7 @@ function showUploadingMessage(selectedID, destination) { var shareBarHelp = document.getElementById(selectedID + "shareBarHelp"); shareBarHelp.innerHTML = 'Preparing to Share'; + shareBarHelp.classList.add("uploading"); shareBarHelp.setAttribute("data-destination", destination); } function hideUploadingMessageAndShare(selectedID, storyID) { @@ -270,6 +271,8 @@ function hideUploadingMessageAndShare(selectedID, storyID) { var shareBarHelp = document.getElementById(selectedID + "shareBarHelp"), shareBarHelpDestination = shareBarHelp.getAttribute("data-destination"); + + shareBarHelp.classList.remove("uploading"); if (shareBarHelpDestination) { switch (shareBarHelpDestination) { case 'blast': @@ -387,54 +390,56 @@ function shareButtonHovered(destination, selectedID) { shareButtonsDiv = document.getElementById(selectedID + "shareButtonsDiv").childNodes, itr; - for (itr = 0; itr < shareButtonsDiv.length; itr += 1) { - shareButtonsDiv[itr].style.backgroundColor = "rgba(0, 0, 0, 0)"; - } - shareBarHelp.style.opacity = "1.0"; + if (!shareBarHelp.classList.contains("uploading")) { - switch (destination) { - case 'blast': - var blastToConnectionsButton = document.getElementById(selectedID + "blastToConnectionsButton"); - if (!blastToConnectionsButton.classList.contains("disabled")) { - shareBarHelp.style.backgroundColor = "#EA4C5F"; - shareBarHelp.style.opacity = "1.0"; - blastToConnectionsButton.style.backgroundColor = "#EA4C5F"; - blastToConnectionsButton.style.opacity = "1.0"; - shareBarHelp.innerHTML = blastShareText; - } else { - shareBarHelp.style.backgroundColor = "#000000"; - shareBarHelp.style.opacity = "0.5"; - blastToConnectionsButton.style.backgroundColor = "#000000"; - blastToConnectionsButton.style.opacity = "0.5"; - shareBarHelp.innerHTML = blastAlreadySharedText; - } - break; - case 'hifi': - var shareWithEveryoneButton = document.getElementById(selectedID + "shareWithEveryoneButton"); - if (!shareWithEveryoneButton.classList.contains("disabled")) { - shareBarHelp.style.backgroundColor = "#1FC6A6"; - shareBarHelp.style.opacity = "1.0"; - shareWithEveryoneButton.style.backgroundColor = "#1FC6A6"; - shareWithEveryoneButton.style.opacity = "1.0"; - shareBarHelp.innerHTML = hifiShareText; - } else { - shareBarHelp.style.backgroundColor = "#000000"; - shareBarHelp.style.opacity = "0.5"; - shareWithEveryoneButton.style.backgroundColor = "#000000"; - shareWithEveryoneButton.style.opacity = "0.5"; - shareBarHelp.innerHTML = hifiAlreadySharedText; - } - break; - case 'facebook': - shareBarHelp.style.backgroundColor = "#3C58A0"; - shareBarHelp.innerHTML = facebookShareText; - document.getElementById(selectedID + "facebookButton").style.backgroundColor = "#3C58A0"; - break; - case 'twitter': - shareBarHelp.style.backgroundColor = "#00B4EE"; - shareBarHelp.innerHTML = twitterShareText; - document.getElementById(selectedID + "twitterButton").style.backgroundColor = "#00B4EE"; - break; + for (itr = 0; itr < shareButtonsDiv.length; itr += 1) { + shareButtonsDiv[itr].style.backgroundColor = "rgba(0, 0, 0, 0)"; + } + shareBarHelp.style.opacity = "1.0"; + switch (destination) { + case 'blast': + var blastToConnectionsButton = document.getElementById(selectedID + "blastToConnectionsButton"); + if (!blastToConnectionsButton.classList.contains("disabled")) { + shareBarHelp.style.backgroundColor = "#EA4C5F"; + shareBarHelp.style.opacity = "1.0"; + blastToConnectionsButton.style.backgroundColor = "#EA4C5F"; + blastToConnectionsButton.style.opacity = "1.0"; + shareBarHelp.innerHTML = blastShareText; + } else { + shareBarHelp.style.backgroundColor = "#000000"; + shareBarHelp.style.opacity = "0.5"; + blastToConnectionsButton.style.backgroundColor = "#000000"; + blastToConnectionsButton.style.opacity = "0.5"; + shareBarHelp.innerHTML = blastAlreadySharedText; + } + break; + case 'hifi': + var shareWithEveryoneButton = document.getElementById(selectedID + "shareWithEveryoneButton"); + if (!shareWithEveryoneButton.classList.contains("disabled")) { + shareBarHelp.style.backgroundColor = "#1FC6A6"; + shareBarHelp.style.opacity = "1.0"; + shareWithEveryoneButton.style.backgroundColor = "#1FC6A6"; + shareWithEveryoneButton.style.opacity = "1.0"; + shareBarHelp.innerHTML = hifiShareText; + } else { + shareBarHelp.style.backgroundColor = "#000000"; + shareBarHelp.style.opacity = "0.5"; + shareWithEveryoneButton.style.backgroundColor = "#000000"; + shareWithEveryoneButton.style.opacity = "0.5"; + shareBarHelp.innerHTML = hifiAlreadySharedText; + } + break; + case 'facebook': + shareBarHelp.style.backgroundColor = "#3C58A0"; + shareBarHelp.innerHTML = facebookShareText; + document.getElementById(selectedID + "facebookButton").style.backgroundColor = "#3C58A0"; + break; + case 'twitter': + shareBarHelp.style.backgroundColor = "#00B4EE"; + shareBarHelp.innerHTML = twitterShareText; + document.getElementById(selectedID + "twitterButton").style.backgroundColor = "#00B4EE"; + break; + } } } function shareButtonClicked(destination, selectedID) { From b08d23924a58a9134bd82a05d820389324652036 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 4 May 2017 11:00:13 -0700 Subject: [PATCH 3/6] Keep hover status of both images in sync --- scripts/system/html/js/SnapshotReview.js | 31 +++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/scripts/system/html/js/SnapshotReview.js b/scripts/system/html/js/SnapshotReview.js index 4aede9e3bc..27062faea2 100644 --- a/scripts/system/html/js/SnapshotReview.js +++ b/scripts/system/html/js/SnapshotReview.js @@ -143,11 +143,11 @@ function createShareBar(parentID, isGif, blastButtonDisabled, hifiButtonDisabled '
' + ''; shareBar.innerHTML = shareBarInnerHTML; @@ -164,11 +164,11 @@ function appendShareBar(divID, isGif, blastButtonDisabled, hifiButtonDisabled, c document.getElementById(divID).appendChild(createShareBar(divID, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast)); if (divID === "p0") { selectImageToShare(divID, true); - if (canBlast) { - shareButtonHovered('blast', divID); - } else { - shareButtonHovered('hifi', divID); - } + } + if (canBlast) { + shareButtonHovered('blast', divID, false); + } else { + shareButtonHovered('hifi', divID, false); } } function shareForUrl(selectedID) { @@ -382,7 +382,7 @@ function shareWithEveryone(selectedID, isGif) { showUploadingMessage(selectedID, 'hifi'); } } -function shareButtonHovered(destination, selectedID) { +function shareButtonHovered(destination, selectedID, shouldAlsoModifyOther) { if (selectedID.id) { selectedID = selectedID.id; // sometimes (?), `selectedID` is passed as an HTML object to these functions; we just want the ID } @@ -391,7 +391,6 @@ function shareButtonHovered(destination, selectedID) { itr; if (!shareBarHelp.classList.contains("uploading")) { - for (itr = 0; itr < shareButtonsDiv.length; itr += 1) { shareButtonsDiv[itr].style.backgroundColor = "rgba(0, 0, 0, 0)"; } @@ -441,6 +440,14 @@ function shareButtonHovered(destination, selectedID) { break; } } + + if (shouldAlsoModifyOther && imageCount > 1) { + if (selectedID === "p0" && !document.getElementById("p1").classList.contains("processingGif")) { + shareButtonHovered(destination, "p1", false); + } else if (selectedID === "p1") { + shareButtonHovered(destination, "p0", false); + } + } } function shareButtonClicked(destination, selectedID) { if (selectedID.id) { @@ -525,6 +532,7 @@ window.onload = function () { message.image_data.forEach(function (element, idx) { addImage(element, idx === 1, idx === 0 && messageOptions.canShare, false); }); + document.getElementById("p1").classList.add("processingGif"); } else { var gifPath = message.image_data[0].localPath, p1img = document.getElementById('p1img'); @@ -534,6 +542,7 @@ window.onload = function () { if (messageOptions.canShare) { shareForUrl("p1"); appendShareBar("p1", true, false, false, true); + document.getElementById("p1").classList.remove("processingGif"); } } } else { From 946c5e766253e1da45a8dfc3f5a958a79467e609 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 4 May 2017 15:24:51 -0700 Subject: [PATCH 4/6] Almost finished with not-logged-in and not-shareable --- scripts/system/html/css/SnapshotReview.css | 14 ++ scripts/system/html/css/hifi-style.css | 10 +- scripts/system/html/js/SnapshotReview.js | 184 ++++++++++++++++----- scripts/system/snapshot.js | 147 +++++++++------- 4 files changed, 248 insertions(+), 107 deletions(-) diff --git a/scripts/system/html/css/SnapshotReview.css b/scripts/system/html/css/SnapshotReview.css index bd9bb81fdc..69de4bb147 100644 --- a/scripts/system/html/css/SnapshotReview.css +++ b/scripts/system/html/css/SnapshotReview.css @@ -187,6 +187,20 @@ input[type=button].naked:active { padding-left: 8px; color: white; } +.helpTextDiv { + width: 350px; + height: 65px; + margin-right: 15px; + line-height: 65px; + position: absolute; + bottom: 0; + right: 0; + font-family: Raleway-Regular; + font-weight: 500; + font-size: 16px; + text-align: right; + color: white; +} /* // END styling of share overlay */ diff --git a/scripts/system/html/css/hifi-style.css b/scripts/system/html/css/hifi-style.css index ac34cee09f..ec6cd1a402 100644 --- a/scripts/system/html/css/hifi-style.css +++ b/scripts/system/html/css/hifi-style.css @@ -136,11 +136,14 @@ input[type=radio]:active + label > span > span{ } .grayButton { - font-family: FiraSans-SemiBold; - color: white; + font-family: Raleway-Bold; + font-size: 13px; + color: black; padding: 0px 10px; + border-radius: 3px; border-width: 0px; background-image: linear-gradient(#FFFFFF, #AFAFAF); + min-height: 30px; } .grayButton:hover { background-image: linear-gradient(#FFFFFF, #FFFFFF); @@ -152,7 +155,8 @@ input[type=radio]:active + label > span > span{ background-image: linear-gradient(#FFFFFF, ##AFAFAF); } .blueButton { - font-family: FiraSans-SemiBold; + font-family: Raleway-Bold; + font-size: 13px; color: white; padding: 0px 10px; border-radius: 3px; diff --git a/scripts/system/html/js/SnapshotReview.js b/scripts/system/html/js/SnapshotReview.js index 27062faea2..dc0d319d16 100644 --- a/scripts/system/html/js/SnapshotReview.js +++ b/scripts/system/html/js/SnapshotReview.js @@ -62,6 +62,12 @@ function chooseSnapshotLocation() { action: "chooseSnapshotLocation" })); } +function login() { + EventBridge.emitWebEvent(JSON.stringify({ + type: "snapshot", + action: "login" + })); +} function clearImages() { document.getElementById("snap-button").disabled = false; var snapshotImagesDiv = document.getElementById("snapshot-images"); @@ -74,6 +80,52 @@ function clearImages() { idCounter = 0; } +function selectImageWithHelpText(selectedID, isSelected) { + if (selectedID.id) { + selectedID = selectedID.id; // sometimes (?), `selectedID` is passed as an HTML object to these functions; we just want the ID + } + var imageContainer = document.getElementById(selectedID), + image = document.getElementById(selectedID + 'img'), + shareBar = document.getElementById(selectedID + "shareBar"), + helpTextDiv = document.getElementById(selectedID + "helpTextDiv"), + showShareButtonsButtonDiv = document.getElementById(selectedID + "showShareButtonsButtonDiv"), + itr, + containers = document.getElementsByClassName("shareControls"); + + if (isSelected) { + showShareButtonsButtonDiv.onclick = function () { selectImageWithHelpText(selectedID, false); }; + showShareButtonsButtonDiv.classList.remove("inactive"); + showShareButtonsButtonDiv.classList.add("active"); + + image.onclick = function () { selectImageWithHelpText(selectedID, false); }; + imageContainer.style.outline = "4px solid #00b4ef"; + imageContainer.style.outlineOffset = "-4px"; + + shareBar.style.backgroundColor = "rgba(0, 0, 0, 0.45)"; + shareBar.style.pointerEvents = "initial"; + + helpTextDiv.style.visibility = "visible"; + + for (itr = 0; itr < containers.length; itr += 1) { + var parentID = containers[itr].id.slice(0, 2); + if (parentID !== selectedID) { + selectImageWithHelpText(parentID, false); + } + } + } else { + showShareButtonsButtonDiv.onclick = function () { selectImageWithHelpText(selectedID, true); }; + showShareButtonsButtonDiv.classList.remove("active"); + showShareButtonsButtonDiv.classList.add("inactive"); + + image.onclick = function () { selectImageWithHelpText(selectedID, true); }; + imageContainer.style.outline = "none"; + + shareBar.style.backgroundColor = "rgba(0, 0, 0, 0.0)"; + shareBar.style.pointerEvents = "none"; + + helpTextDiv.style.visibility = "hidden"; + } +} function selectImageToShare(selectedID, isSelected) { if (selectedID.id) { selectedID = selectedID.id; // sometimes (?), `selectedID` is passed as an HTML object to these functions; we just want the ID @@ -97,6 +149,7 @@ function selectImageToShare(selectedID, isSelected) { imageContainer.style.outlineOffset = "-4px"; shareBar.style.backgroundColor = "rgba(0, 0, 0, 0.45)"; + shareBar.style.pointerEvents = "initial"; shareButtonsDiv.style.visibility = "visible"; shareBarHelp.style.visibility = "visible"; @@ -116,12 +169,13 @@ function selectImageToShare(selectedID, isSelected) { imageContainer.style.outline = "none"; shareBar.style.backgroundColor = "rgba(0, 0, 0, 0.0)"; + shareBar.style.pointerEvents = "none"; shareButtonsDiv.style.visibility = "hidden"; shareBarHelp.style.visibility = "hidden"; } } -function createShareBar(parentID, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast) { +function createShareBar(parentID, isLoggedIn, canShare, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast) { var shareBar = document.createElement("div"), shareBarHelpID = parentID + "shareBarHelp", shareButtonsDivID = parentID + "shareButtonsDiv", @@ -130,45 +184,85 @@ function createShareBar(parentID, isGif, blastButtonDisabled, hifiButtonDisabled blastToConnectionsButtonID = parentID + "blastToConnectionsButton", shareWithEveryoneButtonID = parentID + "shareWithEveryoneButton", facebookButtonID = parentID + "facebookButton", - twitterButtonID = parentID + "twitterButton"; + twitterButtonID = parentID + "twitterButton", + shareBarInnerHTML = ''; shareBar.id = parentID + "shareBar"; shareBar.className = "shareControls"; - var shareBarInnerHTML = '' + - '
' + - '' + - '' + - '' + + + if (isLoggedIn) { + if (canShare) { + shareBarInnerHTML = '' + + '
' + + '' + + '' + + '' + + '
' + + '
' + + ''; + + // Add onclick handler to parent DIV's img to toggle share buttons + document.getElementById(parentID + 'img').onclick = function () { selectImageToShare(parentID, true); }; + } else { + shareBarInnerHTML = '
' + + '' + + '' + + '' + + '
' + + '
' + + ''; + // Add onclick handler to parent DIV's img to toggle share buttons + document.getElementById(parentID + 'img').onclick = function () { selectImageWithHelpText(parentID, true); }; + } + } else { + shareBarInnerHTML = '
' + + '' + + '' + + '' + + '
' + '' + - '' + - ''; shareBar.innerHTML = shareBarInnerHTML; - // Add onclick handler to parent DIV's img to toggle share buttons - document.getElementById(parentID + 'img').onclick = function () { selectImageToShare(parentID, true); }; - return shareBar; } -function appendShareBar(divID, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast) { +function appendShareBar(divID, isLoggedIn, canShare, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast) { if (divID.id) { divID = divID.id; // sometimes (?), `containerID` is passed as an HTML object to these functions; we just want the ID } - document.getElementById(divID).appendChild(createShareBar(divID, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast)); + document.getElementById(divID).appendChild(createShareBar(divID, isLoggedIn, canShare, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast)); if (divID === "p0") { - selectImageToShare(divID, true); + if (isLoggedIn) { + if (canShare) { + selectImageWithHelpText(divID, true); + } else { + selectImageToShare(divID, true); + } + } else { + selectImageWithHelpText(divID, true); + } } - if (canBlast) { - shareButtonHovered('blast', divID, false); - } else { - shareButtonHovered('hifi', divID, false); + if (isLoggedIn && canShare) { + if (canBlast) { + shareButtonHovered('blast', divID, false); + } else { + shareButtonHovered('hifi', divID, false); + } } } function shareForUrl(selectedID) { @@ -178,7 +272,7 @@ function shareForUrl(selectedID) { data: paths[parseInt(selectedID.substring(1), 10)] })); } -function addImage(image_data, isGifLoading, canShare, isShowingPreviousImages, blastButtonDisabled, hifiButtonDisabled, canBlast) { +function addImage(image_data, isLoggedIn, canShare, isGifLoading, isShowingPreviousImages, blastButtonDisabled, hifiButtonDisabled, canBlast) { if (!image_data.localPath) { return; } @@ -203,12 +297,13 @@ function addImage(image_data, isGifLoading, canShare, isShowingPreviousImages, b if (isGif) { imageContainer.innerHTML += 'GIF'; } - if (!isGifLoading && !isShowingPreviousImages && canShare) { - appendShareBar(id, isGif, blastButtonDisabled, hifiButtonDisabled, true); + if (!isGifLoading) { + appendShareBar(id, isLoggedIn, canShare, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast); + } + if (!isGifLoading && !isShowingPreviousImages) { shareForUrl(id); } - if (isShowingPreviousImages && image_data.story_id) { - appendShareBar(id, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast); + if (isShowingPreviousImages && isLoggedIn && image_data.story_id) { updateShareInfo(id, image_data.story_id); } } @@ -485,7 +580,7 @@ function handleCaptureSetting(setting) { window.onload = function () { // Uncomment the line below to test functionality in a browser. // See definition of "testInBrowser()" to modify tests. - //testInBrowser(3); + //testInBrowser(4); openEventBridge(function () { // Set up a handler for receiving the data, and tell the .js we are ready to receive it. EventBridge.scriptEventReceived.connect(function (message) { @@ -514,7 +609,7 @@ window.onload = function () { imageCount = message.image_data.length; if (imageCount > 0) { message.image_data.forEach(function (element, idx) { - addImage(element, true, message.canShare, true, message.image_data[idx].blastButtonDisabled, message.image_data[idx].hifiButtonDisabled, messageOptions.canBlast); + addImage(element, messageOptions.isLoggedIn, message.canShare, false, true, message.image_data[idx].blastButtonDisabled, message.image_data[idx].hifiButtonDisabled, messageOptions.canBlast); }); } else { showSnapshotInstructions(); @@ -530,7 +625,7 @@ window.onload = function () { imageCount = message.image_data.length + 1; // "+1" for the GIF that'll finish processing soon message.image_data.push({ localPath: messageOptions.loadingGifPath }); message.image_data.forEach(function (element, idx) { - addImage(element, idx === 1, idx === 0 && messageOptions.canShare, false); + addImage(element, messageOptions.isLoggedIn, idx === 0 && messageOptions.canShare, idx === 1, false); }); document.getElementById("p1").classList.add("processingGif"); } else { @@ -541,14 +636,14 @@ window.onload = function () { paths[1] = gifPath; if (messageOptions.canShare) { shareForUrl("p1"); - appendShareBar("p1", true, false, false, true); + appendShareBar("p1", messageOptions.isLoggedIn, true, false, false, true); document.getElementById("p1").classList.remove("processingGif"); } } } else { imageCount = message.image_data.length; message.image_data.forEach(function (element) { - addImage(element, false, messageOptions.canShare, false); + addImage(element, messageOptions.isLoggedIn, messageOptions.canShare, false, false); }); } break; @@ -590,18 +685,23 @@ function testInBrowser(test) { } else if (test === 1) { imageCount = 2; //addImage({ localPath: 'http://lorempixel.com/553/255' }); - addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.jpg', story_id: 1338 }, false, true, true, false, false, true); - addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.gif', story_id: 1337 }, false, true, true, false, false, true); + addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.jpg', story_id: 1338 }, true, true, false, true, false, false, true); + addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.gif', story_id: 1337 }, true, true, false, true, false, false, true); } else if (test === 2) { - addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.jpg', story_id: 1338 }, false, true, true, false, false, true); - addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.gif', story_id: 1337 }, false, true, true, false, false, true); + addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.jpg', story_id: 1338 }, true, true, false, true, false, false, true); + addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.gif', story_id: 1337 }, true, true, false, true, false, false, true); showConfirmationMessage("p0", 'blast'); showConfirmationMessage("p1", 'hifi'); } else if (test === 3) { imageCount = 2; //addImage({ localPath: 'http://lorempixel.com/553/255' }); - addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.jpg', story_id: 1338 }, false, true, true, false, false, true); - addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.gif', story_id: 1337 }, false, true, true, false, false, true); + addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.jpg', story_id: 1338 }, true, true, false, true, false, false, true); + addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.gif', story_id: 1337 }, true, true, false, true, false, false, true); showUploadingMessage("p0", 'hifi'); - } + } else if (test === 4) { + imageCount = 2; + //addImage({ localPath: 'http://lorempixel.com/553/255' }); + addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.jpg', story_id: 1338 }, false, true, false, true, false, false, true); + addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.gif', story_id: 1337 }, false, true, false, true, false, false, true); +} } diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index b93595f0b4..a4e18d2869 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -29,12 +29,13 @@ var button = tablet.addButton({ sortOrder: 5 }); -var snapshotOptions; +var snapshotOptions = {}; var imageData = []; var storyIDsToMaybeDelete = []; var shareAfterLogin = false; -var snapshotToShareAfterLogin; +var snapshotToShareAfterLogin = []; var METAVERSE_BASE = location.metaverseServerUrl; +var isLoggedIn; // It's totally unnecessary to return to C++ to perform many of these requests, such as DELETEing an old story, // POSTING a new one, PUTTING a new audience, or GETTING story data. It's far more efficient to do all of that within JS @@ -108,7 +109,6 @@ function onMessage(message) { return; } - var isLoggedIn; switch (message.action) { case 'ready': // DOM is ready and page has loaded tablet.emitScriptEvent(JSON.stringify({ @@ -141,6 +141,9 @@ function onMessage(message) { Settings.setValue("previousAnimatedSnapHifiSharingDisabled", false); } break; + case 'login': + openLoginWindow(); + break; case 'chooseSnapshotLocation': var snapshotPath = Window.browseDir("Choose Snapshots Directory", "", ""); @@ -177,18 +180,19 @@ function onMessage(message) { print('Sharing snapshot with audience "for_url":', message.data); Window.shareSnapshot(message.data, message.href || href); } else { - // TODO + shareAfterLogin = true; + snapshotToShareAfterLogin.push({ path: message.data, href: message.href || href }); } break; case 'blastToConnections': isLoggedIn = Account.isLoggedIn(); - if (message.isGif) { - Settings.setValue("previousAnimatedSnapBlastingDisabled", true); - } else { - Settings.setValue("previousStillSnapBlastingDisabled", true); - } - if (isLoggedIn) { + if (message.isGif) { + Settings.setValue("previousAnimatedSnapBlastingDisabled", true); + } else { + Settings.setValue("previousStillSnapBlastingDisabled", true); + } + print('Uploading new story for announcement!'); request({ @@ -234,20 +238,16 @@ function onMessage(message) { }); } }); - - } else { - openLoginWindow(); } break; case 'shareSnapshotWithEveryone': isLoggedIn = Account.isLoggedIn(); - if (message.isGif) { - Settings.setValue("previousAnimatedSnapHifiSharingDisabled", true); - } else { - Settings.setValue("previousStillSnapHifiSharingDisabled", true); - } - if (isLoggedIn) { + if (message.isGif) { + Settings.setValue("previousAnimatedSnapHifiSharingDisabled", true); + } else { + Settings.setValue("previousStillSnapHifiSharingDisabled", true); + } print('Modifying audience of story ID', message.story_id, "to 'for_feed'"); var requestBody = { audience: "for_feed" @@ -275,10 +275,6 @@ function onMessage(message) { print("SUCCESS changing audience" + (message.isAnnouncement ? " and posting announcement!" : "!")); } }); - } else { - openLoginWindow(); - shareAfterLogin = true; - snapshotToShareAfterLogin = { path: message.data, href: message.href || href }; } break; case 'removeFromStoryIDsToMaybeDelete': @@ -291,6 +287,42 @@ function onMessage(message) { } } +function fillImageDataFromPrevious() { + isLoggedIn = Account.isLoggedIn(); + var previousStillSnapPath = Settings.getValue("previousStillSnapPath"); + var previousStillSnapStoryID = Settings.getValue("previousStillSnapStoryID"); + var previousStillSnapBlastingDisabled = Settings.getValue("previousStillSnapBlastingDisabled"); + var previousStillSnapHifiSharingDisabled = Settings.getValue("previousStillSnapHifiSharingDisabled"); + var previousAnimatedSnapPath = Settings.getValue("previousAnimatedSnapPath"); + var previousAnimatedSnapStoryID = Settings.getValue("previousAnimatedSnapStoryID"); + var previousAnimatedSnapBlastingDisabled = Settings.getValue("previousAnimatedSnapBlastingDisabled"); + var previousAnimatedSnapHifiSharingDisabled = Settings.getValue("previousAnimatedSnapHifiSharingDisabled"); + snapshotOptions = { + containsGif: previousAnimatedSnapPath !== "", + processingGif: false, + shouldUpload: false, + canBlast: location.domainId === Settings.getValue("previousSnapshotDomainID"), + isLoggedIn: isLoggedIn + }; + imageData = []; + if (previousStillSnapPath !== "") { + imageData.push({ + localPath: previousStillSnapPath, + story_id: previousStillSnapStoryID, + blastButtonDisabled: previousStillSnapBlastingDisabled, + hifiButtonDisabled: previousStillSnapHifiSharingDisabled + }); + } + if (previousAnimatedSnapPath !== "") { + imageData.push({ + localPath: previousAnimatedSnapPath, + story_id: previousAnimatedSnapStoryID, + blastButtonDisabled: previousAnimatedSnapBlastingDisabled, + hifiButtonDisabled: previousAnimatedSnapHifiSharingDisabled + }); + } +} + var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html"); var isInSnapshotReview = false; var shouldActivateButton = false; @@ -300,37 +332,7 @@ function onButtonClicked() { tablet.gotoHomeScreen(); } else { shouldActivateButton = true; - var previousStillSnapPath = Settings.getValue("previousStillSnapPath"); - var previousStillSnapStoryID = Settings.getValue("previousStillSnapStoryID"); - var previousStillSnapBlastingDisabled = Settings.getValue("previousStillSnapBlastingDisabled"); - var previousStillSnapHifiSharingDisabled = Settings.getValue("previousStillSnapHifiSharingDisabled"); - var previousAnimatedSnapPath = Settings.getValue("previousAnimatedSnapPath"); - var previousAnimatedSnapStoryID = Settings.getValue("previousAnimatedSnapStoryID"); - var previousAnimatedSnapBlastingDisabled = Settings.getValue("previousAnimatedSnapBlastingDisabled"); - var previousAnimatedSnapHifiSharingDisabled = Settings.getValue("previousAnimatedSnapHifiSharingDisabled"); - snapshotOptions = { - containsGif: previousAnimatedSnapPath !== "", - processingGif: false, - shouldUpload: false, - canBlast: location.domainId === Settings.getValue("previousSnapshotDomainID") - } - imageData = []; - if (previousStillSnapPath !== "") { - imageData.push({ - localPath: previousStillSnapPath, - story_id: previousStillSnapStoryID, - blastButtonDisabled: previousStillSnapBlastingDisabled, - hifiButtonDisabled: previousStillSnapHifiSharingDisabled - }); - } - if (previousAnimatedSnapPath !== "") { - imageData.push({ - localPath: previousAnimatedSnapPath, - story_id: previousAnimatedSnapStoryID, - blastButtonDisabled: previousAnimatedSnapBlastingDisabled, - hifiButtonDisabled: previousAnimatedSnapHifiSharingDisabled - }); - } + fillImageDataFromPrevious(); tablet.gotoWebScreen(SNAPSHOT_REVIEW_URL); tablet.webEventReceived.connect(onMessage); HMD.openTablet(); @@ -453,6 +455,7 @@ function isDomainOpen(id, callback) { } function stillSnapshotTaken(pathStillSnapshot, notify) { + isLoggedIn = Account.isLoggedIn(); // show hud Reticle.visible = reticleVisible; Reticle.allowMouseCapture = true; @@ -481,7 +484,8 @@ function stillSnapshotTaken(pathStillSnapshot, notify) { snapshotOptions = { containsGif: false, processingGif: false, - canShare: canShare + canShare: canShare, + isLoggedIn: isLoggedIn }; imageData = [{ localPath: pathStillSnapshot, href: href }]; tablet.emitScriptEvent(JSON.stringify({ @@ -496,6 +500,7 @@ function stillSnapshotTaken(pathStillSnapshot, notify) { function processingGifStarted(pathStillSnapshot) { Window.processingGifStarted.disconnect(processingGifStarted); Window.processingGifCompleted.connect(processingGifCompleted); + isLoggedIn = Account.isLoggedIn(); // show hud Reticle.visible = reticleVisible; Reticle.allowMouseCapture = true; @@ -515,7 +520,8 @@ function processingGifStarted(pathStillSnapshot) { containsGif: true, processingGif: true, loadingGifPath: Script.resolvePath(Script.resourcesPath() + 'icons/loadingDark.gif'), - canShare: canShare + canShare: canShare, + isLoggedIn: isLoggedIn }; imageData = [{ localPath: pathStillSnapshot, href: href }]; tablet.emitScriptEvent(JSON.stringify({ @@ -528,6 +534,7 @@ function processingGifStarted(pathStillSnapshot) { } function processingGifCompleted(pathAnimatedSnapshot) { + isLoggedIn = Account.isLoggedIn(); Window.processingGifCompleted.disconnect(processingGifCompleted); if (!buttonConnected) { button.clicked.connect(onButtonClicked); @@ -540,7 +547,8 @@ function processingGifCompleted(pathAnimatedSnapshot) { snapshotOptions = { containsGif: true, processingGif: false, - canShare: canShare + canShare: canShare, + isLoggedIn: isLoggedIn }; imageData = [{ localPath: pathAnimatedSnapshot, href: href }]; tablet.emitScriptEvent(JSON.stringify({ @@ -576,10 +584,25 @@ function onTabletScreenChanged(type, url) { } } function onUsernameChanged() { - if (shareAfterLogin && Account.isLoggedIn()) { - print('Sharing snapshot after login:', snapshotToShareAfterLogin.path); - Window.shareSnapshot(snapshotToShareAfterLogin.path, snapshotToShareAfterLogin.href); - shareAfterLogin = false; + fillImageDataFromPrevious(); + isDomainOpen(Settings.getValue("previousSnapshotDomainID"), function (canShare) { + tablet.emitScriptEvent(JSON.stringify({ + type: "snapshot", + action: "showPreviousImages", + options: snapshotOptions, + image_data: imageData, + canShare: canShare + })); + }); + if (isLoggedIn) { + if (shareAfterLogin) { + snapshotToShareAfterLogin.forEach(function (element) { + print('Uploading snapshot after login:', element.path); + Window.shareSnapshot(element.path, element.href); + }); + shareAfterLogin = false; + snapshotToShareAfterLogin = []; + } } } function snapshotLocationSet(location) { @@ -595,7 +618,7 @@ button.clicked.connect(onButtonClicked); buttonConnected = true; Window.snapshotShared.connect(snapshotUploaded); tablet.screenChanged.connect(onTabletScreenChanged); -Account.usernameChanged.connect(onUsernameChanged); +GlobalServices.myUsernameChanged.connect(onUsernameChanged); Snapshot.snapshotLocationSet.connect(snapshotLocationSet); Script.scriptEnding.connect(function () { if (buttonConnected) { From 2ad3346697355a0ca759a92178b30c38c5efc1df Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 4 May 2017 16:05:20 -0700 Subject: [PATCH 5/6] Are there bugs? --- scripts/system/html/css/SnapshotReview.css | 1 - scripts/system/html/js/SnapshotReview.js | 22 +++++++------- scripts/system/snapshot.js | 34 ++++++++++++++-------- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/scripts/system/html/css/SnapshotReview.css b/scripts/system/html/css/SnapshotReview.css index 69de4bb147..218eb8c9a5 100644 --- a/scripts/system/html/css/SnapshotReview.css +++ b/scripts/system/html/css/SnapshotReview.css @@ -198,7 +198,6 @@ input[type=button].naked:active { font-family: Raleway-Regular; font-weight: 500; font-size: 16px; - text-align: right; color: white; } /* diff --git a/scripts/system/html/js/SnapshotReview.js b/scripts/system/html/js/SnapshotReview.js index dc0d319d16..25bc25b776 100644 --- a/scripts/system/html/js/SnapshotReview.js +++ b/scripts/system/html/js/SnapshotReview.js @@ -217,8 +217,8 @@ function createShareBar(parentID, isLoggedIn, canShare, isGif, blastButtonDisabl '' + '' + '' + - '' + '' + - '' + '' + - '