forked from cyberfox/jbidwatcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auctionTransform.xsl
171 lines (165 loc) · 7.94 KB
/
auctionTransform.xsl
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE stylesheet [
<!ENTITY space "<xsl:text> </xsl:text>">
<!ENTITY bidColor "">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:jxf="com.jbidwatcher.auction.AuctionTransformer">
<xsl:output method="html" indent="yes" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>
<xsl:template name="textify" match="/">
<xsl:for-each select="jbidwatcher/auctions/server/auction">
Title: <b><xsl:value-of select="./info/title"/></b>
</xsl:for-each>
</xsl:template>
<xsl:template match="/">
<html>
<head>
<title>Auction List</title>
<link rel="shortcut icon" href="/favicon.ico"/>
<style>
.winner { color: green }
.notwinner { color: red }
.unbid { color: black }
.row0 { background-color: #CFCFCF }
.row1 { background-color: #EFEFEF }
td { border-style: hidden; }
th { font-size: small; }
</style>
<script>
function resetRows() {
toggle = 0;
rows=document.getElementsByTagName('tr');
for(i in rows) {
row=rows[i];
if(row) {
if(row.style) row.style.display='table-row';
if(row.className && row.className != '') {
do_toggle(Math.floor(toggle / 2), row);
toggle = (toggle +1) % 4;
}
}
}
}
function do_toggle(toggle, row) {
row.className = row.className.replace('row0 ', '').replace('row1 ', '');
row.className = 'row' + toggle + ' ' + row.className;
}
function onlyRows(classname) {
toggle = 2;
rows=document.getElementsByTagName('tr');
for(i in rows) {
row=rows[i];
if(row.className && row.className != '') {
if(!row.className.match(classname)) {
row.style.display='none';
} else {
do_toggle(Math.floor(toggle / 2), row);
toggle = (toggle +1) % 4;
}
}
}
};
function categories() {
cats = new Array();
rows = document.getElementsByTagName('tr');
for(i in rows) {
row = rows[i];
if(row.className && row.className != '') {
cn = row.className.replace('row0 ', '').replace('row1 ', '');
if(cn && cn != '' && cats[cn] != 1) {
cats[cn] = 1;
}
}
}
return cats;
};
function fillSelect() {
c = categories();
select = document.getElementById('tabselect');
for(i in c) add_select_val(select, i);
};
function add_select_val(select_elm, val){
var option = document.createElement('option');
option.setAttribute('value', val);
option.innerHTML = val;
select_elm.appendChild(option);
};
</script>
</head>
<body>
<div style="padding-bottom: 3px;">
<form name="Add Auction" action="./addAuction" method="GET" style="display: inline;">
<label for="id">Auction Id:</label><input name="id" size="20" value=""/><input type="submit" name="action" value="Add Auction" onClick=""/>
</form> |
<form style="display: inline;">Select Tab to View: <select name="tab" id="tabselect" onchange="resetRows(); if(this.value != 'all') onlyRows(this.value);"><option value="all">All</option></select></form>
</div>
<table border="1" cellpadding="0" cellspacing="0" width="100%" bgcolor="#CCCCFF">
<tr>
<font size="2">
<th align="center" width="10%">Item</th>
<th align="center" width="10%">Start Price</th>
<th align="center" width="11%">Current Price</th>
<th align="center" width="11%">My Max/Snipe Bid</th>
<th align="center" width="8%"># of Bids</th>
<th align="center" width="11%">Start Date</th>
<th align="center" width="18%"><strong>End Date PDT</strong></th>
<th align="center" width="9%">Time Left</th>
</font>
</tr>
<xsl:for-each select="jbidwatcher/auctions/server/auction">
<xsl:variable name="rowclass"><xsl:value-of select="position() mod 2"/></xsl:variable>
<xsl:variable name="curid"><xsl:value-of select="@id"/></xsl:variable>
<xsl:variable name="category"><xsl:value-of select="category"/></xsl:variable>
<tr class="row{$rowclass} {$category}">
<td width="100%" colspan="8">
<font size="3"><strong><a href="/{$curid}"><xsl:value-of select="info/title"/></a></strong></font>
</td>
</tr>
<tr class="row{$rowclass} {$category}" style="font-size: small">
<xsl:variable name="item_class">
<xsl:choose>
<xsl:when test="info/highbidder = ../../server/@user">winner</xsl:when>
<xsl:when test='info/bidcount = 0'>unbid</xsl:when>
<xsl:otherwise>notwinner</xsl:otherwise>
</xsl:choose></xsl:variable>
<td width="10%" align="center" class="{$item_class}"><xsl:value-of select="@id"/></td>
<td width="10%" align="right" class="{$item_class}"><xsl:value-of select="info/minimum/@currency"/>&space;<xsl:value-of select="info/minimum/@price"/></td>
<td width="11%" align="right" class="{$item_class}"><xsl:value-of select="info/currently/@currency"/>&space;<xsl:value-of select="info/currently/@price"/></td>
<td width="11%" align="right" class="{$item_class}">
<xsl:choose>
<xsl:when test="snipe">
Snipe: <xsl:value-of select="snipe/@quantity"/> @ <xsl:value-of select="snipe/@currency"/>&space;<xsl:value-of select="snipe/@price"/>
</xsl:when>
<xsl:when test="bid">
<xsl:value-of select="bid/@quantity"/> @ <xsl:value-of select="bid/@currency"/>&space;<xsl:value-of select="bid/@price"/>
</xsl:when>
<xsl:otherwise>--</xsl:otherwise>
</xsl:choose>
</td>
<td width="8%" align="center" class="{$item_class}"><xsl:choose><xsl:when test="info/fixed">(FP)</xsl:when><xsl:otherwise><xsl:value-of select="info/bidcount"/></xsl:otherwise></xsl:choose></td>
<td width="11%" align="center" class="{$item_class}">
<xsl:variable name="curdate"><xsl:value-of select="info/start"/></xsl:variable>
<xsl:value-of select="jxf:formatDate($curdate)"/>
</td>
<td width="18%" align="center" class="{$item_class}">
<xsl:variable name="curdate"><xsl:value-of select="info/end"/></xsl:variable>
<xsl:value-of select="jxf:formatDate($curdate)"/>
</td>
<td width="9%" align="center" class="{$item_class}">
<xsl:choose>
<xsl:when test="complete">Auction Ended</xsl:when>
<xsl:otherwise>
<xsl:variable name="thisid"><xsl:value-of select="@id"/></xsl:variable>
<a href="snipe?id={$thisid}"><xsl:value-of select="jxf:getTimeLeft($thisid)"/></a>
</xsl:otherwise>
</xsl:choose>
</td>
<xsl:text>
</xsl:text>
</tr>
</xsl:for-each>
</table>
<script type="text/javascript">fillSelect();</script>
</body>
</html>
</xsl:template>
</xsl:stylesheet>