]> git.deb.at Git - deb/packages.git/blob - static/packages.js
Merge branch 'archive-master' of git+ssh://git.debian.org/git/webwml/packages into...
[deb/packages.git] / static / packages.js
1
2 function init_toggle_elem(id_str,show_user_str,hide_user_str) {
3         toggle_toggle_elem(id_str,show_user_str,hide_user_str,'hide');
4 }
5
6 function toggle_toggle_elem(id_str,show_user_str,hide_user_str,mode) {
7         var other_mode = ( mode == "hide" ) ? "show" : "hide";
8         var user_str = ( mode == "hide" ) ? show_user_str : hide_user_str;
9         var link = document.createElement("a");
10         link.setAttribute("href","javascript:toggle_toggle_elem(\""+id_str+"\",\""+show_user_str+"\",\""+hide_user_str+"\",\""+other_mode+"\")");
11         var txt = document.createTextNode("["+user_str+"]");
12         link.appendChild(txt);
13         if (document.getElementById("js_"+id_str).childNodes.length > 0) { 
14                 document.getElementById("js_"+id_str).replaceChild(link,document.getElementById("js_"+id_str).firstChild);
15         } else {
16                 document.getElementById("js_"+id_str).appendChild(link);
17         }
18         toggleDisplay(document.getElementById("html_"+id_str));
19 }
20
21 function toggleDisplay(obj) {
22         if (obj.style.display == "none")
23                 obj.style.display = "";
24         else
25                 obj.style.display = "none";
26 }
27
28 function hide_tab(id) {
29         var tab = document.getElementById(id);
30         if (tab) {
31                 tab.style.display = "none";
32         }
33         var item = document.getElementById(id+"link");
34         if (item) {
35                 item.style.fontWeight = "normal";
36         }
37 }
38
39 function show_tab(id) {
40         var tab = document.getElementById(id);
41         if (tab) {
42                 tab.style.display = "";
43         }
44         var item = document.getElementById(id+"link");
45         if (item) {
46                 item.style.fontWeight = "bold";
47         }
48         var item = document.getElementById("palllink");
49         if (item) {
50                 item.style.fontWeight = "normal";
51         }
52 }
53
54 function init_tab_list(id) {
55         hide_tab("pdeps");
56         hide_tab("pdownload");
57         show_tab("pdesctab");
58         show_tab("pbinaries");
59
60         var tablist = document.getElementById(id);
61         if (tablist) {
62                 var list = document.createElement("ul");
63                 if (document.getElementById("pdesctab")) {
64                         var item = document.createElement("li");
65                         item.setAttribute("id","pdesctablink");
66                         var link = document.createElement("a");
67                         link.setAttribute("href","javascript:go_to_tab(\"pdesctab\")");
68                         var txt = document.createTextNode("[ Description ]");
69                         link.appendChild(txt);
70                         item.appendChild(link);
71                         list.appendChild(item);
72                 }
73                 if (document.getElementById("pbinaries")) {
74                         var item = document.createElement("li");
75                         item.setAttribute("id","pbinarieslink");
76                         var link = document.createElement("a");
77                         link.setAttribute("href","javascript:go_to_tab(\"pbinaries\")");
78                         var txt = document.createTextNode("[ Description ]");
79                         link.appendChild(txt);
80                         item.appendChild(link);
81                         list.appendChild(item);
82                 }
83                 if (document.getElementById("pdeps")) {
84                         var item = document.createElement("li");
85                         item.setAttribute("id","pdepslink");
86                         var link = document.createElement("a");
87                         link.setAttribute("href","javascript:go_to_tab(\"pdeps\")");
88                         var txt = document.createTextNode("[ Dependencies ]");
89                         link.appendChild(txt);
90                         item.appendChild(link);
91                         list.appendChild(item);
92                 }
93                 if (document.getElementById("pdownload")) {
94                         var item = document.createElement("li");
95                         item.setAttribute("id","pdownloadlink");
96                         var link = document.createElement("a");
97                         link.setAttribute("href","javascript:go_to_tab(\"pdownload\")");
98                         var txt = document.createTextNode("[ Download ]");
99                         link.appendChild(txt);
100                         item.appendChild(link);
101                         list.appendChild(item);
102                 }
103                 if (list.childNodes.length > 0) {
104                         var item = document.createElement("li");
105                         item.setAttribute("id","palllink");
106                         var link = document.createElement("a");
107                         link.setAttribute("href","javascript:show_all_tabs()");
108                         var txt = document.createTextNode("[ All ]");
109                         link.appendChild(txt);
110                         item.appendChild(link);
111                         list.appendChild(item);
112                         
113                 }
114                 tablist.appendChild(list);
115         }
116         show_tab("pdesctab");
117         show_tab("pbinaries");
118 }
119
120 function go_to_tab(id) {
121         if (id == "pdeps") {
122                 hide_tab("pdesctab");
123                 hide_tab("pbinaries");
124                 hide_tab("pdownload");
125                 show_tab("pdeps");
126         }
127         if (id == "pdesctab" || id == "pbinaries") {
128                 hide_tab("pdeps");
129                 hide_tab("pdownload");
130                 show_tab("pdesctab");
131                 show_tab("pbinaries");
132         }
133         if (id == "pdownload") {
134                 hide_tab("pdesctab");
135                 hide_tab("pbinaries");
136                 hide_tab("pdeps");
137                 show_tab("pdownload");
138         }
139 }
140
141 function show_all_tabs() {
142         show_tab("pdesctab");
143         show_tab("pbinaries");
144         show_tab("pdeps");
145         show_tab("pdownload");
146         var item = document.getElementById("palllink");
147         if (item) {
148                 item.style.fontWeight = "bold";
149         }
150 }