X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Froom.js;h=0e0aed916e1be31f7e68652b0d0cda87ff5f0205;hb=ea9ea2b7924e1aa5e55f5cbc3909375a38b9d730;hp=9e32b75a217982c7dace7598795d7999aa4c1c6c;hpb=661f4df6044faa6f13597c316bff12863e4df441;p=brisk.git diff --git a/web/room.js b/web/room.js index 9e32b75..0e0aed9 100644 --- a/web/room.js +++ b/web/room.js @@ -44,48 +44,310 @@ function state_add(flags) break; } if (name != "") { - content += ''; + content += ' '; } } return content; } -function j_stand_cont(data) +var standup_data_old = null; + +// TODO !! +// appendChild , removeChild + +function table_add(curtag, td) { + var tbody = null, tr; + + do { + // console.log("wt: "+curtag.tagName); + + if (curtag.tagName.toLowerCase() == "div" || + curtag.tagName.toLowerCase() == "table") { + curtag = curtag.firstChild; + } + else if (curtag.tagName.toLowerCase() == "tbody") { + tbody = curtag; + break; + } + else + curtag = null; + } while (curtag != null); + + curtag = tbody.firstChild; + ct = 0; + do { + if (curtag.tagName.toLowerCase() == "tr") { + if (curtag.firstChild != null) { + curtag = curtag.firstChild; + ct++; + } + else { + curtag.appendChild(td); + return(true); + } + } + else if (curtag.tagName.toLowerCase() == "td") { + if (curtag.nextSibling != null) { + curtag = curtag.nextSibling; + ct++; + } + else { + if (ct < 4) { + curtag.parentNode.appendChild(td); + return (true); + } + else { + ct = 0; + curtag = curtag.parentNode.nextSibling; + } + } + } + else { + curtag = curtag.parentNode; + } + + } while (curtag != null); + + tr = document.createElement("tr"); + tr.appendChild(td); + tbody.appendChild(tr); + + return (true); +} + +function spcs(c1, c2, n) +{ + var ret = ""; var i; - var content; - var st, name = ""; - content = ''; - for (i = 0 ; i < data.length ; i++) { - if ((i % 4) == 0) - content += ''; - content += ''; + // walktable($("standup"), nextag); + // console.log($("standup").firstChild); + // console.log($("standup").firstChild.firstChild.firstChild.firstChild); + + // log_walk($("standup")); - if ((i % 4) == 3) - content += ''; + standup_data_old = data; } - content += ''; + else { + var idx_del, arr_add, idx_mod, arr_mod; + var idx_del_n = 0, idx_add_n = 0, idx_mod_n = 0; + var i, e; + var i_del, i_mod, i_add; + var td; + + idx_del = new Array(); + arr_add = new Array(); + map_add = new Array(); + 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++) { + if (standup_data_old[i][1] == data[e][1]) { + break; + } + } + if (e == data.length) { + idx_del[idx_del_n++] = i; + map_cur[i] = -1; + } + else { + /* modified entries */ + if (standup_data_old[i][0] != data[e][0]) { + arr_mod[idx_mod_n] = data[e]; + idx_mod[idx_mod_n++] = i; + } + map_cur[i] = e; + } + } + + // find new entries + for (e = 0 ; e < data.length ; e++) { + for (i = 0 ; i < standup_data_old.length ; i++) { + if (data[e][1] == standup_data_old[i][1] ) { + break; + } + } + if (i == standup_data_old.length) { + // console.log("ADD: "+data[e][1]); + arr_add[idx_add_n] = data[e]; + map_add[idx_add_n++] = e; + } + } + + // TODO: qui travaso add in del + + i_del = 0; + // alert("del: ["+j_stand_tdcont(standup_data_old[idx_del[i_del]])+"]"); + for (i = 0 , i_del = 0, i_mod = 0, i_add = 0, curtag = table_walk($("standup")) ; curtag != null ; curtag = table_walk(curtag), i++ ) { + // console.log("cur.id: "+curtag.id); + + // alert("i: "+i+" tagname: "+curtag.tagName+" innerHTML: ["+curtag.innerHTML+"]"); + // console.log("inloop["+i+"]: "+curtag.tagName+" ID: "+curtag.id); + if (curtag.innerHTML == "") { + // console.log("innerHTML == none"); + if (i_add < idx_add_n) { + // console.log(" to be new"); + // console.log(" add: CONT:"+j_stand_tdcont(arr_add[i_add])); + curtag.innerHTML = j_stand_tdcont(arr_add[i_add]); + curtag.id = map_add[i_add]; + i_add++ + } + } + + // else if (i_del < idx_del_n && curtag.innerHTML == j_stand_tdcont(standup_data_old[idx_del[i_del]])) { + else if (i_del < idx_del_n && curtag.id == idx_del[i_del]) { + // console.log("to be cancel["+i+"]: ID: "+curtag.id); + if (i_add < idx_add_n) { + // console.log(" to be new"); + // console.log(" add: CONT:"+j_stand_tdcont(arr_add[i_add])); + curtag.innerHTML = j_stand_tdcont(arr_add[i_add]); + curtag.id = map_add[i_add]; + i_add++ + } + else { + // console.log(" to be del"); + curtag.innerHTML = ""; + curtag.id = -1; + } + i_del++; + } + // else if (i_mod < idx_mod_n && curtag.innerHTML == j_stand_tdcont(standup_data_old[idx_mod[i_mod]])) { + else if (i_mod < idx_mod_n && curtag.id == idx_mod[i_mod]) { + // console.log(" to be mod"); + // console.log("mod: "+idx_mod[i_mod]+ " CONT:"+j_stand_tdcont(arr_mod[i_mod])); + curtag.innerHTML = j_stand_tdcont(arr_mod[i_mod]); + curtag.id = map_cur[curtag.id]; + i_mod++; + } + else + curtag.id = map_cur[curtag.id]; + } + // console.log("fineloop"); - $("standup").innerHTML = content; + for (i ; i_add < idx_add_n ; i_add++, i++) { + // console.log("ADD: "+i+" arr_add: "+ arr_add[i_add][1]); + td = document.createElement("td"); + td.className = "room_standup"; + td.id = map_add[i_add]; + td.innerHTML = j_stand_tdcont(arr_add[i_add]); + + table_add($("standup"), td); + } + standup_data_old = data; + return; + } // $("esco").innerHTML = ''; } @@ -173,20 +435,6 @@ function j_login_manager(form) return (false); } -function formtext_hilite(obj) -{ - obj.className = 'input_text'; - addEvent(obj, "focus", function () { this.className = 'input_text_hi'; }); - addEvent(obj, "blur", function () { this.className = 'input_text'; }); -} - -function formsub_hilite(obj) -{ - obj.className = 'input_sub'; - addEvent(obj, "focus", function () { this.className = 'input_sub_hi'; }); - addEvent(obj, "blur", function () { this.className = 'input_sub'; }); -} - function login_formtext_hilite() { formtext_hilite($("nameid")); @@ -200,12 +448,32 @@ function login_init() login_formtext_hilite(); } -function warrant_formtext_hilite() +function warrant_formtext_hilite(form) { + /* formtext_hilite($("nameid")); formtext_hilite($("emailid")); formsub_hilite($("subid")); formsub_hilite($("cloid")); + */ + formtext_hilite(form.elements['name']); + formtext_hilite(form.elements['email']); + formsub_hilite(form.elements['sub']); + formsub_hilite(form.elements['clo']); +} + +function mesgtoadm_formtext_hilite(form) +{ + /* + formtext_hilite($("subjid")); + formtext_hilite($("mesgid")); + formsub_hilite($("subid")); + formsub_hilite($("cloid")); + */ + formtext_hilite(form.elements['subj']); + formtext_hilite(form.elements['mesg']); + formsub_hilite(form.elements['sub']); + formsub_hilite(form.elements['clo']); } @@ -220,14 +488,17 @@ function j_authbox(form) { var no; - if (form.elements['realsub'].value == "chiudi") { - $('authbox').style.visibility = "hidden"; - return (false); - } + do { + if (form.elements['realsub'].value == "chiudi") { + $('authbox').style.visibility = "hidden"; + break; + } + + if (form.elements['name'].value == '' || j_check_email(form.elements['email'].value) == false) { + no = new notify(gst, "
I campi user e/o e-mail non sono validi;
correggeteli per favore.", 1, "chiudi", 280, 100); + break; + } - if (form.elements['name'].value == '' || j_check_email(form.elements['email'].value) == false) - no = new notify(gst, "
I campi user e/o e-mail non sono validi;
correggeteli per favore.", 1, "chiudi", 280, 100); - else { // submit the request token = server_request('mesg', 'warranty', 'cli_name', encodeURIComponent(form.elements['name'].value), @@ -236,9 +507,9 @@ function j_authbox(form) $('authbox').style.visibility = "hidden"; form.elements['name'].value = ""; form.elements['email'].value = ""; - return (false); + break; } - } + } while (0); return (false); } @@ -255,8 +526,72 @@ function authbox(w, h) box.style.height = h+"px"; box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop; - warrant_formtext_hilite(); + warrant_formtext_hilite($('auth_form')); box.style.visibility = "visible"; $("nameid").focus(); } + +function j_mesgtoadmbox(form) +{ + var no; + + do { + if (form.elements['realsub'].value == "chiudi") { + $('mesgtoadmbox').style.visibility = "hidden"; + break; + } + + if (form.elements['mesg'].value == '' || form.elements['subj'].value == '') { + no = new notify(gst, "
Il soggetto e il messaggo non possono essere vuoti;
correggeteli per favore.", 1, "chiudi", 280, 100); + break; + } + + // submit the request + token = server_request('mesg', 'mesgtoadm', + 'cli_subj', encodeURIComponent(form.elements['subj'].value), + 'cli_mesg', encodeURIComponent(form.elements['mesg'].value) ); + if (token == "1") { + $('mesgtoadmbox').style.visibility = "hidden"; + form.elements['subj'].value = ""; + form.elements['mesg'].value = ""; + break; + } + } while (0); + + return (false); +} + +function mesgtoadmbox(w, h) +{ + var box; + + box = $('mesgtoadmbox'); + + box.style.zIndex = 200; + box.style.width = w+"px"; + box.style.marginLeft = -parseInt(w/2)+"px"; + box.style.height = h+"px"; + box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop; + + mesgtoadm_formtext_hilite($('mesgtoadm_form')); + + box.style.visibility = "visible"; + $('mesgtoadm_form').elements['subj'].focus(); +} + +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); + } +}
'; - if (data[i][0] & 0x01) - content += ''; + for (i = 0 ; i < n ; i++) { + if ((i % 2) == 0) + ret += c1; + else + ret += c2; + } - if (data[i][0] & 0x02) - content += ''; + return (ret); +} - content += data[i][1]; + +function table_walk(curtag) +{ + do { + // console.log("wt: "+curtag.tagName); + if (curtag.tagName.toLowerCase() == "div" || + curtag.tagName.toLowerCase() == "table" || + curtag.tagName.toLowerCase() == "tbody") { + curtag = curtag.firstChild; + } + else if (curtag.tagName.toLowerCase() == "tr") { + if (curtag.firstChild != null) + curtag = curtag.firstChild; + else if (curtag.tagName != '') + curtag = curtag.nextSibling; + else + curtag = null; + } + else if (curtag.tagName.toLowerCase() == "td") { + if (curtag.nextSibling != null) + curtag = curtag.nextSibling; + else { + if (curtag.parentNode.nextSibling != null && curtag.parentNode.nextSibling.tagName != '') + curtag = curtag.parentNode.nextSibling; + else + curtag = null; + } + } + else + curtag = null; + + } while (curtag != null && curtag.tagName.toLowerCase() != "td"); + + if (1 == 0) { + if (curtag == null) + alert("outtag == null"); + else + alert("outtag: "+curtag.tagName); + } + return (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); +} + +function j_stand_cont(data) +{ + var i; + var content; + var st = 0, name = ""; + var curtag, nextag; + + if (standup_data_old == null || data.length < 4) { + // if (standup_data_old == null) { - if (data[i][0] & 0x02) - content += ''; + content = ''; + for (i = 0 ; i < data.length ; i++) { + if ((i % 4) == 0) + content += ''; + content += ''; + + if ((i % 4) == 3) + content += ''; + } + content += '
'; + content += j_stand_tdcont(data[i]); + content += '
'; + + $("standup").innerHTML = content; - if (data[i][0] & 0x01) - 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); - content += state_add(data[i][0]); - content += '