X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Fcommons.js;h=d04ef6f834e590136c0db9062a6660457dc12280;hb=9fe7c6c2413b91e1b738603d4fbc039e59d895db;hp=e09f8269b08c0af0fe0fab2fd783d1ab8f55558f;hpb=9b1e396b87b8237ee618a911b4eccf14ec39b349;p=brisk.git diff --git a/web/commons.js b/web/commons.js index e09f826..d04ef6f 100644 --- a/web/commons.js +++ b/web/commons.js @@ -164,22 +164,26 @@ function rnd_int(min, max) { function error_images() { - alert("GHESEMU!"); + // alert("GHESEMU!"); + setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1); } function abort_images() { - alert("ABORTAIMAGES"); + // alert("ABORTAIMAGES"); + setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1); } function unload_images() { - alert("ABORTAIMAGES"); + // alert("ABORTAIMAGES"); + setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1); } function reset_images() { - alert("ABORTAIMAGES"); + // alert("ABORTAIMAGES"); + setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1); } function update_images() @@ -240,15 +244,23 @@ function send_mesg(mesg) } } -function server_request(mesg) +function server_request() { var xhr_wr = createXMLHttpRequest(); - + var i, collect = ""; + + if (arguments.length > 0) { + for (i = 0 ; i < arguments.length ; i+= 2) { + collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]); + } + } + // alert("Args: "+arguments.length); + var is_conn = (sess == "not_connected" ? false : true); // console.log("server_request:preresp: "+xhr_wr.responseText); - xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, false); + xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false); xhr_wr.onreadystatechange = function() { return; }; xhr_wr.send(null); @@ -303,29 +315,7 @@ function act_wakeup() send_mesg("wakeup"); } -/* Stat: TABLE Subst: ASTA */ -function act_asta(card,pnt) -{ - send_mesg("asta|"+card+"|"+pnt); -} -function act_choose(card) -{ - // alert("sitdown"); - send_mesg("choose|"+card); -} - -/* Stat: TABLE Subst: GAME */ -function act_play(card,x,y) -{ - // alert("sitdown"); - send_mesg("play|"+card+"|"+x+"|"+y); -} - -function act_tableinfo() -{ - send_mesg("tableinfo"); -} function act_help() { @@ -353,23 +343,6 @@ function act_whysupport() send_mesg("whysupport"); } -function act_exitlock() -{ - send_mesg("exitlock"); -} - -function safelogout() -{ - var res; - - if (g_exitlock < 2) - res = window.confirm("Sei sicuro di volere abbandonare la partita?\nATTENZIONE: se esci adesso senza il consenso degli altri giocatori non potrai sederti ai tavoli per "+(Math.floor(EXIT_BAN_TIME/60))+" minuti."); - else - res = window.confirm("Sei sicuro di volere abbandonare la partita?"); - if (res) - act_logout(g_exitlock); -} - function act_lascio() { send_mesg("lascio"); @@ -387,14 +360,13 @@ function safelascio() function act_logout(exitlock) { send_mesg("logout|"+exitlock); - // alert("IZZO"); } -function act_reload() +function act_reloadroom() { window.onunload = null; window.onbeforeunload = null; - document.location.reload(); + document.location.assign("index.php"); } function act_shutdown() @@ -551,121 +523,6 @@ slowimg.prototype = { } } -var asta_xarr = new Array(0,66,132); - -/* TODO: impostare gli onclick */ -function dispose_asta(idx, pnt, nopoint) -{ - var i, btn, pass; - var btn; - - for (i = 0 ; i < 10 ; i++) { - btn = $("asta"+i); - if (i < idx) { - btn.src = "img/astapasso"+(pnt >= 0 ? "" : "_ro")+".png"; - btn.style.cursor = (pnt >= 0 ? "pointer" : "default"); - pass = -1; - } - else { - btn.src = "img/asta"+i+(pnt >= 0 ? "" : "_ro")+".png"; - btn.style.cursor = (pnt >= 0 ? "pointer" : "default"); - pass = i; - } - if (i < 19) - btn.style.left = asta_xarr[i % 3]; - else - btn.style.left = asta_xarr[(i+1) % 3]; - - btn.style.top = parseInt(i / 3) * 50 + (i == 9 ? 0 : 1); - - if (pnt >= 0) { - eval("btn.onclick = function () { act_asta("+pass+",61); }"); - btn.style.cursor = "pointer"; - } - else { - btn.onclick = null; - btn.style.cursor = "default"; - } - } - - - btn = $("astaptdiv"); - btn.style.left = asta_xarr[i % 3]; - btn.style.top = parseInt(i / 3) * 50 - 2; - // btn.style.visibility = "visible"; - - btn = $("astapt"); - var rpnt = (pnt < 0 ? -pnt : pnt); - btn.value = (rpnt < 61 ? 61 : (rpnt > 120 ? 120 : rpnt)); - - btn = $("astaptsub"); - btn.style.left = asta_xarr[i % 3]; - btn.style.top = 25 + parseInt(i / 3) * 50 - 1; - btn.src = "img/astaptsub"+(pnt >= 0 ? "" : "_ro")+".png"; - btn.style.cursor = (pnt >= 0 ? "pointer" : "default"); - if (pnt >= 0) { - btn.onclick = function () { act_asta(9,$("astapt").value); }; - btn.style.cursor = "pointer"; - } - else { - btn.onclick = null; - btn.style.cursor = "default"; - } - - i+=1; - if (nopoint) { - btn = $("astapasso"); - btn.style.left = asta_xarr[i % 3]; - btn.style.top = parseInt(i / 3) * 50; - btn.src = "img/astapashalf"+(pnt >= 0 ? "" : "_ro")+".png"; - btn.style.cursor = (pnt >= 0 ? "pointer" : "default"); - if (pnt >= 0) { - btn.onclick = function () { act_asta(-1,0); }; - } - else { - btn.onclick = null; - } - - btn = $("astalascio"); - btn.style.left = asta_xarr[i % 3]; - btn.style.top = parseInt(i / 3) * 50 + 24; - btn.src = "img/astalascio.png"; - btn.style.visibility = "visible"; - btn.onclick = function () { safelascio(); }; - } - else { - btn = $("astapasso"); - btn.style.left = asta_xarr[i % 3]; - btn.style.top = parseInt(i / 3) * 50;; - btn.src = "img/astapasso"+(pnt >= 0 ? "" : "_ro")+".png"; - btn.style.cursor = (pnt >= 0 ? "pointer" : "default"); - if (pnt >= 0) { - btn.onclick = function () { act_asta(-1,0); }; - } - else { - btn.onclick = null; - } - - btn = $("astalascio"); - btn.style.visibility = "hidden"; - btn.onclick = null; - } - // btn.style.visibility = "visible"; - $("asta").style.visibility = "visible"; -} - -function asta_pnt_set(pnt) -{ - btn = $("astapt"); - var rpnt = (pnt < 0 ? -pnt : pnt); - btn.value = (rpnt < 61 ? 61 : (rpnt > 120 ? 120 : rpnt)); -} - -function hide_asta() -{ - $("asta").style.visibility = "hidden"; -} - function notify(st, text, tout, butt, w, h) { @@ -690,14 +547,23 @@ function notify(st, text, tout, butt, w, h) clodiv.className = "notify_clo"; clodiv.appendChild(clo); - box = document.createElement("div"); + cont = document.createElement("div"); + + cont.style.borderBottomStyle = "solid"; + cont.style.borderBottomWidth = "1px"; + cont.style.borderBottomColor = "gray"; + cont.style.height = (h - 30)+"px"; + cont.style.overflow = "auto"; + cont.innerHTML = text; + + box = document.createElement("div"); box.className = "notify"; - box.innerHTML = text; box.style.zIndex = 200; 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(cont); box.appendChild(clodiv); box.style.visibility = "visible"; @@ -783,20 +649,6 @@ function remark_off() } -function choose_seed(card) -{ - var i; - - $("asta").style.visibility = "hidden"; - $("astalascio").style.visibility = "hidden"; - $("chooseed").style.visibility = "visible"; - for (i = 0 ; i < 4 ; i++) { - $("seed"+i).src = "img/"+i+""+card+".png"; - seed=$("seed"+i); - eval("seed.onclick = function () { act_choose("+i+""+card+"); };"); - } -} - function italizer(ga) { var pre, pos; @@ -806,54 +658,6 @@ function italizer(ga) return ga[1]; } -function set_names(so,ea,ne,nw,we) -{ -// alert("EA: "+ea); - $("name").innerHTML = italizer(so); - $("name").title = unescapeHTML(so[1]); - $("name_ea").innerHTML = italizer(ea); - $("name_ea").title = unescapeHTML(ea[1]); - $("name_ne").innerHTML = italizer(ne); - $("name_ne").title = unescapeHTML(ne[1]); - $("name_nw").innerHTML = italizer(nw); - $("name_nw").title = unescapeHTML(nw[1]); - $("name_we").innerHTML = italizer(we); - $("name_we").title = unescapeHTML(we[1]); - - return; -} - -var astat_suffix = new Array("","_ea","_ne","_nw","_we"); - -function show_astat(zer,uno,due,tre,qua) -{ - var astat = new Array(zer,uno,due,tre,qua); - - for (i = 0 ; i < PLAYERS_N ; i++) { - idx = (PLAYERS_N + i - table_pos) % PLAYERS_N; - - if (astat[i] == -2) { - $("public"+astat_suffix[idx]).style.visibility = "hidden"; - } - else if (astat[i] == -1) { - $("public"+astat_suffix[idx]).style.visibility = "visible"; - $("pubacard"+astat_suffix[idx]).src = "img/astapasso.png"; - $("pubapnt"+astat_suffix[idx]).innerHTML = ""; - $("pubapnt"+astat_suffix[idx]).style.visibility = "hidden"; - } - else if (astat[i] <= 10) { - $("public"+astat_suffix[idx]).style.visibility = "visible"; - $("pubacard"+astat_suffix[idx]).src = "img/asta"+astat[i]+".png"; - $("pubapnt"+astat_suffix[idx]).style.visibility = "hidden"; - } - else if (astat[i] <= 120) { - $("public"+astat_suffix[idx]).style.visibility = "visible"; - $("pubacard"+astat_suffix[idx]).src = "img/asta9.png"; - $("pubapnt"+astat_suffix[idx]).style.visibility = "inherit"; // XXX VISIBLE - $("pubapnt"+astat_suffix[idx]).innerHTML = astat[i]; - } - } -} function exitlock_show(num, islock) { @@ -869,36 +673,6 @@ var fin = 0; // exitlock_show(0, true); -function table_init() { - var sux = new Array("", "_ea", "_ne", "_nw", "_we"); - - // console.log("table_init"); - - remark_off(); - $("asta").style.visibility = "hidden"; - $("caller").style.visibility = "hidden"; - show_astat(-2,-2,-2,-2,-2); - for (i=0 ; i < 8 ; i++) { - Drag.init($("card" + i), card_mouseup_cb); - for (e = 0 ; e < PLAYERS_N ; e++) - $("card"+sux[e]+i).style.visibility = "hidden"; - } - for (i=0 ; i < PLAYERS_N ; i++) { - // console.log("shut: "+"takes"+sux[i]); - $("takes"+sux[i]).style.visibility = "hidden"; - } - - for (i = 0 ; i < 8 ; i++) { - cards_pos[i] = i; - cards_ea_pos[i] = i; - cards_ne_pos[i] = i; - cards_nw_pos[i] = i; - cards_we_pos[i] = i; - } - -} - - var chatt_lines = new Array(); var chatt_lines_n = 0; @@ -1111,3 +885,12 @@ function topbanner_cb() // console.log("A: "+a+" B: "+b); } + + +function langtolng(lang) +{ + if (lang == "en") + return ("_en"); + else + return (""); +}