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> <option value="{{ tz }}">{{ tz }}</option>
{% endfor %} {% endfor %}
</select> </select>
<br>
<canvas id="canvas-{{ solution_id }}" width="200" height="200" style="background-color:#eee"></canvas>
<script> <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> </script>

View File

@ -13,6 +13,13 @@
<option value="{{ tz }}">{{ tz }}</option> <option value="{{ tz }}">{{ tz }}</option>
{% endfor %} {% endfor %}
</select> </select>
<br>
<canvas id="canvas-{{ solution_id }}" width="200" height="200" style="background-color:#eee"></canvas>
<script> <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> </script>

View File

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

View File

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