mirror of
https://github.com/overte-org/overte.git
synced 2025-06-05 03:00:41 +02:00
Getting closer
This commit is contained in:
parent
fad470eeea
commit
7c5de1e60b
2 changed files with 22 additions and 11 deletions
|
@ -18,11 +18,12 @@ function clearImages() {
|
||||||
while (snapshotImagesDiv.hasChildNodes()) {
|
while (snapshotImagesDiv.hasChildNodes()) {
|
||||||
snapshotImagesDiv.removeChild(snapshotImagesDiv.lastChild);
|
snapshotImagesDiv.removeChild(snapshotImagesDiv.lastChild);
|
||||||
}
|
}
|
||||||
|
twttr.events.unbind('click');
|
||||||
paths = [];
|
paths = [];
|
||||||
imageCount = 0;
|
imageCount = 0;
|
||||||
idCounter = 0;
|
idCounter = 0;
|
||||||
}
|
}
|
||||||
function addImage(image_data, isGifLoading, isShowingPreviousImages) {
|
function addImage(image_data, isGifLoading, canSharePreviousImages) {
|
||||||
if (!image_data.localPath) {
|
if (!image_data.localPath) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -45,9 +46,9 @@ function addImage(image_data, isGifLoading, isShowingPreviousImages) {
|
||||||
document.getElementById("snapshot-images").appendChild(div);
|
document.getElementById("snapshot-images").appendChild(div);
|
||||||
var isGif = img.src.split('.').pop().toLowerCase() === "gif";
|
var isGif = img.src.split('.').pop().toLowerCase() === "gif";
|
||||||
paths.push(image_data.localPath);
|
paths.push(image_data.localPath);
|
||||||
if (!isGifLoading && !isShowingPreviousImages) {
|
if (!isGifLoading && !canSharePreviousImages) {
|
||||||
shareForUrl(id);
|
shareForUrl(id);
|
||||||
} else if (isShowingPreviousImages) {
|
} else if (canSharePreviousImages) {
|
||||||
appendShareBar(id, image_data.story_id, isGif)
|
appendShareBar(id, image_data.story_id, isGif)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +233,7 @@ window.onload = function () {
|
||||||
var messageOptions = message.options;
|
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, array) {
|
||||||
addImage(element, true, true);
|
addImage(element, true, message.canShare);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'addImages':
|
case 'addImages':
|
||||||
|
@ -267,7 +268,7 @@ window.onload = function () {
|
||||||
handleCaptureSetting(message.setting);
|
handleCaptureSetting(message.setting);
|
||||||
break;
|
break;
|
||||||
case 'snapshotUploadComplete':
|
case 'snapshotUploadComplete':
|
||||||
var isGif = message.shareable_url.split('.').pop().toLowerCase() === "gif";
|
var isGif = message.image_url.split('.').pop().toLowerCase() === "gif";
|
||||||
appendShareBar(isGif || imageCount === 1 ? "p0" : "p1", message.story_id, isGif);
|
appendShareBar(isGif || imageCount === 1 ? "p0" : "p1", message.story_id, isGif);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -108,7 +108,8 @@ function onMessage(message) {
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "showPreviousImages",
|
action: "showPreviousImages",
|
||||||
options: snapshotOptions,
|
options: snapshotOptions,
|
||||||
image_data: imageData
|
image_data: imageData,
|
||||||
|
canShare: !!isDomainOpen(Settings.getValue("previousSnapshotDomainID"))
|
||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
case 'openSettings':
|
case 'openSettings':
|
||||||
|
@ -179,8 +180,9 @@ function onMessage(message) {
|
||||||
}*/
|
}*/
|
||||||
break;
|
break;
|
||||||
case 'shareButtonClicked':
|
case 'shareButtonClicked':
|
||||||
print('Twitter or FB "Share" button clicked! Removing ID', message.story_id, 'from storyIDsToMaybeDelete[].')
|
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));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print('Unknown message action received by snapshot.js!');
|
print('Unknown message action received by snapshot.js!');
|
||||||
|
@ -217,14 +219,15 @@ function snapshotUploaded(isError, reply) {
|
||||||
if (!isError) {
|
if (!isError) {
|
||||||
var replyJson = JSON.parse(reply);
|
var replyJson = JSON.parse(reply);
|
||||||
var storyID = replyJson.user_story.id;
|
var storyID = replyJson.user_story.id;
|
||||||
var shareableURL = replyJson.user_story.details.shareable_url;
|
storyIDsToMaybeDelete.push(storyID);
|
||||||
var isGif = shareableURL.split('.').pop().toLowerCase() === "gif";
|
var imageURL = replyJson.user_story.details.image_url;
|
||||||
|
var isGif = imageURL.split('.').pop().toLowerCase() === "gif";
|
||||||
print('SUCCESS: Snapshot uploaded! Story with audience:for_url created! ID:', storyID);
|
print('SUCCESS: Snapshot uploaded! Story with audience:for_url created! ID:', storyID);
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
tablet.emitScriptEvent(JSON.stringify({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "snapshotUploadComplete",
|
action: "snapshotUploadComplete",
|
||||||
story_id: storyID,
|
story_id: storyID,
|
||||||
shareable_url: shareableURL,
|
image_url: imageURL,
|
||||||
}));
|
}));
|
||||||
if (isGif) {
|
if (isGif) {
|
||||||
Settings.setValue("previousAnimatedSnapStoryID", storyID);
|
Settings.setValue("previousAnimatedSnapStoryID", storyID);
|
||||||
|
@ -246,14 +249,17 @@ function takeSnapshot() {
|
||||||
// Even the domainId could change (e.g., if the user falls into a teleporter while recording).
|
// Even the domainId could change (e.g., if the user falls into a teleporter while recording).
|
||||||
href = location.href;
|
href = location.href;
|
||||||
domainId = location.domainId;
|
domainId = location.domainId;
|
||||||
|
Settings.setValue("previousSnapshotDomainID", domainId);
|
||||||
|
|
||||||
|
maybeDeleteSnapshotStories();
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
tablet.emitScriptEvent(JSON.stringify({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "clearPreviousImages"
|
action: "clearPreviousImages"
|
||||||
}));
|
}));
|
||||||
maybeDeleteSnapshotStories();
|
|
||||||
Settings.setValue("previousStillSnapPath", "");
|
Settings.setValue("previousStillSnapPath", "");
|
||||||
|
Settings.setValue("previousStillSnapStoryID", "");
|
||||||
Settings.setValue("previousAnimatedSnapPath", "");
|
Settings.setValue("previousAnimatedSnapPath", "");
|
||||||
|
Settings.setValue("previousAnimatedSnapStoryID", "");
|
||||||
|
|
||||||
// update button states
|
// update button states
|
||||||
resetOverlays = Menu.isOptionChecked("Overlays"); // For completness. Certainly true if the button is visible to be clicked.
|
resetOverlays = Menu.isOptionChecked("Overlays"); // For completness. Certainly true if the button is visible to be clicked.
|
||||||
|
@ -278,6 +284,10 @@ function takeSnapshot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDomainOpen(id) {
|
function isDomainOpen(id) {
|
||||||
|
print("Checking open status of domain with ID:", id);
|
||||||
|
if (!id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
var request = new XMLHttpRequest();
|
var request = new XMLHttpRequest();
|
||||||
var options = [
|
var options = [
|
||||||
'now=' + new Date().toISOString(),
|
'now=' + new Date().toISOString(),
|
||||||
|
|
Loading…
Reference in a new issue