<html>
<head>
<style type='text/css'>
body, div {
font-size: 11px;
font-family: 'sans-serif', 'Arial';
background-color: #e0e0e0;
}
input {
font-size: 11px;
font-family: 'sans-serif', 'Arial';
}
#content, .wait {
margin: auto auto;
position: relative;
width: 480px;
text-align: center;
}
#content {
display: none;
}
#result {
text-align: justify;
}
ul {
margin-top: 3px;
}
input {
border: 1px solid #808080;
}
</style>
<script type='text/javascript'>
function GetXMLHttpRequest() {
var try_these = [
function () { return new XMLHttpRequest(); },
function () { return new ActiveXObject('Msxml2.XMLHTTP'); },
function () { return new ActiveXObject('Microsoft.XMLHTTP'); },
function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); },
];
for (var i = 0; i < try_these.length; i++) {
var func = try_these[i];
try {
return func();
} catch (e) { }
}
}
var xml = null;
var database = [];
function onReadyStateChange() {
if( xml && xml.readyState == 4 ) {
var lines = xml.responseText.split( "\n" );
for( var i = 1; i < lines.length; i++ ) {
var entries = lines[i].split( ";" );
if( entries.length == 4 ) {
var entry = {};
entry.deutsch = entries[2];
entry.keyword = entries[0].toLowerCase();
entry.latein = entries[1];
entry.lektion = entries[3];
var list = "<ul>";
var de = entry.deutsch.split( ',' );
for( var j = 0; j < de.length; j++ )
list += "<li>" + de[j].replace( /^\s+/, "" ) + "</li>";
entry.de_list = list + "</ul>";
database.push( entry );
}
}
document.getElementById( 'wait' ).style.display = "none";
document.getElementById( 'content' ).style.display = "block";
}
}
function RequestDatabase() {
xml = GetXMLHttpRequest();
xml.onreadystatechange = onReadyStateChange;
xml.open( "GET", "db.txt", true );
xml.send( null );
}
function SearchQuery( query ) {
var results = [];
query = query.toLowerCase();
for( var i = 0; i < database.length && results.length < 100 && query.length; i++ ) {
if( database[i].keyword.indexOf( query ) != -1 ) {
results.push( "<b>" + database[i].latein + "</b>" +
"<br><div style='margin-left: 16px; margin-bottom: 16px;'>" +
"<small><i>(Lektion " + database[i].lektion + "</i></small>)<br>" +
database[i].de_list + "</div>" );
}
}
if( results.length ) {
results.splice( 0, 0, "<b>" + results.length + "</b> Suchergebnisse<br><br>" );
} else {
results.push( "<b>Keine Vokabeln bei der Suche nach '<b>" + query + "</b>' gefunden" );
}
document.getElementById( 'result' ).innerHTML = results.join( "" );
}
window.onload = RequestDatabase;
</script>
</head>
<body>
<center>
<div id='content'>
<h2>Latein Wörterbuch</h2>
<form onSubmit='SearchQuery( document.getElementById( "q" ).value ); return false;'>
<input id='q'> <input type='submit' value='Suchen'>
</form>
<br>
<hr>
<br>
<div id='result'></div>
<br>
<hr>
</div>
<div id='wait'>
Bitte warten...<br>
Datenbank wird geladen...
</div>
</center>
</body>
</html>