X-Git-Url: http://mop.ddnsfree.com/gitweb/?p=brisk.git;a=blobdiff_plain;f=web%2Froom.js;h=c7efc62fef1cc23e4a272b09260bc499cf5c6f9c;hp=e8b19eabf6aad56e18624ad8c8426a9f1be1980d;hb=6d8db1ee47d3c0bb14133d3ab2e0a6bdc7ed60a0;hpb=a00b90507135651af999d563310a85faf82b4463 diff --git a/web/room.js b/web/room.js index e8b19ea..c7efc62 100644 --- a/web/room.js +++ b/web/room.js @@ -1,8 +1,8 @@ /* * brisk - room.js * - * Copyright (C) 2006-2009 Matteo Nastasi - * mailto: nastasi@alternativeoutput.it + * Copyright (C) 2006-2014 Matteo Nastasi + * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it * @@ -22,16 +22,18 @@ */ -/* +/* + data = [ [ flags, name ], ... ] - + */ -function state_add(flags) +function state_add(flags, comp) { - var content = ""; - var st, name = ""; - var tit = ""; + var content = "", supercont = ""; + var st, superst, name = "", supername = "", supersfx = ""; + var tit = "", supertit = ""; + if ((flags & 0xf00) != 0) { st = flags & 0xf00; @@ -65,12 +67,68 @@ function state_add(flags) name = "st_eye.png"; tit = (g_lang == 'en' ? "I'm here!" : "sono presente!"); break; + case 0x800: + name = "st_rabbit.png"; + tit = (g_lang == 'en' ? "Rabbit time" : "sono a spasso col coniglio"); + break; + case 0x900: + name = "st_soccer.png"; + tit = (g_lang == 'en' ? "Soccer time" : "c'è la partita!!"); + break; + case 0xa00: + name = "st_baby.png"; + tit = (g_lang == 'en' ? "Children time" : "ho il pupo da accudire"); + break; + case 0xb00: + name = "st_mop.png"; + tit = (g_lang == 'en' ? "Mop time" : "sto rassettando"); + break; + case 0xc00: + name = "st_babbo.png"; + tit = (g_lang == 'en' ? "Sto dando i regali" : "sto dando i regali"); + break; + case 0xd00: + name = "st_renna.png"; + tit = (g_lang == 'en' ? "in giro per regali" : "in giro per regali"); + break; + case 0xe00: + name = "st_pupaz.png"; + tit = (g_lang == 'en' ? "Neve a gogò" : "neve a gogò"); + break; + case 0xf00: + name = "st_visch.png"; + tit = (g_lang == 'en' ? "aspettando sotto al vischio" : "aspettando sotto al vischio"); + break; default: break; } + } + + if ((flags & 0xf0000) != 0) { + superst = flags & 0x20000; if (name != "") { - content += ' '; + supersfx = "_side"; } + + switch (superst) { + case 0x20000: + if (comp != null) { + supername = "suprend.php?comp="+comp+"&sfx="+supersfx; + } + else { + supername = "img/superuser"+supersfx+".png"; + } + supertit = (g_lang == 'en' ? "Brisk Supporter" : "Brisk Supporter"); + break; + } + } + + if (supername != "") { + content += ' '; + } + + if (name != "") { + content += ' '; } return content; @@ -83,12 +141,12 @@ var standup_data_old = null; function table_add(curtag, td) { - var tbody = null, tr; + var tbody = null, tr, ct; do { // console.log("wt: "+curtag.tagName); - if (curtag.tagName.toLowerCase() == "div" || + if (curtag.tagName.toLowerCase() == "div" || curtag.tagName.toLowerCase() == "table") { curtag = curtag.firstChild; } @@ -99,7 +157,7 @@ function table_add(curtag, td) else curtag = null; } while (curtag != null); - + curtag = tbody.firstChild; ct = 0; do { @@ -162,7 +220,7 @@ function table_walk(curtag) { do { // console.log("wt: "+curtag.tagName); - if (curtag.tagName.toLowerCase() == "div" || + if (curtag.tagName.toLowerCase() == "div" || curtag.tagName.toLowerCase() == "table" || curtag.tagName.toLowerCase() == "tbody") { curtag = curtag.firstChild; @@ -192,7 +250,7 @@ function table_walk(curtag) if (1 == 0) { if (curtag == null) - alert("outtag == null"); + alert("outtag == null"); else alert("outtag: "+curtag.tagName); } @@ -201,37 +259,39 @@ function table_walk(curtag) function j_stand_tdcont(el) { - var content = ""; - - if (el[0] & 0x01) - content += ''; - - if (el[0] & 0x02) - content += ''; - - content += el[1]; - - if (el[0] & 0x02) - content += ''; - - if (el[0] & 0x01) - content += ''; - - content += state_add(el[0]); - - return (content); + return (user_dec_and_state(el)); } -function j_stand_cont(data) +/* + ddata = [ [ , , ], ... ] + */ +function j_stand_cont(ddata) { - var i; + var i, ii; var content; var st = 0, name = ""; var curtag, nextag; + var data; + + if (g_listen & l_list_isol) { + data = new Array(); + + for (i = 0, ii = 0 ; ii < ddata.length ; ii++) { + if ((ddata[ii][0] & 0x02) == 0) { + continue; + } + data[i++] = ddata[ii]; + } + } + else + data = ddata; + + // WARNING: + // + // managing update needs this branch (for few users and the else!!) + // if (standup_data_old == null || data.length < 4) { - // if (standup_data_old == null) { - content = ''; for (i = 0 ; i < data.length ; i++) { if ((i % 4) == 0) @@ -239,25 +299,15 @@ function j_stand_cont(data) content += ''; - + if ((i % 4) == 3) content += ''; } + if ((i % 4) < 3) + content += ''; content += '
'; content += j_stand_tdcont(data[i]); content += '
'; - - $("standup").innerHTML = content; - - // console.log("inizio"); - // for (i = 0 , curtag = table_walk($("standup")) ; curtag != null ; curtag = table_walk(curtag), i++ ) { - // console.log("inloop["+i+"]: "+curtag.tagName+" ID: "+curtag.id); - // } - // console.log("fine "+i); - // walktable($("standup"), nextag); - // console.log($("standup").firstChild); - // console.log($("standup").firstChild.firstChild.firstChild.firstChild); - - // log_walk($("standup")); + $("standup").innerHTML = content; standup_data_old = data; } @@ -274,7 +324,7 @@ function j_stand_cont(data) idx_mod = new Array(); arr_mod = new Array(); map_cur = new Array(); - + // find removed entries for (i = 0 ; i < standup_data_old.length ; i++) { for (e = 0 ; e < data.length ; e++) { @@ -288,7 +338,9 @@ function j_stand_cont(data) } else { /* modified entries */ - if (standup_data_old[i][0] != data[e][0]) { + if (standup_data_old[i][0] != data[e][0] || + standup_data_old[i].length != data[e].length || + (data[e].length == 3 && standup_data_old[i][2] != data[e][2])) { arr_mod[idx_mod_n] = data[e]; idx_mod[idx_mod_n++] = i; } @@ -309,7 +361,7 @@ function j_stand_cont(data) map_add[idx_add_n++] = e; } } - + // TODO: qui travaso add in del i_del = 0; @@ -369,21 +421,43 @@ function j_stand_cont(data) table_add($("standup"), td); } - standup_data_old = data; - return; } - // $("esco").innerHTML = ''; + + var usr = $("standup").getElementsByClassName("id_usr"); + for (i = 0 ; i < usr.length ; i++) { + addEvent(usr[i], "click", click_update_cb); + } } function esco_cb() { - window.onbeforeunload = null; - window.onunload = null; - // nonunload = true; - act_logout(); + window.onbeforeunload = null; + window.onunload = null; + // nonunload = true; + act_logout(0); }; +var g_user_info_target = ""; +function info_show(username) +{ + // ret = server_request('mesg', 'prefs|save','__POST__', 'prefs', JSON.stringify(g_prefs)); + var udata = server_request('mesg', 'chatt|/info ' + username); + + // FIXME: just to be finished + console.log(udata); +} + +function click_update_cb(e) +{ + if (g_user_info_target == e.target.innerHTML) { + g_user_info_target = ""; + info_show(e.target.innerHTML); + } + else { + g_user_info_target = e.target.innerHTML; + } +} function j_tab_cont(table_idx, data) { @@ -391,24 +465,15 @@ function j_tab_cont(table_idx, data) var content = ''; for (i = 0 ; i < data.length ; i++) { - if (data[i][0] & 0x01) - content += ''; - - if (data[i][0] & 0x02) - content += ''; - - content += data[i][1]; - - if (data[i][0] & 0x02) - content += ''; - - if (data[i][0] & 0x01) - content += ''; - content += state_add(data[i][0]); + content += j_stand_tdcont(data[i]); content += '
'; } $("table"+table_idx).innerHTML = content; + var usr = $("table"+table_idx).getElementsByClassName("id_usr"); + for (i = 0 ; i < usr.length ; i++) { + addEvent(usr[i], "click", click_update_cb); + } } function j_tab_act_cont(idx, act) @@ -418,14 +483,21 @@ function j_tab_act_cont(idx, act) $("table_act"+idx).innerHTML = ''; } else if (act == 'sitreser') { - // // MLANG 1 - $("table_act"+idx).innerHTML = ''; + $("table_act"+idx).innerHTML = ''; + } + else if (act == 'sitcert') { + // MLANG 1 + $("table_act"+idx).innerHTML = ''; } else if (act == 'wake') { // MLANG 1 $("table_act"+idx).innerHTML = ''; } + else if (act == 'resercert') { + // MLANG 1 + $("table_act"+idx).innerHTML = ''; + } else if (act == 'reserved') { // MLANG 1 $("table_act"+idx).innerHTML = ''; @@ -435,6 +507,83 @@ function j_tab_act_cont(idx, act) } } +function j_check_login(login, ret) +{ + if (login.length > 12) { + // FIXME LANG + ret.ret += (g_lang == 'en' ? "Nickname too long." : "Nickname troppo lungo."); + return (false); + } + var old_c = '', old_ct = 0; + + for (i = 0 ; i < login.length ; i++) { + if ((login[i] >= '0' && login[i] <= '9') || + (login[i] >= 'a' && login[i] <= 'z') || + (login[i] >= 'A' && login[i] <= 'Z')) { + if (old_c != login[i]) { + old_c = login[i]; + old_ct = 0; + } + else { + if (old_ct > 3) { + // FIXME LANG + ret.ret = (g_lang == 'en' ? "More than three contiguous '" + old_c + "' not allowed." : + "Il nickname contiene più di tre caratteri '" + old_c + "' consecutivi."); + return (false); + } + } + old_ct++; + continue; + } + else { + // FIXME LANG + ret.ret = (g_lang == 'en' ? "Nickname includes not allowed '" + login[i] + "' character." : + "Il nickname contiene un carattere '" + login[i] + "' non consentito."); + return (false); + } + } + + return (true); +} + + +function j_new_apprentice(form) +{ + var ret = { ret: '' }; + var token; + + do { + if (form.elements['realsub'].value == "close") { + $('apprentice_div').style.display = 'none'; + break; + } + + if (j_check_login(form.elements['nameid'].value, ret) == false || + j_check_email(form.elements['emailid'].value, ret) == false) { + + no = new notify(gst, "
" + ret.ret + "
", 1, (g_lang == 'en' ? "Close." : "Chiudi."), 280, 100); + break; + } + + // submit the request + token = server_request('mesg', 'apprentice', + 'cli_name', encodeURIComponent(form.elements['nameid'].value), + 'cli_email', encodeURIComponent(form.elements['emailid'].value), + 'cli_lang', g_lang); + if (token == "1") { + // FIXME LANG + $('apprentice_div').style.display = "none"; + no = new notify(gst, "
Richiesta inviata con successo.
Riceverai a breve un' e-mail per verificare la correttezza dell'indirizzo.
", 1, (g_lang == 'en' ? "Close." : "Chiudi."), 280, 100); + } + else { + no = new notify(gst, "
" + token + "
", 1, (g_lang == 'en' ? "Close." : "Chiudi."), 280, 100); + } + } while (0); + + return (false); +} + + function j_login_manager(form) { var token; @@ -447,20 +596,20 @@ function j_login_manager(form) /* richiede token */ token = server_request('mesg', 'getchallenge', 'cli_name', encodeURIComponent(form.elements['nameid'].value)); tokens = token.split('|'); - + // console.log('XX token: '+token); // console.log(tokens); if (token == null) return (false); token = calcMD5(tokens[1]+calcMD5(form.elements['passid'].value)); - + form.elements['passid_private'].value = token; form.elements['passid'].value = ""; // FIXME da sost con la stessa len di A return (true); } - + return (false); } @@ -506,16 +655,19 @@ function mesgtoadm_formtext_hilite(form) } -function j_check_email(email) +function j_check_email(email, ret) { - if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) + if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,10})+$/.test(email)) return (true); + ret.ret += (g_lang == 'en' ? "Invalid email address. " : + "Indirizzo e-mail non valido."); + return (false); } function j_authbox(form) { - var no; + var no, ret = { "ret": "" }; do { if (form.elements['realsub'].value == "chiudi") { @@ -523,17 +675,17 @@ function j_authbox(form) break; } - if (form.elements['name'].value == '' || j_check_email(form.elements['email'].value) == false) { + if (form.elements['name'].value == '' || j_check_email(form.elements['email'].value, ret) == false) { // MLANG 2-4 - no = new notify(gst, - (g_lang == 'en' ? "
nickname and/or e-mail fields are invalid;
please, fix them." : - "
I campi nickname e/o e-mail non sono validi;
correggeteli per favore."), - 1, (g_lang == 'en' ? "close" : "chiudi"), 280, 100); + no = new notify(gst, + (g_lang == 'en' ? "
" + ret.ret + "
please, fix." : + "
" + ret.ret + "
correggere, per favore."), + 1, (g_lang == 'en' ? "close" : "chiudi"), 280, 100); break; } // submit the request - token = server_request('mesg', 'warranty', + token = server_request('mesg', 'warranty', 'cli_name', encodeURIComponent(form.elements['name'].value), 'cli_email', encodeURIComponent(form.elements['email'].value) ); if (token == "1") { @@ -567,10 +719,10 @@ function authbox(w, h) function j_mesgtoadmbox(form) { - var no; + var no; do { - if (form.elements['realsub'].value == "chiudi") { + if (form.elements['realsub'].value == "cloid") { $('mesgtoadmbox').style.visibility = "hidden"; break; } @@ -578,13 +730,13 @@ function j_mesgtoadmbox(form) if (form.elements['mesg'].value == '' || form.elements['subj'].value == '') { // MLANG 1-3 no = new notify(gst, (g_lang == 'en' ? "
subject and the message cannot be void;
please, fix them." : - "
Il soggetto e il messaggo non possono essere vuoti;
correggeteli per favore."), 1, - (g_lang == 'en' ? "close" : "chiudi"), 280, 100); + "
Il soggetto e il messaggo non possono essere vuoti;
correggeteli per favore."), 1, + (g_lang == 'en' ? "close" : "chiudi"), 280, 100); break; } - + // submit the request - token = server_request('mesg', 'mesgtoadm', + token = server_request('mesg', 'mesgtoadm', 'cli_subj', encodeURIComponent(form.elements['subj'].value), 'cli_mesg', encodeURIComponent(form.elements['mesg'].value) ); if (token == "1") { @@ -618,11 +770,11 @@ function mesgtoadmbox(w, h) function j_pollbox(form) { - var no, i, choose; + var no, i, choose; do { // submit the request - + for (i = 0 ; i < form.elements.length ; i++) { if (form.elements[i].checked == true) break; @@ -630,14 +782,14 @@ function j_pollbox(form) if (i == form.elements.length) { // MLANG 1-3 no = new notify(gst, (g_lang == 'en' ? "
You must choose ah item;
please, fix it." : - "
Non hai espresso nessuna preferenza;
correggi per favore."), 1, - (g_lang == 'en' ? "close" : "chiudi"), 280, 100); + "
Non hai espresso nessuna preferenza;
correggi per favore."), 1, + (g_lang == 'en' ? "close" : "chiudi"), 280, 100); return false; } else choose = form.elements[i].value; - token = server_request('mesg', 'poll', + token = server_request('mesg', 'poll', 'cli_choose', encodeURIComponent(choose) ); if (token == "1") { @@ -651,24 +803,6 @@ function j_pollbox(form) } - - -function list_set(what, setco, info) -{ - if (what == 'auth') { - $('list_auth').style.color = 'red'; - $('list_all').style.color = 'black'; - } - else { - $('list_auth').style.color = 'black'; - $('list_all').style.color = 'red'; - } - $('list_info').innerHTML = info; - if (setco) { - createCookie("CO_list", what, 24*365, cookiepath); - } -} - function sideslide(domobj, height, step) { this.st = 'wait'; @@ -694,7 +828,7 @@ sideslide.prototype = { start: function() { var instant = this; - + this.st = 'wait'; this.id = setTimeout(function () { instant.sideslide_cb(); }, this.twait); },