129 lines
3.6 KiB
JavaScript
129 lines
3.6 KiB
JavaScript
var userContentFadeOut = 800;
|
|
var userContentFadeIn = 1400;
|
|
var mainFadeImageDelay = 0;
|
|
var mainFadeImagePeriod = 2000;
|
|
var mainFadeTitleDelay = 500;
|
|
var mainFadeTitlePeriod = 1500;
|
|
var mainFadeContentDelay = 1500;
|
|
var mainFadeContentPeriod = 1000;
|
|
|
|
var selectedTextImgId;
|
|
var selectedImageImgId;
|
|
var selectedBlackTextImage;
|
|
|
|
var isAnonymous;
|
|
var userName = 0;
|
|
|
|
//
|
|
// Initializes the main view.
|
|
//
|
|
function init() {
|
|
checkLogin(240000);
|
|
}
|
|
|
|
//Sends a ping to the server on a regular basis to prevent loss of the session and to check the logged in status of the user.
|
|
//Updates the logLink to display Log In or Log Out depending on the login state.
|
|
// interval: The time increment between pings to the server, in milliseconds.
|
|
function checkLogin(interval) {
|
|
var url = "/PingController.java";
|
|
var httpRequest = null;
|
|
|
|
if(window.XMLHttpRequest) {
|
|
httpRequest = new XMLHttpRequest();
|
|
}
|
|
else if(window.ActiveXObject) {
|
|
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
|
|
}
|
|
else {
|
|
return;
|
|
}
|
|
|
|
if(httpRequest != null) {
|
|
httpRequest.onreadystatechange = function() {
|
|
if(httpRequest.readyState == 4) {
|
|
if((httpRequest.status == 200) || (httpRequest.status == 0)) {
|
|
if(httpRequest.responseText == "") {
|
|
location.pathname = "/secure/index.html";
|
|
}
|
|
else {
|
|
if(httpRequest.responseText != userName) {
|
|
userName = httpRequest.responseText;
|
|
|
|
if(userName == "Anonymous") {
|
|
isAnonymous = true;
|
|
}
|
|
|
|
//TODO: May provide a personalized welcome to the user, also might want to enable a link to change the user's settings.
|
|
|
|
}
|
|
|
|
setTimeout("checkLogin('" + interval + "')", interval);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
httpRequest.open("POST",url,true);
|
|
httpRequest.send(null);
|
|
}
|
|
}
|
|
|
|
//Called by the login/logout link at the top of the main page.
|
|
//Either displays the login portion of the view, or logs the user off and updates the link text.
|
|
function logout() {
|
|
var url = "/secure/LogoutController.java";
|
|
var httpRequest = null;
|
|
|
|
if(window.XMLHttpRequest) {
|
|
httpRequest = new XMLHttpRequest();
|
|
}
|
|
else if(window.ActiveXObject) {
|
|
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
|
|
}
|
|
else {
|
|
return;
|
|
}
|
|
|
|
if(httpRequest != null) {
|
|
httpRequest.open("POST",url,false);
|
|
httpRequest.send(null);
|
|
|
|
if((httpRequest.status == 200) || (httpRequest.status == 0)) {
|
|
document.getElementById("logLink").innerHTML = "Log In";
|
|
location.pathname = "/secure/index.html"
|
|
}
|
|
}
|
|
}
|
|
|
|
//Switches between visible components.
|
|
// fromComponentId: The component ID that will become invisible.
|
|
// toComponentId: The component ID that will become visible.
|
|
// focusComponentId: The component ID that will gain focus.
|
|
function switchComponents(fromComponentId, toComponentId, focusComponentId) {
|
|
errorText.innerHTML = "";
|
|
errorText.style.visibility = "hidden";
|
|
replaceFade(fromComponentId, userContentFadeOut, 5, toComponentId, userContentFadeIn, 5, focusComponentId);
|
|
}
|
|
|
|
//
|
|
// Called by the mouse over and out functions of the images and text associated with the main menu items.
|
|
//
|
|
function mainMenuRollover(textImageId, imageUrl) {
|
|
if(selectedTextImgId != textImageId) {
|
|
document.getElementById(textImageId).src = imageUrl;
|
|
}//if//
|
|
}//mainMenuRollover()//
|
|
|
|
//
|
|
// Opens the edit user settings popup.
|
|
//
|
|
function openSettings() {
|
|
var w = window.open('/secure/authenticated/identified/SettingsViewController.java', 'SettingsEditor', 'width=800,height=700,status,scrollbars,resizable');
|
|
w.focus();
|
|
}
|
|
|
|
//
|
|
// Opens a window to send a message to the company.
|
|
//
|
|
function contactUsClicked() {
|
|
window.open('/secure/ContactUsViewController.java', 'ContactUsEditor', 'width=800,height=800,status,scrollbars,resizable');
|
|
} |