wrong index fixed
[brisk.git] / web / room.js
1 /*
2  *  brisk - room.js
3  *
4  *  Copyright (C) 2006-2009 Matteo Nastasi
5  *                          mailto: nastasi@alternativeoutput.it 
6  *                                  matteo.nastasi@milug.org
7  *                          web: http://www.alternativeoutput.it
8  *
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.
13  *
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.
21  *
22  */
23
24
25 /* 
26    data = [ [ flags, name ],  ... ]
27    
28 */
29
30 var l_list_all = 0x00;
31 var l_list_auth = 0x01;
32 var l_list_isol = 0x02;
33
34 function state_add(flags)
35 {
36     var content = "";
37     var st, name = "";
38     var tit = "";
39
40     if ((flags & 0xf00) != 0) {
41         st = flags & 0xf00;
42         // MLANG 4,12,16,20,24,28
43         switch (st) {
44         case 0x100:
45             name = "st_pau.png";
46             tit = (g_lang == 'en' ? "I'm doing a break" : "sono in pausa");
47             break;
48         case 0x200:
49             name = "st_out.png";
50             tit = (g_lang == 'en' ? "I'm away" : "sono fuori");
51             break;
52         case 0x300:
53             name = "st_dog.png";
54             tit = (g_lang == 'en' ? "Dog time" : "sono a spasso col cane");
55             break;
56         case 0x400:
57             name = "st_eat.png";
58             tit = (g_lang == 'en' ? "I'm eating" : "sto mangiando");
59             break;
60         case 0x500:
61             name = "st_wrk.png";
62             tit = (g_lang == 'en' ? "I'm working" : "sono a lavoro");
63             break;
64         case 0x600:
65             name = "st_smk.png";
66             tit = (g_lang == 'en' ? "I'm smoking a sigarett (and keeping a cancer)" : "sto fumando una sigaretta (e facendomi venire il cancro)");
67             break;
68         case 0x700:
69             name = "st_eye.png";
70             tit = (g_lang == 'en' ? "I'm here!" : "sono presente!");
71             break;
72         default:
73             break;
74         }
75         if (name != "") {
76             content += '&nbsp;<img title="'+tit+'" class="unbo" src="img/'+name+'">';
77         }
78     }
79
80     return content;
81 }
82
83 var standup_data_old = null;
84
85 // TODO !!
86 // appendChild , removeChild
87
88 function table_add(curtag, td)
89 {
90     var tbody  = null, tr;
91
92     do {
93         // console.log("wt: "+curtag.tagName);
94
95         if (curtag.tagName.toLowerCase() == "div" || 
96             curtag.tagName.toLowerCase() == "table") {
97             curtag = curtag.firstChild;
98         }
99         else if (curtag.tagName.toLowerCase() == "tbody") {
100             tbody = curtag;
101             break;
102         }
103         else
104             curtag = null;
105     } while (curtag != null);
106     
107     curtag = tbody.firstChild;
108     ct = 0;
109     do {
110         if (curtag.tagName.toLowerCase() == "tr") {
111             if (curtag.firstChild != null) {
112                 curtag = curtag.firstChild;
113                 ct++;
114             }
115             else {
116                 curtag.appendChild(td);
117                 return(true);
118             }
119         }
120         else if (curtag.tagName.toLowerCase() == "td") {
121             if (curtag.nextSibling != null) {
122                 curtag = curtag.nextSibling;
123                 ct++;
124             }
125             else {
126                 if (ct < 4) {
127                     curtag.parentNode.appendChild(td);
128                     return (true);
129                 }
130                 else {
131                     ct = 0;
132                     curtag = curtag.parentNode.nextSibling;
133                 }
134             }
135         }
136         else {
137             curtag = curtag.parentNode;
138         }
139
140     } while (curtag != null);
141
142     tr = document.createElement("tr");
143     tr.appendChild(td);
144     tbody.appendChild(tr);
145
146     return (true);
147 }
148
149 function spcs(c1, c2, n)
150 {
151     var ret = "";
152     var i;
153
154     for (i = 0 ; i < n ; i++) {
155         if ((i % 2) == 0)
156             ret += c1;
157         else
158             ret += c2;
159     }
160
161     return (ret);
162 }
163
164
165 function table_walk(curtag)
166 {
167     do {
168         // console.log("wt: "+curtag.tagName);
169         if (curtag.tagName.toLowerCase() == "div" || 
170             curtag.tagName.toLowerCase() == "table" ||
171             curtag.tagName.toLowerCase() == "tbody") {
172             curtag = curtag.firstChild;
173         }
174         else if (curtag.tagName.toLowerCase() == "tr") {
175             if (curtag.firstChild != null)
176                 curtag = curtag.firstChild;
177             else if (curtag.tagName != '')
178                 curtag = curtag.nextSibling;
179             else
180                 curtag = null;
181         }
182         else if (curtag.tagName.toLowerCase() == "td") {
183             if (curtag.nextSibling != null)
184                 curtag = curtag.nextSibling;
185             else {
186                 if (curtag.parentNode.nextSibling != null && curtag.parentNode.nextSibling.tagName != '')
187                     curtag = curtag.parentNode.nextSibling;
188                 else
189                     curtag = null;
190             }
191         }
192         else
193             curtag = null;
194
195     } while (curtag != null && curtag.tagName.toLowerCase() != "td");
196
197     if (1 == 0) {
198         if (curtag == null)
199             alert("outtag == null"); 
200         else
201             alert("outtag: "+curtag.tagName);
202     }
203     return (curtag);
204 }
205
206 function j_stand_tdcont(el)
207 {
208     var content = "";
209
210     if (el[0] & 0x01)
211         content += '<b>';
212     
213     if (el[0] & 0x02)
214         content += '<i>';
215     
216     content += el[1];
217     
218     if (el[0] & 0x02)
219         content += '</i>';
220     
221     if (el[0] & 0x01)
222         content += '</b>';
223             
224     content += state_add(el[0]);
225     
226     return (content);
227 }
228
229 function j_stand_cont(data)
230 {
231     var i;
232     var content;
233     var st = 0, name = "";
234     var curtag, nextag;
235
236     if (standup_data_old == null || data.length < 4) {
237     // if (standup_data_old == null) {
238         
239         content = '<table cols="'+(data.length < 4 ? data.length : 4)+'" class="table_standup">';
240         for (i = 0, ii = 0 ; ii < data.length ; ii++) {
241             if (g_listen & l_list_isol && ((data[ii][0] & 0x02) == 0)) {
242                 continue;
243             }
244             if ((i % 4) == 0)
245                 content += '<tr>';
246             content += '<td id="'+i+'" class="room_standup">';
247             content += j_stand_tdcont(data[ii]);
248             content += '</td>';
249             
250             if ((i % 4) == 3)
251                 content += '</tr>';
252
253             i++;
254         }
255         content += '</table>';
256         
257         $("standup").innerHTML = content;
258
259         // console.log("inizio");
260         // for (i = 0 , curtag = table_walk($("standup")) ; curtag != null ;  curtag = table_walk(curtag), i++ ) {
261         //     console.log("inloop["+i+"]: "+curtag.tagName+"  ID: "+curtag.id);
262         // }
263         // console.log("fine "+i);
264
265         // walktable($("standup"), nextag);
266         // console.log($("standup").firstChild);
267         // console.log($("standup").firstChild.firstChild.firstChild.firstChild);
268
269         // log_walk($("standup"));
270
271         standup_data_old = data;
272     }
273     else {
274         var idx_del, arr_add, idx_mod, arr_mod;
275         var idx_del_n = 0, idx_add_n = 0, idx_mod_n = 0;
276         var i, e;
277         var i_del, i_mod, i_add;
278         var td;
279
280         idx_del = new Array();
281         arr_add = new Array();
282         map_add = new Array();
283         idx_mod = new Array();
284         arr_mod = new Array();
285         map_cur = new Array();
286         
287         // find removed entries
288         for (i = 0 ; i < standup_data_old.length ; i++) {
289             for (e = 0 ; e < data.length ; e++) {
290                 if (standup_data_old[i][1] == data[e][1]) {
291                     break;
292                 }
293             }
294             if (e == data.length || 
295                 (g_listen & l_list_isol && ((data[e][0] & 0x02) == 0))) {
296                 idx_del[idx_del_n++] = i;
297                 map_cur[i] = -1;
298             }
299             else {
300                 /* modified entries */
301                 if (standup_data_old[i][0] != data[e][0]) {
302                     arr_mod[idx_mod_n] = data[e];
303                     idx_mod[idx_mod_n++] = i;
304                 }
305                 map_cur[i] = e;
306             }
307         }
308
309         // find new entries
310         for (e = 0 ; e < data.length ; e++) {
311             for (i = 0 ; i < standup_data_old.length ; i++) {
312                 if (data[e][1] == standup_data_old[i][1] ) {
313                     break;
314                 }
315             }
316             if (i == standup_data_old.length &&
317                 !(g_listen & l_list_isol && ((data[e][0] & 0x02) == 0))) {
318                 // console.log("ADD: "+data[e][1]);
319                 arr_add[idx_add_n]   = data[e];
320                 map_add[idx_add_n++] = e;
321             }
322         }
323         
324         // TODO: qui travaso add in del
325
326         i_del = 0;
327         // alert("del: ["+j_stand_tdcont(standup_data_old[idx_del[i_del]])+"]");
328         for (i = 0 , i_del = 0, i_mod = 0, i_add = 0, curtag = table_walk($("standup")) ; curtag != null ;  curtag = table_walk(curtag), i++ ) {
329             // console.log("cur.id: "+curtag.id);
330
331             // alert("i: "+i+"  tagname: "+curtag.tagName+"  innerHTML: ["+curtag.innerHTML+"]");
332             // console.log("inloop["+i+"]: "+curtag.tagName+"  ID: "+curtag.id);
333             if (curtag.innerHTML == "") {
334                 // console.log("innerHTML == none");
335                 if (i_add < idx_add_n) {
336                     // console.log("  to be new");
337                     // console.log("  add:   CONT:"+j_stand_tdcont(arr_add[i_add]));
338                     curtag.innerHTML = j_stand_tdcont(arr_add[i_add]);
339                     curtag.id = map_add[i_add];
340                     i_add++
341                 }
342             }
343
344             // else if (i_del < idx_del_n && curtag.innerHTML == j_stand_tdcont(standup_data_old[idx_del[i_del]])) {
345             else if (i_del < idx_del_n && curtag.id == idx_del[i_del]) {
346                 // console.log("to be cancel["+i+"]:  ID: "+curtag.id);
347                 if (i_add < idx_add_n) {
348                     // console.log("  to be new");
349                     // console.log("  add:   CONT:"+j_stand_tdcont(arr_add[i_add]));
350                     curtag.innerHTML = j_stand_tdcont(arr_add[i_add]);
351                     curtag.id = map_add[i_add];
352                     i_add++
353                 }
354                 else {
355                     // console.log("  to be del");
356                     curtag.innerHTML = "";
357                     curtag.id = -1;
358                 }
359                 i_del++;
360             }
361             // else if (i_mod < idx_mod_n && curtag.innerHTML == j_stand_tdcont(standup_data_old[idx_mod[i_mod]])) {
362             else if (i_mod < idx_mod_n && curtag.id == idx_mod[i_mod]) {
363                 // console.log("  to be mod");
364                 // console.log("mod: "+idx_mod[i_mod]+ "  CONT:"+j_stand_tdcont(arr_mod[i_mod]));
365                 curtag.innerHTML = j_stand_tdcont(arr_mod[i_mod]);
366                 curtag.id = map_cur[curtag.id];
367                 i_mod++;
368             }
369             else
370                 curtag.id = map_cur[curtag.id];
371         }
372         // console.log("fineloop");
373
374         for (i ; i_add < idx_add_n ; i_add++, i++) {
375             // console.log("ADD: "+i+" arr_add: "+ arr_add[i_add][1]);
376             td = document.createElement("td");
377             td.className = "room_standup";
378             td.id = map_add[i_add];
379             td.innerHTML = j_stand_tdcont(arr_add[i_add]);
380
381             table_add($("standup"), td);
382         }
383
384         standup_data_old = data;
385         return;
386     }
387     // $("esco").innerHTML =  '<input class="button" name="logout" value="Esco." onclick="esco_cb();" type="button">';
388 }
389
390 function esco_cb() {
391     window.onbeforeunload = null; 
392     window.onunload = null; 
393     // nonunload = true; 
394     act_logout();
395  };
396
397
398
399 function j_tab_cont(table_idx, data)
400 {
401     var i;
402     var content = '';
403
404     for (i = 0 ; i < data.length ; i++) {
405         if (data[i][0] & 0x01)
406             content += '<b>';
407
408         if (data[i][0] & 0x02)
409             content += '<i>';
410
411         content += data[i][1];
412         
413         if (data[i][0] & 0x02)
414             content += '</i>';
415
416         if (data[i][0] & 0x01)
417             content += '</b>';
418         content += state_add(data[i][0]);
419
420         content += '<br>';
421     }
422     $("table"+table_idx).innerHTML = content;
423 }
424
425 function j_tab_act_cont(idx, act)
426 {
427     if (act == 'sit') {
428         // MLANG 1
429         $("table_act"+idx).innerHTML = '<input type="button" class="button" name="xhenter'+idx+'"  value="'+(g_lang == 'en' ? "Sit down." : "Mi siedo.")+'" onclick="act_sitdown('+idx+');">';
430     }
431     else if (act == 'sitreser') {
432         // <img class="nobo" title="tavolo riservato agli utenti registrati" style="display: inline; margin-right: 80px;" src="img/okauth.png">
433         // MLANG 1
434         $("table_act"+idx).innerHTML = '<input type="button" style="background-repeat: no-repeat; background-position: center; background-image: url(\'img/okauth.png\');" class="button" name="xhenter'+idx+'"  value="'+(g_lang == 'en' ? "Sit down." : "Mi siedo.")+'" onclick="act_sitdown('+idx+');">';
435     }
436     else if (act == 'wake') {
437         // MLANG 1
438         $("table_act"+idx).innerHTML = '<input type="button" class="button" name="xwakeup"  value="'+(g_lang == 'en' ? "Wake up." : "Mi alzo.")+'" onclick="act_wakeup();">';
439     }
440     else if (act == 'reserved') {
441         // MLANG 1
442         $("table_act"+idx).innerHTML = '<img class="nobo" title="'+(g_lang == 'en' ? "reserved table for authenticated users only" : "tavolo riservato agli utenti registrati")+'" style="margin-right: 20px;" src="img/onlyauth.png">';
443     }
444     else {
445         $("table_act"+idx).innerHTML = '';
446     }
447 }
448
449 function j_login_manager(form)
450 {
451     var token;
452
453     if (form.elements['passid'].value == '')
454         return (true);
455
456     else {
457         // console.log("richiesta token");
458         /* richiede token */
459         token = server_request('mesg', 'getchallenge', 'cli_name', encodeURIComponent(form.elements['nameid'].value));
460         tokens = token.split('|');
461         
462         // console.log('XX token: '+token);
463         // console.log(tokens);
464         if (token == null)
465             return (false);
466
467         token = calcMD5(tokens[1]+calcMD5(form.elements['passid'].value));
468         
469         form.elements['passid_private'].value = token;
470         form.elements['passid'].value = ""; // FIXME da sost con la stessa len di A
471
472         return (true);
473     }
474     
475     return (false);
476 }
477
478 function login_formtext_hilite()
479 {
480     formtext_hilite($("nameid"));
481     formtext_hilite($("passid"));
482     formsub_hilite($("sub"));
483 }
484
485 function login_init()
486 {
487     menu_init();
488     login_formtext_hilite();
489 }
490
491 function warrant_formtext_hilite(form)
492 {
493     /*
494     formtext_hilite($("nameid"));
495     formtext_hilite($("emailid"));
496     formsub_hilite($("subid"));
497     formsub_hilite($("cloid"));
498     */
499     formtext_hilite(form.elements['name']);
500     formtext_hilite(form.elements['email']);
501     formsub_hilite(form.elements['sub']);
502     formsub_hilite(form.elements['clo']);
503 }
504
505 function mesgtoadm_formtext_hilite(form)
506 {
507     /*
508     formtext_hilite($("subjid"));
509     formtext_hilite($("mesgid"));
510     formsub_hilite($("subid"));
511     formsub_hilite($("cloid"));
512     */
513     formtext_hilite(form.elements['subj']);
514     formtext_hilite(form.elements['mesg']);
515     formsub_hilite(form.elements['sub']);
516     formsub_hilite(form.elements['clo']);
517 }
518
519
520 function j_check_email(email)
521 {
522     if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
523         return (true);
524     return (false);
525 }
526
527 function j_authbox(form)
528 {
529     var no; 
530
531     do {
532         if (form.elements['realsub'].value == "chiudi") {
533             $('authbox').style.visibility = "hidden";
534             break;
535         }
536
537         if (form.elements['name'].value == '' || j_check_email(form.elements['email'].value) == false) {
538             // MLANG 2-4
539             no = new notify(gst, 
540                             (g_lang == 'en' ? "<br><b>nickname</b> and/or <b>e-mail</b> fields are invalid;<br>please, fix them." :
541                              "<br>I campi <b>nickname</b> e/o <b>e-mail</b> non sono validi;<br> correggeteli per favore."),
542                             1, (g_lang == 'en' ? "close" : "chiudi"), 280, 100); 
543             break;
544         }
545
546         // submit the request
547         token = server_request('mesg', 'warranty', 
548                                'cli_name', encodeURIComponent(form.elements['name'].value),
549                                'cli_email', encodeURIComponent(form.elements['email'].value) );
550         if (token == "1") {
551             $('authbox').style.visibility = "hidden";
552             form.elements['name'].value = "";
553             form.elements['email'].value = "";
554             break;
555         }
556     } while (0);
557
558     return (false);
559 }
560
561 function authbox(w, h)
562 {
563     var box;
564
565     box = $('authbox');
566
567     box.style.zIndex = 200;
568     box.style.width  = w+"px";
569     box.style.marginLeft  = -parseInt(w/2)+"px";
570     box.style.height = h+"px";
571     box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
572
573     warrant_formtext_hilite($('auth_form'));
574
575     box.style.visibility = "visible";
576     $("nameid").focus();
577 }
578
579 function j_mesgtoadmbox(form)
580 {
581     var no; 
582
583     do {
584         if (form.elements['realsub'].value == "chiudi") {
585             $('mesgtoadmbox').style.visibility = "hidden";
586             break;
587         }
588
589         if (form.elements['mesg'].value == '' || form.elements['subj'].value == '') {
590             // MLANG 1-3
591             no = new notify(gst, (g_lang == 'en' ? "<br><b>subject</b> and the <b>message</b> cannot be void;<br>please, fix them." :
592                                   "<br>Il <b>soggetto</b> e il <b>messaggo</b> non possono essere vuoti;<br>correggeteli per favore."), 1, 
593                                   (g_lang == 'en' ? "close" : "chiudi"), 280, 100); 
594             break;
595         }
596                 
597         // submit the request
598         token = server_request('mesg', 'mesgtoadm', 
599                                'cli_subj', encodeURIComponent(form.elements['subj'].value),
600                                'cli_mesg', encodeURIComponent(form.elements['mesg'].value) );
601         if (token == "1") {
602             $('mesgtoadmbox').style.visibility = "hidden";
603             form.elements['subj'].value = "";
604             form.elements['mesg'].value = "";
605             break;
606         }
607     } while (0);
608
609     return (false);
610 }
611
612 function mesgtoadmbox(w, h)
613 {
614     var box;
615
616     box = $('mesgtoadmbox');
617
618     box.style.zIndex = 200;
619     box.style.width  = w+"px";
620     box.style.marginLeft  = -parseInt(w/2)+"px";
621     box.style.height = h+"px";
622     box.style.top = parseInt((document.body.clientHeight - h) / 2) + document.body.scrollTop;
623
624     mesgtoadm_formtext_hilite($('mesgtoadm_form'));
625
626     box.style.visibility = "visible";
627     $('mesgtoadm_form').elements['subj'].focus();
628 }
629
630 function j_pollbox(form)
631 {
632     var no, i, choose; 
633
634     do {
635         // submit the request
636         
637         for (i = 0 ; i < form.elements.length ; i++) {
638             if (form.elements[i].checked == true)
639                 break;
640         }
641         if (i == form.elements.length) {
642             // MLANG 1-3
643             no = new notify(gst, (g_lang == 'en' ? "<br>You must choose ah item;<br> please, fix it." :
644                                   "<br>Non hai espresso nessuna preferenza;<br> correggi per favore."), 1, 
645                             (g_lang == 'en' ? "close" : "chiudi"), 280, 100); 
646             return false;
647         }
648         else
649             choose = form.elements[i].value;
650
651         token = server_request('mesg', 'poll', 
652                                'cli_choose', encodeURIComponent(choose) );
653
654         if (token == "1") {
655             // TODO: mesg to user
656             // $('mesgtoadmbox').style.visibility = "hidden";
657             break;
658         }
659     } while (0);
660
661     return (false);
662 }
663
664
665
666
667 function list_set(what, is_update, info)
668 {
669     // console.log(what);
670     var i;
671     var relo = false;
672     var old_st = readCookie("CO_list");
673     
674     if (what == 'auth') {
675         $('list_auth').style.color = 'red';
676         $('list_isol').style.color = 'black';
677         $('list_all').style.color = 'black';
678         if (old_st == 'isolation')
679             relo = true;
680         g_listen = l_list_auth;
681     }
682     else if (what == 'isolation') {
683         $('list_auth').style.color = 'black';
684         $('list_isol').style.color = 'red';
685         $('list_all').style.color = 'black';
686         if (old_st != 'isolation')
687             relo = true;
688         g_listen = l_list_isol;
689     }
690     else {
691         $('list_auth').style.color = 'black';
692         $('list_isol').style.color = 'black';
693         $('list_all').style.color = 'red';
694         if (old_st == 'isolation')
695             relo = true;
696         g_listen = l_list_all;
697     }
698     $('list_info').innerHTML = info;
699     if (is_update) {
700         createCookie("CO_list", what, 24*365, cookiepath);
701     }
702
703
704     if (relo || !is_update) {
705         for (i = g_tables_auth_n ; i < g_tables_n ; i++) {
706             
707             if (i % 4 == 0) {
708                 $('tr_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
709             }
710             
711             $('td_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
712         }
713         // ricalculation of standup area
714         if (standup_data_old != null) {
715             standup_data = standup_data_old;
716             standup_data_old = null;
717             j_stand_cont(standup_data);
718         }
719     }
720 }
721
722 function sideslide(domobj, height, step)
723 {
724     this.st = 'wait';
725     this.twait = 5000;
726
727     this.domobj = domobj;
728     this.height = height;
729     this.step = step;
730
731     this.start();
732 }
733
734 sideslide.prototype = {
735     id: null,
736     st: 'wait',
737     twait: 0,
738     scroll: 0,
739     countdown: 0,
740
741     domobj: null,
742     height: 0,
743     step: 0,
744
745     start: function() {
746         var instant = this;
747         
748         this.st = 'wait';
749         this.id = setTimeout(function () { instant.sideslide_cb(); }, this.twait);
750     },
751
752     sideslide_cb: function() {
753         var instant = this;
754
755         if (this.st == 'wait') {
756             this.st = 'scroll';
757             this.countdown = 10;
758             this.id = setInterval(function () { instant.sideslide_cb(); }, 100);
759         }
760         else if (this.st == 'scroll') {
761             this.scroll += (this.step / 10);
762             if (this.scroll >= this.height - this.step) {
763                 this.scroll = 0;
764             }
765             this.domobj.scrollTop = this.scroll;
766             this.countdown--;
767             if (this.countdown == 0) {
768                 this.stop();
769                 this.st = 'wait';
770                 this.id = setTimeout(function () { instant.sideslide_cb(); }, this.twait);
771             }
772         }
773     },
774
775
776     stop: function() {
777         if (this.id != null) {
778             clearInterval(this.id);
779             this.id = null;
780         }
781     }
782
783 }