// To enable/disable custom login UI
var kCustomLogin = false;
function init() {
// IMPORTANT - onLoadBegin has to be called at the end of your body's onload function
// Failing to call this function will make your custom home page unusable
onLoadEnter();
var useCachedDbFilter = false;
// OPTIONAL - custom login
// This page may get redirected back if previous login failed
// Get the error code so you can display customized message
if (kCustomLogin == true) {
var loginErrorCode = getLoginErrorCode();
if (loginErrorCode != null) {
// DB name from the last login error
var dbName = getDatabaseNameFromLoginError();
if (dbName != null) {
// Keep the db name in an attribute, so you can use it for the next login attempt
document.getElementById('myLogin').setAttribute('db', dbName);
document.getElementById('message').innerHTML = 'Sign in to open "' + dbName + '"';
if (loginErrorCode != 0) {
showErrorMsg('Error: ' + loginErrorCode);
}
showLogin(true);
var dbFilter = sessionStorage.getItem('db_filter');
if (dbFilter) {
useCachedDbFilter = true;
generateContent(dbFilter);
}
}
}
}
// Get the database names
if (!useCachedDbFilter) {
loadXMLDoc();
}
// IMPORTANT - onLoadEnd has to be called at the end of your body's onload function
// Failing to call this function will make your custom home page unusable
onLoadExit();
}
function loadXMLDoc(user, pwd)
{
var xmlhttp;
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
sessionStorage.setItem('db_filter', xmlhttp.responseText)
generateContent(xmlhttp.responseText);
} else if (xmlhttp.status == 401) {
sessionStorage.removeItem('db_filter');
showFilterLogin(true);
}
}
}
// Change webdUrl to point to IP address of your Web Publishing engine
// Default URL is prefined in fmwebd_home.js
var url = webdUrl + 'dbnames?customfilterlogin=1';
function showLogin(show) {
document.getElementById('myLogin').style.display = show ? 'block' : 'none';
}
function showErrorMsg(errMsg) {
document.getElementById('error').innerHTML = errMsg;
document.getElementById('error').style.display = 'block';
}
function doLogin() {
var dbName = document.getElementById('myLogin').getAttribute('db');
var user = document.getElementById('user').value;
var pwd = document.getElementById('pwd').value;
function showFilterLogin(show) {
document.getElementById('filterLogin').style.display = show ? 'block' : 'none';
}
function doFilterLogin() {
var user = document.getElementById('filterUser').value;
var pwd = document.getElementById('filterPwd').value;
showFilterLogin(false);
loadXMLDoc(user, pwd);
}
Sign in to view databases hosted by FileMaker Server.