mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 14:29:03 +02:00
Don't let user blast in certain cases
This commit is contained in:
parent
d8095c5ea5
commit
1067d1e0f6
2 changed files with 26 additions and 19 deletions
|
@ -112,7 +112,7 @@ function selectImageToShare(selectedID, isSelected) {
|
||||||
shareButtonsDiv.style.visibility = "hidden";
|
shareButtonsDiv.style.visibility = "hidden";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function createShareBar(parentID, isGif, blastButtonDisabled, hifiButtonDisabled) {
|
function createShareBar(parentID, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast) {
|
||||||
var shareBar = document.createElement("div"),
|
var shareBar = document.createElement("div"),
|
||||||
shareButtonsDivID = parentID + "shareButtonsDiv",
|
shareButtonsDivID = parentID + "shareButtonsDiv",
|
||||||
showShareButtonsButtonDivID = parentID + "showShareButtonsButtonDiv",
|
showShareButtonsButtonDivID = parentID + "showShareButtonsButtonDiv",
|
||||||
|
@ -125,10 +125,11 @@ function createShareBar(parentID, isGif, blastButtonDisabled, hifiButtonDisabled
|
||||||
|
|
||||||
shareBar.id = parentID + "shareBar";
|
shareBar.id = parentID + "shareBar";
|
||||||
shareBar.className = "shareControls";
|
shareBar.className = "shareControls";
|
||||||
shareBar.innerHTML = '<div class="shareButtons" id="' + shareButtonsDivID + '" style="visibility:hidden">' +
|
var shareBarInnerHTML = '<div class="shareButtons" id="' + shareButtonsDivID + '" style="visibility:hidden">';
|
||||||
'<input type="button"' + (blastButtonDisabled ? ' disabled' : '') + ' class="blastToConnections blueButton" id="' +
|
if (canBlast) {
|
||||||
blastToConnectionsButtonID + '" value="BLAST TO MY CONNECTIONS" onclick="blastToConnections(' + parentID + ', ' + isGif + ')" />' +
|
shareBarInnerHTML += '<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="' +
|
}
|
||||||
|
shareBarInnerHTML += '<input type="button"' + (hifiButtonDisabled ? ' disabled' : '') + ' class="shareWithEveryone" id="' +
|
||||||
shareWithEveryoneButtonID + '" onclick="shareWithEveryone(' + parentID + ', ' + isGif + ')" />' +
|
shareWithEveryoneButtonID + '" onclick="shareWithEveryone(' + parentID + ', ' + isGif + ')" />' +
|
||||||
'<a class="facebookButton" id="' + facebookButtonID + '" onclick="shareButtonClicked(\'facebook\', ' + parentID + ')"></a>' +
|
'<a class="facebookButton" id="' + facebookButtonID + '" onclick="shareButtonClicked(\'facebook\', ' + parentID + ')"></a>' +
|
||||||
'<a class="twitterButton" id="' + twitterButtonID + '" onclick="shareButtonClicked(\'twitter\', ' + parentID + ')"></a>' +
|
'<a class="twitterButton" id="' + twitterButtonID + '" onclick="shareButtonClicked(\'twitter\', ' + parentID + ')"></a>' +
|
||||||
|
@ -141,13 +142,18 @@ function createShareBar(parentID, isGif, blastButtonDisabled, hifiButtonDisabled
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
|
shareBar.innerHTML = shareBarInnerHTML;
|
||||||
|
|
||||||
// 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 appendShareBar(divID, isGif, blastButtonDisabled, hifiButtonDisabled) {
|
function appendShareBar(divID, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast) {
|
||||||
document.getElementById(divID).appendChild(createShareBar(divID, isGif, blastButtonDisabled, hifiButtonDisabled));
|
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));
|
||||||
if (divID === "p0") {
|
if (divID === "p0") {
|
||||||
selectImageToShare(divID, true);
|
selectImageToShare(divID, true);
|
||||||
}
|
}
|
||||||
|
@ -159,7 +165,7 @@ function shareForUrl(selectedID) {
|
||||||
data: paths[parseInt(selectedID.substring(1), 10)]
|
data: paths[parseInt(selectedID.substring(1), 10)]
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
function addImage(image_data, isGifLoading, canShare, isShowingPreviousImages, blastButtonDisabled, hifiButtonDisabled) {
|
function addImage(image_data, isGifLoading, canShare, isShowingPreviousImages, blastButtonDisabled, hifiButtonDisabled, canBlast) {
|
||||||
if (!image_data.localPath) {
|
if (!image_data.localPath) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -184,11 +190,11 @@ function addImage(image_data, isGifLoading, canShare, isShowingPreviousImages, b
|
||||||
imageContainer.innerHTML += '<span class="gifLabel">GIF</span>';
|
imageContainer.innerHTML += '<span class="gifLabel">GIF</span>';
|
||||||
}
|
}
|
||||||
if (!isGifLoading && !isShowingPreviousImages && canShare) {
|
if (!isGifLoading && !isShowingPreviousImages && canShare) {
|
||||||
|
appendShareBar(id, isGif, blastButtonDisabled, hifiButtonDisabled, true);
|
||||||
shareForUrl(id);
|
shareForUrl(id);
|
||||||
appendShareBar(id, isGif, blastButtonDisabled, hifiButtonDisabled);
|
|
||||||
}
|
}
|
||||||
if (isShowingPreviousImages && image_data.story_id) {
|
if (isShowingPreviousImages && image_data.story_id) {
|
||||||
appendShareBar(id, isGif, blastButtonDisabled, hifiButtonDisabled);
|
appendShareBar(id, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast);
|
||||||
updateShareInfo(id, image_data.story_id);
|
updateShareInfo(id, image_data.story_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,7 +359,7 @@ function handleCaptureSetting(setting) {
|
||||||
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(2);
|
//testInBrowser(1);
|
||||||
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) {
|
||||||
|
@ -382,7 +388,7 @@ window.onload = function () {
|
||||||
imageCount = message.image_data.length;
|
imageCount = message.image_data.length;
|
||||||
if (imageCount > 0) {
|
if (imageCount > 0) {
|
||||||
message.image_data.forEach(function (element, idx) {
|
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, messageOptions.canBlast);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
showSnapshotInstructions();
|
showSnapshotInstructions();
|
||||||
|
@ -408,7 +414,7 @@ window.onload = function () {
|
||||||
paths[1] = gifPath;
|
paths[1] = gifPath;
|
||||||
if (messageOptions.canShare) {
|
if (messageOptions.canShare) {
|
||||||
shareForUrl("p1");
|
shareForUrl("p1");
|
||||||
appendShareBar("p1", true, false, false);
|
appendShareBar("p1", true, false, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -454,13 +460,13 @@ function testInBrowser(test) {
|
||||||
if (test === 0) {
|
if (test === 0) {
|
||||||
showSetupInstructions();
|
showSetupInstructions();
|
||||||
} else if (test === 1) {
|
} else if (test === 1) {
|
||||||
imageCount = 1;
|
imageCount = 2;
|
||||||
//addImage({ localPath: 'http://lorempixel.com/553/255' });
|
//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.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', 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' }, 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', story_id: 1338 }, false, true, true, false, false, true);
|
||||||
} else if (test === 2) {
|
} 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.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' }, 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', story_id: 1338 }, false, true, true, false, false, true);
|
||||||
showUploadingMessage("p0", 'facebook');
|
showUploadingMessage("p0", 'facebook');
|
||||||
showUploadingMessage("p1", 'twitter');
|
showUploadingMessage("p1", 'twitter');
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,7 +311,8 @@ function onButtonClicked() {
|
||||||
snapshotOptions = {
|
snapshotOptions = {
|
||||||
containsGif: previousAnimatedSnapPath !== "",
|
containsGif: previousAnimatedSnapPath !== "",
|
||||||
processingGif: false,
|
processingGif: false,
|
||||||
shouldUpload: false
|
shouldUpload: false,
|
||||||
|
canBlast: location.domainId === Settings.getValue("previousSnapshotDomainID")
|
||||||
}
|
}
|
||||||
imageData = [];
|
imageData = [];
|
||||||
if (previousStillSnapPath !== "") {
|
if (previousStillSnapPath !== "") {
|
||||||
|
|
Loading…
Reference in a new issue