Fixed gnome-vfs http: GLib-ERROR **: The thread system is not yet initialized.
[www.jankratochvil.net.git] / project / captive / DriverSurvey.js
1 /* $Id$
2  * Captive MS-Windows Driver Survey helper.
3  * Copyright (C) 2005 Jan Kratochvil <project-www.jankratochvil.net@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 // Double-run protection due to the My::Web "text/javascript" compatibility hack.
21 if (!window.var_project_captive_DriverSurvey_done) {
22         var var_project_captive_DriverSurvey_done=1;
23
24 function DriverSurvey_validate(form)
25 {
26         var e_kinds_array=form.elements["kind"];
27         var checked=0;
28         for (var kindi=0;kindi<e_kinds_array.length;kindi++)
29                 if (e_kinds_array[kindi].checked)
30                         checked++;
31         if (1!=checked) {
32                 // FIXME: Unify with: project::captive::DriverSurvey
33                 alert("Please check the appropriate leftmost checkmark.");
34                 return false;
35                 }
36         return true;
37 }
38
39 function DriverSurvey_error_check()
40 {
41         var e_error=document.getElementById("error");
42         if (e_error && e_error.textContent)
43                 alert(e_error.textContent);
44 }
45
46 function DriverSurvey_error_check_delayed()
47 {
48         // HACK: 0ms - wait for 'css_inherit.js' finalization.
49         setTimeout('DriverSurvey_error_check();',0);
50 }
51
52 function display(name,state)
53 {
54         var e=document.getElementById(name);
55         if (e)
56                 e.style.display=(state ? "table-row" : "none");
57         return e;
58 }
59
60 var products_shown;
61
62 function display_product(producti,state)
63 {
64         for (var rowi=0;display("product"+producti+"_row"+rowi,state);rowi++);
65         return !!rowi;
66 }
67
68 function DriverSurvey_init()
69 {
70         DriverSurvey_error_check_delayed();
71         display("product0_row0",0);
72         display_product("next",1);
73         products_shown=1;
74         for (var producti=products_shown;display_product(producti+0);producti++);
75 }
76
77 function Survey_productnext(form)
78 {
79         display("product0_row0",1);
80         display_product(products_shown++,1);
81         if (!display_product(products_shown,0))
82                 display_product("next",0);
83         return false;
84 }
85
86 function click_on(id)
87 {
88         var e;
89         if (document.getElementById)
90                 e=document.getElementById(id);
91         if (e)
92                 e.click();
93 }
94
95 /* Origin: http://simon.incutio.com/archive/2004/05/26/addLoadEvent */
96 function addLoadEvent(func)
97 {
98         var onload_orig=window.onload;
99         if (typeof(onload_orig)!='function')
100                 window.onload = func;
101         else
102                 window.onload = function()
103                 {
104                         onload_orig();
105                         func();
106                 };
107 }
108
109 if (document.getElementById)
110         addLoadEvent(DriverSurvey_init);
111
112 }