function UserLogin(mapi) { this.mapi = mapi; this.userid = -1; this.cbobj = null; this.cbmeth = null; var imageThis = this; this.initialize = initialize; function initialize() { this.node = document.createElement('div'); this.node.id = 'login'; this.node.style.position = "absolute"; this.node.style.display = "none"; this.node.style.top = '65px'; this.node.style.left = '310px'; this.node.innerHTML = '
close

Registrace»|Zapomenuté heslo»

'; this.mapi.elmap.appendChild(this.node); this.nodeclose = document.getElementById('userloginclose'); this.nodeform = document.getElementById('userloginform'); this.nodename = document.getElementById('userloginname'); this.nodepass = document.getElementById('userloginpass'); google.maps.event.addDomListener(this.nodeform, "submit", function(e) {imageThis.onLoginClick.call(imageThis, e);}); //PJ google.maps.event.addDomListener(this.nodeclose, "click", function(e) {imageThis.closeLoginDialog.call(imageThis, e);}); //PJ } this.setCallBack = setCallBack; function setCallBack (obj, meth) { this.cbobj = obj; this.cbmeth = meth; } this.doCallBack = doCallBack; function doCallBack(data) { if ((this.cbobj) && (this.cbmeth)) { var tcbojb = this.cbobj; var tcbmeth = this.cbmeth; this.cbobj = null; this.cbmeth = null; tcbmeth.call(tcbojb, data); } } this.isLoggedIn = isLoggedIn; function isLoggedIn(obj, meth) { this.setCallBack(obj, meth); addCallback(callbacktype.isloggedinsuccess, this, this.foundIsLoggedIn); addCallback(callbacktype.isloggedincomplete, this, this.completeIsLoggedIn); addCallback(callbacktype.isloggedinerror, this, this.errorIsLoggedIn); var url = 'isloggedin.php'; jQuery.ajax({cache:false, error:function() { runCallback(callbacktype.isloggedinerror, ''); }, success:function(data) { runCallback(callbacktype.isloggedinsuccess, data); }, complete:function() { runCallback(callbacktype.isloggedincomplete, ''); }, url:url, type:'get'}); } this.foundIsLoggedIn = foundIsLoggedIn; function foundIsLoggedIn(data) { try { if (data.getElementsByTagName("isloggedin")[0].lastChild.nodeValue != 1) { this.doCallBack(false); } else { this.userid = data.getElementsByTagName("userid")[0].lastChild.nodeValue this.doCallBack(true); } } catch (e) { this.doCallBack(false); } } this.errorIsLoggedIn = errorIsLoggedIn; function errorIsLoggedIn() { this.doCallBack(false); } this.completeIsLoggedIn = completeIsLoggedIn; function completeIsLoggedIn() { } this.openLoginDialog = openLoginDialog; function openLoginDialog(caption) { if (caption != null) { alert(caption); } google.maps.event.clearInstanceListeners(this.nodeform); google.maps.event.addDomListener(this.nodeform, "submit", function(e) { imageThis.onLoginClick.call(imageThis, e);}); //PJ this.nodename.value = ''; this.nodepass.value = ''; this.node.style.display = 'block'; } this.closeLoginDialog = closeLoginDialog; function closeLoginDialog() { this.node.style.display = 'none'; google.maps.event.clearInstanceListeners(this.nodeform); //PJ google.maps.event.addDomListener(this.nodeform, "submit", cancelAction); //PJ } this.onLoginClick = onLoginClick; function onLoginClick(e) { this.login(this.nodename.value, this.nodepass.value); try { if (e && e.preventDefault) e.preventDefault(); } catch(e) { } return false; } this.login = login; function login(name, pass) { addCallback(callbacktype.loginsuccess, this, this.foundLogin); addCallback(callbacktype.logincomplete, this, this.completeLogin); addCallback(callbacktype.loginerror, this, this.errorLogin); var params = {user:this.nodename.value, pass:this.nodepass.value}; var url = 'login.php'; jQuery.ajax({cache:false, data:params, error:function() { runCallback(callbacktype.loginerror, ''); }, success:function(data) { runCallback(callbacktype.loginsuccess, data); }, complete:function() { runCallback(callbacktype.logincomplete, ''); }, url:url, type:'post'}); } this.foundLogin = foundLogin; function foundLogin(data) { try { if (data.getElementsByTagName("isloggedin")[0].lastChild.nodeValue != 1) { this.errorLogin(); } else { this.userid = data.getElementsByTagName("userid")[0].lastChild.nodeValue this.closeLoginDialog(); alert('Přihlášení bylo úspěšné.'); } } catch (e) { this.errorLogin(); } } this.errorLogin = errorLogin; function errorLogin() { alert('Přihlášení nebylo úspěšné.'); this.nodename.value = ''; this.nodepass.value = ''; } this.completeLogin = completeLogin; function completeLogin() { } } userLogin = null;