+ #{showDateTime $ orderIssued $ o}
+ | #{name}
+ | #{prettyISK $ orderPriceCents o}
+ | #{orderVolRemaining o}/#{orderVolEntered o} (#{orderMinVolume o})
+ | #{prettyISK $ orderVolRemaining o * orderPriceCents o}
+ | #{prettyRange $ orderRange o}
+ | #{orderDuration o}
+ | #{prettyISK $ orderEscrowCents o}
+ | #{stationname}
+ |
+ Total
+ |
+ |
+ |
+ | #{prettyISK $ sellsum}
+ |
+ |
+ | #{prettyISK $ sellescrow}
+ |
- Current Buy Orders:
-
-
- Last changed
- | Item
- | Price
- | Quantity (min)
- | Range
- | Duration
- | Escrow
- | Station
- $forall (Entity _ o, Single name) <- buyorders
+ Current Buy Orders:
+
- #{showDateTime $ orderIssued $ o}
- | #{name}
- | #{prettyISK $ orderPriceCents o}
- | #{orderVolRemaining o}/#{orderVolEntered o} (#{orderMinVolume o})
- | Range
- | #{orderDuration o}
- | #{prettyISK $ orderEscrowCents o}
- | StationName
+ | Last changed
+ | Item
+ | Price
+ | Quantity (min)
+ | Value
+ | Range
+ | Duration
+ | Escrow
+ | Station
+ $forall (Entity _ o, Single name, Single stationname, Single regionid) <- buyorders
+ |
+ #{showDateTime $ orderIssued $ o}
+ | #{name}
+ | #{prettyISK $ orderPriceCents o}
+ | #{orderVolRemaining o}/#{orderVolEntered o} (#{orderMinVolume o})
+ | #{prettyISK $ orderPriceCents o * orderVolRemaining o}
+ | #{prettyRange $ orderRange o}
+ | #{orderDuration o}
+ | #{prettyISK $ orderEscrowCents o}
+ | #{stationname}
+ |
+ Total
+ |
+ |
+ |
+ | #{prettyISK $ buysum}
+ |
+ |
+ | #{prettyISK $ buyescrow}
+ |
|]
)
+
+sumOrders :: Int64 -> Entity Order -> Int64
+sumOrders s (Entity _ o) = s + orderPriceCents o * orderVolRemaining o
+
+sumEscrow :: Int64 -> Entity Order -> Int64
+sumEscrow s (Entity _ o) = s + orderEscrowCents o
+
+prettyRange :: Int32 -> String
+prettyRange = show . (toEnum :: Int -> MO.Range) . fromIntegral
diff --git a/Import.hs b/Import.hs
index b71baae..2f362fe 100644
--- a/Import.hs
+++ b/Import.hs
@@ -61,6 +61,7 @@ loginLayout user widget = do
addStylesheet $ StaticR css_neat_css
addScript $ StaticR js_jquery_js
addScript $ StaticR js_bootstrap_js
+ addScript $ StaticR js_neat_js
$(widgetFile "default-layout")
withUrlRenderer $(hamletFile "templates/login-layout-wrapper.hamlet")
diff --git a/static/css/neat.css b/static/css/neat.css
index 07bd08c..1bed530 100644
--- a/static/css/neat.css
+++ b/static/css/neat.css
@@ -14,6 +14,14 @@
background-color: #ffcccc;
}
+.outbid {
+ background-color: #ffcccc;
+}
+
+.not_outbid {
+ background-color: #33cc33;
+}
+
.profit {
background-color: #88ff88;
}
diff --git a/static/js/neat.js b/static/js/neat.js
new file mode 100644
index 0000000..a6bafd0
--- /dev/null
+++ b/static/js/neat.js
@@ -0,0 +1,69 @@
+/*
+neat utility functions
+*/
+
+Number.prototype.formatMoney = function(c, d, t) {
+var n = this,
+ c = isNaN(c = Math.abs(c)) ? 2 : c,
+ d = d == undefined ? "." : t,
+ t = t == undefined ? "," : d,
+ s = n < 0 ? "-" : "",
+ i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
+ j = (j = i.length) > 3 ? j % 3 : 0;
+ return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
+};
+
+
+function checkOrders() {
+ $('table.sellOrders tr.order').each(function(ix,el) {
+ var d = $(el).attr('data').split(';');
+ $.getJSON("https://public-crest.eveonline.com/market/"+d[1]+"/orders/sell/?type=https://public-crest.eveonline.com/types/"+d[0]+"/",function(ret, status, xhr) {
+ var outbid = false;
+ var outbidprice = parseFloat(d[2])/100;
+ $(ret.items).each(function(index,order) {
+ if (order.price < parseFloat(d[2])/100) {
+ outbid = true;
+ if (order.price < outbidprice) {
+ outbidprice = order.price;
+ }
+ }
+ });
+ if (outbid) {
+ $(el).addClass('outbid');
+ var priceel = $(el).find('.price');
+ priceel.html(function(index, old) {
+ return old + " " + outbidprice.formatMoney(2);
+ });
+ } else {
+ $(el).addClass('not_outbid');
+ }
+ });
+ });
+
+ $('table.buyOrders tr.order').each(function(ix,el) {
+ var d = $(el).attr('data').split(';');
+ $.getJSON("https://public-crest.eveonline.com/market/"+d[1]+"/orders/buy/?type=https://public-crest.eveonline.com/types/"+d[0]+"/",function(ret, status, xhr) {
+ var outbid = false;
+ var outbidprice = parseFloat(d[2])/100;
+ $(ret.items).each(function(index,order) {
+ if (order.price > parseFloat(d[2])/100) {
+ outbid = true;
+ if (order.price > outbidprice) {
+ outbidprice = order.price;
+ }
+ }
+ });
+ if (outbid) {
+ $(el).addClass('outbid');
+ var priceel = $(el).find('.price');
+ priceel.html(function(index, old) {
+ return old + " " + outbidprice.formatMoney(2);
+ });
+ } else {
+ $(el).addClass('not_outbid');
+ }
+ });
+ });
+
+}
+
| | |