Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Link shorten on share, formatted text, schema.org tags added - Added link shortening on social sharing click, if there is an error, the default worldview link will be passed. - Formatted sharing text on each platform. - Added schema.org meta tags to index page for passing in information about the page and image to be used.

ZachTRiceb44e94a73171
diff --git a/web/index.html b/web/index.html
index 957cd9050..67efc1446 100644
--- a/web/index.html
+++ b/web/index.html
@@ -38,6 +38,11 @@
<meta http-equiv="Cache-control" content="no-store">
<meta http-equiv="Pragma" content="no-cache">
+ <!-- schema.org for social sharing -->
+ <!-- <meta itemprop="name" content="EOSDIS Worldview"> -->
+ <!-- <meta itemprop="description" content="NASA's Worldview Application"> -->
+ <!-- <meta itemprop="image" content="{http://www.your_url.com/your_image.png}"> -->
+
<!-- CSS resources ==================================================== -->
<link type="text/css" rel="Stylesheet" href="ext/node_modules/font-awesome/css/font-awesome.min.css">
@@ -48,8 +53,8 @@
<link type="text/css" rel="Stylesheet" href="ext/ui/iCheck-1.0.2-patch/skins/square/grey.css">
<link type="text/css" rel="Stylesheet" href="ext/ui/iCheck-1.0.2-patch/skins/square/red.css">
- <link type="text/css" rel="Stylesheet" href="ext/ui/iCheck-1.0.2-patch/skins/line/red.css">
-
+ <link type="text/css" rel="Stylesheet" href="ext/ui/iCheck-1.0.2-patch/skins/line/red.css">
+
<!-- link.dev --> <link type="text/css" rel="Stylesheet" href="ext/ui/jquery.jscrollpane-2.0.22/jquery.jscrollpane.css">
<!-- link.prod --> <!-- <link type="text/css" rel="Stylesheet" href="ext/ui/jquery.jscrollpane-2.0.22/jquery.jscrollpane.min.css"> -->
@@ -154,7 +159,7 @@
<!-- link.dev --> <script type="text/javascript" src="ext/image/jcrop-0.9.12/jquery.Jcrop.js"></script>
<!-- link.prod --> <!-- <script type="text/javascript" src="ext/image/jcrop-0.9.12/jquery.Jcrop.min.js"></script> -->
-
+
<script type="text/javascript" src="ext/ui/noUiSlider-6.1.10/jquery.nouislider.min.js"></script>
@@ -245,7 +250,7 @@
<!-- link.dev --> <script type="text/javascript" src="js/naturalEvents/wv.naturalEvents.model.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/naturalEvents/wv.naturalEvents.ui.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/naturalEvents/wv.naturalEvents.map.js"></script>
-
+
<!-- link.dev --> <script type="text/javascript" src="js/map/wv.map.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/map/wv.map.model.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/map/wv.map.rotate.js"></script>
@@ -255,7 +260,7 @@
<!-- link.dev --> <script type="text/javascript" src="js/map/wv.map.precachetile.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/map/wv.map.ui.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/map/wv.map.animate.js"></script>
-
+
<!-- link.dev --> <script type="text/javascript" src="js/link/wv.link.model.js"></script>
<!-- link.dev --> <script type="text/javascript" src="js/link/wv.link.ui.js"></script>
@@ -382,13 +387,13 @@
</header>
<div id="layer-modal-main">
<div id="layer-categories">
-
+
</div>
<div id="selected-category">
-
+
</div>
<div id="layers-all">
-
+
</div>
</div>
<footer>
diff --git a/web/js/link/wv.link.ui.js b/web/js/link/wv.link.ui.js
index fc3221057..ab8a9bd9f 100644
--- a/web/js/link/wv.link.ui.js
+++ b/web/js/link/wv.link.ui.js
@@ -70,31 +70,27 @@ wv.link.ui = wv.link.ui || function(models, config) {
item += "</div>";
// Social Sharing
- var baseLink = window.location.href;
- var baseEncodedLink = encodeURIComponent(baseLink);
+ var defaultLink = encodeURIComponent('http://worldview.earthdata.nasa.gov');
var shareMessage = encodeURIComponent('Check out what I found in NASA\'s Worldview!');
shareMessage = shareMessage.replace(/'/g, '%27');
-
var fbAppId = 'yourFacebookAppId';
- var fbDisplay = 'popup';
var fbRedirectUri = "https%3A%2F%2Fdevelopers.facebook.com%2Ftools%2Fexplorer";
+ var twitterHashTag = encodeURIComponent('#NASAWorldview');
+
+ item += "<div id='social-share'>";
- item += "<div id='social-share'><div id='social-message'></div><div class='social'>";
- // Facebook
- // https://developers.facebook.com/docs/sharing/reference/share-dialog#redirect
- item += "<a class='icon-link fa fa-facebook fa-2x' href='https://www.facebook.com/dialog/share?app_id=" + fbAppId + "&display=" + fbDisplay + "&href=" + baseEncodedLink + "&redirect_uri=" + fbRedirectUri + "' target='_blank' title='Share via Facebook!'></a>";
+ // Facebook: https://developers.facebook.com/docs/sharing/reference/share-dialog#redirect
+ item += "<a id='fb-share' class='icon-link fa fa-facebook fa-2x' href='https://www.facebook.com/dialog/share?app_id=" + fbAppId + "&href=" + defaultLink + "&redirect_uri=" + fbRedirectUri + "&display=popup' target='_blank' title='Share via Facebook!'></a>";
- // Twitter
- // https://dev.twitter.com/web/tweet-button/parameters#web-intent-example
- item += "<a class='icon-link fa fa-twitter fa-2x' href='https://twitter.com/intent/tweet?text=" + shareMessage + "' target='_blank' title='Share via Twitter!'></a>";
+ // Twitter: https://dev.twitter.com/web/tweet-button/parameters#web-intent-example
+ item += "<a id='tw-share' class='icon-link fa fa-twitter fa-2x' href='https://twitter.com/intent/tweet?url=" + defaultLink + "&text=" + shareMessage + '%20' + twitterHashTag + "%20-' target='_blank' title='Share via Twitter!'></a>";
- // Google Plus
- // https://developers.google.com/+/web/share/#sharelink-endpoint
- item += "<a class='icon-link fa fa-google-plus fa-2x' href='https://plus.google.com/share?url=" + baseEncodedLink + "' target='_blank' title='Share via Google Plus!'></a>";
+ // Google Plus: https://developers.google.com/+/web/share/#sharelink-endpoint
+ item += "<a id='gp-share' class='icon-link fa fa-google-plus fa-2x' href='https://plus.google.com/share?url=" + defaultLink + "' target='_blank' title='Share via Google Plus!'></a>";
// Email
- item += "<a class='icon-link fa fa-envelope fa-2x' href='mailto:?subject=" + shareMessage + "&body=" + baseEncodedLink + "' target='_self' title='Share via Email!'></a>";
- item += "</div></div>";
+ item += "<a id='email-share' class='icon-link fa fa-envelope fa-2x' href='mailto:?subject=" + shareMessage + "&body=" + shareMessage + "%20-%20" + defaultLink + "' target='_self' title='Share via Email!'></a>";
+ item += "</div>";
$dialog.html(item).iCheck({checkboxClass: 'icheckbox_square-grey'});
@@ -135,6 +131,37 @@ wv.link.ui = wv.link.ui || function(models, config) {
$dialog.dialog("open");
setTimeout(updateLink, 500);
+ // When an icon-link is clicked, replace the URL with short link.
+ $(".icon-link").on("click", function() {
+ var promise = models.link.shorten();
+ promise.done(function(result) {
+ if ( result.status_code === 200 ) {
+ var shortLink = result.data.url;
+ var shortEncodedLink = encodeURIComponent(shortLink);
+ // Set Facebook
+ var fbLink = document.getElementById("fb-share");
+ fbLink.setAttribute("href", "https://www.facebook.com/dialog/share?app_id=" + fbAppId + "&href=" + shortEncodedLink + "&redirect_uri=" + fbRedirectUri + "&display=popup");
+
+ // Set Twitter
+ var twLink = document.getElementById("tw-share");
+ twLink.setAttribute("href", "https://twitter.com/intent/tweet?url=" + shortEncodedLink + "&text=" + shareMessage + '%20' + twitterHashTag + "%20-");
+
+ // Set Google Plus
+ var gpLink = document.getElementById("gp-share");
+ gpLink.setAttribute("href", "https://plus.google.com/share?url=" + shortLink + "");
+
+ // Set Email
+ var emailLink = document.getElementById("email-share");
+ emailLink.setAttribute("href", "mailto:?subject=" + shareMessage + "&body=" + shareMessage + "%20-%20" + shortLink + "");
+ return false;
+ } else {
+ error(result.status_code, result.status_txt);
+ }
+ }).fail(function(jqXHR, textStatus, errorThrown) {
+ error(textStatus, errorThrown);
+ });
+ });
+
//$("#wv-link-shorten-check").button();
$("#wv-link-shorten-check").on("ifChanged", function() {
var checked = $("#wv-link-shorten-check").prop("checked");