');
+ caption.addClass("caption");
+ caption.text(item['title']);
+ caption.appendTo(aHr);
+ let descrip = $('
');
+ descrip.text(item['desc']);
+ descrip.appendTo(aHr);
+ aHr.appendTo(divTh);
+ divTh.appendTo(divCol);
+ divCol.appendTo(imgContainer);
+ descrip.hide();
+ img.hover(function () {
+ descrip.show();
+ });
+ })
+ if ((page + 1) < numpages) {
+ let linkContainer = $('#seemore');
+ linkContainer.empty();
+ let link = $('
');
+ link.text('See More');
+ link.addClass("badge badge-primary");
+ link.appendTo(linkContainer);
+ $(linkContainer).on('click', function () {
+ page = page + 1;
+ renderImages(renderData, page);
+ })
+ }
+}
+
+$("#btn").on("click", function () {
+ let searchTerm = $("#sContent").val();
+
+ $.ajax({
+
+ url: "https://images-api.nasa.gov/search",
+
+ data: {
+ q: searchTerm,
+ media_type: "image"
+ },
+
+ type: "GET",
+
+ dataType: "json",
+ })
+ .done(function (json) {
+ nasaData = json.collection.items;
+ renderData = nasaData.map(function (item) {
+ return {
+ title: item.data[0].title,
+ desc: item.data[0].description,
+ href: item.links[0].href
+ }
+ })
+ renderImages(renderData, page);
+ })
+ .fail(function (xhr, status, errorThrown) {
+ alert("Sorry, there was a problem!");
+ console.log("Error: " + errorThrown);
+ console.log("Status: " + status);
+ console.dir(xhr);
+ })
+ .always(function (xhr, status) {
+ console.log("The request is complete!");
+ })
+});
+
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..9cfa7cd
--- /dev/null
+++ b/index.html
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+ Nasa Image Previewer
+
+
+
+
+
+
+
+
Nasa Image Previewer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file