Add share/copy menu

master
Skylar Ittner 2 years ago
parent d3768071cf
commit 1d0803eca4

@ -46,4 +46,93 @@ function dolookup(words) {
} catch (e) {
app.dialog.alert(e, "Error");
}
}
function openLocationActionDialog(latitude, longitude, words) {
app.actions.create({
buttons: [
[
{
text: words,
label: true,
bold: true
}
],
[
{
text: "<i class='far fa-share'></i> &nbsp; Share",
label: true
},
{
text: "FixPhrase",
onClick: function () {
window.plugins.socialsharing.shareWithOptions({
message: words
});
}
},
{
text: "Link",
onClick: function () {
window.plugins.socialsharing.shareWithOptions({
message: words,
url: "https://fixphrase.com/#" + words.replaceAll(" ", "-")
});
}
},
{
text: "Coordinates",
onClick: function () {
window.plugins.socialsharing.shareWithOptions({
message: latitude + ", " + longitude
});
}
}
],
[
{
text: "<i class='far fa-copy'></i> &nbsp; Copy",
label: true
},
{
text: "FixPhrase",
onClick: function () {
console.log("wefuiefhui weu");
navigator.clipboard.writeText(words).then(() => {
app.toast.show({text: "Copied!", closeTimeout: 3000});
});
}
},
{
text: "Link",
onClick: function () {
navigator.clipboard.writeText("https://fixphrase.com/#" + words.replaceAll(" ", "-")).then(() => {
app.toast.show({text: "Copied!", closeTimeout: 3000});
});
}
},
{
text: "Coordinates",
onClick: function () {
navigator.clipboard.writeText(latitude + ", " + longitude).then(() => {
app.toast.show({text: "Copied!", closeTimeout: 3000});
});
}
}
],
[
{
text: "Open in Default Maps App",
onClick: function () {
openGeoLink("geo:" + latitude + "," + longitude);
}
}
],
[
{
text: "Cancel"
}
]
]
}).open();
}

@ -68,9 +68,14 @@ function animateMapIn(latitude, longitude, zoom, heading) {
function showLocationPopup(latitude, longitude, words, accuracy) {
clearRectangle();
$("#location-info-words").text(words);
$("#location-info-coordlink").attr("href", "geo:" + (Math.round(latitude * 10000) / 10000) + "," + (Math.round(longitude * 10000) / 10000));
$("#location-info-coords").text((Math.round(latitude * 10000) / 10000) + ", " + (Math.round(longitude * 10000) / 10000));
$("#location-info-coordlink").css("visibility", "");
latitude = (Math.round(latitude * 10000) / 10000);
longitude = (Math.round(longitude * 10000) / 10000);
$("#location-info-coords").text(latitude + ", " + longitude);
$("#openLocationActionDialogButton").css("visibility", "");
$("#openLocationActionDialogButton").off("click");
$("#openLocationActionDialogButton").on("click", function () {
openLocationActionDialog(latitude, longitude, words);
});
drawRectangle(
latitude - (accuracy / 2),
longitude - (accuracy / 2),

@ -58,6 +58,22 @@ var getLocation = function (success, error) {
}
}
var openGeoLink = function (href) {
if (platform_type == "cordova") {
if (cordova.platformId == "ios") {
window.open(href.replace("geo:", "http://maps.apple.com/?q="), "_system");
} else if (cordova.platformId == "android") {
window.open(href.replace("geo:", "geo:0,0?q="), "_system");
} else {
window.open(href, "_system");
}
} else if (platform_type == "nw") {
require('nw.gui').Shell.openExternal(href);
} else {
window.open(href, "_blank");
}
}
function initCordova() {
platform_type = "cordova";
@ -150,13 +166,7 @@ function initCordova() {
// Handle geo: urls
$("body").on("click", "a[href^='geo:']", function (evt) {
if (cordova.platformId == "ios") {
window.open($(this).attr("href").replace("geo:", "http://maps.apple.com/?q="), "_system");
} else if (cordova.platformId == "android") {
window.open($(this).attr("href").replace("geo:", "geo:0,0?q="), "_system");
} else {
window.open($(this).attr("href"), "_system");
}
openGeoLink($(this).attr("href"));
evt.preventDefault();
});
}
@ -198,7 +208,7 @@ function initNW() {
// Handle geo: urls
$("body").on("click", "a[href^='geo:']", function (evt) {
require('nw.gui').Shell.openExternal($(this).attr("href"));
openGeoLink($(this).attr("href"));
evt.preventDefault();
});
@ -222,8 +232,8 @@ function initBrowser() {
window.open(url);
}
$("body").on("click", ".geolink", function (evt) {
window.open($(this).attr("href"), "_blank");
$("body").on("click", "a[href^='geo:']", function (evt) {
openGeoLink($(this).attr("href"));
evt.preventDefault();
});

@ -33,9 +33,14 @@
</div>
<div class="toolbar toolbar-bottom" id="location-info-toolbar">
<div class="toolbar-inner padding-horizontal-half display-block" id="location-info-toolbar-inner">
<div id="location-info-words" style="font-weight: bold;" class="copyonclick"></div>
<a id="location-info-coordlink" href="" style="visibility: hidden;"><i class="fas fa-external-link"></i> <span id="location-info-coords"></span></a>
<div class="toolbar-inner padding-horizontal-half" id="location-info-toolbar-inner">
<div>
<div id="location-info-words" style="font-weight: bold;" class="copyonclick"></div>
<div id="location-info-coords"></div>
</div>
<div class="link" style="visibility: hidden;" id="openLocationActionDialogButton">
<i class="fas fa-external-link"></i>
</div>
</div>
</div>
</div>
Loading…
Cancel
Save