mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 07:09:47 +02:00
Initial sharing code hooked up
This commit is contained in:
parent
01e78612c7
commit
c08b40b950
2 changed files with 32 additions and 46 deletions
|
@ -43,7 +43,7 @@ function addImage(data) {
|
||||||
document.getElementById(id).style.height = img.clientHeight;
|
document.getElementById(id).style.height = img.clientHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
paths.push(data);
|
paths.push(data.localPath);
|
||||||
}
|
}
|
||||||
function createShareOverlay(parentID, isGif) {
|
function createShareOverlay(parentID, isGif) {
|
||||||
var shareOverlayContainer = document.createElement("DIV");
|
var shareOverlayContainer = document.createElement("DIV");
|
||||||
|
@ -99,7 +99,7 @@ function createShareOverlay(parentID, isGif) {
|
||||||
'<br/>' +
|
'<br/>' +
|
||||||
'<div class="shareControls">' +
|
'<div class="shareControls">' +
|
||||||
'<div class="hifiShareControls">' +
|
'<div class="hifiShareControls">' +
|
||||||
'<input type="button" class="shareWithEveryone" id="' + shareWithEveryoneButtonID + '" value="SHARE WITH EVERYONE" onclick="" /><br>' +
|
'<input type="button" class="shareWithEveryone" id="' + shareWithEveryoneButtonID + '" value="SHARE WITH EVERYONE" onclick="shareWithEveryone(parentID)" /><br>' +
|
||||||
'<input type="checkbox" class="inviteConnections" id="' + inviteConnectionsCheckboxID + '" checked="checked" />' +
|
'<input type="checkbox" class="inviteConnections" id="' + inviteConnectionsCheckboxID + '" checked="checked" />' +
|
||||||
'<label class="shareButtonLabel" for="' + inviteConnectionsCheckboxID + '">Invite My Connections</label><br>' +
|
'<label class="shareButtonLabel" for="' + inviteConnectionsCheckboxID + '">Invite My Connections</label><br>' +
|
||||||
'<input type="button" class="cancelShare" value="CANCEL" onclick="cancelSharing(' + parentID + ')" />' +
|
'<input type="button" class="cancelShare" value="CANCEL" onclick="cancelSharing(' + parentID + ')" />' +
|
||||||
|
@ -129,6 +129,15 @@ function selectImageToShare(selectedID) {
|
||||||
shareOverlayBackground.style.display = "inline";
|
shareOverlayBackground.style.display = "inline";
|
||||||
shareOverlay.style.display = "inline";
|
shareOverlay.style.display = "inline";
|
||||||
}
|
}
|
||||||
|
function shareWithEveryone(selectedID) {
|
||||||
|
selectedID = selectedID.id; // Why is this necessary?
|
||||||
|
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: "snapshot",
|
||||||
|
action: "shareSnapshot",
|
||||||
|
data: paths[parseInt(selectedID.substring(1))]
|
||||||
|
}));
|
||||||
|
}
|
||||||
function cancelSharing(selectedID) {
|
function cancelSharing(selectedID) {
|
||||||
selectedID = selectedID.id; // Why is this necessary?
|
selectedID = selectedID.id; // Why is this necessary?
|
||||||
var shareOverlayContainer = document.getElementById(selectedID + "shareOverlayContainer");
|
var shareOverlayContainer = document.getElementById(selectedID + "shareOverlayContainer");
|
||||||
|
@ -208,7 +217,7 @@ window.onload = function () {
|
||||||
document.getElementById('p0').style.height = p0img.clientHeight;
|
document.getElementById('p0').style.height = p0img.clientHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
paths[0].localPath = gifPath;
|
paths[0] = gifPath;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
imageCount = message.data.length;
|
imageCount = message.data.length;
|
||||||
|
@ -232,13 +241,6 @@ window.onload = function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
// beware of bug: Cannot send objects at top level. (Nested in arrays is fine.)
|
|
||||||
function shareSelected() {
|
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
|
||||||
type: "snapshot",
|
|
||||||
action: paths
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
function doNotShare() {
|
function doNotShare() {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
|
|
|
@ -96,43 +96,31 @@ function onMessage(message) {
|
||||||
//
|
//
|
||||||
onClicked();
|
onClicked();
|
||||||
break;
|
break;
|
||||||
default:
|
case 'shareSnapshot':
|
||||||
//tablet.webEventReceived.disconnect(onMessage); // <<< It's probably this that's missing?!
|
|
||||||
HMD.closeTablet();
|
|
||||||
isLoggedIn = Account.isLoggedIn();
|
isLoggedIn = Account.isLoggedIn();
|
||||||
message.action.forEach(function (submessage) {
|
if (!isLoggedIn) {
|
||||||
if (submessage.share && !isLoggedIn) {
|
needsLogin = true;
|
||||||
needsLogin = true;
|
shareAfterLogin = true;
|
||||||
submessage.share = false;
|
snapshotToShareAfterLogin = { path: message.data, href: message.href || href };
|
||||||
shareAfterLogin = true;
|
} else {
|
||||||
snapshotToShareAfterLogin = {path: submessage.localPath, href: submessage.href || href};
|
print('sharing', message.data);
|
||||||
}
|
outstanding++;
|
||||||
if (submessage.share) {
|
Window.shareSnapshot(message.data, message.href || href);
|
||||||
print('sharing', submessage.localPath);
|
|
||||||
outstanding = true;
|
|
||||||
Window.shareSnapshot(submessage.localPath, submessage.href || href);
|
|
||||||
} else {
|
|
||||||
print('not sharing', submessage.localPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
if (outstanding && shouldOpenFeedAfterShare()) {
|
|
||||||
showFeedWindow();
|
|
||||||
outstanding = false;
|
|
||||||
}
|
}
|
||||||
if (needsLogin) { // after the possible feed, so that the login is on top
|
|
||||||
var isLoggedIn = Account.isLoggedIn();
|
|
||||||
|
|
||||||
if (!isLoggedIn) {
|
if (needsLogin) {
|
||||||
if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar"))
|
if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar"))
|
||||||
|| (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar"))) {
|
|| (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar"))) {
|
||||||
Menu.triggerOption("Login / Sign Up");
|
Menu.triggerOption("Login / Sign Up");
|
||||||
} else {
|
} else {
|
||||||
tablet.loadQMLOnTop("../../dialogs/TabletLoginDialog.qml");
|
tablet.loadQMLOnTop("../../dialogs/TabletLoginDialog.qml");
|
||||||
HMD.openTablet();
|
HMD.openTablet();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
print('Unknown message action received by snapshot.js!');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,11 +286,7 @@ function onConnected() {
|
||||||
print('sharing', snapshotToShareAfterLogin.path);
|
print('sharing', snapshotToShareAfterLogin.path);
|
||||||
Window.shareSnapshot(snapshotToShareAfterLogin.path, snapshotToShareAfterLogin.href);
|
Window.shareSnapshot(snapshotToShareAfterLogin.path, snapshotToShareAfterLogin.href);
|
||||||
shareAfterLogin = false;
|
shareAfterLogin = false;
|
||||||
if (shouldOpenFeedAfterShare()) {
|
|
||||||
showFeedWindow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
button.clicked.connect(onClicked);
|
button.clicked.connect(onClicked);
|
||||||
|
|
Loading…
Reference in a new issue