Merge lp:~rjwills/ensoft-sextant/fix-double-request into lp:ensoft-sextant

Proposed by Robert
Status: Merged
Approved by: Robert
Approved revision: 26
Merged at revision: 26
Proposed branch: lp:~rjwills/ensoft-sextant/fix-double-request
Merge into: lp:ensoft-sextant
Diff against target: 20 lines (+6/-3)
1 file modified
resources/sextant/web/queryjavascript.js (+6/-3)
To merge this branch: bzr merge lp:~rjwills/ensoft-sextant/fix-double-request
Reviewer Review Type Date Requested Status
Robert Approve
Review via email: mp+236425@code.launchpad.net

Commit message

Fix the bug where the result image is requested twice.

This change is the smallest possible fix. It takes the XHR response and base64-encodes it to construct a data URL. This data URL can then be set as the image source, which saves the second request.

Description of the change

Fix the bug where the result image is requested twice.

This change is the smallest possible fix. It takes the XHR response and base64-encodes it to construct a data URL. This data URL can then be set as the image source, which saves the second request.

To post a comment you must log in.
Revision history for this message
Robert (rjwills) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'resources/sextant/web/queryjavascript.js'
2--- resources/sextant/web/queryjavascript.js 2014-09-04 16:05:22 +0000
3+++ resources/sextant/web/queryjavascript.js 2014-09-29 21:10:39 +0000
4@@ -150,10 +150,13 @@
5 document.getElementById("function_names_output").innerHTML =
6 xmlhttp.responseText;
7 show_item("function_names_output");
8- }
9- else{
10+ } else {
11+ // At the moment, we base64-encode the result and then construct
12+ // a 'data:' URL. In the future, we may want to set the source
13+ // URL of the image directly, as that is probably less wasteful.
14 show_item("output_image");
15- document.getElementById("output_image").src = string;
16+ var dataUrl = "data:image/svg+xml;base64," + btoa(xmlhttp.responseText);
17+ document.getElementById("output_image").src = dataUrl;
18 }
19 }
20 else if (xmlhttp.readyState == 4 && xmlhttp.status == 400){

Subscribers

People subscribed via source and target branches