Skip to content

Commit

Permalink
bug fixing in sort algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
tursics committed Mar 14, 2017
1 parent 33671ba commit 15c73e0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
8 changes: 5 additions & 3 deletions karte-2016-2017.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,18 @@ <h3>Wie kaputt ist Ihre Schule?</h3>
<th data-priority="5">Schulnummer</th>
<th>Schule</th>
<th data-priority="3">Gebäude</th>
<th>Preis 2016</th>
<th>Kosten 2016</th>
<th data-priority="3">Prio 2016</th>
<th>Preis 2017</th>
<th>Kosten 2017</th>
<th data-priority="3">Programm</th>
<th>Summe</th>
</tr>
</thead>
<tbody>
<tr></tr>
</tbody>
</table>
<a href="#pageMap" class="ui-btn ui-btn-inline ui-btn-b carat-l ui-btn-icon-left ui-nodisc-icon" data-rel="back">Zurück zur Karte</a>
<a href="#pageMap" class="ui-btn ui-btn-inline ui-btn-b carat-l ui-btn-icon-left ui-nodisc-icon">Zurück zur Karte</a>
</div>
</div>
</body>
Expand Down
26 changes: 23 additions & 3 deletions karte-2016-2017.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,18 @@ function createMarker(data) {
}
}
}
$('#dataTable tr:last').after('<tr' + (bg ? ' style="background:#cdf;"' : '') + '><td>' + val.Schulnummer + '</td><td>' + val.Schulname + '</td><td>' + val.Bauwerk + '</td><td style="text-align:right;">' + formatNumber(val.GebaeudeGesamt) + '</td><td>' + val.PrioritaetGesamt + '</td><td style="text-align:right;">' + kosten + '</td></tr>');
$('#dataTable tr:last').after('<tr' + (bg ? ' style="background:#cdf;"' : '') + '><td>' + val.Schulnummer + '</td><td>' + val.Schulname + '</td><td>' + val.Bauwerk + '</td><td style="text-align:right;">' + formatNumber(val.GebaeudeGesamt) + '</td><td>' + val.PrioritaetGesamt + '</td><td style="text-align:right;">' + kosten + '</td><td></td><td></td></tr>');

for (id in budget) {
item = budget[id];
if (item.Gebaeudenummer === val.Gebaeudenummer) {
kosten = parseFloat(String(item.Kostenansatz).replace('.', '').replace('.', '').replace(',', '.'));
if (isNaN(kosten)) {
kosten = 0;
}
$('#dataTable tr:last').after('<tr' + (bg ? ' style="background:#cdf;"' : '') + '><td>' + val.Schulnummer + '</td><td><i class="fa fa-sign-out" aria-hidden="true"></i> ' + item.Beschreibung + '</td><td>' + val.Bauwerk + '</td><td></td><td></td><td></td><td>' + item.Programm + '</td><td style="text-align:right;">' + formatNumber(kosten) + '</td></tr>');
}
}
}
});
} catch (e) {
Expand Down Expand Up @@ -686,10 +697,10 @@ function initMap(elementName, lat, lng, zoom) {
data = enrichMissingData(data);
data.sort(function (a, b) {
if ((a.Schulnummer.length === 5) && (b.Schulnummer.length !== 5)) {
return false;
return -1;
}
if ((a.Schulnummer.length !== 5) && (b.Schulnummer.length === 5)) {
return true;
return 1;
}
if ((a.Schulnummer.length !== 5) && (b.Schulnummer.length !== 5)) {
return a.Schulnummer > b.Schulnummer ? 1 : -1;
Expand Down Expand Up @@ -758,6 +769,15 @@ $(document).on("pageshow", "#pageMap", function () {

// -----------------------------------------------------------------------------

$(document).on("pageshow", "#pageTable", function () {
'use strict';

// center the city hall
initMap('mapContainer', 52.515807, 13.479470, 16);
});

// -----------------------------------------------------------------------------

$(function () {
'use strict';

Expand Down

0 comments on commit 15c73e0

Please sign in to comment.