Wikipedia Viewer
How do I make an wikipedia viewer?
A Wikipedia viewer built for freeCodeCamp. Uses the MediaWiki API.. What is a wikipedia viewer? How do you make a wikipedia viewer? This script and codes were developed by Zac Clemans on 14 January 2023, Saturday.
Wikipedia Viewer - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Wikipedia Viewer</title> <meta name="viewport" content="width=device-width, initial-scale=1">
<link href='https://fonts.googleapis.com/css?family=Playfair+Display:400,700,900' rel='stylesheet' type='text/css'>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="header" class="container-fluid"> <h1>QWiki: Wikipedia FAST!</h1>
</div>
<div id="divider" class="container-fluid">
</div>
<div id="main" class="container"> <div class="row special" id="search-container"> <div class="col-sm-8"><input id="search-bar" type="text" value="Search Wikipedia"></div> <div class="col-sm-2" id="search-button"><i class="glyphicon glyphicon-search"></i></div> <div class="col-sm-2" id="random-button"><i class="glyphicon glyphicon-question-sign"></i></div> </div> <div class="col-sm-8" id="suggest-holder"> <ul> </ul> </div>
</div>
<div id="footer"> <h5 id="name">Created by: Zac Clemans</h5> <h5 id="credit">Powered by: MediaWiki API</h5>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Wikipedia Viewer - Script Codes CSS Codes
body { font-family: Open-Sans; color: #36332e; background: #f0f0f0;
}
a { text-decoration: none; color: #36332e;
}
a:hover { text-decoration: none; color: #e69a4e;
}
#header { font-family: Playfair; background: #f8b504;
}
#header h1 { font-weight: 900;
}
#divider { height: 10px; margin-bottom: 40px; background: #36332e; box-shadow: 5px 5px 5px #a4a4a4;
}
#main { position: relative;
}
#main #search-container { font-size: 20px;
}
#main #search-container #search-bar { width: 100%; height: 40px; padding-left: 10px; border: none; border-radius: 5px;
}
#main #search-container #search-button, #main #search-container #random-button { text-align: center; line-height: 40px; height: 40px; border: 1px solid #36332e; border-radius: 5px; background: #f8b504;
}
#main #search-container #search-button:hover, #main #search-container #random-button:hover { cursor: pointer;
}
#main #search-container #search-button:active, #main #search-container #random-button:active { color: white; background: #36332e;
}
#suggest-holder { position: absolute; display: none; width: 66.6%; margin-top: -1px; margin-left: -15px; background: white; /*border: 2px solid rgb(197, 218, 237);*/ z-index: 1;
}
#suggest-holder ul { list-style: none; margin: 0; padding: 0;
}
#suggest-holder ul li { padding: 5px;
}
#suggest-holder ul li:hover, #suggest-holder ul li.active { cursor: pointer; background: rgba(150, 150, 150, 0.2);
}
.article-container { margin-bottom: 10px; border: 2px solid #383d40; border-radius: 10px; background: white;
}
.article-container h3, .article-container p { margin-left: 20px;
}
div.special > div[class*="col-"] { padding: 0;
}
#footer { position: fixed; bottom: 0; left: 0; right: 0; background: #f8b504;
}
#footer #name { float: left; font-weight: 700; padding-left: 20px;
}
#footer #credit { float: right; font-weight: 700; padding-right: 20px;
}
Wikipedia Viewer - Script Codes JS Codes
var $searchBar = $("#search-bar");
var $searchBtn = $("#search-button");
var $suggestHolder = $("#suggest-holder");
var index = -1;
var keySelection = false;
$searchBtn.on('click', function(){ $suggestHolder.slideUp(); $suggestHolder.css('border', ''); var query = $searchBar.val(); $.ajax({ url: "https://www.wikipedia.org/w/api.php", data: { action: "query", list: "search", format: "json", srsearch: query, srlimit: "25" }, dataType: "jsonp", success: function(data){ appendArticles(data.query.search); }, type: "GET" });
});
$searchBar.on('focus', function(){ $(this).select();
});
$searchBar.on('keyup', function(e){ if (e.which == 13){ // Enter key if ($("#suggest-holder li").hasClass('active')){ $searchBar.val($("#suggest-holder li.active").text()); $searchBtn.click(); } $searchBtn.click(); } else if (e.which == 27){ // Esc key $suggestHolder.slideUp(); } else if (e.which == 40){ // Down key index++; if (index > $("#suggest-holder li").length - 1){ index = $("#suggest-holder li").length - 1; } keySelection = true; } else if (e.which == 38){ // Up key index--; if (index < 0){ index = 0; } keySelection = true; } else{ index = -1; $suggestHolder.slideDown(); $("#suggest-holder ul").empty(); if ($searchBar.val().length > 1){ var query = $("#search-bar").val(); $.ajax({ url: "https://www.wikipedia.org/w/api.php", data: { action: "opensearch", format: "json", search: query }, dataType: "jsonp", success: function(data){ data[1].forEach(function(suggestion, index){ $("#suggest-holder ul").append("<li>" + suggestion + "</li>"); }); }, type: "GET" }); } } if (keySelection){ $("#suggest-holder li.active").removeClass('active'); $("#suggest-holder li").eq(index).addClass('active'); }
});
$("ul").on('click', 'li', function(){ $searchBar.val($(this).text()); $searchBtn.click();
});
$("#random-button").on('click', function(){ window.open("https://en.wikipedia.org/wiki/Special:Random")
});
$searchBar.on('focusout', function(){ $suggestHolder.slideUp(); $suggestHolder.css('border', ''); $("#suggest-holder li.active").removeClass('active');
});
function appendArticles(articleList){ $(".article-container").remove(); articleList.forEach(function(article, index){ $("#main") .append("<a href='https://en.wikipedia.org/wiki/" + article.title + "' target='_blank'>" + "<div class='article-container'>" + "<h3>" + article.title + "</h3>" + "<p>" + article.snippet + "</p>" + "</div>" + "</a>"); }); $(".article-container:first").css('margin-top', '40px') $(".article-container:last").css('margin-bottom', '60px')
}
Developer | Zac Clemans |
Username | thalpha |
Uploaded | January 14, 2023 |
Rating | 3 |
Size | 4,426 Kb |
Views | 4,048 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Recipe Box | 7,954 Kb |
D3 Map Project | 3,119 Kb |
JQuery Calculator | 3,124 Kb |
Tic-Tac-Toe | 5,278 Kb |
Simon Says | 3,674 Kb |
D3 Force-directed Graph Project | 3,348 Kb |
FCC Camper Leaderboard Redux Refactor | 9,125 Kb |
Recipe Box Redux Refactor | 11,597 Kb |
Markdown Previewer | 3,771 Kb |
D3 Bar Graph Project | 3,011 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
A cube | KyleDavidE | 18,627 Kb |
Collapsing Widget | Er40 | 4,279 Kb |
A Pen by Mohomed Anees | Mohomedanees | 12,597 Kb |
Polygon Logo in CSS | Kai | 3,412 Kb |
Responsive slide | Thorien | 2,400 Kb |
Nice textured background | Hans | 2,659 Kb |
Commuter Line Tokyu 8500 | Pedox | 7,031 Kb |
Horizontal scroll fixed element | HerrSerker | 0 Kb |
A Pen by Andrea Verlicchi | Verlok | 2,018 Kb |
3d css cube | Semenchenko | 4,578 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!