4 * Copyright (C) 2006-2015 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.
25 var EXIT_BAN_TIME = 900;
26 var cookiepath = "/brisk/";
28 var mlang_commons = { 'imgload_a' : { 'it' : 'Immagini caricate ',
29 'en' : 'Loaded images ' },
30 'imgload_b' : { 'it' : '%.',
32 'gamleav' : { 'it' : 'Sei sicuro di volere lasciare questa mano?' ,
33 'en' : 'Are you sure to leave this game?' },
34 'brileav' : { 'it' : ' Vuoi veramente abbandonare la briscola ?\n(clicca annulla o cancel se vuoi ricaricare la briscola)',
35 'en' : ' Are you really sure to leave briscola ?\n(click cancel yo reload it)' },
36 'brireco' : { 'it' : 'Ripristino della briscola fallito, per non perdere la sessione ricaricare la pagina manualmente.',
37 'en' : 'Recovery of briscola failed, to keep the current session reload the page manually.' },
38 'btn_sit' : { 'it' : 'Mi siedo.',
40 'btn_exit' : { 'it' : 'Esco.',
42 'tit_list' : { '0' : { 'it' : '',
44 '1' : { 'it' : '(solo aut.)',
45 'en' : '(only aut.)' },
46 '2' : { 'it' : '(isolam.to)',
47 'en' : '(isolation)' } },
48 'tos_refu' : { 'it' : 'Rifiutando di sottoscrivere i nuovi termini del servizio non ti sarà più possibile accedere come utente registrato al sito, sei proprio sicuro di voler rifiutare le nuove condizioni d\'uso ?',
49 'en' : 'EN Rifiutando di sottoscrivere i nuovi termini del servizio non ti sarà più possibile accedere come utente registrato al sito, sei proprio sicuro di voler rifiutare le nuove condizioni d\'uso ?'
53 function $(id) { return document.getElementById(id); }
55 function dec2hex(d, padding)
57 var hex = Number(d).toString(16);
58 padding = typeof (padding) === "undefined" || padding === null ? padding = 2 : padding;
60 while (hex.length < padding) {
67 function getStyle(x,IEstyleProp, MozStyleProp)
70 var y = x.currentStyle[IEstyleProp];
71 } else if (window.getComputedStyle) {
72 var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(MozStyleProp);
77 /* replacement of setInterval on IE */
79 /*if not IE, do nothing*/
80 if(!document.uniqueID){return;};
82 /*Copy the default setInterval behavior*/
83 var nativeSetInterval = window.setInterval;
84 window.setInterval = function(fn,ms) {
86 if(arguments.length <= 2) {
87 return nativeSetInterval(fn,ms);
90 for(var i=2;i<arguments.length;i+=1) {
91 param[i-2] = arguments[i];
95 if(typeof(fn)=='function') {
97 return (function (fn,ms,param) {
98 var fo = function () {
99 fn.apply(window,param);
101 return nativeSetInterval(fo,ms);
104 else if(typeof(fn)=='string')
106 return nativeSetInterval(fn,ms);
110 throw Error('setInterval Error\nInvalid function type');
114 /*Copy the default setTimeout behavior*/
115 var nativeSetTimeout = window.setTimeout;
116 window.setTimeout = function(fn,ms) {
118 if(arguments.length <= 2) {
119 return nativeSetTimeout(fn,ms);
122 for(var i=2;i<arguments.length;i+=1) {
123 param[i-2] = arguments[i];
127 if(typeof(fn)=='function') {
129 return (function (fn,ms,param) {
130 var fo = function () {
131 fn.apply(window,param);
133 return nativeSetTimeout(fo,ms);
136 else if(typeof(fn)=='string')
138 return nativeSetTimeout(fn,ms);
142 throw Error('setTimeout Error\nInvalid function type');
148 function addEvent(obj, type, fn)
150 if (obj.addEventListener) {
151 obj.addEventListener( type, fn, false);
153 else if (obj.attachEvent) {
154 obj["e"+type+fn] = fn;
155 obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
156 obj.attachEvent( "on"+type, obj[type+fn] );
159 throw new Error("Event registration not supported");
162 function removeEvent(obj,type,fn)
164 if (obj.removeEventListener) {
165 obj.removeEventListener( type, fn, false );
167 else if (obj.detachEvent) {
168 obj.detachEvent( "on"+type, obj[type+fn] );
170 obj["e"+type+fn] = null;
174 // var card_pos = RANGE 0 <= x < cards_ea_n
176 function show_bigpict(obj, act, x, y)
180 if (arguments.length > 4)
185 big = $(obj.id+"_big"+sfx);
187 big.style.left = obj.offsetLeft + x+"px";
188 big.style.top = obj.offsetTop + y+"px";
189 big.style.visibility = "visible";
192 big.style.visibility = "hidden";
196 function rnd_int(min, max) {
197 return Math.floor(Math.random() * (max - min + 1) + min);
200 function error_images()
202 // alert("GHESEMU!");
203 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
206 function abort_images()
208 // alert("ABORTAIMAGES");
209 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
212 function unload_images()
214 // alert("ABORTAIMAGES");
215 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
218 function reset_images()
220 // alert("ABORTAIMAGES");
221 setTimeout(preload_images, 2000, g_preload_img_arr, g_imgct-1);
224 function update_images()
226 // MLANG "Immagine caricate" + g_preload_imgsz_arr[g_imgct] + "%."
227 $("imgct").innerHTML = mlang_commons['imgload_a'][g_lang]+g_preload_imgsz_arr[g_imgct]+"%.";
228 if (g_imgct+1 < g_preload_img_arr.length) {
230 setTimeout(preload_images, 100, g_preload_img_arr, g_imgct-1);
232 // $("imgct").innerHTML += "U";
235 function preload_images(arr,idx)
239 // $("imgct").innerHTML = "Stiamo caricando "+arr[idx]+"%.<br>";
240 im.onload = update_images;
241 im.onerror = error_images;
242 im.onabort = abort_images;
243 im.onunload = unload_images;
244 im.onreset = reset_images;
246 // $("imgct").innerHTML += "P";
249 function safestatus(a)
257 function createXMLHttpRequest() {
258 if (typeof(ActiveXObject) != 'undefined') { // Konqueror complain as unknown object
259 try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
260 try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
262 try { return new XMLHttpRequest(); } catch(e) {}
263 alert("XMLHttpRequest not supported");
267 function send_mesg(mesg, content)
269 var is_conn = (sess == "not_connected" ? false : true);
271 if (is_conn && xstm && xstm.transp_type.startsWith('websocket')) {
272 if (typeof(content) != 'undefined') {
273 mesg = mesg + content;
275 var target = window.location.href.substring(0,
276 window.location.href.lastIndexOf('/') + 1) + 'index_wr.php';
277 var ws_msg = JSON.stringify({
282 table_idx: readCookie("table_idx"),
283 table_token: readCookie("table_token"),
284 lang: readCookie("lang")
286 // console.log(ws_msg);
289 if (xstm.transp.ws.readyState == 1) {
290 xstm.transp.ws.send(ws_msg);
293 xstm.transp.out_queue.push(ws_msg);
299 var xhr_wr = createXMLHttpRequest();
301 if (typeof(content) != 'undefined') {
302 mesg = mesg + encodeURIComponent(content);
304 // alert("xhr_wr: "+xhr_wr+" is_conn: "+is_conn);
305 xhr_wr.open('GET', 'index_wr.php?&'+(is_conn ? 'sess='+sess : '')+'&stp='+gst.st+'&mesg='+mesg, (is_conn ? true : false));
306 xhr_wr.setRequestHeader("If-Modified-Since", new Date().toUTCString());
307 xhr_wr.onreadystatechange = function() { return; };
308 if (typeof(g_debug) == 'number' && g_debug > 0
309 && typeof(console) == 'object' && typeof(console.log) == 'function') {
310 var ldate = new Date();
311 console.log(ldate.getTime()+':MESG:'+mesg);
316 if (xhr_wr.responseText != null) {
317 eval(xhr_wr.responseText);
324 sync request to server
325 server_request([arg0=arg1[, arg2=arg3[, ...]]])
326 if var name == '__POST__' than all other vars will be managed as POST content
327 and the call will be a POST
329 function server_request()
331 var xhr_wr = createXMLHttpRequest();
332 var i, collect = "", post_collect = null, is_post = false;
334 if (arguments.length > 0) {
335 for (i = 0 ; i < arguments.length ; i+= 2) {
336 if (arguments[i] == "__POST__") {
343 post_collect += (post_collect == "" ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
345 collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
348 // alert("Args: "+arguments.length);
350 var is_conn = (sess == "not_connected" ? false : true);
352 // console.log("server_request:preresp: "+xhr_wr.responseText);
355 xhr_wr.open('POST', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
356 xhr_wr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
359 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
361 xhr_wr.onreadystatechange = function() { return; };
362 xhr_wr.send(post_collect);
364 if (xhr_wr.responseText != null) {
365 // console.log("server_request:resp: "+xhr_wr.responseText);
366 return (xhr_wr.responseText);
372 /* Stat: CHAT and TABLE */
374 function chatt_checksend(obj,e)
380 if(window.event) { // IE
383 else if(e.which) { // Netscape/Firefox/Opera
386 // alert("OBJ: "+obj);
387 if (keynum == 13 && obj.value != "") { // Enter
388 act_chatt(obj.value);
392 function act_chatt(value)
394 if (value.substring(0, 6) == "/info ") {
395 info_show(value.substring(6));
398 send_mesg("chatt|", value);
403 obj.disabled = false;
415 function act_sitdown(table)
417 send_mesg("sitdown|"+table);
420 function act_wakeup()
425 function act_splash()
435 function act_passwdhowto()
437 send_mesg("passwdhowto");
440 function act_mesgtoadm()
442 send_mesg("mesgtoadm");
447 act_chatt('/tav '+$('txt_in').value);
448 $('txt_in').value = '';
456 function act_placing()
458 send_mesg("placing");
461 function act_roadmap()
463 send_mesg("roadmap");
466 function act_lascio()
471 function safelascio()
474 // MLANG "Sei sicuro di volere lasciare questa mano?"
475 res = window.confirm(mlang_commons['gamleav'][g_lang]);
480 function act_logout(exitlock)
482 send_mesg("logout|"+exitlock);
485 function act_reloadroom()
487 window.onunload = null;
488 window.onbeforeunload = null;
489 document.location.assign("index.php");
492 function act_shutdown()
496 send_mesg("shutdown");
497 // while (xhr_wr.readyState != 4)
501 function postact_logout()
503 // alert("postact_logout");
508 // eraseCookie("sess");
509 document.location.assign("index.php");
513 type - 'hard' or 'soft'
514 code - if soft: accept (0), refuse (1), download (2), later (3)
515 if hard: accept (0), refuse (1), download (2)
517 function act_tosmgr(type, code, tos_curr, tos_vers)
519 if (type != "soft" && type != "hard") {
525 send_mesg("tosmgr|"+type+"|"+code+"|"+tos_curr+"|"+tos_vers);
536 function tos_confirm(val, url)
542 return (window.confirm(mlang_commons['tos_refu'][g_lang]));
545 dlm = new download_mgr(url);
555 function slowimg(img,x1,y1,deltat,free,action,srcend)
557 x1,y1 - destination coords
558 deltat - time for each frame (in msec)
559 free - when the release the local block for other operations (range: 0 - 1)
560 action - function to run when the image is moved
561 srcend - image to switch when the image is moved
564 function sleep(st, delay)
566 // alert("LOC_NEW PRE: "+st.st_loc_new);
570 setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; }},
574 function slowimg(img,x1,y1,deltat,free,action,srcend) {
577 // this.x0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("left"));
578 this.x0 = parseInt(getStyle(this.img,"left", "left"));
579 // alert("img.x0 = "+this.x0);
580 // this.y0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("top"));
581 this.y0 = parseInt(getStyle(this.img,"top", "top"));
584 this.deltat = deltat;
586 this.action = action;
587 this.srcend = srcend;
590 slowimg.prototype = {
609 setstart: function(x0,y0)
615 setaction: function(act)
621 settime: function(time)
623 this.time = (time < this.deltat ? this.deltat : time);
624 this.step_n = parseInt(this.time / this.deltat);
625 this.dx = (this.x1 - this.x0) / this.step_n;
626 this.dy = (this.y1 - this.y0) / this.step_n;
627 if (this.step_n * this.deltat == this.time) {
631 this.step_free = parseInt(this.step_n * this.free);
637 // $("logz").innerHTML += " xxxxxxxxxxxxxxxxxxxxxSTART<br>";
639 this.st.st_loc_new++;
641 this.img.style.visibility = "visible";
642 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
647 // $("log").innerHTML = "Val " + this.step_cur + " N: " + this.step_n + "<br>";
648 if (this.step_cur == 0) {
649 var date = new Date();
650 // $("logz").innerHTML = "Timestart: " + date + "<br>";
652 if (this.step_cur <= this.step_n) {
653 this.img.style.left = this.x0 + this.dx * this.step_cur;
654 this.img.style.top = this.y0 + this.dy * this.step_cur;
656 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
657 if (this.step_cur == this.step_free && this.st != null) {
658 if (this.st.st_loc < this.st.st_loc_new) {
659 // alert("QUI1 " + this.step_cur + " ZZ "+ this.step_free);
666 this.img.style.left = this.x1;
667 this.img.style.top = this.y1;
668 // $("logz").innerHTML += "xxxxxxxxxxxxxxxCLEAR<br>";
669 var date = new Date();
670 // $("logz").innerHTML += "Timestop: " + date + "<br>";
672 if (this.action != null) {
676 if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
681 if (this.srcend != null) {
682 this.img.src = this.srcend;
688 function div_show(div)
690 div.style.top = parseInt((document.body.clientHeight - parseInt(getStyle(div,"height", "height"))) / 2) + document.body.scrollTop;
691 div.style.visibility = "visible";
697 tout: if < 0 => infinite
705 function notify_document(st, text, tout, butt, confirm_func, confirm_func_args, w, h, is_opa, block_time)
707 var i, clo, clodiv_ctx, clodiv_wai, box;
711 this.ancestor = document.body;
712 this.confirm_func = confirm_func;
713 this.confirm_func_args = confirm_func_args;
714 this.st.st_loc_new++;
716 clodiv_ctx = document.createElement("div");
717 clodiv_ctx.className = "notify_clo";
719 for (i = 0 ; i < butt.length ; i++) {
720 this.input_add(butt[i], i, this.hide, clodiv_ctx);
723 if (block_time > 0) {
724 clodiv_wai = document.createElement("div");
725 clodiv_wai.className = "notify_clo";
727 this.input_add("leggere, prego.", 0, null, clodiv_wai);
728 this.clodiv = clodiv_wai;
729 this.clodiv_pkg = clodiv_ctx;
730 clodiv_ctx.style.display = 'none';
733 this.clodiv = clodiv_ctx;
736 cont = document.createElement("div");
738 cont.style.borderBottomStyle = "solid";
739 cont.style.borderBottomWidth = "1px";
740 cont.style.borderBottomColor = "gray";
741 cont.style.height = (h - 50)+"px";
742 cont.style.overflow = "auto";
743 cont.style.textAlign = "left";
744 cont.style.padding = "8px";
745 cont.style.fontFamily = "monospace";
746 cont.innerHTML = text;
748 box = document.createElement("div");
750 box.className = "notify_opaque";
752 box.className = "notify";
754 box.style.zIndex = 200;
755 box.style.width = w+"px";
756 box.style.marginLeft = -parseInt(w/2)+"px";
757 box.style.height = h+"px";
758 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
759 box.appendChild(cont);
760 box.appendChild(this.clodiv);
761 box.style.visibility = "visible";
765 this.ancestor.appendChild(box);
768 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
771 if (block_time != 0) {
772 this.tblkid = setTimeout(function(obj){ obj.notitag.removeChild(obj.clodiv); obj.clodiv = obj.clodiv_pkg; obj.clodiv.style.display = ''; obj.notitag.appendChild(obj.clodiv); }, block_time, this);
776 notify_document.prototype = {
790 confirm_func_args: [],
797 onclick_cb: name of the onclick callback (with signature f(idx) ) or null
798 anc: parent dom object
800 return new button dom object
802 input_add: function(s, idx, onclick_cb, anc)
806 clo = document.createElement("input");
808 clo.className = "button";
809 clo.style.bottom = "4px";
810 clo.style.margin = "2px";
815 clo.onclick = function () { onclick_cb.call(this.obj, this.obj_idx); };
818 anc.appendChild(clo);
825 // alert("quiz: "+this.rett);
831 if (this.st.st_loc < this.st.st_loc_new) {
838 if (this.confirm_func != null) {
841 args = [ val ].concat(this.confirm_func_args);
843 if (this.confirm_func.apply(null, args) == false) {
848 clearTimeout(this.toutid);
849 this.ancestor.removeChild(this.notitag);
857 function notify_ex(st, text, tout, butt, w, h, is_opa, block_time)
864 this.ancestor = document.body;
866 this.st.st_loc_new++;
868 clo = document.createElement("input");
870 clo.className = "button";
871 clo.style.bottom = "4px";
873 if (block_time > 0) {
874 clo.value = "leggere, prego.";
879 clo.onclick = function () { this.obj.hide() };
882 clodiv = document.createElement("div");
883 clodiv.className = "notify_clo";
885 this.clodiv = clodiv;
887 clodiv.appendChild(clo);
889 cont = document.createElement("div");
891 cont.style.borderBottomStyle = "solid";
892 cont.style.borderBottomWidth = "1px";
893 cont.style.borderBottomColor = "gray";
894 cont.style.height = (h - 30)+"px";
895 cont.style.overflow = "auto";
896 cont.innerHTML = text;
898 box = document.createElement("div");
900 box.className = "notify_opaque";
902 box.className = "notify";
904 box.style.zIndex = 200;
905 box.style.width = w+"px";
906 box.style.marginLeft = -parseInt(w/2)+"px";
907 box.style.height = h+"px";
908 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
909 box.appendChild(cont);
910 box.appendChild(clodiv);
911 box.style.visibility = "visible";
915 this.ancestor.appendChild(box);
917 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
919 if (block_time != 0) {
920 this.tblkid = setTimeout(function(obj){ obj.clo.value = obj.butt; obj.clo.onclick = function () { this.obj.hide() }; formsub_hilite(obj.clo); obj.clo.focus(); }, block_time, this);
930 notify_ex.prototype = {
942 if (this.st.st_loc < this.st.st_loc_new) {
949 clearTimeout(this.toutid);
950 this.ancestor.removeChild(this.notitag);
956 notify.prototype = notify_ex.prototype; // Define sub-class
957 notify.prototype.constructor = notify;
958 notify.baseConstructor = notify_ex;
959 notify.superClass = notify_ex.prototype;
961 function notify(st, text, tout, butt, w, h)
963 notify_ex.call(this, st, text, tout, butt, w, h, false, 0);
969 this.st_loc_new = -1;
970 this.comms = new Array;
980 sleep: function(delay) {
984 this.sleep_hdl = setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; obj.sleep_hdl = null; }},
990 if (this.sleep_hdl != null) {
991 clearTimeout(this.sleep_hdl);
992 this.sleep_hdl = null;
997 function remark_step()
999 var ct = $("remark").l_remct;
1005 $("remark").className = "remark"+ct;
1006 $("remark").l_remct = ct;
1007 setTimeout(remark_step,500);
1010 $("remark").className = "remark0";
1015 function remark_on()
1017 if ($("remark").l_remct == 0) {
1018 $("remark").l_remct = 1;
1019 setTimeout(remark_step,500);
1023 function remark_off()
1025 $("remark").l_remct = 0;
1026 $("remark").className = "remark0";
1030 function italizer(ga)
1034 return "<i>"+ga[1]+"</i>";
1040 function exitlock_show(num, islock)
1044 num = (num < 3 ? num : 3);
1045 $("exitlock").src = "img/exitlock"+num+(islock ? "n" : "y")+".png";
1046 // alert("EXITLOCK: "+$("exitlock").src);
1047 $("exitlock").style.visibility = "visible";
1052 // exitlock_show(0, true);
1055 var chatt_lines = new Array();
1056 var chatt_lines_n = 0;
1058 var CHATT_MAXLINES = 40;
1060 function user_decorator(user, is_real)
1062 var name, i, sp = "", cl = "";
1063 var flags = user[0] & 0x03 | ((user[0] & 0x0c0000) >> 16);
1065 // console.log(user[1]+" FLAGS: "+flags);
1067 for (i = 0 ; i < 4 ; i++) {
1068 if (flags & (1 << i)) {
1069 cl += sp + "au" + i + (is_real ? "" : "_off");
1075 name = "<span class='" + cl + "'><span class='" +
1076 (is_real && (flags & 0xfffffe && ((flags & 0x01) == 0)) ? "id_usr" : "") +
1077 "'>" + user[1] + "</span></span>";
1086 function user_dec_and_state(el)
1091 content = user_decorator(el, true);
1092 content += state_add(el[0],(typeof(el[2]) != 'undefined' ? el[2] : null));
1099 function chatt_sub(dt,data,str)
1101 var must_scroll = false;
1105 var bolder = [ (data[0] | 1), data[1] ];
1106 name = user_decorator(bolder, false);
1108 if ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight >= 0)
1111 // alert("ARRIVA NAME: "+ name + " STR:"+str);
1112 if (chatt_lines_n == CHATT_MAXLINES) {
1113 $("txt").innerHTML = "";
1114 for (i = 0 ; i < (CHATT_MAXLINES - 1) ; i++) {
1115 chatt_lines[i] = chatt_lines[i+1];
1116 $("txt").innerHTML += chatt_lines[i];
1118 chatt_lines[i] = dt+name+": "+str+ "<br>";
1119 $("txt").innerHTML += chatt_lines[i];
1122 chatt_lines[chatt_lines_n] = dt+name+": "+str+ "<br>";
1123 $("txt").innerHTML += chatt_lines[chatt_lines_n];
1126 // $("txt").innerHTML;
1130 $("txt").scrollTop = 10000000;
1132 // alert("scTOP "+$("txt").scrollTop+" scHEIGHT: "+$("txt").scrollHeight+" HEIGHT: "+getStyle($("txt"),"height", "height") );
1136 * GESTIONE DEI COOKIES
1138 function createCookie(name,value,hours,path) {
1140 var date = new Date();
1141 date.setTime(date.getTime()+(hours*60*60*1000));
1142 var expires = "; expires="+date.toGMTString();
1144 else var expires = "";
1145 document.cookie = name+"="+value+expires+"; path="+path;
1148 function readCookie(name) {
1149 var nameEQ = name + "=";
1150 var ca = document.cookie.split(';');
1151 for(var i=0;i < ca.length;i++) {
1153 while (c.charAt(0)==' ')
1154 c = c.substring(1,c.length);
1155 if (c.indexOf(nameEQ) == 0)
1156 return c.substring(nameEQ.length,c.length);
1161 function eraseCookie(name) {
1162 createCookie(name,"",-1);
1165 function onbeforeunload_cb () {
1169 function onunload_cb () {
1171 if (typeof(xstm) != "undefined")
1172 xstm.the_end = true;
1179 function room_checkspace(emme,tables,inpe)
1182 for (i = 0 ; i < emme ; i++)
1187 for (i = 0 ; i < 5 ; i++)
1188 alta += nome+"<br>";
1190 for (i = 0 ; i < tables ; i++) {
1191 $("table"+i).innerHTML = alta;
1193 $("table_act"+i).innerHTML = "<input type=\"button\" class=\"button\" name=\"xhenter"+i+"\" value=\""+mlang_commons['btn_sit'][g_lang]+"\" onclick=\"act_sitdown(1);\">";
1196 stand = "<table class=\"table_standup\"><tbody><tr>";
1197 for (i = 0 ; i < inpe ; i++) {
1198 stand += "<td>"+nome+"</td>";
1199 if ((i+1) % 4 == 0) {
1200 stand += "</tr><tr>";
1204 $("standup").innerHTML = stand;
1206 // VERIFY: what is this button ?
1208 $("esco").innerHTML = "<input class=\"button\" name=\"logout\" type=\"button\" value=\""+mlang_commons['btn_exit'][g_lang]+"\" onclick=\"act_logout();\" type=\"button\">";
1211 function unescapeHTML(cont) {
1212 var div = document.createElement('div');
1216 div.innerHTML = cont;
1217 if (div.childNodes[0]) {
1218 if (div.childNodes.length > 1) {
1219 if (div.childNodes.toArray)
1222 var length = div.childNodes.length, results = new Array(length);
1224 results[length] = div.childNodes[length];
1226 for (i=0 ; i<results.length ; i++)
1227 memo = memo + results[i].nodeValue;
1233 return (div.childNodes[0].nodeValue);
1242 samples = [{'name': <name>, 'file': <file>}, ... ]
1244 function jukebox(samples)
1247 this.enable = false;
1250 var pro_audio_el = document.createElement('audio');
1251 this.enable = !!(pro_audio_el.canPlayType && pro_audio_el.canPlayType('audio/mpeg;').replace(/no/, ''));
1253 for (i in samples) {
1254 sample = samples[i];
1256 this.audio[sample['name']] = a = document.createElement('audio');
1258 source = document.createElement('source');
1259 source.setAttribute('src', sample['file']);
1260 source.setAttribute('type', 'audio/mpeg');
1261 a.appendChild(source);
1267 jukebox.prototype = {
1268 is_enabled: function() {
1272 play: function(name) {
1277 if (!(name in this.audio)) {
1280 a = this.audio[name];
1286 function topbanner_init()
1288 setInterval(topbanner_cb, 666);
1292 function topbanner_cb()
1296 a = $('topbanner').style.backgroundColor;
1297 b = $('topbanner').style.borderLeftColor;
1299 $('topbanner').style.backgroundColor = b;
1300 $('topbanner').style.borderColor = a+" "+a+" "+a+" "+a;
1302 // console.log("A: "+a+" B: "+b);
1305 function sidebanner_init(idx)
1307 setInterval(function () { sidebanner_cb(idx); }, 666);
1310 function sidebanner_cb(idx)
1314 a = $('sidebanner'+idx).style.backgroundColor;
1315 b = $('sidebanner'+idx).style.borderLeftColor;
1317 $('sidebanner'+idx).style.backgroundColor = b;
1318 $('sidebanner'+idx).style.borderColor = a+" "+a+" "+a+" "+a;
1320 // console.log("A: "+a+" B: "+b);
1324 function langtolng(lang)
1332 function formtext_hilite(obj)
1334 obj.className = 'input_text';
1335 addEvent(obj, "focus", function () { this.className = 'input_text_hi'; });
1336 addEvent(obj, "blur", function () { this.className = 'input_text'; });
1339 function formsub_hilite(obj)
1341 obj.className = 'input_sub';
1342 addEvent(obj, "focus", function () { this.className = 'input_sub_hi'; });
1343 addEvent(obj, "blur", function () { this.className = 'input_sub'; });
1346 // return the value of the radio button that is checked
1347 // return an empty string if none are checked, or
1348 // there are no radio buttons
1349 function get_checked_value(radioObj) {
1352 var radioLength = radioObj.length;
1353 if(radioLength == undefined)
1354 if(radioObj.checked)
1355 return radioObj.value;
1358 for(var i = 0; i < radioLength; i++) {
1359 if(radioObj[i].checked) {
1360 return radioObj[i].value;
1366 // set the radio button with the given value as being checked
1367 // do nothing if there are no radio buttons
1368 // if the given value does not exist, all the radio buttons
1369 // are reset to unchecked
1370 function set_checked_value(radioObj, newValue) {
1373 var radioLength = radioObj.length;
1374 if(radioLength == undefined) {
1375 radioObj.checked = (radioObj.value == newValue.toString());
1378 for(var i = 0; i < radioLength; i++) {
1379 radioObj[i].checked = false;
1380 if(radioObj[i].value == newValue.toString()) {
1381 radioObj[i].checked = true;
1386 function url_append_arg(url, name, value)
1388 var pos, sep, pref, rest;
1390 if ((pos = url.indexOf('?'+name+'=')) == -1) {
1391 pos = url.indexOf('&'+name+'=');
1394 if ((pos = url.indexOf('?')) != -1)
1399 return (url+sep+name+"="+encodeURIComponent(value));
1402 pref = url.substring(0, pos+1);
1403 rest = url.substring(pos+1);
1404 // alert("rest: "+rest+" pos: "+pos);
1405 if ((pos = rest.indexOf('&')) != -1) {
1406 rest = rest.substring(pos);
1411 return (pref+name+"="+encodeURIComponent(value)+rest);
1415 function url_append_args(url)
1420 for (i = 1 ; i < arguments.length-1 ; i+= 2) {
1421 ret = url_append_arg(ret, arguments[i], arguments[i+1]);
1427 function url_complete(parent, url)
1430 var host = "", path = "";
1433 p = parent.indexOf("://");
1435 rest = parent.substring(p+3);
1436 p2 = rest.indexOf("/");
1438 host = parent.substring(0, p+3+p2);
1439 rest = parent.substring(p+3+p2);
1451 p = rest.lastIndexOf("/");
1453 path = rest.substring(0, p+1);
1456 // alert("host: ["+host+"] path: ["+path+"]");
1457 if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/' || url.substring(0,4) == 'ws:/' || url.substring(0,5) == 'wss:/') {
1460 else if (url.substring(0,1) == '/') {
1464 return (host+path+url);
1468 function download_mgr(url)
1472 if ((ifra = $('the_downloader')) == null) {
1473 ifra = document.createElement("iframe");
1474 ifra.style.display = "none";
1475 ifra.id = 'the_downloader';
1476 document.body.appendChild(ifra);
1479 ifra.contentWindow.location.href = url;
1484 download_mgr.prototype = {
1488 function submit_click(obj)
1490 obj.form.elements['realsub'].value = obj.id;