Merge lp:~patrickas/ensoft-sextant/no-caching into lp:ensoft-sextant

Proposed by Patrick Stevens
Status: Merged
Approved by: Phil Connell
Approved revision: 24
Merged at revision: 22
Proposed branch: lp:~patrickas/ensoft-sextant/no-caching
Merge into: lp:ensoft-sextant
Diff against target: 277 lines (+117/-116)
1 file modified
resources/sextant/web/queryjavascript.js (+117/-116)
To merge this branch: bzr merge lp:~patrickas/ensoft-sextant/no-caching
Reviewer Review Type Date Requested Status
Phil Connell Approve
Review via email: mp+233341@code.launchpad.net

Commit message

Make Sextant Web ask browsers not to cache the SVGs generated.

Description of the change

Make Sextant Web ask browsers not to cache the SVGs generated. (This is done by adding a random query parameter to the image request.)

To post a comment you must log in.
22. By Patrick Stevens <email address hidden>

Merge trunk changes

23. By Patrick Stevens <email address hidden>

Revert change to sextant.conf

Revision history for this message
Phil Connell (pconnell) wrote :

Change looks fine, but sadly the file's indentation is utterly screwed up (so needs a change for consistency).

Revision history for this message
Phil Connell (pconnell) :
review: Needs Fixing
24. By Patrick Stevens <email address hidden>

Expand tabs into spaces

Revision history for this message
Phil Connell (pconnell) :
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 09:46:18 +0000
3+++ resources/sextant/web/queryjavascript.js 2014-09-04 16:05:30 +0000
4@@ -7,13 +7,13 @@
5
6
7 function get_names_for_autocomplete(info_needed){
8- //Function queries to database to create a list
9- //which is used to populate the auto-complete text boxes.
10- var xmlhttp = new XMLHttpRequest();
11- xmlhttp.onreadystatechange = function(){
12- if (xmlhttp.status = 200){
13- var values_list = xmlhttp.responseText;
14- if (values_list != "") {
15+ //Function queries to database to create a list
16+ //which is used to populate the auto-complete text boxes.
17+ var xmlhttp = new XMLHttpRequest();
18+ xmlhttp.onreadystatechange = function(){
19+ if (xmlhttp.status = 200){
20+ var values_list = xmlhttp.responseText;
21+ if (values_list != "") {
22 values_list = JSON.parse(values_list);
23 if (info_needed =='programs'){
24 //We need to populate the program names list
25@@ -22,42 +22,42 @@
26 if (info_needed =='funcs'){
27 //We need to populate the functions list for the arguments
28 add_options("function_names", values_list);
29- }
30+ }
31 }
32- }
33- }
34- if (info_needed == 'programs'){
35- var string = "/database_properties?query=" + info_needed + "&program_name=";
36- }
37- else{
38- var string = "/database_properties?query=" + "functions" +
39- "&program_name=" + document.getElementById("program_name").value;
40- if (info_needed == 'programs'){
41- var string = "/database_properties?query=" +
42- info_needed + "&program_name=" + prog_name;
43- }
44- //"GET" information from the specified url (string)
45- xmlhttp.open("GET", string, true);
46- xmlhttp.send();
47- }
48- xmlhttp.open("GET", string, true);
49- xmlhttp.send();
50+ }
51+ }
52+ if (info_needed == 'programs'){
53+ var string = "/database_properties?query=" + info_needed + "&program_name=";
54+ }
55+ else{
56+ var string = "/database_properties?query=" + "functions" +
57+ "&program_name=" + document.getElementById("program_name").value;
58+ if (info_needed == 'programs'){
59+ var string = "/database_properties?query=" +
60+ info_needed + "&program_name=" + prog_name;
61+ }
62+ //"GET" information from the specified url (string)
63+ xmlhttp.open("GET", string, true);
64+ xmlhttp.send();
65+ }
66+ xmlhttp.open("GET", string, true);
67+ xmlhttp.send();
68 }
69
70
71 function add_options(selectedlist, values_list){
72- //Adds all the options obtained from the list of program
73- //names or function names to an auto complete drop-down box
74- var options = ''
75- if (values_list.length == 1 || values_list.length ==0){
76- options += '<option value="'+values_list+'"/>';
77- }
78- else{
79- for (var i=0; i < values_list.length;++i){
80- options += '<option value="'+values_list[i]+'"/>';
81- }
82- }
83- document.getElementById(selectedlist).innerHTML = options;
84+ //Adds all the options obtained from the list of program
85+ //names or function names to an auto complete drop-down box
86+ var options = ''
87+ if (values_list.length == 1 || values_list.length ==0){
88+ options += '<option value="'+values_list+'"/>';
89+ }
90+ else{
91+ for (var i=0; i < values_list.length;++i){
92+ options += '<option value="'+values_list[i]+'"/>';
93+ }
94+ }
95+ document.getElementById(selectedlist).innerHTML = options;
96 }
97
98
99@@ -83,32 +83,32 @@
100 = (label1 == "" && label2 == "") ? "none" : "block";
101 }
102
103-
104+
105 function display_when(){
106- //For each query specifies when auto-complete text boxes should be made
107- //visible or invisible and makes them read only
108- var query_list = document.getElementById("query_list");
109+ //For each query specifies when auto-complete text boxes should be made
110+ //visible or invisible and makes them read only
111+ var query_list = document.getElementById("query_list");
112
113- var no_functions = new Array();
114- var prog_name = document.getElementById("program_name").value;
115- if (query_list.options[query_list.selectedIndex].value == "functions_calling"){
116+ var no_functions = new Array();
117+ var prog_name = document.getElementById("program_name").value;
118+ if (query_list.options[query_list.selectedIndex].value == "functions_calling"){
119 set_arguments("Function being called", "");
120- }
121- if (query_list.options[query_list.selectedIndex].value == "functions_called_by"){
122+ }
123+ if (query_list.options[query_list.selectedIndex].value == "functions_called_by"){
124 set_arguments("Function calling", "");
125- }
126- if (query_list.options[query_list.selectedIndex].value == "all_call_paths"){
127- set_arguments("Function calling", "Function being called");
128- }
129- if (query_list.options[query_list.selectedIndex].value == "shortest_call_path"){
130- set_arguments("Function calling", "Function being called");
131- }
132- if (query_list.options[query_list.selectedIndex].value == "whole_program") {
133- set_arguments("", "");
134- }
135- if (query_list.options[query_list.selectedIndex].value == "function_names"){
136- set_arguments("", "");
137- }
138+ }
139+ if (query_list.options[query_list.selectedIndex].value == "all_call_paths"){
140+ set_arguments("Function calling", "Function being called");
141+ }
142+ if (query_list.options[query_list.selectedIndex].value == "shortest_call_path"){
143+ set_arguments("Function calling", "Function being called");
144+ }
145+ if (query_list.options[query_list.selectedIndex].value == "whole_program") {
146+ set_arguments("", "");
147+ }
148+ if (query_list.options[query_list.selectedIndex].value == "function_names"){
149+ set_arguments("", "");
150+ }
151 }
152
153
154@@ -116,66 +116,67 @@
155 function execute_query(){
156 document.getElementById("output_image").src = "";
157
158- //Returns error in alert window if query not executed properly,
159- //otherwise performs the query and outputs it
160- show_item("please-wait");
161- var query_id = document.getElementById("query_list").value;
162- if (query_id == "function_names"){
163- //url for page containing all function names
164- var string = "/database_properties?program_name=" +
165- document.getElementById("program_name").value + "&query=functions";
166- }
167- else{
168- //If not function names we will want a graph as an output;
169- //url returns svg file of graph.
170- var string = "/output_graph.svg?program_name=" +
171- document.getElementById("program_name").value +
172- "&query=" + query_id + "&func1=";
173+ //Returns error in alert window if query not executed properly,
174+ //otherwise performs the query and outputs it
175+ show_item("please-wait");
176+ var query_id = document.getElementById("query_list").value;
177+ if (query_id == "function_names"){
178+ //url for page containing all function names
179+ var string = "/database_properties?program_name=" +
180+ document.getElementById("program_name").value + "&query=functions";
181+ }
182+ else{
183+ //If not function names we will want a graph as an output;
184+ //url returns svg file of graph.
185+ // We use a random number argument to prevent caching.
186+ var string = "/output_graph.svg?stop_cache=" + String(Math.random()) + "&program_name=" +
187+ document.getElementById("program_name").value +
188+ "&query=" + query_id + "&func1=";
189 string = string + document.getElementById("function_1").value +
190- "&func2=" + document.getElementById("function_2").value;
191+ "&func2=" + document.getElementById("function_2").value;
192 string = string + "&suppress_common=" +
193- document.getElementById('suppress_common').checked.toString();
194+ document.getElementById('suppress_common').checked.toString();
195
196- }
197- var xmlhttp = new XMLHttpRequest();
198- xmlhttp.open("GET", string, true);
199- xmlhttp.send();
200- xmlhttp.onreadystatechange = function(){
201- if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
202- //readyState == 4 means query has finished executing.
203- //status == 200 means "GET"ing has been successful.
204- if (query_id == "function_names"){
205- //Text output displayed in paragraph.
206- document.getElementById("function_names_output").innerHTML =
207- xmlhttp.responseText;
208- show_item("function_names_output");
209- }
210- else{
211+ }
212+ var xmlhttp = new XMLHttpRequest();
213+ xmlhttp.open("GET", string, true);
214+ xmlhttp.send();
215+ xmlhttp.onreadystatechange = function(){
216+ if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
217+ //readyState == 4 means query has finished executing.
218+ //status == 200 means "GET"ing has been successful.
219+ if (query_id == "function_names"){
220+ //Text output displayed in paragraph.
221+ document.getElementById("function_names_output").innerHTML =
222+ xmlhttp.responseText;
223+ show_item("function_names_output");
224+ }
225+ else{
226 show_item("output_image");
227- document.getElementById("output_image").src = string;
228- }
229- }
230- else if (xmlhttp.readyState == 4 && xmlhttp.status == 400){
231- //Error occurred during query; display response.
232- show_error(xmlhttp.responseText);
233- }
234- else if(xmlhttp.readyState == 4 && xmlhttp.status == 404){
235- //Error occurred during query; display response.
236- show_error(xmlhttp.responseText);
237- }
238- else if(xmlhttp.readyState ==4 && xmlhttp.status == 204){
239- //Query executed correctly but graph returned is empty
240- show_error("Graph returned was empty");
241- }
242- else if (xmlhttp.readyState == 4 && xmlhttp.status == 502) {
243- //Error occurs if Neo4j isn't running
244- show_error("Bad Gateway received - are you sure the database server is running?");
245- }
246- else if(xmlhttp.readyState ==4){
247- //query executed correctly
248- show_error("An unknown error occurred");
249- }
250- }
251+ document.getElementById("output_image").src = string;
252+ }
253+ }
254+ else if (xmlhttp.readyState == 4 && xmlhttp.status == 400){
255+ //Error occurred during query; display response.
256+ show_error(xmlhttp.responseText);
257+ }
258+ else if(xmlhttp.readyState == 4 && xmlhttp.status == 404){
259+ //Error occurred during query; display response.
260+ show_error(xmlhttp.responseText);
261+ }
262+ else if(xmlhttp.readyState ==4 && xmlhttp.status == 204){
263+ //Query executed correctly but graph returned is empty
264+ show_error("Graph returned was empty");
265+ }
266+ else if (xmlhttp.readyState == 4 && xmlhttp.status == 502) {
267+ //Error occurs if Neo4j isn't running
268+ show_error("Bad Gateway received - are you sure the database server is running?");
269+ }
270+ else if(xmlhttp.readyState ==4){
271+ //query executed correctly
272+ show_error("An unknown error occurred");
273+ }
274+ }
275 }
276
277 function show_item(id) {

Subscribers

People subscribed via source and target branches