From d3e4e8c776b5137afd929942b114afed074bacdf Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Sat, 22 Nov 2008 10:39:32 +0000 Subject: [PATCH] unmediated logout refactored --- web/commons.js | 42 +++++++++++++++++++++++++++++++++--------- web/index_rd.php | 4 ++-- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/web/commons.js b/web/commons.js index c950435..fb78a4d 100644 --- a/web/commons.js +++ b/web/commons.js @@ -228,6 +228,7 @@ function send_mesg(mesg) var xhr_wr = createXMLHttpRequest(); var is_conn = (sess == "not_connected" ? false : true); + // alert("xhr_wr: "+xhr_wr+" is_conn: "+is_conn); xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, (is_conn ? true : false)); xhr_wr.onreadystatechange = function() { return; }; xhr_wr.send(null); @@ -245,14 +246,14 @@ function server_request(mesg) var is_conn = (sess == "not_connected" ? false : true); - console.log("server_request:preresp: "+xhr_wr.responseText); + // console.log("server_request:preresp: "+xhr_wr.responseText); xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, false); xhr_wr.onreadystatechange = function() { return; }; xhr_wr.send(null); if (xhr_wr.responseText != null) { - console.log("server_request:resp: "+xhr_wr.responseText); + // console.log("server_request:resp: "+xhr_wr.responseText); return (xhr_wr.responseText); } else @@ -386,11 +387,13 @@ function safelascio() function act_logout(exitlock) { send_mesg("logout|"+exitlock); + // alert("IZZO"); } function act_reload() { window.onunload = null; + window.onbeforeunload = null; document.location.reload(); } @@ -399,8 +402,8 @@ function act_shutdown() var c = 0; send_mesg("shutdown"); - while (xhr_wr.readyState != 4) - c++; + // while (xhr_wr.readyState != 4) + // c++; } function postact_logout() @@ -694,6 +697,7 @@ function notify(st, text, tout, butt, w, h) box.style.width = w+"px"; box.style.marginLeft = -parseInt(w/2)+"px"; box.style.height = h+"px"; + box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop; box.appendChild(clodiv); box.style.visibility = "visible"; @@ -955,19 +959,29 @@ function eraseCookie(name) { var onunload_times = 0; -function onunload_cb () { +function onbeforeunload_cb () { + return(""); +} + +function onunload_cb_old () { var u = 0; + + // if (nonunload == true) + // return true; + if (onunload_times == 0) { var res = window.confirm(" Vuoi veramente abbandonare la briscola ?\n(clicca annulla o cancel se vuoi ricaricare la briscola)"); if (res == true) { the_end = true; act_shutdown(); - while (1) - u++; + // while (1) + // u++; } else { try { - location = self.location; + document.location.href = self.location; // = self.location; + // alert ("passiamo di qui"+self.location); + return (false); } catch (e) { alert("Ripristino della briscola fallito, per non perdere la sessione ricaricare la pagina manualmente."); } @@ -978,6 +992,15 @@ function onunload_cb () { return(false); } +function onunload_cb () { + + the_end = true; + + act_shutdown(); + + return(false); +} + function room_checkspace(emme,tables,inpe) { @@ -1005,7 +1028,8 @@ function room_checkspace(emme,tables,inpe) stand += ""; $("standup").innerHTML = stand; - $("esco").innerHTML = ""; + // VERIFY: what is this button ? + $("esco").innerHTML = ""; } function unescapeHTML(cont) { diff --git a/web/index_rd.php b/web/index_rd.php index 8b25ae0..8f724d1 100644 --- a/web/index_rd.php +++ b/web/index_rd.php @@ -57,7 +57,7 @@ function unrecerror() $is_page_streaming = TRUE; log_rd2("UNREC_ERROR:".var_export(debug_backtrace())); - return (sprintf('the_end=true; window.onunload = null; document.location.assign("index.php");')); + return (sprintf('the_end=true; window.onunload = null; window.onbeforeunload = null; document.location.assign("index.php");')); } function page_sync($sess, $page, $table_idx, $table_token) @@ -69,7 +69,7 @@ function page_sync($sess, $page, $table_idx, $table_token) $is_page_streaming = TRUE; log_rd2("PAGE_SYNC"); - return (sprintf('createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); the_end=true; window.onunload = null; document.location.assign("%s");', $table_idx, $table_token, $page)); + return (sprintf('createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); the_end=true; window.onunload = null; window.onbeforeunload = null; document.location.assign("%s");', $table_idx, $table_token, $page)); } -- 2.17.1