support multiple solutions

This commit is contained in:
Daniel Tsvetkov 2020-02-12 15:47:25 +01:00
parent 9a0f756beb
commit aaca101d1f
4 changed files with 20 additions and 13 deletions

View File

@ -13,6 +13,13 @@
<option value="{{ tz }}">{{ tz }}</option>
{% endfor %}
</select>
<br>
<canvas id="canvas-{{ solution_id }}" width="200" height="200" style="background-color:#eee"></canvas>
<script>
drawClock("{{dt.iso8601_time}}");
var canvas = document.getElementById("canvas-{{ solution_id }}");
var ctx = canvas.getContext("2d");
var radius = canvas.height / 2;
ctx.translate(radius, radius);
radius = radius * 0.90;
drawClock(ctx, radius, "{{dst_dt.iso8601_time}}");
</script>

View File

@ -13,6 +13,13 @@
<option value="{{ tz }}">{{ tz }}</option>
{% endfor %}
</select>
<br>
<canvas id="canvas-{{ solution_id }}" width="200" height="200" style="background-color:#eee"></canvas>
<script>
drawClock("{{dst_dt.iso8601_time}}");
var canvas = document.getElementById("canvas-{{ solution_id }}");
var ctx = canvas.getContext("2d");
var radius = canvas.height / 2;
ctx.translate(radius, radius);
radius = radius * 0.90;
drawClock(ctx, radius, "{{dst_dt.iso8601_time}}");
</script>

View File

@ -39,7 +39,6 @@
</br>
<div id="solutions"></div>
</form>
<canvas id="canvas" width="200" height="200" style="background-color:#eee"></canvas>
</main>
<script src="{{ url_for('static', filename='jquery.js') }}"></script>
<script src="{{ url_for('static', filename='jquery.debounce.js') }}"></script>
@ -48,15 +47,8 @@
<script>
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
var radius = canvas.height / 2;
ctx.translate(radius, radius);
radius = radius * 0.90;
function drawClock(time) {
var time = time.split(':');
function drawClock(ctx, radius, time) {
time = time.split(':');
drawFace(ctx, radius, time);
drawNumbers(ctx, radius);
drawTime(ctx, radius, time);

View File

@ -251,12 +251,13 @@ def resolve_query(query):
"solutions": [],
}
solutions = resolve_query_type(query)
for solution in solutions:
for sol_id, solution in enumerate(solutions):
element = {}
handler, results, query_type, hi = solution
element["handler"] = handler
element["query_type"] = query_type
element["highlight"] = hi
element["solution_id"] = sol_id
try:
if query_type == QUERY_TYPE_DT:
element["dt"] = dt_pretty(results)