Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mineralwasserauswahl als Drop-Down-Liste implementiert #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions src/data/mineralwaesser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tw.data.referenceWaters = {
"wueteria": {
"Wüteria": {
"natrium": 10.7,
"kalium": 2.6,
"calcium": 118,
Expand All @@ -9,7 +9,7 @@ tw.data.referenceWaters = {
"sulfat": 68,
"sources": ["http://www.wueteria.de/unser_wasser/index.php"]
},
"teusser": {
"Teusser": {
"natrium": 53,
"kalium": 8,
"calcium": 565,
Expand All @@ -19,7 +19,7 @@ tw.data.referenceWaters = {
"sulfat": 1450,
"sources": ["http://www.teusser.de/index.php?id=225"]
},
"volvic": {
"Volvic": {
"natrium": 11.6,
"kalium": 6.2,
"calcium": 11.5,
Expand All @@ -29,7 +29,7 @@ tw.data.referenceWaters = {
"sulfat": 8.1,
"sources": ["http://books.google.de/books?id=lzEoGWyqMBwC&pg=PA198&lpg=PA198&dq=volvic+nitratgehalt&source=bl&ots=pJEE0i9HwK&sig=OI_PeSr_QGBCfpeVCu70N4ohy8g&hl=de&ei=4-yvSuHrJ8jK_gbV0p3ZDA&sa=X&oi=book_result&ct=result&resnum=6#v=onepage&q&f=false"]
},
"vittel": {
"Vittel": {
"natrium": 7.7,
"kalium": 5.2,
"calcium": 94,
Expand All @@ -38,7 +38,36 @@ tw.data.referenceWaters = {
"nitrat": 0.1,
"sulfat": 120,
"sources": ["http://books.google.de/books?id=lzEoGWyqMBwC&pg=PA198&lpg=PA198&dq=volvic+nitratgehalt&source=bl&ots=pJEE0i9HwK&sig=OI_PeSr_QGBCfpeVCu70N4ohy8g&hl=de&ei=4-yvSuHrJ8jK_gbV0p3ZDA&sa=X&oi=book_result&ct=result&resnum=6#v=onepage&q&f=false"]
}
},
"Krumbach Classic": {
"natrium": 9.1,
"kalium": 2.3,
"calcium": 87,
"magnesium": 23.3,
"chlorid": 6.4,
"nitrat": 0.3,
"sulfat": 19,
"sources": ["http://www.krumbach-mineralwasser.de/sortiment-sanfter-geschmack-hat-viele-sorten1.html?pid=31&id=sort_classic"]
},
"Krumbach Medium": {
"natrium": 9.1,
"kalium": 2.3,
"calcium": 87,
"magnesium": 23.3,
"chlorid": 6.4,
"nitrat": 0.3,
"sulfat": 19,
"sources": ["http://www.krumbach-mineralwasser.de/sortiment-sanfter-geschmack-hat-viele-sorten1.html?pid=31&id=sort_classic"]
},
"Apollinaris Selection": {
"natrium": 0.47,
"kalium": 0.03,
"calcium": 0.09,
"magnesium": 0.12,
"chlorid": 0.13,
"sulfat": 0.1,
"sources": ["http://www.apollinaris.de/de_de/#/produkte/gastronomie/selektion"]
},
};

tw.data.nutrientDailyDosis = {
Expand Down
19 changes: 12 additions & 7 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,21 @@ <h1 style="display:none">Was steckt in meinem Leitungswasser?</h1>
</div>

<div class="section section-compare" style="display:none;margin-top:-32px;">

<div class="row">
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-12 compare-nav">
<button type="button" class="btn btn-primary btn-lg btn-block active" data-water="volvic">Volvic</button>
<button type="button" class="btn btn-primary btn-lg btn-block" data-water="wueteria">Wüteria Heiligenquelle</button>
<button type="button" class="btn btn-primary btn-lg btn-block" data-water="teusser">Teusser Naturell</button>
<button type="button" class="btn btn-primary btn-lg btn-block" data-water="vittel">Vittel</button>
<button type="button" class="btn btn-primary btn-lg btn-block" data-water="self" style="margin-top:2em;">mein Leitungswasser</button>
<p>Wählen Sie ein Mineralwasser aus der Liste aus und vergleichen Sie es mit den Werten von Ihrem Leitungswasser.</p>

<form class="form-horizontal form-choose-water" role="form">
<div class="form-group select-water">
<label for="water" class="col-sm-4 control-label">Mineralwasser</label>
<div class="col-sm-8">
<select id="water" class="water form-control">
<option value="Volvic">Volvic</option>
</select>
</div>
</div>
</form>
<p><br /></p>
</div>
<div class="col-lg-7 col-md-7 col-sm-7 col-xs-12">
Expand Down Expand Up @@ -372,8 +379,6 @@ <h1 style="display:none">Was steckt in meinem Leitungswasser?</h1>
<p><br /></p>
<p><br /></p>
<p><button type="button" class="btn btn-warning switch-to-section" data-section="explanation"><span class="glyphicon glyphicon-chevron-left"></span> Zurück</button></p>
<p><br /></p>
<p><small>Beispielhaft wurden zwei überregional bekannte Wasser sowie zwei Wasser aus dem Landkreis Heilbronn ausgewählt. Alle vier sind stille Mineralwasser.</small></p>
</div>

<div class="section section-map" style="display:none;">
Expand Down
8 changes: 8 additions & 0 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ var tw = {
$('.city').html(generateOptionsHtml(cities, true));
};

var setupCompareForm = function() {
var waters = Object.keys(tw.data.referenceWaters);
waters.sort();

$('.water').html(generateOptionsHtml(waters));
};

var updateSection = function() {
$('.section').hide();
$('.section-' + section).show();
Expand Down Expand Up @@ -245,6 +252,7 @@ var tw = {
completeReferenceWaters();
setupForm();
setupQuickForm();
setupCompareForm();
setupTabs('natrium');
setupSectionSwitch();
tw.gauge.init();
Expand Down
18 changes: 7 additions & 11 deletions src/js/comparison.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,12 @@
};

var bottleInstance = null;
var referenceWater = 'volvic';
var valueLabel = 'Volvic';
var referenceWater = 'Vittel';
var attribute = null;
var selfValue = null;

var getValue = function() {
return (referenceWater === 'self') ? selfValue : tw.data.referenceWaters[referenceWater][attribute];
return tw.data.referenceWaters[referenceWater][attribute];
};

var getUnit = function() {
Expand All @@ -132,7 +131,7 @@

var updateDescription = function() {
d3.selectAll('.comparison-water-value').text(formatValue(tw.utils.getMeanValue(getValue())) + ' ' + getUnit());
d3.selectAll('.comparison-water-label').text(valueLabel);
d3.selectAll('.comparison-water-label').text(referenceWater);
};

var update = function(newAttribute, value) {
Expand All @@ -151,20 +150,17 @@
};

var updateReferenceWater = function() {
d3.select('.compare-nav').selectAll('button').classed('active', false);

var currentElement = d3.select(this);
currentElement.classed('active', true);
referenceWater = currentElement.attr('data-water');
valueLabel = currentElement.text();
referenceWater = $('#water option:selected').text();

updateDescription();
bottleInstance.applyValue(getValue());
};

var init = function() {
bottleInstance = new Bottle(d3.select('.bottle-img'));
d3.select('.compare-nav').selectAll('button').on('click', updateReferenceWater);
$('#water').on('change', updateReferenceWater);
$("#water option[value='" + referenceWater + "']").attr('selected', true);

return this;
};

Expand Down