Merge branch 'master' of git.elab.kth.se:davide/ELAB-partsearch

master
Davide Bongiovanni 6 years ago
commit 3fb61c0cbd

@ -47,6 +47,16 @@ def serveImage(img):
def index():
return render_template('partsearch.html')
@app.route('/parts/getlocations/')
def get_locations():
s = 'select id, map from locations'
r = db_engine.execute(text(s))
l = {}
for row in r:
l[row[0]]=row[1]
r.close()
return json.dumps(l)
@app.route('/parts/getpartinfo/<partID>')
def get_part_info(partID):
s = 'select * from parts as p inner join locations as l on p.location_id=l.id where p.id = :id;'

@ -295,3 +295,23 @@ $(document).ready(function() {
perform_query();
});
});
$(document).ready(function() {
$("#clickablemap").on("click", function(event) {
var $img = $(this);
var currentClickPosX = event.pageX - $img.offset().left;
var currentClickPosY = event.pageY - $img.offset().top;
var currentWidth = $img.width();
var currentHeight = $img.height();
var naturalWidth = this.naturalWidth;
var naturalHeight = this.naturalHeight;
var correctX = ((naturalWidth / currentWidth) * currentClickPosX).toFixed(0);
var correctY = ((naturalHeight / currentHeight) * currentClickPosY).toFixed(0);
$("#mapURL").html("elab.png?x=" + correctX + "&y=" + correctY);
$("#clickablemap").attr("src", "http://127.0.0.1:5000/parts/map/elab.png?x=" + correctX + "&y=" + correctY);
});
});

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ELAB Part Search Engine</title>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="static/style.css">
<script src="https://use.fontawesome.com/2fef7be393.js"></script>
<script type="text/javascript" src="static/script.js"></script>
</head>
<body>
<div id="mapURL">unknown.png</div>
<br />
<img src="maps/elab.png" id="clickablemap" style="margin-top: 50px; margin-left: 3em; max-height: 830px;"/>
</body>
</html>
Loading…
Cancel
Save