ordersprinter/spider/index.html

122 lines
3.2 KiB
HTML

<html>
<head>
<title>OrderSprinter Spider Startseite</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="styles/spider.css">
<script src="3rdparty/jquery-2.0.3.min.js"></script>
<script src="utils.js"></script>
</head>
<body>
<script>
/**
* Check if installation exists or needs to be done. This way the user can call the index.html page
* independently of the fact if he starts a fresh installation or uses an existing one.
*/
function startInstallationOrUseIt() {
doAjax("GET", "php/generals.php?command=isInstalled", null, handleResultOfInstallCheck, "PHP-Problem");
}
/**
* Handle the result of the check if the installatinón was done already. If not the user
* is forwarded to the install page.
*/
function handleResultOfInstallCheck(is_installed) {
if (is_installed == "Yes") {
useInstallation();
} else {
reloadPage("install.html");
}
}
/**
* If the user could be logged in forward him to the overview page. Otherwise give a
* useful message.
*/
function handleLoginResult(status) {
if (status == "Yes") {
// user could be logged in
reloadPage("overview.php");
} else {
// user entered wrong access code
alert("Falscher Zugangscode");
}
}
/**
* If the user is logged in the navigation menu and the logout button is shown. Otherwise
* the panel to log in is displayed.
*/
function handleLoginStatus(isLoggedIn) {
if (isLoggedIn == "YES") {
// no login mask!
$("#loginwindow").hide();
$("#logoutsection").show();
bindLogout();
} else {
// user needs to log in!
$("#loginwindow").show();
$("#logoutsection").hide();
// enable the function to log in
$("#loginbtn").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
doAjax("POST", "php/generals.php?command=login", { authcode:$("#accesspass").val() }, handleLoginResult,null );
});
}
}
/**
* This method is called if it is clear that no installation is required. The existing
* installation shall be used. The next steps depend on if the user is already logged in.
*/
function useInstallation() {
doAjax("GET","php/generals.php?command=getSpiderVersion",null,insertSpiderVersion,null);
// is the user logged in already
doAjax("POST","php/generals.php?command=isUserLoggedIn",null,handleLoginStatus,null);
}
/**
* This is the first script entry for jQuery enabled sites.
*/
$( document ).ready(function() {
// check what might be the next step (installation or use of existing installation)
startInstallationOrUseIt();
});
</script>
<p>
<div>
<img src=img/spider-logo.png />
</div>
</p>
<div id="loginwindow">
<h1>OrderSprinter Spider</h1>
<form>
<table class="gentable">
<tr><td>Zugangspasswort:<td><input type="password" id="accesspass" /></tr>
<tr><td colspan=2><input type="submit" style="width:100%;height:70px;" value="Einloggen" id="loginbtn"/></tr>
</table>
</form>
</div>
<div id=logoutsection class="gentable">
<form>
<input type="submit" style="width:100%;height:70px;" value="Ausloggen" id="logoutbtn"/>
</form>
</div>
<br>
<div><i>OrderSprinter Spider - Version <span id=spiderversion></span></i></div>
</body>
</html>