A Pen by Arpit Yadav on CodePen.
Created
March 30, 2018 04:54
-
-
Save Ace-ezer/afffe46018abcaff4c5b72380b406a9a to your computer and use it in GitHub Desktop.
wikipedia viewer
This file contains 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
<!-- stuck on js first--> | |
<body background="https://c1.staticflickr.com/1/60/174104896_77c6a27c82_o.jpg"> | |
<div class="container-fluid"> | |
<div class="text-center"><h1>Wikipedia Viewer</h1></div> | |
<div id="main"> | |
<div class="row" id="r1"> | |
<div class="col-md-12 text-center"><a href="https://en.wikipedia.org/wiki/Special:Random" target="_blank">Click Here</a> for a Random Search.</div> | |
</div> | |
<div class="row" id="r2"> | |
<div class="col-md-12 text-center"> | |
<span> | |
<input type="text" id="data" placeholder="Enter Text..." class=" search " > | |
<button id="search" class="btn"><i class="fa fa-search"> Search</i></button> | |
</span> | |
</div></div> | |
</div> | |
<ul id="out"> </ul> | |
</div> | |
</body> |
This file contains 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(){ | |
$("#search").on("click",function(){ | |
var skey= $("#data").val(); | |
var surl="https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search="+skey+"&namespace=0&limit=10&callback=?"; | |
$.ajax({ | |
type : 'GET', | |
url : surl, | |
asynch: false, | |
contentType:'plain/text', | |
dataType:'json', | |
success : function(arr){ | |
$("#out").html(''); | |
for(var i=0;i<arr[1].length;i++) | |
{ $("#out").append("<li class='block'><a href='"+arr[3][i]+"' target='_blank'><h2> "+arr[1][i]+"</h2><p><h3> "+arr[2][i]+"</h3></p></a></li>"); | |
} | |
}, | |
error : function(err){ | |
alert('error'); | |
} | |
}); | |
}); | |
}); |
This file contains 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://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta/js/bootstrap.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.6/angular.js"></script> |
This file contains 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
@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"); | |
h1{ | |
font-style : italic; | |
font-family: monospace; | |
font-size: 90px; | |
background-color: grey; | |
color: white; | |
} | |
#main{ | |
margin-top: 70px; | |
margin-bottom: 50 px; | |
} | |
#r1{ | |
font-size:30px; | |
font-family:lobster; | |
} | |
h2{ | |
font-family: georgia; | |
font-variant: large-caps; | |
font-size: 30px; | |
} | |
h3{ | |
font-family: sans-serif; | |
font-size: 20px; | |
} | |
ul{ list-style-type: none; | |
margin: 20px; | |
padding: 10px; | |
width:90%; | |
} | |
li{ | |
display: block; | |
background-color:lavender; | |
padding:30px; | |
margin: 10px; | |
opacity: 1; | |
} | |
li a{ | |
color:black; | |
} | |
li a:hover{ | |
color: orange; | |
} | |
p{ | |
font-weight: bold; | |
} | |
#data{ | |
width: 50%; | |
padding: 10px; | |
border-radius:5px; | |
font-size: 17px; | |
} | |
#search{ | |
font-size: 21px; | |
background-color:purple; | |
border-color:purple; | |
border-radius: 5px; | |
color: white; | |
} |
This file contains 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://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> | |
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css" rel="stylesheet" /> | |
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wikipedia viewer