Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link objects to their descriptions in NASA Archive. #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions web-root/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<div id="menu-left" class="menubar">
<div id="search-holder" class="menu-item">
<span class="icon-search"></span>
<input type="text" id="search"></input>
<input type="text" id="search"/>
</div>
<div id="menu-groups" class="menu-item">
<div class="menu-title">Groups</div>
Expand Down Expand Up @@ -71,15 +71,15 @@
<span class="box-header">Legend</span>
<ul id="legend">
<li>
<img class="dot" src="/dot-red.png"></img>
<img class="dot" src="/dot-red.png"/>
Satellite
</li>
<li>
<img class="dot" src="/dot-blue.png"></img>
<img class="dot" src="/dot-blue.png"/>
Rocket body
</li>
<li>
<img class="dot" src="/dot-grey.png"></img>
<img class="dot" src="/dot-grey.png"/>
Debris
</li>
</ul>
Expand Down Expand Up @@ -118,6 +118,16 @@
</div>
<div id="search-results"></div>
<div id="sat-hoverbox">(none)</div>
<div class="sat-description">
<div class="sat-description__header">
<div class="sat-description__header--left">About</div>
<a class="sat-description__header--right sat-description__close">X</a>
</div>
<div class="sat-description__content"></div>
<div class="sat-description__footer">
<b>Credits:</b> NASA Space Science Data Coordinated Archive
</div>
</div>
<div id="sat-infobox">
<div id="sat-info-title">This is a title</div>
<div id="all-objects-link" class="link">Find all objects from this launch...</div>
Expand Down
43 changes: 43 additions & 0 deletions web-root/nasainfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
$catalogURLTemplate = 'http://nssdc.gsfc.nasa.gov/nmc/masterCatalog.do?sc=%s';
$designator = htmlspecialchars($_GET['intldes']);
$redirect = filter_var($_GET['redirect'], FILTER_VALIDATE_BOOLEAN);

if ($designator) {
if ($redirect) {
header('Location: ' . sprintf($catalogURLTemplate, $designator), true, 302);
exit;
} else {
$catalogEntryHtml = file_get_contents(sprintf($catalogURLTemplate, $designator));

if ($catalogEntryHtml) {
$catalogEntryDocument = new DOMDocument();
if ($catalogEntryDocument->loadHTML($catalogEntryHtml)) {
$xpath = new DOMXPath($catalogEntryDocument);

$match = $xpath->query('//div[@id="contentwrapper"]//div[@class="urone"]');
if ($match->length > 0) {
$description = '';
$descriptionParts = $match[0]->childNodes;
for ($i = 1; $i < $descriptionParts->length; ++$i) {
$description .= trim($descriptionParts[$i]->nodeValue);
}

header('Content-Type: text/json', true, 200);

$data = array(
'description' => $description
);

echo json_encode($data);

exit;
}
}
}
}
}

// fall back - if any error happened during data extraction above, return 404
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found', true, 404);
?>
21 changes: 20 additions & 1 deletion web-root/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,22 @@ $(document).ready(function() {
initialRotation = false;
camZoomSnappedOnSat = false;
});

$('.sat-description__close').click(function() {
$('.sat-description').fadeOut();
});
// debugContext = $('#debug-canvas')[0].getContext('2d');
// debugImageData = debugContext.createImageData(debugContext.canvas.width, debugContext.canvas.height);
drawLoop(); //kick off the animationFrame()s
});

function selectSat(satId) {
$('.sat-description').fadeOut();

selectedSat = satId;
if(satId === -1) {
$('#sat-infobox').fadeOut();
orbitDisplay.clearSelectOrbit();
orbitDisplay.clearSelectOrbit();
} else {
camZoomSnappedOnSat = true;
camAngleSnappedOnSat = true;
Expand All @@ -262,6 +268,19 @@ function selectSat(satId) {
// camSnapToSat(satId);
var sat = satSet.getSat(satId);
if(!sat) return;

var nasaInfoUrl = 'nasainfo.php?intldes=' + sat.intlDes;
$.getJSON(nasaInfoUrl, function (data){
var satDescription = $('.sat-description');
var satDescriptionContent = $('.sat-description__content', satDescription);
var learnMore = $('<a/>').prop('href', nasaInfoUrl + '&redirect=true').text('Learn more...');

satDescriptionContent.html(data.description);
satDescriptionContent.append($('<br/>'), learnMore);

satDescription.fadeIn();
});

orbitDisplay.setSelectOrbit(satId);
$('#sat-infobox').fadeIn();
$('#sat-info-title').html(sat.OBJECT_NAME);
Expand Down
57 changes: 55 additions & 2 deletions web-root/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,59 @@ ul {
pointer-events: none;
}

.sat-description {
background: black;
border-radius: 5px;
border: 1px solid rgba(255, 255, 255, 0.2);
cursor: default;
color: white;
position: absolute;
top: 50%;
left: 50%;
padding: 1px;
margin-top: auto;
margin-bottom: auto;
display: none;
}

.sat-description__header {
padding: 1px;
border-radius: 5px;
border: 1px solid rgba(255, 255, 255, 0.2);
display: flex;
flex-direction: row;
}

.sat-description__header--left {
padding: 4px;
flex-grow: 1;
}

.sat-description__header--right {
flex: none;
display: flex;
align-items: center;
justify-content: center;
width: 25px;
height: 25px;
font-size: 10px;
border-radius: 5px;
border: 1px solid rgba(255, 255, 255, 0.2);
cursor: hand;
text-decoration: none;
}

.sat-description__content {
overflow-y: scroll;
padding: 9px;
max-width: 400px;
max-height: 250px;
}

.sat-description__footer {
font-size: 8pt;
}

#sat-infobox {
background: black;
cursor:default;
Expand Down Expand Up @@ -186,7 +239,7 @@ ul {
font-size: 12px;
height: 28px;
float: right;
margin-right: 10 px;
margin-right: 10px;
}

#search {
Expand Down Expand Up @@ -359,4 +412,4 @@ ul {

#controls-info>li {
margin-top: 10px;
}
}