X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Froom.js;h=7085be4068d54b301ff9dfdc166692564f4699ba;hb=ff8f72d120d4fd4a7b096dbff8f9aa527f522e19;hp=85ea6993ce015237d6057fa6b2cee21aba0d911c;hpb=698268dca9fec84ee56bdad33209683c0c4148a9;p=brisk.git
diff --git a/web/room.js b/web/room.js
index 85ea699..7085be4 100644
--- a/web/room.js
+++ b/web/room.js
@@ -1,8 +1,8 @@
/*
* brisk - room.js
*
- * Copyright (C) 2006-2012 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,12 +22,11 @@
*/
-/*
+/*
data = [ [ flags, name ], ... ]
-
-*/
+*/
function state_add(flags, comp)
{
@@ -106,9 +105,9 @@ function state_add(flags, comp)
}
if ((flags & 0xf0000) != 0) {
- superst = flags & 0xf0000;
+ superst = flags & 0x20000;
if (name != "") {
- supersfx = "_side";
+ supersfx = "_side";
}
switch (superst) {
@@ -127,7 +126,7 @@ function state_add(flags, comp)
if (supername != "") {
content += ' ';
}
-
+
if (name != "") {
content += ' ';
}
@@ -147,7 +146,7 @@ function table_add(curtag, td)
do {
// console.log("wt: "+curtag.tagName);
- if (curtag.tagName.toLowerCase() == "div" ||
+ if (curtag.tagName.toLowerCase() == "div" ||
curtag.tagName.toLowerCase() == "table") {
curtag = curtag.firstChild;
}
@@ -158,7 +157,7 @@ function table_add(curtag, td)
else
curtag = null;
} while (curtag != null);
-
+
curtag = tbody.firstChild;
ct = 0;
do {
@@ -221,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;
@@ -251,7 +250,7 @@ function table_walk(curtag)
if (1 == 0) {
if (curtag == null)
- alert("outtag == null");
+ alert("outtag == null");
else
alert("outtag: "+curtag.tagName);
}
@@ -275,7 +274,7 @@ function j_stand_cont(ddata)
var data;
- if (g_listen & l_list_isol) {
+ if (g_prefs.listen & l_list_isol) {
data = new Array();
for (i = 0, ii = 0 ; ii < ddata.length ; ii++) {
@@ -295,19 +294,22 @@ function j_stand_cont(ddata)
if (standup_data_old == null || data.length < 4) {
content = '
';
for (i = 0 ; i < data.length ; i++) {
+ if (ddata[i][1] == window.myname) {
+ ddata[i][0] |= 1;
+ }
if ((i % 4) == 0)
content += '';
content += '';
content += j_stand_tdcont(data[i]);
content += ' | ';
-
+
if ((i % 4) == 3)
content += '
';
}
if ((i % 4) < 3)
content += '';
content += '
';
-
+
$("standup").innerHTML = content;
standup_data_old = data;
@@ -325,7 +327,7 @@ function j_stand_cont(ddata)
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++) {
@@ -362,7 +364,7 @@ function j_stand_cont(ddata)
map_add[idx_add_n++] = e;
}
}
-
+
// TODO: qui travaso add in del
i_del = 0;
@@ -422,35 +424,40 @@ function j_stand_cont(ddata)
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", info_show_cb);
+ }
}
function esco_cb() {
- window.onbeforeunload = null;
- window.onunload = null;
- // nonunload = true;
+ window.onbeforeunload = null;
+ window.onunload = null;
+ // nonunload = true;
act_logout(0);
};
-
-
function j_tab_cont(table_idx, data)
{
var i;
var content = '';
for (i = 0 ; i < data.length ; i++) {
- // content += user_decorator(data[i]);
- // content += state_add(data[i][0]);
+ if (data[i][1] == window.myname) {
+ data[i][0] |= 1;
+ }
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", info_show_cb);
+ }
}
function j_tab_act_cont(idx, act)
@@ -459,15 +466,26 @@ function j_tab_act_cont(idx, act)
// MLANG 1
$("table_act"+idx).innerHTML = '';
}
+ else if (act == 'sitappr') {
+ // MLANG 1
+ $("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 = '';
@@ -477,6 +495,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 = 1;
+ }
+ else {
+ if (old_ct > 2) {
+ // FIXME LANG
+ ret.ret = (g_lang == 'en' ? "More than two contiguous '" + old_c + "' not allowed." :
+ "Il nickname contiene più di 2 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;
@@ -489,20 +584,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);
}
@@ -548,16 +643,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") {
@@ -565,17 +663,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") {
@@ -609,10 +707,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;
}
@@ -620,13 +718,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") {
@@ -660,11 +758,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;
@@ -672,14 +770,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") {
@@ -718,7 +816,7 @@ sideslide.prototype = {
start: function() {
var instant = this;
-
+
this.st = 'wait';
this.id = setTimeout(function () { instant.sideslide_cb(); }, this.twait);
},