Lint cleanup; Immediate share button visibility;

This commit is contained in:
Zach Fox 2017-05-02 14:10:24 -07:00
parent 5302110e7b
commit d1dff7606c
6 changed files with 289 additions and 163 deletions

View file

@ -31,6 +31,7 @@ void SnapshotUploader::uploadSuccess(QNetworkReply& reply) {
auto dataObject = doc.object().value("data").toObject(); auto dataObject = doc.object().value("data").toObject();
QString thumbnailUrl = dataObject.value("thumbnail_url").toString(); QString thumbnailUrl = dataObject.value("thumbnail_url").toString();
QString imageUrl = dataObject.value("image_url").toString(); QString imageUrl = dataObject.value("image_url").toString();
QString snapshotID = dataObject.value("id").toString();
auto addressManager = DependencyManager::get<AddressManager>(); auto addressManager = DependencyManager::get<AddressManager>();
QString placeName = _inWorldLocation.authority(); // We currently only upload shareable places, in which case this is just host. QString placeName = _inWorldLocation.authority(); // We currently only upload shareable places, in which case this is just host.
QString currentPath = _inWorldLocation.path(); QString currentPath = _inWorldLocation.path();
@ -43,6 +44,7 @@ void SnapshotUploader::uploadSuccess(QNetworkReply& reply) {
if (dataObject.contains("shareable_url")) { if (dataObject.contains("shareable_url")) {
detailsObject.insert("shareable_url", dataObject.value("shareable_url").toString()); detailsObject.insert("shareable_url", dataObject.value("shareable_url").toString());
} }
detailsObject.insert("snapshot_id", snapshotID);
QString pickledDetails = QJsonDocument(detailsObject).toJson(); QString pickledDetails = QJsonDocument(detailsObject).toJson();
userStoryObject.insert("details", pickledDetails); userStoryObject.insert("details", pickledDetails);
userStoryObject.insert("thumbnail_url", thumbnailUrl); userStoryObject.insert("thumbnail_url", thumbnailUrl);

View file

@ -104,7 +104,7 @@ input[type=button].naked:active {
*/ */
/* /*
// START styling of share bar // START styling of share overlay
*/ */
.shareControls { .shareControls {
display: flex; display: flex;
@ -212,6 +212,28 @@ input[type=button].naked:active {
// END styling of share overlay // END styling of share overlay
*/ */
/*
// START styling of uploading message
*/
.uploadingMessage {
width: 100%;
height: 100%;
position: absolute;
text-align: center;
background-color: rgba(0, 0, 0, 0.8);
left: 0;
top: 0;
}
.uploadingMessage > img {
width: 72px;
height: 72px;
display: block;
margin: 60px auto 10px auto;
}
/*
// END styling of uploading message
*/
/* /*
// START styling of snapshot controls (bottom panel) and its contents // START styling of snapshot controls (bottom panel) and its contents
*/ */

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -1,3 +1,5 @@
/*jslint browser:true */
/*jslint maxlen: 180*/
"use strict"; "use strict";
// //
// SnapshotReview.js // SnapshotReview.js
@ -17,23 +19,23 @@ function showSetupInstructions() {
var snapshotImagesDiv = document.getElementById("snapshot-images"); var snapshotImagesDiv = document.getElementById("snapshot-images");
snapshotImagesDiv.className = "snapshotInstructions"; snapshotImagesDiv.className = "snapshotInstructions";
snapshotImagesDiv.innerHTML = '<img class="centeredImage" src="./img/snapshotIcon.png" alt="Snapshot Instructions" width="64" height="64"/>' + snapshotImagesDiv.innerHTML = '<img class="centeredImage" src="./img/snapshotIcon.png" alt="Snapshot Instructions" width="64" height="64"/>' +
'<br/>' + '<br/>' +
'<p>This app lets you take and share snaps and GIFs with your connections in High Fidelity.</p>' + '<p>This app lets you take and share snaps and GIFs with your connections in High Fidelity.</p>' +
"<h4>Setup Instructions</h4>" + "<h4>Setup Instructions</h4>" +
"<p>Before you can begin taking snaps, please choose where you'd like to save snaps on your computer:</p>" + "<p>Before you can begin taking snaps, please choose where you'd like to save snaps on your computer:</p>" +
'<br/>' + '<br/>' +
'<div style="text-align:center;">' + '<div style="text-align:center;">' +
'<input class="blueButton" style="margin-left:auto;margin-right:auto;width:130px;" type="button" value="CHOOSE" onclick="chooseSnapshotLocation()" />' + '<input class="blueButton" style="margin-left:auto;margin-right:auto;width:130px;" type="button" value="CHOOSE" onclick="chooseSnapshotLocation()" />' +
'</div>'; '</div>';
document.getElementById("snap-button").disabled = true; document.getElementById("snap-button").disabled = true;
} }
function showSetupComplete() { function showSetupComplete() {
var snapshotImagesDiv = document.getElementById("snapshot-images"); var snapshotImagesDiv = document.getElementById("snapshot-images");
snapshotImagesDiv.className = "snapshotInstructions"; snapshotImagesDiv.className = "snapshotInstructions";
snapshotImagesDiv.innerHTML = '<img class="centeredImage" src="./img/snapshotIcon.png" alt="Snapshot Instructions" width="64" height="64"/>' + snapshotImagesDiv.innerHTML = '<img class="centeredImage" src="./img/snapshotIcon.png" alt="Snapshot Instructions" width="64" height="64"/>' +
'<br/>' + '<br/>' +
"<h4>You're all set!</h4>" + "<h4>You're all set!</h4>" +
'<p>Try taking a snapshot by pressing the red button below.</p>'; '<p>Try taking a snapshot by pressing the red button below.</p>';
} }
function chooseSnapshotLocation() { function chooseSnapshotLocation() {
EventBridge.emitWebEvent(JSON.stringify({ EventBridge.emitWebEvent(JSON.stringify({
@ -52,68 +54,71 @@ function clearImages() {
imageCount = 0; imageCount = 0;
idCounter = 0; idCounter = 0;
} }
function addImage(image_data, isGifLoading, canShare, isShowingPreviousImages, blastButtonDisabled, hifiButtonDisabled) {
if (!image_data.localPath) { function selectImageToShare(selectedID, isSelected) {
return; if (selectedID.id) {
selectedID = selectedID.id; // sometimes (?), `selectedID` is passed as an HTML object to these functions; we just want the ID
} }
var id = "p" + idCounter++; var imageContainer = document.getElementById(selectedID),
// imageContainer setup image = document.getElementById(selectedID + 'img'),
var imageContainer = document.createElement("DIV"); shareBar = document.getElementById(selectedID + "shareBar"),
imageContainer.id = id; shareButtonsDiv = document.getElementById(selectedID + "shareButtonsDiv"),
imageContainer.style.width = "95%"; showShareButtonsButton = document.getElementById(selectedID + "showShareButtonsButton"),
imageContainer.style.height = "240px"; itr,
imageContainer.style.margin = "5px auto"; containers = document.getElementsByClassName("shareControls");
imageContainer.style.display = "flex";
imageContainer.style.justifyContent = "center"; if (isSelected) {
imageContainer.style.alignItems = "center"; showShareButtonsButton.onclick = function () { selectImageToShare(selectedID, false); };
imageContainer.style.position = "relative"; showShareButtonsButton.classList.remove("inactive");
// img setup showShareButtonsButton.classList.add("active");
var img = document.createElement("IMG");
img.id = id + "img"; image.onclick = function () { selectImageToShare(selectedID, false); };
if (imageCount > 1) { imageContainer.style.outline = "4px solid #00b4ef";
img.setAttribute("class", "multiple"); imageContainer.style.outlineOffset = "-4px";
}
img.src = image_data.localPath; shareBar.style.backgroundColor = "rgba(0, 0, 0, 0.5)";
imageContainer.appendChild(img);
document.getElementById("snapshot-images").appendChild(imageContainer); shareButtonsDiv.style.visibility = "visible";
paths.push(image_data.localPath);
var isGif = img.src.split('.').pop().toLowerCase() === "gif"; for (itr = 0; itr < containers.length; itr += 1) {
if (isGif) { var parentID = containers[itr].id.slice(0, 2);
imageContainer.innerHTML += '<span class="gifLabel">GIF</span>'; if (parentID !== selectedID) {
} selectImageToShare(parentID, false);
if (!isGifLoading && !isShowingPreviousImages && canShare) { }
shareForUrl(id); }
} else if (isShowingPreviousImages && canShare && image_data.story_id) { } else {
appendShareBar(id, image_data.story_id, isGif, blastButtonDisabled, hifiButtonDisabled) showShareButtonsButton.onclick = function () { selectImageToShare(selectedID, true); };
showShareButtonsButton.classList.remove("active");
showShareButtonsButton.classList.add("inactive");
image.onclick = function () { selectImageToShare(selectedID, true); };
imageContainer.style.outline = "none";
shareBar.style.backgroundColor = "rgba(0, 0, 0, 0.0)";
shareButtonsDiv.style.visibility = "hidden";
} }
} }
function appendShareBar(divID, story_id, isGif, blastButtonDisabled, hifiButtonDisabled) { function createShareBar(parentID, isGif, blastButtonDisabled, hifiButtonDisabled) {
var story_url = "https://highfidelity.com/user_stories/" + story_id; var shareBar = document.createElement("div"),
var parentDiv = document.getElementById(divID); shareButtonsDivID = parentID + "shareButtonsDiv",
parentDiv.setAttribute('data-story-id', story_id); showShareButtonsButtonDivID = parentID + "showShareButtonsButtonDiv",
document.getElementById(divID).appendChild(createShareBar(divID, isGif, story_url, blastButtonDisabled, hifiButtonDisabled)); showShareButtonsButtonID = parentID + "showShareButtonsButton",
if (divID === "p0") { showShareButtonsLabelID = parentID + "showShareButtonsLabel",
selectImageToShare(divID, true); blastToConnectionsButtonID = parentID + "blastToConnectionsButton",
} shareWithEveryoneButtonID = parentID + "shareWithEveryoneButton",
} facebookButtonID = parentID + "facebookButton",
function createShareBar(parentID, isGif, shareURL, blastButtonDisabled, hifiButtonDisabled) { twitterButtonID = parentID + "twitterButton";
var shareBar = document.createElement("div");
shareBar.id = parentID + "shareBar"; shareBar.id = parentID + "shareBar";
shareBar.className = "shareControls"; shareBar.className = "shareControls";
var shareButtonsDivID = parentID + "shareButtonsDiv"; shareBar.innerHTML = '<div class="shareButtons" id="' + shareButtonsDivID + '" style="visibility:hidden">' +
var showShareButtonsButtonDivID = parentID + "showShareButtonsButtonDiv"; '<input type="button"' + (blastButtonDisabled ? ' disabled' : '') + ' class="blastToConnections blueButton" id="' +
var showShareButtonsButtonID = parentID + "showShareButtonsButton"; blastToConnectionsButtonID + '" value="BLAST TO MY CONNECTIONS" onclick="blastToConnections(' + parentID + ', ' + isGif + ')" />' +
var showShareButtonsLabelID = parentID + "showShareButtonsLabel"; '<input type="button"' + (hifiButtonDisabled ? ' disabled' : '') + ' class="shareWithEveryone" id="' +
var blastToConnectionsButtonID = parentID + "blastToConnectionsButton"; shareWithEveryoneButtonID + '" onclick="shareWithEveryone(' + parentID + ', ' + isGif + ')" />' +
var shareWithEveryoneButtonID = parentID + "shareWithEveryoneButton"; '<a class="facebookButton" id="' + facebookButtonID + '" onclick="shareButtonClicked(\'facebook\', ' + parentID + ')"></a>' +
var facebookButtonID = parentID + "facebookButton"; '<a class="twitterButton" id="' + twitterButtonID + '" onclick="shareButtonClicked(\'twitter\', ' + parentID + ')"></a>' +
var twitterButtonID = parentID + "twitterButton";
shareBar.innerHTML += '' +
'<div class="shareButtons" id="' + shareButtonsDivID + '" style="visibility:hidden">' +
'<input type="button"' + (blastButtonDisabled ? ' disabled' : '') + ' class="blastToConnections blueButton" id="' + blastToConnectionsButtonID + '" value="BLAST TO MY CONNECTIONS" onclick="blastToConnections(' + parentID + ', ' + isGif + ')" />' +
'<input type="button"' + (hifiButtonDisabled ? ' disabled' : '') + ' class="shareWithEveryone" id="' + shareWithEveryoneButtonID + '" onclick="shareWithEveryone(' + parentID + ', ' + isGif + ')" />' +
'<a class="facebookButton" id="' + facebookButtonID + '" onclick="shareButtonClicked(' + parentID + ')" target="_blank" href="https://www.facebook.com/dialog/feed?app_id=1585088821786423&link=' + shareURL + '"></a>' +
'<a class="twitterButton" id="' + twitterButtonID + '" onclick="shareButtonClicked(' + parentID + ')" target="_blank" href="https://twitter.com/intent/tweet?text=I%20just%20took%20a%20snapshot!&url=' + shareURL + '&via=highfidelity&hashtags=VR,HiFi"></a>' +
'</div>' + '</div>' +
'<div class="showShareButtonsButtonDiv" id="' + showShareButtonsButtonDivID + '">' + '<div class="showShareButtonsButtonDiv" id="' + showShareButtonsButtonDivID + '">' +
'<label id="' + showShareButtonsLabelID + '" for="' + showShareButtonsButtonID + '">SHARE</label>' + '<label id="' + showShareButtonsLabelID + '" for="' + showShareButtonsButtonID + '">SHARE</label>' +
@ -124,103 +129,196 @@ function createShareBar(parentID, isGif, shareURL, blastButtonDisabled, hifiButt
'</div>'; '</div>';
// Add onclick handler to parent DIV's img to toggle share buttons // Add onclick handler to parent DIV's img to toggle share buttons
document.getElementById(parentID + 'img').onclick = function () { selectImageToShare(parentID, true) }; document.getElementById(parentID + 'img').onclick = function () { selectImageToShare(parentID, true); };
return shareBar; return shareBar;
} }
function selectImageToShare(selectedID, isSelected) { function appendShareBar(divID, isGif, blastButtonDisabled, hifiButtonDisabled) {
if (selectedID.id) { document.getElementById(divID).appendChild(createShareBar(divID, isGif, blastButtonDisabled, hifiButtonDisabled));
selectedID = selectedID.id; // sometimes (?), `selectedID` is passed as an HTML object to these functions; we just want the ID if (divID === "p0") {
} selectImageToShare(divID, true);
var imageContainer = document.getElementById(selectedID);
var image = document.getElementById(selectedID + 'img');
var shareBar = document.getElementById(selectedID + "shareBar");
var shareButtonsDiv = document.getElementById(selectedID + "shareButtonsDiv");
var showShareButtonsButton = document.getElementById(selectedID + "showShareButtonsButton");
if (isSelected) {
showShareButtonsButton.onclick = function () { selectImageToShare(selectedID, false) };
showShareButtonsButton.classList.remove("inactive");
showShareButtonsButton.classList.add("active");
image.onclick = function () { selectImageToShare(selectedID, false) };
imageContainer.style.outline = "4px solid #00b4ef";
imageContainer.style.outlineOffset = "-4px";
shareBar.style.backgroundColor = "rgba(0, 0, 0, 0.5)";
shareButtonsDiv.style.visibility = "visible";
var containers = document.getElementsByClassName("shareControls");
var parentID;
for (var i = 0; i < containers.length; ++i) {
parentID = containers[i].id.slice(0, 2);
if (parentID !== selectedID) {
selectImageToShare(parentID, false);
}
}
} else {
showShareButtonsButton.onclick = function () { selectImageToShare(selectedID, true) };
showShareButtonsButton.classList.remove("active");
showShareButtonsButton.classList.add("inactive");
image.onclick = function () { selectImageToShare(selectedID, true) };
imageContainer.style.outline = "none";
shareBar.style.backgroundColor = "rgba(0, 0, 0, 0.0)";
shareButtonsDiv.style.visibility = "hidden";
} }
} }
function shareForUrl(selectedID) { function shareForUrl(selectedID) {
EventBridge.emitWebEvent(JSON.stringify({ EventBridge.emitWebEvent(JSON.stringify({
type: "snapshot", type: "snapshot",
action: "shareSnapshotForUrl", action: "shareSnapshotForUrl",
data: paths[parseInt(selectedID.substring(1))] data: paths[parseInt(selectedID.substring(1), 10)]
})); }));
} }
function addImage(image_data, isGifLoading, canShare, isShowingPreviousImages, blastButtonDisabled, hifiButtonDisabled) {
if (!image_data.localPath) {
return;
}
var id = "p" + (idCounter++),
imageContainer = document.createElement("DIV"),
img = document.createElement("IMG"),
isGif = img.src.split('.').pop().toLowerCase() === "gif";
imageContainer.id = id;
imageContainer.style.width = "95%";
imageContainer.style.height = "240px";
imageContainer.style.margin = "5px auto";
imageContainer.style.display = "flex";
imageContainer.style.justifyContent = "center";
imageContainer.style.alignItems = "center";
imageContainer.style.position = "relative";
img.id = id + "img";
img.src = image_data.localPath;
imageContainer.appendChild(img);
document.getElementById("snapshot-images").appendChild(imageContainer);
paths.push(image_data.localPath);
if (isGif) {
imageContainer.innerHTML += '<span class="gifLabel">GIF</span>';
}
if (!isGifLoading && !isShowingPreviousImages && canShare) {
shareForUrl(id);
appendShareBar(id, isGif, blastButtonDisabled, hifiButtonDisabled);
}
if (isShowingPreviousImages && image_data.story_id) {
appendShareBar(id, isGif, blastButtonDisabled, hifiButtonDisabled);
updateShareInfo(id, image_data.story_id);
}
}
function showUploadingMessage(selectedID, destination) {
if (selectedID.id) {
selectedID = selectedID.id; // sometimes (?), `containerID` is passed as an HTML object to these functions; we just want the ID
}
var uploadingMessage = document.createElement("div");
uploadingMessage.id = selectedID + "uploadingMessage";
uploadingMessage.className = "uploadingMessage";
uploadingMessage.setAttribute("data-destination", destination);
var socialIcon = document.createElement("img");
switch (destination) {
case 'blast':
socialIcon.src = "img/shareIcon.png";
break;
case 'hifi':
socialIcon.src = "img/shareToFeed.png";
break;
case 'facebook':
socialIcon.src = "img/fb_logo72.png";
break;
case 'twitter':
socialIcon.src = "img/twitter_logo72.png";
break;
}
uploadingMessage.appendChild(socialIcon);
uploadingMessage.innerHTML += '<span>Preparing Snapshot for Sharing...</span>';
document.getElementById(selectedID).appendChild(uploadingMessage);
}
function hideUploadingMessage(selectedID, storyID) {
if (selectedID.id) {
selectedID = selectedID.id; // sometimes (?), `containerID` is passed as an HTML object to these functions; we just want the ID
}
var uploadingMessage = document.getElementById(selectedID + "uploadingMessage");
if (uploadingMessage) {
uploadingMessage.remove();
var destination = uploadingMessage.getAttribute("data-destination");
switch (destination) {
case 'blast':
blastToConnections(selectedID, selectedID === "p1");
break;
case 'hifi':
shareWithEveryone(selectedID, selectedID === "p1");
break;
case 'facebook':
var facebookButton = document.getElementById(selectedID + "facebookButton");
window.open(facebookButton.getAttribute("href"), "_blank");
break;
case 'twitter':
var twitterButton = document.getElementById(selectedID + "twitterButton");
window.open(twitterButton.getAttribute("href"), "_blank");
break;
}
EventBridge.emitWebEvent(JSON.stringify({
type: "snapshot",
action: "removeFromStoryIDsToMaybeDelete",
story_id: storyID
}));
}
}
function updateShareInfo(containerID, storyID) {
if (containerID.id) {
containerID = containerID.id; // sometimes (?), `containerID` is passed as an HTML object to these functions; we just want the ID
}
var shareBar = document.getElementById(containerID + "shareBar"),
parentDiv = document.getElementById(containerID),
shareURL = "https://highfidelity.com/user_stories/" + storyID,
facebookButton = document.getElementById(containerID + "facebookButton"),
twitterButton = document.getElementById(containerID + "twitterButton");
parentDiv.setAttribute('data-story-id', storyID);
facebookButton.setAttribute("target", "_blank");
facebookButton.setAttribute("href", 'https://www.facebook.com/dialog/feed?app_id=1585088821786423&link=' + shareURL);
twitterButton.setAttribute("target", "_blank");
twitterButton.setAttribute("href", 'https://twitter.com/intent/tweet?text=I%20just%20took%20a%20snapshot!&url=' + shareURL + '&via=highfidelity&hashtags=VR,HiFi');
hideUploadingMessage(containerID, storyID);
}
function blastToConnections(selectedID, isGif) { function blastToConnections(selectedID, isGif) {
selectedID = selectedID.id; // `selectedID` is passed as an HTML object to these functions; we just want the ID if (selectedID.id) {
selectedID = selectedID.id; // sometimes (?), `selectedID` is passed as an HTML object to these functions; we just want the ID
}
document.getElementById(selectedID + "blastToConnectionsButton").disabled = true; document.getElementById(selectedID + "blastToConnectionsButton").disabled = true;
EventBridge.emitWebEvent(JSON.stringify({ var storyID = document.getElementById(selectedID).getAttribute("data-story-id");
type: "snapshot",
action: "blastToConnections", if (storyID) {
story_id: document.getElementById(selectedID).getAttribute("data-story-id"), EventBridge.emitWebEvent(JSON.stringify({
isGif: isGif type: "snapshot",
})); action: "blastToConnections",
story_id: storyID,
isGif: isGif
}));
} else {
showUploadingMessage(selectedID, 'blast');
}
} }
function shareWithEveryone(selectedID, isGif) { function shareWithEveryone(selectedID, isGif) {
selectedID = selectedID.id; // `selectedID` is passed as an HTML object to these functions; we just want the ID if (selectedID.id) {
selectedID = selectedID.id; // sometimes (?), `selectedID` is passed as an HTML object to these functions; we just want the ID
}
document.getElementById(selectedID + "shareWithEveryoneButton").disabled = true; document.getElementById(selectedID + "shareWithEveryoneButton").disabled = true;
EventBridge.emitWebEvent(JSON.stringify({ var storyID = document.getElementById(selectedID).getAttribute("data-story-id");
type: "snapshot",
action: "shareSnapshotWithEveryone",
story_id: document.getElementById(selectedID).getAttribute("data-story-id"),
isGif: isGif
}));
}
function shareButtonClicked(selectedID) {
selectedID = selectedID.id; // `selectedID` is passed as an HTML object to these functions; we just want the ID
EventBridge.emitWebEvent(JSON.stringify({
type: "snapshot",
action: "shareButtonClicked",
story_id: document.getElementById(selectedID).getAttribute("data-story-id")
}));
}
function cancelSharing(selectedID) {
selectedID = selectedID.id; // `selectedID` is passed as an HTML object to these functions; we just want the ID
var shareBar = document.getElementById(selectedID + "shareBar");
shareBar.style.display = "inline"; if (storyID) {
EventBridge.emitWebEvent(JSON.stringify({
type: "snapshot",
action: "shareSnapshotWithEveryone",
story_id: storyID,
isGif: isGif
}));
} else {
showUploadingMessage(selectedID, 'hifi');
}
}
function shareButtonClicked(destination, selectedID) {
if (selectedID.id) {
selectedID = selectedID.id; // sometimes (?), `selectedID` is passed as an HTML object to these functions; we just want the ID
}
var storyID = document.getElementById(selectedID).getAttribute("data-story-id");
if (!storyID) {
showUploadingMessage(selectedID, destination);
}
} }
function handleCaptureSetting(setting) { function handleCaptureSetting(setting) {
var stillAndGif = document.getElementById('stillAndGif'); var stillAndGif = document.getElementById('stillAndGif'),
var stillOnly = document.getElementById('stillOnly'); stillOnly = document.getElementById('stillOnly');
stillAndGif.checked = setting; stillAndGif.checked = setting;
stillOnly.checked = !setting; stillOnly.checked = !setting;
@ -229,19 +327,20 @@ function handleCaptureSetting(setting) {
type: "snapshot", type: "snapshot",
action: "captureStillAndGif" action: "captureStillAndGif"
})); }));
} };
stillOnly.onclick = function () { stillOnly.onclick = function () {
EventBridge.emitWebEvent(JSON.stringify({ EventBridge.emitWebEvent(JSON.stringify({
type: "snapshot", type: "snapshot",
action: "captureStillOnly" action: "captureStillOnly"
})); }));
} };
} }
window.onload = function () { window.onload = function () {
// Uncomment the line below to test functionality in a browser. // Uncomment the line below to test functionality in a browser.
// See definition of "testInBrowser()" to modify tests. // See definition of "testInBrowser()" to modify tests.
//testInBrowser(false); //testInBrowser(2);
openEventBridge(function () { openEventBridge(function () {
// Set up a handler for receiving the data, and tell the .js we are ready to receive it. // Set up a handler for receiving the data, and tell the .js we are ready to receive it.
EventBridge.scriptEventReceived.connect(function (message) { EventBridge.scriptEventReceived.connect(function (message) {
@ -251,7 +350,9 @@ window.onload = function () {
if (message.type !== "snapshot") { if (message.type !== "snapshot") {
return; return;
} }
var messageOptions = message.options;
switch (message.action) { switch (message.action) {
case 'showSetupInstructions': case 'showSetupInstructions':
showSetupInstructions(); showSetupInstructions();
@ -265,9 +366,8 @@ window.onload = function () {
break; break;
case 'showPreviousImages': case 'showPreviousImages':
clearImages(); clearImages();
var messageOptions = message.options;
imageCount = message.image_data.length; imageCount = message.image_data.length;
message.image_data.forEach(function (element, idx, array) { message.image_data.forEach(function (element, idx) {
addImage(element, true, message.canShare, true, message.image_data[idx].blastButtonDisabled, message.image_data[idx].hifiButtonDisabled); addImage(element, true, message.canShare, true, message.image_data[idx].blastButtonDisabled, message.image_data[idx].hifiButtonDisabled);
}); });
break; break;
@ -275,28 +375,28 @@ window.onload = function () {
// The last element of the message contents list contains a bunch of options, // The last element of the message contents list contains a bunch of options,
// including whether or not we can share stuff // including whether or not we can share stuff
// The other elements of the list contain image paths. // The other elements of the list contain image paths.
var messageOptions = message.options;
if (messageOptions.containsGif) { if (messageOptions.containsGif) {
if (messageOptions.processingGif) { if (messageOptions.processingGif) {
imageCount = message.image_data.length + 1; // "+1" for the GIF that'll finish processing soon 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.push({ localPath: messageOptions.loadingGifPath });
message.image_data.forEach(function (element, idx, array) { message.image_data.forEach(function (element, idx) {
addImage(element, idx === 1, idx === 0 && messageOptions.canShare, false); addImage(element, idx === 1, idx === 0 && messageOptions.canShare, false);
}); });
} else { } else {
var gifPath = message.image_data[0].localPath; var gifPath = message.image_data[0].localPath,
var p1img = document.getElementById('p1img'); p1img = document.getElementById('p1img');
p1img.src = gifPath; p1img.src = gifPath;
paths[1] = gifPath; paths[1] = gifPath;
if (messageOptions.canShare) { if (messageOptions.canShare) {
shareForUrl("p1"); shareForUrl("p1");
appendShareBar("p1", true, false, false);
} }
} }
} else { } else {
imageCount = message.image_data.length; imageCount = message.image_data.length;
message.image_data.forEach(function (element, idx, array) { message.image_data.forEach(function (element) {
addImage(element, false, messageOptions.canShare, false); addImage(element, false, messageOptions.canShare, false);
}); });
} }
@ -306,7 +406,7 @@ window.onload = function () {
break; break;
case 'snapshotUploadComplete': case 'snapshotUploadComplete':
var isGif = message.image_url.split('.').pop().toLowerCase() === "gif"; var isGif = message.image_url.split('.').pop().toLowerCase() === "gif";
appendShareBar(isGif ? "p1" : "p0", message.story_id, isGif); updateShareInfo(isGif ? "p1" : "p0", message.story_id);
break; break;
default: default:
console.log("Unknown message action received in SnapshotReview.js."); console.log("Unknown message action received in SnapshotReview.js.");
@ -333,13 +433,18 @@ function takeSnapshot() {
})); }));
} }
function testInBrowser(isTestingSetupInstructions) { function testInBrowser(test) {
if (isTestingSetupInstructions) { if (test === 0) {
showSetupInstructions(); showSetupInstructions();
} else { } else if (test === 1) {
imageCount = 1; imageCount = 1;
//addImage({ localPath: 'http://lorempixel.com/553/255' }); //addImage({ localPath: 'http://lorempixel.com/553/255' });
addImage({ localPath: 'C:/Users/valef/Desktop/hifi-snap-by-zfox-on-2017-05-01_15-48-15.gif' }, false, true, true, false, false); addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.gif' }, false, true, true, false, false);
addImage({ localPath: 'C:/Users/valef/Desktop/hifi-snap-by-zfox-on-2017-05-01_15-48-15.jpg' }, false, true, true, false, false); addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.jpg' }, false, true, true, false, false);
} else if (test === 2) {
addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.gif' }, false, true, true, false, false);
addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/hifi-snap-by-zfox-on-2017-05-01_13-28-58.jpg' }, false, true, true, false, false);
showUploadingMessage("p0", 'facebook');
showUploadingMessage("p1", 'twitter');
} }
} }

View file

@ -182,7 +182,6 @@ function onMessage(message) {
break; break;
case 'blastToConnections': case 'blastToConnections':
isLoggedIn = Account.isLoggedIn(); isLoggedIn = Account.isLoggedIn();
storyIDsToMaybeDelete.splice(storyIDsToMaybeDelete.indexOf(message.story_id), 1);
if (message.isGif) { if (message.isGif) {
Settings.setValue("previousAnimatedSnapBlastingDisabled", true); Settings.setValue("previousAnimatedSnapBlastingDisabled", true);
} else { } else {
@ -242,7 +241,6 @@ function onMessage(message) {
break; break;
case 'shareSnapshotWithEveryone': case 'shareSnapshotWithEveryone':
isLoggedIn = Account.isLoggedIn(); isLoggedIn = Account.isLoggedIn();
storyIDsToMaybeDelete.splice(storyIDsToMaybeDelete.indexOf(message.story_id), 1);
if (message.isGif) { if (message.isGif) {
Settings.setValue("previousAnimatedSnapHifiSharingDisabled", true); Settings.setValue("previousAnimatedSnapHifiSharingDisabled", true);
} else { } else {
@ -283,8 +281,7 @@ function onMessage(message) {
snapshotToShareAfterLogin = { path: message.data, href: message.href || href }; snapshotToShareAfterLogin = { path: message.data, href: message.href || href };
} }
break; break;
case 'shareButtonClicked': case 'removeFromStoryIDsToMaybeDelete':
print('Twitter or FB "Share" button clicked! Removing ID', message.story_id, 'from storyIDsToMaybeDelete[].');
storyIDsToMaybeDelete.splice(storyIDsToMaybeDelete.indexOf(message.story_id), 1); storyIDsToMaybeDelete.splice(storyIDsToMaybeDelete.indexOf(message.story_id), 1);
print('storyIDsToMaybeDelete[] now:', JSON.stringify(storyIDsToMaybeDelete)); print('storyIDsToMaybeDelete[] now:', JSON.stringify(storyIDsToMaybeDelete));
break; break;