r1328: - Add jQuery to the entire system
[bugdar.git] / templates / global.js
1 /*=====================================================================*\
2 || ###################################################################
3 || # Bugdar [#]version[#]
4 || # Copyright ©2002-[#]year[#] Blue Static
5 || #
6 || # This program is free software; you can redistribute it and/or modify
7 || # it under the terms of the GNU General Public License as published by
8 || # the Free Software Foundation; version [#]gpl[#] of the License.
9 || #
10 || # This program is distributed in the hope that it will be useful, but
11 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 || # more details.
14 || #
15 || # You should have received a copy of the GNU General Public License along
16 || # with this program; if not, write to the Free Software Foundation, Inc.,
17 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18 || ###################################################################
19 \*=====================================================================*/
20
21 var firstRun = true;
22
23 function draw_cancel(location)
24 {
25 location = (location == "" ? "history.back(1)" : "window.location=\"" + location + "\"");
26 document.write("<input name=\"cancel\" type=\"button\" value=\"" + lang["Cancel"] + "\" onclick=\"" + location + "\" />");
27 }
28
29 function setup_report(prod, comp, vers)
30 {
31 var hasProduct = ((prod + 0) > 0);
32 var target = $("#pcv-select");
33
34 $.get(
35 "productselect.php",
36 { "do": "pcvajax", "product": prod, "piece": "product" },
37 function(result)
38 {
39 target.html(" <select name=\"product\" id=\"pcv-product\" onchange=\"change_pcv(" + (!hasProduct) + ", true)\">" + result + "</select> ");
40 if (hasProduct)
41 {
42 setup_report_component(prod, comp, vers);
43 }
44 }
45 );
46 }
47
48 function setup_report_component(prod, comp, vers)
49 {
50 var target = $("#pcv-select");
51
52 $.get(
53 "productselect.php",
54 { "do": "pcvajax", "product": prod, "component": comp, "piece": "component" },
55 function(result)
56 {
57 if (result != "")
58 {
59 if (firstRun)
60 {
61 target.html(target.html() + " <select name=\"component\" id=\"pcv-component\" onchange=\"change_pcv(false, false)\">" + result + "</select> ");
62 }
63 else
64 {
65 $("#pcv-component").html(result);
66 }
67 }
68 setup_report_version(prod, comp, vers);
69 }
70 );
71 }
72
73 function setup_report_version(prod, comp, vers)
74 {
75 var target = $("#pcv-select");
76
77 $.get(
78 "productselect.php",
79 { "do": "pcvajax", "product": prod, "component": comp, "version": vers, "piece": "version" },
80 function(result)
81 {
82 if (firstRun)
83 {
84 target.html(target.html() + " <select name=\"version\" id=\"pcv-version\">" + result + "</select> ");
85 }
86 else
87 {
88 $("#pcv-version").html(result);
89 }
90 firstRun = false;
91 }
92 );
93 }
94
95 function change_pcv(doProducts, doComponents)
96 {
97 if (doProducts)
98 {
99 setup_report($("#pcv-product").val(), $("#pcv-component").val(), $("#pcv-version").val());
100 }
101 else if (doComponents)
102 {
103 setup_report_component($("#pcv-product").val(), $("#pcv-component").val(), $("#pcv-version").val());
104 }
105 else
106 {
107 setup_report_version($("#pcv-product").val(), $("#pcv-component").val(), $("#pcv-version").val());
108 }
109 }
110
111 /*=====================================================================*\
112 || ###################################################################
113 || # $HeadURL$
114 || # $Id$
115 || ###################################################################
116 \*=====================================================================*/