A Pen by Zoran Stanic on CodePen.
Created
November 11, 2016 00:15
-
-
Save pilgrim011/dae0dc82b83c881789ba484a0ddcb4fc to your computer and use it in GitHub Desktop.
Wikipedia Viewer3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class = "text-center"> | |
<h1>Wikipedia Viewer</h1> | |
<a href="https://en.wikipedia.org/wiki/Special:Random" id ="random">Click here for a random article</a> | |
</div> | |
<div class = "text-center" id = "search"> | |
<button><img src= "http://icons.iconarchive.com/icons/zerode/plump/128/Search-icon.png" alt="Click to search" id="clickImage"></button> | |
<h3>Click icon to search</h3> | |
</div> | |
<div class="list-group" id = "lista"> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$("img").on("click", function(){ | |
$("img").remove(); | |
$("h3").remove(); | |
$("#search").html("<form><input type=text name=query id = what><input type=button value=Search id = find></form>"); | |
$("#find").click(function(){ | |
var input = document.getElementById("what").value; | |
var wiki = "https://en.wikipedia.org/w/api.php?action=opensearch&search=" + input + "&limit=10&namespace=0&utf8&snippet&format=json&$parse&callback=?"; | |
$.getJSON(wiki, function(data){ | |
for (var i=0;i<10;i++){ | |
$("#lista").append("<a href=" + data[3][i] + ">" + | |
"<li>" + data[1][i] + "</li>" + | |
"<p>" + data[2][i] + "</p>" + | |
"</a>"); | |
} | |
}); | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a{ | |
color: black; | |
font-size:30px; | |
} | |
a:hover{ | |
text-decoration:none; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment