summaryrefslogtreecommitdiff
path: root/bug/query.pl
blob: 4fff9bbbf07daa52eb29b48a88fea85659e1ea01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

#
#     Copyright (C) 2011 Loic Dachary <loic@dachary.org>
#
#     This program is free software: you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
#
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with this program.  If not, see <http:www.gnu.org/licenses/>.
#

use Scalar::Util qw(looks_like_number);

while(<STDIN>) {
    eval $_ if(s/(cpts|vers)\[(\d+)\]\s+=/\$$1\[$2\]=/);
    if(/<select\s+name="product"/../<\/select/) {
        if(/libreoffice/i) {
            $libreoffice = $count;
        }
	if(/<select\s+name="product"/) {
	    $count = 0;
	} elsif(/<option/) {
	    $count++;
	}
    }
}

print "<?xml version='1.0' encoding='ISO-8859-1'?>\n";

@versions = sort { 
    if (looks_like_number(substr($a, 0, 1)) == 0) { 
        return 1;
    } elsif (looks_like_number(substr($b, 0, 1)) == 0) {
        return -1;
    } else {
        return lc($b) cmp lc($a);
    } } @{$vers[$libreoffice]};
print <<EOF;
            <div class="select-header">
              <div class="chosen">(chose one)</div>
            </div>
            <div class="choices">
              <div class="select-top">
                <div class="select-left">
                  <div class="select-bottom">
                    <div class="select-right">
                      <div class="top-left"></div>
                      <div class="top-right"></div>
                      <div class="bottom-left"></div>
                      <div class="bottom-right"></div>
                      <div class="center">
                        <ul>
EOF
    print " <li class='choice' data='NONE' idvalue='-1'>None</li>\n";
    for($count = 0; $count < @versions; $count++) {
        print " <li class='choice' data='$versions[$count]' idvalue='$count'>$versions[$count]</li>\n";
    }
    print <<EOF;
                        </ul>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
EOF