Commit b07bf5f2 authored by Phil Höfer's avatar Phil Höfer
Browse files

Merge branch '6-stability-issue' into 'master'

Resolve "Stability Issue"

Closes #6

See merge request open-source/metager-app!1
parents 873e05b8 623e0825
const TRIES = 3;
const TRYDELAYINCRMS = 1000;
function loadXMLDoc(filename)
{
var xhttp = new XMLHttpRequest();
......@@ -6,30 +9,48 @@ xhttp.send("");
return xhttp.responseXML;
}
function render(content)
function render(err, content)
{
style = loadXMLDoc("style/material.xsl");
if (document.implementation && document.implementation.createDocument)
{
xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(style);
resultDocument = xsltProcessor.transformToFragment(content, document);
document.body.replaceWith(resultDocument);
}
if (err) {
alert("Fehler bei der Suche! Bitte prüfen Sie Ihr Netzwerk.");
location.href="index.xhtml";
} else {
style = loadXMLDoc("style/material.xsl");
if (document.implementation && document.implementation.createDocument)
{
xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(style);
resultDocument = xsltProcessor.transformToFragment(content, document);
document.body.replaceWith(resultDocument);
}
}
}
/**
* Returns OpenSearch responseXML for the given query.
* Delivers OpenSearch responseXML to callback for the given query.
*/
function search(query,focus) {
function search(query,focus,callback, trycount) {
query = query || "eingabe=";
focus = focus || "focus=web";
return loadXMLDoc("https://metager3.de/meta/meta.ger3?"+focus+"&"+query+"&encoding=utf8&out=atom10&appversion=0.1.0");
let doc;
trycount = trycount || 0;
try {
doc = loadXMLDoc("https://metager3.de/meta/meta.ger3?"+focus+"&"+query+"&encoding=utf8&out=atom10&appversion=3.0.0");
callback(null, doc);
} catch (e) {
if(++trycount < TRIES) {
console.log("search error, tries left: "+ (TRIES - trycount) );
setTimeout(search, trycount * TRYDELAYINCRMS, query, focus, callback, trycount);
} else {
console.log("search failed");
callback(e);
}
};
}
function boot()
{
render(search(getParameter('eingabe'),getParameter('focus')));
search(getParameter('eingabe'),getParameter('focus'),render);
}
function getParameter(parameterName) {
......
......@@ -12,5 +12,20 @@
<script type="text/javascript" defer="defer" src="app/results.js"></script>
</head>
<body onload="boot()">
<header class="persistent-search">
<form class="search-card card elevation-2" id="searchform">
<a href="index.xhtml" class="back">
<img src="img/Logo-square-inverted.svg" alt="MetaGer" title="MetaGer, die sichere Suchmaschine"/>
</a>
<input type="text" name="eingabe" placeholder="MetaGer-Suche" value="" class="query-input" disabled="disabled"/>
<button type="submit" class="search-button fa"></button>
</form>
</header>
<main class="results-container">
<progress class="resultpage-progress" title="Suche wird durchgeführt…"/>
</main>
<footer class="footer-text">
MetaGer wird entwickelt und betrieben vom SUMA-EV - Verein für freien Wissenszugang.
</footer>
</body>
</html>
......@@ -14,6 +14,15 @@ input:focus {
outline: none;
}
.resultpage-progress {
width: 25px;
margin-top: 45px;
margin-left: auto;
margin-right: auto;
position: relative;
display: block;
}
.card {
background-color: #FFFFFF;
margin: 8px;
......
Supports Markdown
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