Wiki Search

Developer
Size
3,062 Kb
Views
12,144

How do I make an wiki search?

What is a wiki search? How do you make a wiki search? This script and codes were developed by Paulo Sérgio on 19 November 2022, Saturday.

Wiki Search Previews

Wiki Search - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Wiki Search</title> <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="maincontainer" ng-app="myapp"> <div class="container-fluid" ng-controller="WikiController"> <div class="row"> <div class="jumbotron"> <h1 class="title text-center">Wiki Search</h1> <div class="row"> <div class="col-xs-1 col-xs-offset-3"> <div class="input-group"> <button ng-click="getContent(true)" class="btn btn-info">Random Search</button> </div> </div> <div class="col-xs-5"> <div class="input-group"> <span class="input-group-btn"> <button class="btn btn-primary" ng-click="getContent()" type="button">Go!</button> </span> <input type="text" class="form-control" ng-model="search" placeholder="Type here!"></input> </div> </div> </div> <!-- end row --> </div> <!-- end jumbotron --> </div> <!-- end row --> <div class="row example-animate-container"> <div class="col-md-4 animate-repeat" ng-if="!random" ng-repeat="result in wikiresult"> <div class="panel panel-default element"> <div class="panel-heading">{{result.title}}</div> <div class="panel-body"> <p ng-bind-html="toHtml(result.snippet)"></p> </div> </div> </div> <!-- end col-md-4 --> <div class="container" ng-if="random"> <div class="panel panel-default element"> <div class="panel-heading">{{wikiresult.title}}</div> <div class="panel-body"> <p ng-bind-html="toHtml(wikiresult.extract)"></p> </div> </div> </div> </div> </div>
</div> <script src='https://code.jquery.com/jquery-2.2.4.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.min.js'></script>
<script src='https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-sanitize.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.0/angular-animate.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Wiki Search - Script Codes CSS Codes

.element { opacity: 0.25;
}

Wiki Search - Script Codes JS Codes

var app = angular.module('myapp', ['ngSanitize' , 'ngAnimate']);
app.controller('WikiController' , ['$scope' , '$sce', '$timeout', function($scope , $sce , $timeout){ $scope.wikiresult = []; //data has be changed $scope.$watch('wikiresult' , function(){ //console.log('wikiresult has changed'); //animate the html $timeout(function(){ console.log("on timeout"); var element = $(".element"); element.each( function(index , el) { //console.log("on each"); //console.dir(el); $(el).stop().animate({ opacity: 1, 'background-color': '#354147 !important' } , 1000); }); } , 1000); }) $scope.getContent = function(hasRandom){ //console.log("on click" + hasRandom); if(!hasRandom) $scope.getWiki($scope.search , false); else $scope.getWiki(null,true); } $scope.toHtml = function(html){ //var html = $scope.html; return $sce.trustAsHtml(html); } $scope.getWiki = function(content , random){ var url , wikipediaPage = content; url = ""; if(content) url = 'https://en.wikipedia.org/w/api.php?action=query&list=search&format=json&srsearch=' + wikipediaPage; else url = 'https://en.wikipedia.org/w/api.php?action=query&list=random&generator=random&prop=extracts&exchars=1500&format=json'; if(random) $scope.random = true; else $scope.random = false; $.ajax({ url: url, dataType: 'jsonp' }).done(function(data) { //console.log(data); //var query = data.query; //$scope.wikiresult = data.query.search; $scope.$apply(function () { if(!$scope.random) { //console.log("dont has random"); $scope.wikiresult = data.query.search; } else { var result = data.query.pages; var keys = Object.keys(result); //console.log(keys); $scope.wikiresult = data.query.pages[keys[0]]; } //console.dir($scope.wikiresult); }); }); }
}]);
Wiki Search - Script Codes
Wiki Search - Script Codes
Home Page Home
Developer Paulo Sérgio
Username paulo101977
Uploaded November 19, 2022
Rating 3
Size 3,062 Kb
Views 12,144
Do you need developer help for Wiki Search?

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!

Paulo Sérgio (paulo101977) Script Codes
Create amazing captions 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!