Skip to content

Commit

Permalink
cleanup js code
Browse files Browse the repository at this point in the history
  • Loading branch information
afourmy committed Feb 24, 2018
1 parent fe2c0dd commit 7bb4555
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@
{% endif %}
</head>
<body>

<form id="aform" method="post">
<div class="btn-group" style="z-index:500; position: absolute; left:40vw; top:10px;">

{% if view == '2D' %}
<button type="submit" class="btn btn-primary" name="view" value="3D">3D view</button>
{% else %}
Expand All @@ -49,11 +47,8 @@
<strong><p class="btn btn-danger score" style="min-width:100px;" id="score">Score</p></strong>
</div>
</form>

<div class="panel-group" style="z-index:500; position: absolute; top: 20px; left:20px;">

<iframe src="https://ghbtns.com/github-btn.html?user=afourmy&repo=pytsp&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>

<iframe src="https://ghbtns.com/github-btn.html?user=afourmy&repo=pytsp&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
<div class="panel panel-primary panel-transparent">
<div class="panel-heading">Construction heuristics</div>
<div class="panel-body">
Expand Down Expand Up @@ -87,7 +82,6 @@
</div>

<div class="panel-group" style="z-index:500; position: absolute; top: 20px; right:20px;">

<form id="fileform" class="form-horizontal form-label-left" enctype="multipart/form-data" method="post" >
<div style="padding-bottom:5px;">
<label class="btn btn-default btn-file" style="width:100%;">Import a graph
Expand Down Expand Up @@ -140,14 +134,12 @@
</div>
</div>
</div>

{% if view == '2D' %}
<div id="map">
{% else %}
<div id="earth" style="position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%;">
{% endif %}
<script>

document.getElementById("file").onchange = function() {
$("#fileform").submit();
};
Expand Down Expand Up @@ -211,24 +203,18 @@
var sliders = ['base', 'ga'];
for (i = 0; i < sliders.length; i++) {
$('#' + sliders[i] + '_slider').slider({
formatter: function(value) {
return 'Speed';
}
formatter: function(value) { return 'Speed'; }
});
}

$('#Crossover_rate').slider({
tooltip_position: 'left',
formatter: function(value) {
return 'Crossover rate: ' + value;
}
formatter: function(value) { return 'Crossover rate: ' + value; }
});

$('#Mutation_rate').slider({
tooltip_position: 'left',
formatter: function(value) {
return 'Mutation rate: ' + value;
}
formatter: function(value) { return 'Mutation rate: ' + value; }
});

socket.on('draw', function(paths, lengths, best) {
Expand All @@ -241,7 +227,6 @@

// 2D code
{% if view == '2D' %}

var map = L.map('map', { zoomControl:false }).setView([39, -98], 5);
var osm_layer = L.tileLayer(layers['osm']);
map.addLayer(osm_layer);
Expand Down Expand Up @@ -271,9 +256,7 @@
marker.setIcon(icon_city),
marker.addTo(map);
{% endfor %}

{% else %}

var options = {sky:true, atmosphere: true};
var earth = new WE.map('earth', options);

Expand Down Expand Up @@ -308,14 +291,13 @@
{% endif %}
}

var polylines = [];
function clearLines(){
for (i = 0; i < polylines.length; i++) {
{% if view == '2D' %}
map.removeLayer(polylines[i]);
{% else %}
try {
polylines[i].destroy();
}
try { polylines[i].destroy(); }
catch(err) {};
{% endif %}
}
Expand All @@ -325,8 +307,6 @@
- lengths for updating the length in real-time, if createPath is not
called from another function like createIntermediatePath */

// lines of the path displayed
var polylines = [];
async function draw(paths, lengths){
for (j = 0; j < paths.length; j++) {
// update the score
Expand Down

0 comments on commit 7bb4555

Please sign in to comment.