Commit cad8e6ea authored by Jyrki's avatar Jyrki 🐾

slidrrerrs

parent 8449f222
......@@ -56,6 +56,9 @@ updateCounters = ->
$('span#builds-fields').html window.gameVars.fields.count
$('span#builds-cattle').html window.gameVars.cattleGrid.count
# market sliders
$("span[name=market-#{x}-val]").html $("input[name=market-slider][data-type=#{x}]").val() for x in ['wheat', 'livestock', 'fields', 'cattle']
# statistics
$('td#stats-wheat-produced').html window.gameVars.wheat.produced
$('td#stats-wheat-consumed').html window.gameVars.wheat.consumed
......@@ -199,3 +202,11 @@ fitim = window.setInterval fieldTimer, 100
whtim = window.setInterval wheatTimer, 100
$(document).ready -> updateCounters()
marketSliderChange = ->
self = $ this
selector = "span[name=market-#{self[0].dataset.type}-val]"
$(selector).html self.val()
$(document).on "change", "input[name=market-slider]", marketSliderChange
$(document).on "mousemove", "input[name=market-slider]", marketSliderChange
......@@ -118,13 +118,13 @@
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<button class="btn btn-market btn-block btn-success">Buy {n} Wheat</button>
<button class="btn btn-market btn-block btn-success">Buy <span name="market-wheat-val">{n}</span> Wheat</button>
</div>
<div class="col-md-6">
<button class="btn btn-market btn-block btn-danger">Sell {n} Wheat</button>
<button class="btn btn-market btn-block btn-danger">Sell <span name="market-wheat-val">{n}</span> Wheat</button>
</div>
</div>
<input type="range">
<input type="range" name="market-slider" data-type="wheat">
</div>
</div>
<!-- Livestock Panel -->
......@@ -135,13 +135,13 @@
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<button class="btn btn-market btn-block btn-success">Buy {n} Livestock</button>
<button class="btn btn-market btn-block btn-success">Buy <span name="market-livestock-val">{n}</span> Livestock</button>
</div>
<div class="col-md-6">
<button class="btn btn-market btn-block btn-danger">Sell {n} Livestock</button>
<button class="btn btn-market btn-block btn-danger">Sell <span name="market-livestock-val">{n}</span> Livestock</button>
</div>
</div>
<input type="range">
<input type="range" name="market-slider" data-type="livestock">
</div>
</div>
<!-- Fields Panel -->
......@@ -152,13 +152,13 @@
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<button class="btn btn-market btn-block btn-success">Buy {n} Fields</button>
<button class="btn btn-market btn-block btn-success">Buy <span name="market-fields-val">{n}</span> Fields</button>
</div>
<div class="col-md-6">
<button class="btn btn-market btn-block btn-danger">Sell {n} Fields</button>
<button class="btn btn-market btn-block btn-danger">Sell <span name="market-fields-val">{n}</span> Fields</button>
</div>
</div>
<input type="range">
<input type="range" name="market-slider" data-type="fields">
</div>
</div>
<!-- Cattle Grids Panel -->
......@@ -169,13 +169,13 @@
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<button class="btn btn-market btn-block btn-success">Buy {n} Cattle Grids</button>
<button class="btn btn-market btn-block btn-success">Buy <span name="market-cattle-val">{n}</span> Cattle Grids</button>
</div>
<div class="col-md-6">
<button class="btn btn-market btn-block btn-danger">Sell {n} Cattle Grids</button>
<button class="btn btn-market btn-block btn-danger">Sell <span name="market-cattle-val">{n}</span> Cattle Grids</button>
</div>
</div>
<input type="range">
<input type="range" name="market-slider" data-type="cattle">
</div>
</div>
</div>
......
// Generated by CoffeeScript 1.7.1
(function() {
var eventTimer, evtim, fieldTimer, fitim, initItem, updateCounters, warTimer, wheatTimer, whtim;
var eventTimer, evtim, fieldTimer, fitim, initItem, marketSliderChange, updateCounters, warTimer, wheatTimer, whtim;
initItem = function(defaultCount, consumable) {
var retobj;
......@@ -44,6 +44,7 @@
};
updateCounters = function() {
var x, _i, _len, _ref;
$('span#valuables-gold').html(window.gameVars.gold);
$('span#goods-wheat').html(window.gameVars.wheat.count);
$('span#goods-livestock').html(window.gameVars.liveStock.count);
......@@ -53,6 +54,11 @@
$('span#people-all').html(window.gameVars.people.home + window.gameVars.people.war + window.gameVars.people.shelter);
$('span#builds-fields').html(window.gameVars.fields.count);
$('span#builds-cattle').html(window.gameVars.cattleGrid.count);
_ref = ['wheat', 'livestock', 'fields', 'cattle'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
x = _ref[_i];
$("span[name=market-" + x + "-val]").html($("input[name=market-slider][data-type=" + x + "]").val());
}
$('td#stats-wheat-produced').html(window.gameVars.wheat.produced);
$('td#stats-wheat-consumed').html(window.gameVars.wheat.consumed);
$('td#stats-wheat-bought').html(window.gameVars.wheat.bought);
......@@ -217,4 +223,15 @@
return updateCounters();
});
marketSliderChange = function() {
var selector, self;
self = $(this);
selector = "span[name=market-" + self[0].dataset.type + "-val]";
return $(selector).html(self.val());
};
$(document).on("change", "input[name=market-slider]", marketSliderChange);
$(document).on("mousemove", "input[name=market-slider]", marketSliderChange);
}).call(this);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment