diff --git a/console/src/main.js b/console/src/main.js
index 668ddf304f..d37b3f4ee7 100644
--- a/console/src/main.js
+++ b/console/src/main.js
@@ -352,7 +352,7 @@ function buildMenuArray(serverState) {
},
{
label: 'Share',
- click: function() { }
+ click: function() { shell.openExternal('http://localhost:40100/settings/?action=share') }
},
{
type: 'separator'
diff --git a/domain-server/resources/web/settings/js/settings.js b/domain-server/resources/web/settings/js/settings.js
index c733256fe3..ddd0c471ad 100644
--- a/domain-server/resources/web/settings/js/settings.js
+++ b/domain-server/resources/web/settings/js/settings.js
@@ -126,6 +126,20 @@ var viewHelpers = {
}
}
+var qs = (function(a) {
+ if (a == "") return {};
+ var b = {};
+ for (var i = 0; i < a.length; ++i)
+ {
+ var p=a[i].split('=', 2);
+ if (p.length == 1)
+ b[p[0]] = "";
+ else
+ b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
+ }
+ return b;
+})(window.location.search.substr(1).split('&'));
+
$(document).ready(function(){
/*
* Clamped-width.
@@ -272,9 +286,80 @@ $(document).ready(function(){
// $('body').scrollspy({ target: '#setup-sidebar'})
- reloadSettings();
+ reloadSettings(function(success){
+ if (success) {
+ handleAction();
+ } else {
+ swal({
+ title: '',
+ type: 'error',
+ text: "There was a problem loading the domain settings.\nPlease refresh the page to try again.",
+ });
+ }
+ });
});
+function handleAction() {
+ // check if we were passed an action to handle
+ var action = qs["action"];
+
+ if (action == "share") {
+ // figure out if we already have a stored domain ID
+ if (Settings.data.values.metaverse.id.length > 0) {
+ // we need to ask the API what a shareable name for this domain is
+ getDomainFromAPI(function(data){
+ // check if we have owner_places (for a real domain) or a name (for a temporary domain)
+ if (data && data.status == "success") {
+ var shareName;
+ if (data.domain.owner_places) {
+ shareName = data.domain.owner_places[0].name
+ } else if (data.domain.name) {
+ shareName = data.domain.name;
+ }
+
+ var shareLink = "hifi://" + shareName;
+
+ console.log(shareLink);
+
+ // show a dialog with a copiable share URL
+ swal({
+ title: "Share",
+ type: "input",
+ inputPlaceholder: shareLink,
+ inputValue: shareLink,
+ text: "Copy this URL to invite friends to your domain.",
+ closeOnConfirm: true
+ });
+
+ $('.sweet-alert input').select();
+
+ } else {
+ // show an error alert
+ swal({
+ title: '',
+ type: 'error',
+ text: "There was a problem retreiving domain information from High Fidelity API.",
+ confirmButtonText: 'Try again',
+ showCancelButton: true,
+ closeOnConfirm: false
+ }, function(isConfirm){
+ if (isConfirm) {
+ // they want to try getting domain share info again
+ showSpinnerAlert("Requesting domain information...")
+ handleAction();
+ } else {
+ swal.close();
+ }
+ });
+ }
+ });
+ } else {
+ // no domain ID present, just show the share dialog
+ createTemporaryDomain();
+ }
+ }
+}
+
function dynamicButton(button_id, text) {
return $("");
}
@@ -577,29 +662,33 @@ function placeTableRowForPlaceObject(place) {
return placeTableRow(place.name, placePathOrIndex, false);
}
-function reloadPlacesOrTemporaryName() {
+function getDomainFromAPI(callback) {
// we only need to do this if we have a current domain ID
var domainID = Settings.data.values.metaverse.id;
if (domainID.length > 0) {
var domainURL = Settings.METAVERSE_URL + "/api/v1/domains/" + domainID;
- $.getJSON(domainURL, function(data){
- // check if we have owner_places (for a real domain) or a name (for a temporary domain)
- if (data.status == "success") {
- if (data.domain.owner_places) {
- // add a table row for each of these names
- _.each(data.domain.owner_places, function(place){
- $('#' + Settings.PLACES_TABLE_ID + " tbody").append(placeTableRowForPlaceObject(place));
- });
- } else if (data.domain.name) {
- // add a table row for this temporary domain name
- $('#' + Settings.PLACES_TABLE_ID + " tbody").append(placeTableRow(data.domain.name, '/', true));
- }
- }
- });
+ $.getJSON(domainURL, function(data){ callback(data) }).fail(callback);
}
}
+function reloadPlacesOrTemporaryName() {
+ getDomainFromAPI(function(data){
+ // check if we have owner_places (for a real domain) or a name (for a temporary domain)
+ if (data.status == "success") {
+ if (data.domain.owner_places) {
+ // add a table row for each of these names
+ _.each(data.domain.owner_places, function(place){
+ $('#' + Settings.PLACES_TABLE_ID + " tbody").append(placeTableRowForPlaceObject(place));
+ });
+ } else if (data.domain.name) {
+ // add a table row for this temporary domain name
+ $('#' + Settings.PLACES_TABLE_ID + " tbody").append(placeTableRow(data.domain.name, '/', true));
+ }
+ }
+ })
+}
+
function appendDomainIDButtons() {
var domainIDInput = $(Settings.DOMAIN_ID_SELECTOR);
@@ -728,7 +817,7 @@ function createTemporaryDomain() {
});
}
-function reloadSettings() {
+function reloadSettings(callback) {
$.getJSON('/settings.json', function(data){
_.extend(data, viewHelpers)
@@ -757,6 +846,12 @@ function reloadSettings() {
placement: 'right',
title: 'This setting is in the master config file and cannot be changed'
});
+
+ // call the callback now that settings are loaded
+ callback(true);
+ }).fail(function() {
+ // call the failure object since settings load faild
+ callback(false)
});
}
diff --git a/domain-server/resources/web/settings/js/sweetalert.min.js b/domain-server/resources/web/settings/js/sweetalert.min.js
index d81d1e906b..5c029c2532 100755
--- a/domain-server/resources/web/settings/js/sweetalert.min.js
+++ b/domain-server/resources/web/settings/js/sweetalert.min.js
@@ -1 +1 @@
-!function(e,t,n){"use strict";!function o(e,t,n){function a(s,l){if(!t[s]){if(!e[s]){var i="function"==typeof require&&require;if(!l&&i)return i(s,!0);if(r)return r(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=t[s]={exports:{}};e[s][0].call(c.exports,function(t){var n=e[s][1][t];return a(n?n:t)},c,c.exports,o,e,t,n)}return t[s].exports}for(var r="function"==typeof require&&require,s=0;s=0;)n=n.replace(" "+t+" "," ");e.className=n.replace(/^\s+|\s+$/g,"")}},i=function(e){var n=t.createElement("div");return n.appendChild(t.createTextNode(e)),n.innerHTML},u=function(e){e.style.opacity="",e.style.display="block"},c=function(e){if(e&&!e.length)return u(e);for(var t=0;t0?setTimeout(o,t):e.style.display="none"});o()},h=function(n){if("function"==typeof MouseEvent){var o=new MouseEvent("click",{view:e,bubbles:!1,cancelable:!0});n.dispatchEvent(o)}else if(t.createEvent){var a=t.createEvent("MouseEvents");a.initEvent("click",!1,!1),n.dispatchEvent(a)}else t.createEventObject?n.fireEvent("onclick"):"function"==typeof n.onclick&&n.onclick()},g=function(t){"function"==typeof t.stopPropagation?(t.stopPropagation(),t.preventDefault()):e.event&&e.event.hasOwnProperty("cancelBubble")&&(e.event.cancelBubble=!0)};a.hasClass=r,a.addClass=s,a.removeClass=l,a.escapeHtml=i,a._show=u,a.show=c,a._hide=d,a.hide=f,a.isDescendant=p,a.getTopMargin=m,a.fadeIn=v,a.fadeOut=y,a.fireClick=h,a.stopEventPropagation=g},{}],5:[function(t,o,a){Object.defineProperty(a,"__esModule",{value:!0});var r=t("./handle-dom"),s=t("./handle-swal-dom"),l=function(t,o,a){var l=t||e.event,i=l.keyCode||l.which,u=a.querySelector("button.confirm"),c=a.querySelector("button.cancel"),d=a.querySelectorAll("button[tabindex]");if(-1!==[9,13,32,27].indexOf(i)){for(var f=l.target||l.srcElement,p=-1,m=0;m"),i.innerHTML=e.html?e.text:s.escapeHtml(e.text||"").split("\n").join("
"),e.text&&s.show(i),e.customClass)s.addClass(t,e.customClass),t.setAttribute("data-custom-class",e.customClass);else{var d=t.getAttribute("data-custom-class");s.removeClass(t,d),t.setAttribute("data-custom-class","")}if(s.hide(t.querySelectorAll(".sa-icon")),e.type&&!a.isIE8()){var f=function(){for(var o=!1,a=0;ao;o++)n=parseInt(e.substr(2*o,2),16),n=Math.round(Math.min(Math.max(0,n+n*t),255)).toString(16),a+=("00"+n).substr(n.length);return a};o.extend=a,o.hexToRgb=r,o.isIE8=s,o.logStr=l,o.colorLuminance=i},{}]},{},[1])}(window,document);
\ No newline at end of file
+!function(e,t,n){"use strict";!function o(e,t,n){function a(s,l){if(!t[s]){if(!e[s]){var i="function"==typeof require&&require;if(!l&&i)return i(s,!0);if(r)return r(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=t[s]={exports:{}};e[s][0].call(c.exports,function(t){var n=e[s][1][t];return a(n?n:t)},c,c.exports,o,e,t,n)}return t[s].exports}for(var r="function"==typeof require&&require,s=0;s=0;)n=n.replace(" "+t+" "," ");e.className=n.replace(/^\s+|\s+$/g,"")}},i=function(e){var n=t.createElement("div");return n.appendChild(t.createTextNode(e)),n.innerHTML},u=function(e){e.style.opacity="",e.style.display="block"},c=function(e){if(e&&!e.length)return u(e);for(var t=0;t0?setTimeout(o,t):e.style.display="none"});o()},h=function(n){if("function"==typeof MouseEvent){var o=new MouseEvent("click",{view:e,bubbles:!1,cancelable:!0});n.dispatchEvent(o)}else if(t.createEvent){var a=t.createEvent("MouseEvents");a.initEvent("click",!1,!1),n.dispatchEvent(a)}else t.createEventObject?n.fireEvent("onclick"):"function"==typeof n.onclick&&n.onclick()},b=function(t){"function"==typeof t.stopPropagation?(t.stopPropagation(),t.preventDefault()):e.event&&e.event.hasOwnProperty("cancelBubble")&&(e.event.cancelBubble=!0)};a.hasClass=r,a.addClass=s,a.removeClass=l,a.escapeHtml=i,a._show=u,a.show=c,a._hide=d,a.hide=f,a.isDescendant=p,a.getTopMargin=m,a.fadeIn=v,a.fadeOut=y,a.fireClick=h,a.stopEventPropagation=b},{}],5:[function(t,o,a){Object.defineProperty(a,"__esModule",{value:!0});var r=t("./handle-dom"),s=t("./handle-swal-dom"),l=function(t,o,a){var l=t||e.event,i=l.keyCode||l.which,u=a.querySelector("button.confirm"),c=a.querySelector("button.cancel"),d=a.querySelectorAll("button[tabindex]");if(-1!==[9,13,32,27].indexOf(i)){for(var f=l.target||l.srcElement,p=-1,m=0;m"),i.innerHTML=e.html?e.text:s.escapeHtml(e.text||"").split("\n").join("
"),e.text&&s.show(i),e.customClass)s.addClass(t,e.customClass),t.setAttribute("data-custom-class",e.customClass);else{var d=t.getAttribute("data-custom-class");s.removeClass(t,d),t.setAttribute("data-custom-class","")}if(s.hide(t.querySelectorAll(".sa-icon")),e.type&&!a.isIE8()){var f=function(){for(var o=!1,a=0;ao;o++)n=parseInt(e.substr(2*o,2),16),n=Math.round(Math.min(Math.max(0,n+n*t),255)).toString(16),a+=("00"+n).substr(n.length);return a};o.extend=a,o.hexToRgb=r,o.isIE8=s,o.logStr=l,o.colorLuminance=i},{}]},{},[1]),"function"==typeof define&&define.amd?define(function(){return sweetAlert}):"undefined"!=typeof module&&module.exports&&(module.exports=sweetAlert)}(window,document);