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