feedbrowser: convert custom AJAX to jQuery AJAX, this makes it work in IE6
[angstrom:feedbrowser.git] / scripts / js / repo.js
1 /* feed.js
2 (c) Koen Kooi 2009-2010
3 Licensed under the GPLv2
4 */
5
6 var qsParm = new Array();
7 qsParm['pkgsearch'] = null;
8 qsParm['arch'] = null;
9 qsParm['section'] = null;
10 qsParm['pkgname'] = null;
11
12
13 function qs() {
14         var query = window.location.search.substring(1);
15         var parms = query.split('&');
16         for (var i=0; i<parms.length; i++) {
17                 var pos = parms[i].indexOf('=');
18                 if (pos > 0) {
19                         var key = parms[i].substring(0,pos);
20                         var val = parms[i].substring(pos+1);
21                         qsParm[key] = val;
22                 }
23         }
24         if (qsParm['pkgsearch']) {
25                 document.getElementById('pkgsearch').value = qsParm['pkgsearch'];
26                 pkgQuery();
27         }
28         if (qsParm['pkgname']) {
29                 document.getElementById('pkgsearch').value = qsParm['pkgname'];
30                 pkgQuery();
31         }
32         if (qsParm['section']) {
33                 pkgQuery();
34         }
35         
36 }
37
38 function pkgQuery() {
39         var action = 'pkgquery';
40         var params = '';
41         
42         if (qsParm['pkgname']) {
43                 action = 'pkgname';
44                 params = '&pkgname=' + qsParm['pkgname'];
45                 qsParm['pkgname'] = null;
46         } 
47         
48         if (document.getElementById('pkgsearch').value != "") {
49                 params = params + '&pkgsearch=' + document.getElementById('pkgsearch').value;
50         } else {
51                 if (qsParm['pkgsearch']) {
52                         params = params + '&pkgsearch=' + qsParm['pkgsearch'];
53                 }
54         }
55         if (qsParm['arch']) {
56                 params = params + '&arch=' + qsParm['arch'];
57                 qsParm['arch'] = null;
58         }
59         if (qsParm['section']) {
60                 action = 'section';
61                 params = params + '&section=' + qsParm['section'];
62                 qsParm['section'] = null;
63         }
64         
65         params = '&action=' + action + params;
66         document.getElementById('opkgoutput').innerHTML = "loading, please wait";       
67         $.ajax({
68            type: "POST",
69            url: 'section.php',
70            data: params,
71            success: function(msg){
72                 document.getElementById('opkgoutput').innerHTML = msg;
73            }
74          });    
75 }
76
77 function getLetter() {
78         var params = 'action=searchletter';
79         $.ajax({
80            type: "POST",
81            url: 'section.php',
82            data: params,
83            success: function(msg){
84                 document.getElementById('searchletter').innerHTML = msg;
85            }
86          });
87
88
89 function getSection() {
90         var params = 'action=sectionslist';
91         $.ajax({
92            type: "POST",
93            url: 'section.php',
94            data: params,
95            success: function(msg){
96                 document.getElementById('sectionslist').innerHTML = msg;
97            }
98          }); 
99
100
101
102 function toggleVisibility(elementId) {
103         var elementObj = document.getElementById(elementId);
104         if (elementObj.style.display == '') {
105                 elementObj.style.display = 'none';
106         }
107         else {
108                 elementObj.style.display = '';
109         }
110 }
111