4 * Copyright (C) 2006-2011 Matteo Nastasi
5 * mailto: nastasi@alternativeoutput.it
6 * matteo.nastasi@milug.org
7 * web: http://www.alternativeoutput.it
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. You should have received a
18 * copy of the GNU General Public License along with this program; if
19 * not, write to the Free Software Foundation, Inc, 59 Temple Place -
20 * Suite 330, Boston, MA 02111-1307, USA.
24 var mlang_briskin5 = { 'is_calling' : { 'it' : ' sta chiamando',
25 'en' : ' is calling' } }
27 function background_set()
29 $("bg").style.backgroundImage = 'url("img/brisk_table_sand'+table_pos+'.jpg")';
32 /* Stat: TABLE Subst: ASTA */
33 function act_asta(card,pnt)
35 send_mesg("asta|"+card+"|"+pnt);
38 var asta_xarr = new Array(0,66,132);
40 /* TODO: impostare gli onclick */
41 function dispose_asta(idx, pnt, nopoint)
45 var lng = langtolng(g_lang);
47 for (i = 0 ; i < 10 ; i++) {
50 btn.src = "img/astapasso"+(pnt >= 0 ? "" : "_ro")+lng+".png";
51 btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
55 btn.src = "img/asta"+i+(pnt >= 0 ? "" : "_ro")+lng+".png";
56 btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
60 btn.style.left = asta_xarr[i % 3];
62 btn.style.left = asta_xarr[(i+1) % 3];
64 btn.style.top = parseInt(i / 3) * 50 + (i == 9 ? 0 : 1);
67 eval("btn.onclick = function () { act_asta("+pass+",61); }");
68 btn.style.cursor = "pointer";
72 btn.style.cursor = "default";
78 btn.style.left = asta_xarr[i % 3];
79 btn.style.top = parseInt(i / 3) * 50 - 2;
80 // btn.style.visibility = "visible";
83 var rpnt = (pnt < 0 ? -pnt : pnt);
84 btn.value = (rpnt < 61 ? 61 : (rpnt > 120 ? 120 : rpnt));
87 btn.style.left = asta_xarr[i % 3];
88 btn.style.top = 25 + parseInt(i / 3) * 50 - 1;
89 btn.src = "img/astaptsub"+(pnt >= 0 ? "" : "_ro")+lng+".png";
90 btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
92 btn.onclick = function () { act_asta(9,$("astapt").value); };
93 btn.style.cursor = "pointer";
97 btn.style.cursor = "default";
102 btn = $("astapasso");
103 btn.style.left = asta_xarr[i % 3];
104 btn.style.top = parseInt(i / 3) * 50;
105 btn.src = "img/astapashalf"+(pnt >= 0 ? "" : "_ro")+lng+".png";
106 btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
108 btn.onclick = function () { act_asta(-1,0); };
114 btn = $("astalascio");
115 btn.style.left = asta_xarr[i % 3];
116 btn.style.top = parseInt(i / 3) * 50 + 24;
117 btn.src = "img/astalascio"+lng+".png";
118 btn.style.visibility = "visible";
119 btn.onclick = function () { safelascio(); };
122 btn = $("astapasso");
123 btn.style.left = asta_xarr[i % 3];
124 btn.style.top = parseInt(i / 3) * 50;;
125 btn.src = "img/astapasso"+(pnt >= 0 ? "" : "_ro")+lng+".png";
126 btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
128 btn.onclick = function () { act_asta(-1,0); };
134 btn = $("astalascio");
135 btn.style.visibility = "hidden";
138 // btn.style.visibility = "visible";
139 $("asta").style.visibility = "visible";
142 function asta_pnt_set(pnt)
145 var rpnt = (pnt < 0 ? -pnt : pnt);
146 btn.value = (rpnt < 61 ? 61 : (rpnt > 120 ? 120 : rpnt));
151 $("asta").style.visibility = "hidden";
154 function choose_seed(card)
158 $("asta").style.visibility = "hidden";
159 $("astalascio").style.visibility = "hidden";
160 $("chooseed").style.visibility = "visible";
161 for (i = 0 ; i < 4 ; i++) {
162 $("seed"+i).src = "img/"+i+""+card+".png";
164 eval("seed.onclick = function () { act_choose("+i+""+card+"); };");
168 var astat_suffix = new Array("","_ea","_ne","_nw","_we");
170 function show_astat(zer,uno,due,tre,qua)
172 var astat = new Array(zer,uno,due,tre,qua);
173 var lng = langtolng(g_lang);
175 for (i = 0 ; i < PLAYERS_N ; i++) {
176 idx = (PLAYERS_N + i - table_pos) % PLAYERS_N;
178 if (astat[i] == -2) {
179 $("public"+astat_suffix[idx]).style.visibility = "hidden";
181 else if (astat[i] == -1) {
182 $("public"+astat_suffix[idx]).style.visibility = "visible";
183 $("pubacard"+astat_suffix[idx]).src = "img/astapasso"+lng+".png";
184 $("pubapnt"+astat_suffix[idx]).innerHTML = "";
185 $("pubapnt"+astat_suffix[idx]).style.visibility = "hidden";
187 else if (astat[i] <= 10) {
188 $("public"+astat_suffix[idx]).style.visibility = "visible";
189 $("pubacard"+astat_suffix[idx]).src = "img/asta"+astat[i]+lng+".png";
190 $("pubapnt"+astat_suffix[idx]).style.visibility = "hidden";
192 else if (astat[i] <= 120) {
193 $("public"+astat_suffix[idx]).style.visibility = "visible";
194 $("pubacard"+astat_suffix[idx]).src = "img/asta9"+lng+".png";
195 $("pubapnt"+astat_suffix[idx]).style.visibility = "inherit"; // XXX VISIBLE
196 $("pubapnt"+astat_suffix[idx]).innerHTML = astat[i];
202 function table_init() {
203 var sux = new Array("", "_ea", "_ne", "_nw", "_we");
205 // console.log("table_init");
208 $("asta").style.visibility = "hidden";
209 $("caller").style.visibility = "hidden";
210 show_astat(-2,-2,-2,-2,-2);
213 for (i=0 ; i < 8 ; i++) {
214 Drag.init($("card" + i), card_mouseup_cb);
215 for (e = 0 ; e < PLAYERS_N ; e++)
216 $("card"+sux[e]+i).style.visibility = "hidden";
218 for (i=0 ; i < PLAYERS_N ; i++) {
219 // console.log("shut: "+"takes"+sux[i]);
220 $("takes"+sux[i]).style.visibility = "hidden";
223 for (i = 0 ; i < 8 ; i++) {
233 function act_choose(card)
235 send_mesg("choose|"+card);
238 function act_play(card,x,y)
240 send_mesg("play|"+card+"|"+x+"|"+y);
243 function act_tableinfo()
245 send_mesg("tableinfo");
248 function act_exitlock()
250 send_mesg("exitlock");
253 function safelogout()
258 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.");
260 res = window.confirm("Sei sicuro di volere abbandonare la partita?");
262 act_logout(g_exitlock);
265 function act_reload()
267 window.onunload = null;
268 window.onbeforeunload = null;
269 document.location.reload();
272 function set_names(so,ea,ne,nw,we)
274 // alert("SET NAME");
275 $("name").innerHTML = italizer(so);
276 $("name").title = unescapeHTML(so[1]);
277 $("name_ea").innerHTML = italizer(ea);
278 $("name_ea").title = unescapeHTML(ea[1]);
279 $("name_ne").innerHTML = italizer(ne);
280 $("name_ne").title = unescapeHTML(ne[1]);
281 $("name_nw").innerHTML = italizer(nw);
282 $("name_nw").title = unescapeHTML(nw[1]);
283 $("name_we").innerHTML = italizer(we);
284 $("name_we").title = unescapeHTML(we[1]);
286 for (i = 0 ; i < PLAYERS_N ; i++)
287 $("name"+astat_suffix[i]).title_orig = $("name"+astat_suffix[i]).title;
292 function set_iscalling(idx)
296 for (i = 0 ; i < PLAYERS_N ; i++) {
297 $("name"+astat_suffix[i]).className = "pubinfo"+astat_suffix[i]+(i == idx ? "_iscalling" : "");
298 $("name"+astat_suffix[i]).title = $("name"+astat_suffix[i]).title_orig + (i == idx ? mlang_briskin5['is_calling'][g_lang] : "");
302 function preferences_init()
306 if ((rd = readCookie("CO_bin5_pref_ring_endauct")) != null) {
307 $('pref_ring_endauct').checked = (rd == "true" ? true : false);
310 $('pref_ring_endauct').checked = false;
312 $('preferences').ring_endauct = $('pref_ring_endauct').checked;
315 function preferences_update()
318 createCookie("CO_bin5_pref_ring_endauct", ($('preferences').ring_endauct ? "true" : "false"), 24*3650, cookiepath);
319 ret = server_request('mesg', 'preferences_update');
322 function act_preferences_update()
325 preferences_showhide();
328 function pref_ring_endauct_set(obj)
330 $('preferences').ring_endauct = obj.checked;
334 function preferences_show()
338 div_show($('preferences'));
341 function preferences_showhide()
343 if ($('preferences').style.visibility == 'hidden') {
346 $('preferences').style.top = parseInt((document.body.clientHeight -
347 parseInt(getStyle($('preferences'), "height","height"))
348 ) / 2) + document.body.scrollTop;
349 $('preferences').style.visibility = 'visible';
352 $('preferences').style.visibility = 'hidden';