comparison js/core.js @ 2331:ee5e2db32f7c

Improved querystring parsing
author Giulio Moro <giuliomoro@yahoo.it>
date Wed, 04 May 2016 17:24:38 +0100
parents 59083312c5ff
children e22ec7b6cfbd
comparison
equal deleted inserted replaced
2329:59083312c5ff 2331:ee5e2db32f7c
144 if (window.location.search.length != 0) 144 if (window.location.search.length != 0)
145 { 145 {
146 var search = window.location.search.split('?')[1]; 146 var search = window.location.search.split('?')[1];
147 // Now split the requests into pairs 147 // Now split the requests into pairs
148 var searchQueries = search.split('&'); 148 var searchQueries = search.split('&');
149
149 for (var i in searchQueries) 150 for (var i in searchQueries)
150 { 151 {
151 // Split each request into 152 // Split each key-value pair
152 searchQueries[i] = searchQueries[i].split('='); 153 searchQueries[i] = searchQueries[i].split('=');
153 switch(searchQueries[i][0]) { 154 var key = searchQueries[i][0];
154 case "url": 155 var value = decodeURIComponent(searchQueries[i][1]);
155 url = decodeURI(searchQueries[i][1]); 156 switch(key) {
156 break; 157 case "url":
157 case "returnURL": 158 url = value;
158 gReturnURL = decodeURI(searchQueries[i][1]); 159 break;
159 break; 160 case "returnURL":
161 gReturnURL = value;
162 break;
160 } 163 }
161 } 164 }
162 loadProjectSpec(url); 165 loadProjectSpec(url);
163 window.onbeforeunload = function() { 166 window.onbeforeunload = function() {
164 return "Please only leave this page once you have completed the tests. Are you sure you have completed all testing?"; 167 return "Please only leave this page once you have completed the tests. Are you sure you have completed all testing?";