Commit 986bd338 authored by Antoine Beaupré's avatar Antoine Beaupré

redirect to dynamic search engine, remove javascript implementation

parent 5681b60d
goto = function(btn, prefix){
btn.disabled=true;
var page = document.getElementById('pageinput').value;
var suite = document.getElementById('suiteinput').value;
var parts = page.split('.');
var manpage;
var section = 1; // sane default
manpage = parts[0];
if (parts.length > 1) {
section = parts[1];
}
else {
parts = page.split(/[()]/); // guess it's man(1)
manpage = parts[0];
if (parts.length > 1) {
section = parts[1];
}
else {
console.warn('cannot parse section, assuming section ' + section);
}
}
// what a shame, javascript, no fkn printf??
path = prefix + suite + '/man/man' + section + '/' + manpage + '.' + section + '.html';
var request = new XMLHttpRequest();
console.log('opening new HTTP request to page ' + path)
request.open('GET', path, true);
request.onreadystatechange = function(){
if (request.readyState === 4){
if (request.status === 404) {
window.location = prefix + '404.html?page=' + page
btn.disabled=false;
return false;
}
else {
console.log("redirecting to "+ path)
window.location = path;
btn.disabled=false;
return false;
}
}
};
request.send();
btn.disabled=false;
return false;
}
......@@ -2,7 +2,6 @@
<html>
<head>
<link rel="stylesheet" type="text/css" charset="utf-8" media="all" href="{{prefix|default('/')}}debian.css">
<script src="{{prefix|default('/')}}search.js"></script>
<title>{{title|default('')}}</title>
<meta description="{{description|default('')}}" />
</head>
......@@ -15,16 +14,15 @@
<a href="{{prefix|default('/')}}" title="Debian Manpages Home"><img src="{{prefix|default('/')}}Pics/openlogo-50.png" alt="Debian" width="50" height="61"></a>
</div> <!-- end logo -->
<div id="searchbox">
<!-- no dynamic search yet other than Javascript, give a 404 for non-JS users -->
<form name="search" method="get" action="{{prefix|default('/')}}404.html">
<form name="search" method="get" action="{{prefix|default('/')}}search">
<p>
<select id="suiteinput" name="suite">
{% for suite, string in suites.iteritems() %}
<option value="{{suite}}">{{string}}</option>
{% endfor %}
</select>
<input id="pageinput" name="page" value="" size="27">
<input id="searchsubmit" type="submit" value="Search" onclick="return goto(this, prefix='{{prefix|default('/')}}')">
<input id="pageinput" name="pattern" value="" size="27">
<input id="searchsubmit" type="submit" value="Search">
</p>
</form>
</div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment