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)
269 var is_conn = (sess == "not_connected" ? false : true);
271 if (is_conn && xstm && xstm.transp_type.startsWith('websocket')) {
272 var target = window.location.href.substring(
273 0, window.location.href.lastIndexOf('/') + 1) + 'index_wr.php';
274 var ws_msg = {target: target, mesg: mesg, stp:gst.st, sess:sess};
275 xstm.transp.ws.send(ws_msg);
278 var xhr_wr = createXMLHttpRequest();
280 // alert("xhr_wr: "+xhr_wr+" is_conn: "+is_conn);
281 xhr_wr.open('GET', 'index_wr.php?&'+(is_conn ? 'sess='+sess : '')+'&stp='+gst.st+'&mesg='+mesg, (is_conn ? true : false));
282 xhr_wr.setRequestHeader("If-Modified-Since", new Date().toUTCString());
283 xhr_wr.onreadystatechange = function() { return; };
284 if (typeof(g_debug) == 'number' && g_debug > 0
285 && typeof(console) == 'object' && typeof(console.log) == 'function') {
286 var ldate = new Date();
287 console.log(ldate.getTime()+':MESG:'+mesg);
292 if (xhr_wr.responseText != null) {
293 eval(xhr_wr.responseText);
300 sync request to server
301 server_request([arg0=arg1[, arg2=arg3[, ...]]])
302 if var name == '__POST__' than all other vars will be managed as POST content
303 and the call will be a POST
305 function server_request()
307 var xhr_wr = createXMLHttpRequest();
308 var i, collect = "", post_collect = null, is_post = false;
310 if (arguments.length > 0) {
311 for (i = 0 ; i < arguments.length ; i+= 2) {
312 if (arguments[i] == "__POST__") {
319 post_collect += (post_collect == "" ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
321 collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
324 // alert("Args: "+arguments.length);
326 var is_conn = (sess == "not_connected" ? false : true);
328 // console.log("server_request:preresp: "+xhr_wr.responseText);
331 xhr_wr.open('POST', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
332 xhr_wr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
335 xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
337 xhr_wr.onreadystatechange = function() { return; };
338 xhr_wr.send(post_collect);
340 if (xhr_wr.responseText != null) {
341 // console.log("server_request:resp: "+xhr_wr.responseText);
342 return (xhr_wr.responseText);
348 /* Stat: CHAT and TABLE */
350 function chatt_checksend(obj,e)
356 if(window.event) { // IE
359 else if(e.which) { // Netscape/Firefox/Opera
362 // alert("OBJ: "+obj);
363 if (keynum == 13 && obj.value != "") { // Enter
364 act_chatt(obj.value);
368 function act_chatt(value)
370 if (value.substring(0, 6) == "/info ") {
371 info_show(value.substring(6));
374 send_mesg("chatt|"+encodeURIComponent(value));
379 obj.disabled = false;
391 function act_sitdown(table)
393 send_mesg("sitdown|"+table);
396 function act_wakeup()
401 function act_splash()
411 function act_passwdhowto()
413 send_mesg("passwdhowto");
416 function act_mesgtoadm()
418 send_mesg("mesgtoadm");
423 act_chatt('/tav '+$('txt_in').value);
424 $('txt_in').value = '';
432 function act_placing()
434 send_mesg("placing");
437 function act_roadmap()
439 send_mesg("roadmap");
442 function act_lascio()
447 function safelascio()
450 // MLANG "Sei sicuro di volere lasciare questa mano?"
451 res = window.confirm(mlang_commons['gamleav'][g_lang]);
456 function act_logout(exitlock)
458 send_mesg("logout|"+exitlock);
461 function act_reloadroom()
463 window.onunload = null;
464 window.onbeforeunload = null;
465 document.location.assign("index.php");
468 function act_shutdown()
472 send_mesg("shutdown");
473 // while (xhr_wr.readyState != 4)
477 function postact_logout()
479 // alert("postact_logout");
484 // eraseCookie("sess");
485 document.location.assign("index.php");
489 type - 'hard' or 'soft'
490 code - if soft: accept (0), refuse (1), download (2), later (3)
491 if hard: accept (0), refuse (1), download (2)
493 function act_tosmgr(type, code, tos_curr, tos_vers)
495 if (type != "soft" && type != "hard") {
501 send_mesg("tosmgr|"+type+"|"+code+"|"+tos_curr+"|"+tos_vers);
512 function tos_confirm(val, url)
518 return (window.confirm(mlang_commons['tos_refu'][g_lang]));
521 dlm = new download_mgr(url);
531 function slowimg(img,x1,y1,deltat,free,action,srcend)
533 x1,y1 - destination coords
534 deltat - time for each frame (in msec)
535 free - when the release the local block for other operations (range: 0 - 1)
536 action - function to run when the image is moved
537 srcend - image to switch when the image is moved
540 function sleep(st, delay)
542 // alert("LOC_NEW PRE: "+st.st_loc_new);
546 setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; }},
550 function slowimg(img,x1,y1,deltat,free,action,srcend) {
553 // this.x0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("left"));
554 this.x0 = parseInt(getStyle(this.img,"left", "left"));
555 // alert("img.x0 = "+this.x0);
556 // this.y0 = parseInt(document.defaultView.getComputedStyle(this.img, "").getPropertyValue("top"));
557 this.y0 = parseInt(getStyle(this.img,"top", "top"));
560 this.deltat = deltat;
562 this.action = action;
563 this.srcend = srcend;
566 slowimg.prototype = {
585 setstart: function(x0,y0)
591 setaction: function(act)
597 settime: function(time)
599 this.time = (time < this.deltat ? this.deltat : time);
600 this.step_n = parseInt(this.time / this.deltat);
601 this.dx = (this.x1 - this.x0) / this.step_n;
602 this.dy = (this.y1 - this.y0) / this.step_n;
603 if (this.step_n * this.deltat == this.time) {
607 this.step_free = parseInt(this.step_n * this.free);
613 // $("logz").innerHTML += " xxxxxxxxxxxxxxxxxxxxxSTART<br>";
615 this.st.st_loc_new++;
617 this.img.style.visibility = "visible";
618 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
623 // $("log").innerHTML = "Val " + this.step_cur + " N: " + this.step_n + "<br>";
624 if (this.step_cur == 0) {
625 var date = new Date();
626 // $("logz").innerHTML = "Timestart: " + date + "<br>";
628 if (this.step_cur <= this.step_n) {
629 this.img.style.left = this.x0 + this.dx * this.step_cur;
630 this.img.style.top = this.y0 + this.dy * this.step_cur;
632 setTimeout(function(obj){ obj.animate(); }, this.deltat, this);
633 if (this.step_cur == this.step_free && this.st != null) {
634 if (this.st.st_loc < this.st.st_loc_new) {
635 // alert("QUI1 " + this.step_cur + " ZZ "+ this.step_free);
642 this.img.style.left = this.x1;
643 this.img.style.top = this.y1;
644 // $("logz").innerHTML += "xxxxxxxxxxxxxxxCLEAR<br>";
645 var date = new Date();
646 // $("logz").innerHTML += "Timestop: " + date + "<br>";
648 if (this.action != null) {
652 if (this.st != null && this.st.st_loc < this.st.st_loc_new) {
657 if (this.srcend != null) {
658 this.img.src = this.srcend;
664 function div_show(div)
666 div.style.top = parseInt((document.body.clientHeight - parseInt(getStyle(div,"height", "height"))) / 2) + document.body.scrollTop;
667 div.style.visibility = "visible";
673 tout: if < 0 => infinite
681 function notify_document(st, text, tout, butt, confirm_func, confirm_func_args, w, h, is_opa, block_time)
683 var i, clo, clodiv_ctx, clodiv_wai, box;
687 this.ancestor = document.body;
688 this.confirm_func = confirm_func;
689 this.confirm_func_args = confirm_func_args;
690 this.st.st_loc_new++;
692 clodiv_ctx = document.createElement("div");
693 clodiv_ctx.className = "notify_clo";
695 for (i = 0 ; i < butt.length ; i++) {
696 this.input_add(butt[i], i, this.hide, clodiv_ctx);
699 if (block_time > 0) {
700 clodiv_wai = document.createElement("div");
701 clodiv_wai.className = "notify_clo";
703 this.input_add("leggere, prego.", 0, null, clodiv_wai);
704 this.clodiv = clodiv_wai;
705 this.clodiv_pkg = clodiv_ctx;
706 clodiv_ctx.style.display = 'none';
709 this.clodiv = clodiv_ctx;
712 cont = document.createElement("div");
714 cont.style.borderBottomStyle = "solid";
715 cont.style.borderBottomWidth = "1px";
716 cont.style.borderBottomColor = "gray";
717 cont.style.height = (h - 50)+"px";
718 cont.style.overflow = "auto";
719 cont.style.textAlign = "left";
720 cont.style.padding = "8px";
721 cont.style.fontFamily = "monospace";
722 cont.innerHTML = text;
724 box = document.createElement("div");
726 box.className = "notify_opaque";
728 box.className = "notify";
730 box.style.zIndex = 200;
731 box.style.width = w+"px";
732 box.style.marginLeft = -parseInt(w/2)+"px";
733 box.style.height = h+"px";
734 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
735 box.appendChild(cont);
736 box.appendChild(this.clodiv);
737 box.style.visibility = "visible";
741 this.ancestor.appendChild(box);
744 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
747 if (block_time != 0) {
748 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);
752 notify_document.prototype = {
766 confirm_func_args: [],
773 onclick_cb: name of the onclick callback (with signature f(idx) ) or null
774 anc: parent dom object
776 return new button dom object
778 input_add: function(s, idx, onclick_cb, anc)
782 clo = document.createElement("input");
784 clo.className = "button";
785 clo.style.bottom = "4px";
786 clo.style.margin = "2px";
791 clo.onclick = function () { onclick_cb.call(this.obj, this.obj_idx); };
794 anc.appendChild(clo);
801 // alert("quiz: "+this.rett);
807 if (this.st.st_loc < this.st.st_loc_new) {
814 if (this.confirm_func != null) {
817 args = [ val ].concat(this.confirm_func_args);
819 if (this.confirm_func.apply(null, args) == false) {
824 clearTimeout(this.toutid);
825 this.ancestor.removeChild(this.notitag);
833 function notify_ex(st, text, tout, butt, w, h, is_opa, block_time)
840 this.ancestor = document.body;
842 this.st.st_loc_new++;
844 clo = document.createElement("input");
846 clo.className = "button";
847 clo.style.bottom = "4px";
849 if (block_time > 0) {
850 clo.value = "leggere, prego.";
855 clo.onclick = function () { this.obj.hide() };
858 clodiv = document.createElement("div");
859 clodiv.className = "notify_clo";
861 this.clodiv = clodiv;
863 clodiv.appendChild(clo);
865 cont = document.createElement("div");
867 cont.style.borderBottomStyle = "solid";
868 cont.style.borderBottomWidth = "1px";
869 cont.style.borderBottomColor = "gray";
870 cont.style.height = (h - 30)+"px";
871 cont.style.overflow = "auto";
872 cont.innerHTML = text;
874 box = document.createElement("div");
876 box.className = "notify_opaque";
878 box.className = "notify";
880 box.style.zIndex = 200;
881 box.style.width = w+"px";
882 box.style.marginLeft = -parseInt(w/2)+"px";
883 box.style.height = h+"px";
884 box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
885 box.appendChild(cont);
886 box.appendChild(clodiv);
887 box.style.visibility = "visible";
891 this.ancestor.appendChild(box);
893 this.toutid = setTimeout(function(obj){ obj.unblock(); }, tout, this);
895 if (block_time != 0) {
896 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);
906 notify_ex.prototype = {
918 if (this.st.st_loc < this.st.st_loc_new) {
925 clearTimeout(this.toutid);
926 this.ancestor.removeChild(this.notitag);
932 notify.prototype = notify_ex.prototype; // Define sub-class
933 notify.prototype.constructor = notify;
934 notify.baseConstructor = notify_ex;
935 notify.superClass = notify_ex.prototype;
937 function notify(st, text, tout, butt, w, h)
939 notify_ex.call(this, st, text, tout, butt, w, h, false, 0);
945 this.st_loc_new = -1;
946 this.comms = new Array;
956 sleep: function(delay) {
960 this.sleep_hdl = setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; obj.sleep_hdl = null; }},
966 if (this.sleep_hdl != null) {
967 clearTimeout(this.sleep_hdl);
968 this.sleep_hdl = null;
973 function remark_step()
975 var ct = $("remark").l_remct;
981 $("remark").className = "remark"+ct;
982 $("remark").l_remct = ct;
983 setTimeout(remark_step,500);
986 $("remark").className = "remark0";
993 if ($("remark").l_remct == 0) {
994 $("remark").l_remct = 1;
995 setTimeout(remark_step,500);
999 function remark_off()
1001 $("remark").l_remct = 0;
1002 $("remark").className = "remark0";
1006 function italizer(ga)
1010 return "<i>"+ga[1]+"</i>";
1016 function exitlock_show(num, islock)
1020 num = (num < 3 ? num : 3);
1021 $("exitlock").src = "img/exitlock"+num+(islock ? "n" : "y")+".png";
1022 // alert("EXITLOCK: "+$("exitlock").src);
1023 $("exitlock").style.visibility = "visible";
1028 // exitlock_show(0, true);
1031 var chatt_lines = new Array();
1032 var chatt_lines_n = 0;
1034 var CHATT_MAXLINES = 40;
1036 function user_decorator(user, is_real)
1038 var name, i, sp = "", cl = "";
1039 var flags = user[0] & 0x03 | ((user[0] & 0x0c0000) >> 16);
1041 // console.log(user[1]+" FLAGS: "+flags);
1043 for (i = 0 ; i < 4 ; i++) {
1044 if (flags & (1 << i)) {
1045 cl += sp + "au" + i + (is_real ? "" : "_off");
1051 name = "<span class='" + cl + "'><span class='" +
1052 (is_real && (flags & 0xfffffe && ((flags & 0x01) == 0)) ? "id_usr" : "") +
1053 "'>" + user[1] + "</span></span>";
1062 function user_dec_and_state(el)
1067 content = user_decorator(el, true);
1068 content += state_add(el[0],(typeof(el[2]) != 'undefined' ? el[2] : null));
1075 function chatt_sub(dt,data,str)
1077 var must_scroll = false;
1081 var bolder = [ (data[0] | 1), data[1] ];
1082 name = user_decorator(bolder, false);
1084 if ($("txt").scrollTop + parseInt(getStyle($("txt"),"height", "height")) - $("txt").scrollHeight >= 0)
1087 // alert("ARRIVA NAME: "+ name + " STR:"+str);
1088 if (chatt_lines_n == CHATT_MAXLINES) {
1089 $("txt").innerHTML = "";
1090 for (i = 0 ; i < (CHATT_MAXLINES - 1) ; i++) {
1091 chatt_lines[i] = chatt_lines[i+1];
1092 $("txt").innerHTML += chatt_lines[i];
1094 chatt_lines[i] = dt+name+": "+str+ "<br>";
1095 $("txt").innerHTML += chatt_lines[i];
1098 chatt_lines[chatt_lines_n] = dt+name+": "+str+ "<br>";
1099 $("txt").innerHTML += chatt_lines[chatt_lines_n];
1102 // $("txt").innerHTML;
1106 $("txt").scrollTop = 10000000;
1108 // alert("scTOP "+$("txt").scrollTop+" scHEIGHT: "+$("txt").scrollHeight+" HEIGHT: "+getStyle($("txt"),"height", "height") );
1112 * GESTIONE DEI COOKIES
1114 function createCookie(name,value,hours,path) {
1116 var date = new Date();
1117 date.setTime(date.getTime()+(hours*60*60*1000));
1118 var expires = "; expires="+date.toGMTString();
1120 else var expires = "";
1121 document.cookie = name+"="+value+expires+"; path="+path;
1124 function readCookie(name) {
1125 var nameEQ = name + "=";
1126 var ca = document.cookie.split(';');
1127 for(var i=0;i < ca.length;i++) {
1129 while (c.charAt(0)==' ')
1130 c = c.substring(1,c.length);
1131 if (c.indexOf(nameEQ) == 0)
1132 return c.substring(nameEQ.length,c.length);
1137 function eraseCookie(name) {
1138 createCookie(name,"",-1);
1141 function onbeforeunload_cb () {
1145 function onunload_cb () {
1147 if (typeof(xstm) != "undefined")
1148 xstm.the_end = true;
1155 function room_checkspace(emme,tables,inpe)
1158 for (i = 0 ; i < emme ; i++)
1163 for (i = 0 ; i < 5 ; i++)
1164 alta += nome+"<br>";
1166 for (i = 0 ; i < tables ; i++) {
1167 $("table"+i).innerHTML = alta;
1169 $("table_act"+i).innerHTML = "<input type=\"button\" class=\"button\" name=\"xhenter"+i+"\" value=\""+mlang_commons['btn_sit'][g_lang]+"\" onclick=\"act_sitdown(1);\">";
1172 stand = "<table class=\"table_standup\"><tbody><tr>";
1173 for (i = 0 ; i < inpe ; i++) {
1174 stand += "<td>"+nome+"</td>";
1175 if ((i+1) % 4 == 0) {
1176 stand += "</tr><tr>";
1180 $("standup").innerHTML = stand;
1182 // VERIFY: what is this button ?
1184 $("esco").innerHTML = "<input class=\"button\" name=\"logout\" type=\"button\" value=\""+mlang_commons['btn_exit'][g_lang]+"\" onclick=\"act_logout();\" type=\"button\">";
1187 function unescapeHTML(cont) {
1188 var div = document.createElement('div');
1192 div.innerHTML = cont;
1193 if (div.childNodes[0]) {
1194 if (div.childNodes.length > 1) {
1195 if (div.childNodes.toArray)
1198 var length = div.childNodes.length, results = new Array(length);
1200 results[length] = div.childNodes[length];
1202 for (i=0 ; i<results.length ; i++)
1203 memo = memo + results[i].nodeValue;
1209 return (div.childNodes[0].nodeValue);
1218 samples = [{'name': <name>, 'file': <file>}, ... ]
1220 function jukebox(samples)
1223 this.enable = false;
1226 var pro_audio_el = document.createElement('audio');
1227 this.enable = !!(pro_audio_el.canPlayType && pro_audio_el.canPlayType('audio/mpeg;').replace(/no/, ''));
1229 for (i in samples) {
1230 sample = samples[i];
1232 this.audio[sample['name']] = a = document.createElement('audio');
1234 source = document.createElement('source');
1235 source.setAttribute('src', sample['file']);
1236 source.setAttribute('type', 'audio/mpeg');
1237 a.appendChild(source);
1243 jukebox.prototype = {
1244 is_enabled: function() {
1248 play: function(name) {
1253 if (!(name in this.audio)) {
1256 a = this.audio[name];
1262 function topbanner_init()
1264 setInterval(topbanner_cb, 666);
1268 function topbanner_cb()
1272 a = $('topbanner').style.backgroundColor;
1273 b = $('topbanner').style.borderLeftColor;
1275 $('topbanner').style.backgroundColor = b;
1276 $('topbanner').style.borderColor = a+" "+a+" "+a+" "+a;
1278 // console.log("A: "+a+" B: "+b);
1281 function sidebanner_init(idx)
1283 setInterval(function () { sidebanner_cb(idx); }, 666);
1286 function sidebanner_cb(idx)
1290 a = $('sidebanner'+idx).style.backgroundColor;
1291 b = $('sidebanner'+idx).style.borderLeftColor;
1293 $('sidebanner'+idx).style.backgroundColor = b;
1294 $('sidebanner'+idx).style.borderColor = a+" "+a+" "+a+" "+a;
1296 // console.log("A: "+a+" B: "+b);
1300 function langtolng(lang)
1308 function formtext_hilite(obj)
1310 obj.className = 'input_text';
1311 addEvent(obj, "focus", function () { this.className = 'input_text_hi'; });
1312 addEvent(obj, "blur", function () { this.className = 'input_text'; });
1315 function formsub_hilite(obj)
1317 obj.className = 'input_sub';
1318 addEvent(obj, "focus", function () { this.className = 'input_sub_hi'; });
1319 addEvent(obj, "blur", function () { this.className = 'input_sub'; });
1322 // return the value of the radio button that is checked
1323 // return an empty string if none are checked, or
1324 // there are no radio buttons
1325 function get_checked_value(radioObj) {
1328 var radioLength = radioObj.length;
1329 if(radioLength == undefined)
1330 if(radioObj.checked)
1331 return radioObj.value;
1334 for(var i = 0; i < radioLength; i++) {
1335 if(radioObj[i].checked) {
1336 return radioObj[i].value;
1342 // set the radio button with the given value as being checked
1343 // do nothing if there are no radio buttons
1344 // if the given value does not exist, all the radio buttons
1345 // are reset to unchecked
1346 function set_checked_value(radioObj, newValue) {
1349 var radioLength = radioObj.length;
1350 if(radioLength == undefined) {
1351 radioObj.checked = (radioObj.value == newValue.toString());
1354 for(var i = 0; i < radioLength; i++) {
1355 radioObj[i].checked = false;
1356 if(radioObj[i].value == newValue.toString()) {
1357 radioObj[i].checked = true;
1362 function url_append_arg(url, name, value)
1364 var pos, sep, pref, rest;
1366 if ((pos = url.indexOf('?'+name+'=')) == -1) {
1367 pos = url.indexOf('&'+name+'=');
1370 if ((pos = url.indexOf('?')) != -1)
1375 return (url+sep+name+"="+encodeURIComponent(value));
1378 pref = url.substring(0, pos+1);
1379 rest = url.substring(pos+1);
1380 // alert("rest: "+rest+" pos: "+pos);
1381 if ((pos = rest.indexOf('&')) != -1) {
1382 rest = rest.substring(pos);
1387 return (pref+name+"="+encodeURIComponent(value)+rest);
1391 function url_append_args(url)
1396 for (i = 1 ; i < arguments.length-1 ; i+= 2) {
1397 ret = url_append_arg(ret, arguments[i], arguments[i+1]);
1403 function url_complete(parent, url)
1406 var host = "", path = "";
1409 p = parent.indexOf("://");
1411 rest = parent.substring(p+3);
1412 p2 = rest.indexOf("/");
1414 host = parent.substring(0, p+3+p2);
1415 rest = parent.substring(p+3+p2);
1427 p = rest.lastIndexOf("/");
1429 path = rest.substring(0, p+1);
1432 // alert("host: ["+host+"] path: ["+path+"]");
1433 if (url.substring(0,6) == 'http:/' || url.substring(0,7) == 'https:/' || url.substring(0,4) == 'ws:/' || url.substring(0,5) == 'wss:/') {
1436 else if (url.substring(0,1) == '/') {
1440 return (host+path+url);
1444 function download_mgr(url)
1448 if ((ifra = $('the_downloader')) == null) {
1449 ifra = document.createElement("iframe");
1450 ifra.style.display = "none";
1451 ifra.id = 'the_downloader';
1452 document.body.appendChild(ifra);
1455 ifra.contentWindow.location.href = url;
1460 download_mgr.prototype = {
1464 function submit_click(obj)
1466 obj.form.elements['realsub'].value = obj.id;