Wikipedia viewer

Developer
Size
3,085 Kb
Views
32,384

How do I make an wikipedia viewer?

What is a wikipedia viewer? How do you make a wikipedia viewer? This script and codes were developed by Matheus on 03 September 2022, Saturday.

Wikipedia viewer Previews

Wikipedia viewer - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>wikipedia viewer</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <link href="https://fonts.googleapis.com/css?family=Abril+Fatface" rel="stylesheet">
<div ng-app="wikiApp" ng-controller="wikiController"> <h1> Wikipedia Viewer </h1> <p id="description"> Search, or click <a target="_blank" href="https://en.wikipedia.org/wiki/Special:Random">here</a> to get a random article </p> <form ng-submit="funcSearch()"> <input type="text" name="search" placeholder="Search.." ng-model="input"> </form> <div id="articleContent" ng-repeat="items in articlesList.items"> <a href={{items.articleLink}} target="_blank"> <p id="articleTitle"><b> {{items.articleTitle}}</b></p> <p id="articleExtract"> {{items.articleText}} </p> </a> </div>
</div> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.2/angular-animate.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Wikipedia viewer - Script Codes CSS Codes

body{ background-color: purple;
}
h1{ text-align: center; font-family: 'Abril Fatface', cursive; font-size: 50px;
}
#description{ font-size: 20px; text-align: center; position: relative; top: 10px;
}
a{ color: black;
}
input[type=text] { width: 130px; box-sizing: border-box; border: 2px solid #ccc; border-radius: 4px; font-size: 16px; background-color: white; background-image: url('https://cdn1.iconfinder.com/data/icons/hawcons/32/698627-icon-111-search-128.png'); background-size: 30px 30px; background-position: 6px 6px; background-repeat: no-repeat; padding: 12px 20px 12px 40px; -webkit-transition: width 0.4s ease-in-out; transition: width 0.4s ease-in-out; margin: auto; display: block; border-style: solid; border-color: black; border-width: 3px; border-radius: 10px; position: relative; top: 10px;
}
input[type=text]:focus { width: 50%;
}
#articleContent{ width: 900px; height: 75px; background-color: white; margin: auto; position: relative; top: 30px; border-style: solid; border-color: black; border-width: 2px; border-radius: 10px;
}
#articleTitle{ font-size: 20px; position: relative; bottom: 13px; left: 10px;
}
#articleExtract{ font-size: 15px; position: relative; bottom: 13px; left: 10px;
}
a{ text-decoration: none;
}

Wikipedia viewer - Script Codes JS Codes

//https://www.mediawiki.org/w/api.php
//https://en.wikipedia.org/w/api.php?action=query&generator=links&titles=Metallica
//https://en.wikipedia.org/w/api.php?format=jsonfm&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=metallica&callback=JSON_CALLBACK
var myApp = angular.module('wikiApp', []);
myApp.controller('wikiController', ['$scope', '$timeout', '$http', function($scope, $timeout, $http) { $scope.funcSearch = function(){ //declares new empty articles object list $scope.articlesList = { items: [ ] }; //set url for wikipedia API var url="https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=" + $scope.input + "&callback=JSON_CALLBACK"; //http connection fails with jquery $http.jsonp(url).success(function(data) { //evaluetes and organizes received data var pagesList=Object.keys(data.query.pages); console.log(pagesList); for (var i=0; i<pagesList.length; i++){ var extract; if (data.query.pages[pagesList[i]].extract.length > 110){ extract=data.query.pages[pagesList[i]].extract.substring(0,110); extract+="..." } else extract=data.query.pages[pagesList[i]].extract; var auxObj = { articleTitle: data.query.pages[pagesList[i]].title, articleLink: "https://en.wikipedia.org/?curid=" + pagesList[i], articleText: extract } $scope.articlesList.items.push(auxObj); } console.log($scope.articlesList); }); }
}]);
Wikipedia viewer - Script Codes
Wikipedia viewer - Script Codes
Home Page Home
Developer Matheus
Username MatheusLima92
Uploaded September 03, 2022
Rating 3
Size 3,085 Kb
Views 32,384
Do you need developer help for Wikipedia viewer?

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!

Matheus (MatheusLima92) Script Codes
Create amazing blog posts with AI!

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!