Skip to content

Commit a5ff5d9

Browse files
committed
Fixed getParams from url
1 parent bba6c5e commit a5ff5d9

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

wwwroot/editor.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
function getParams() {
2+
var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
3+
var result = {};
4+
url.forEach(function(item) {
5+
var param = item.split("=");
6+
result[param[0]] = param[1];
7+
});
8+
return result;
9+
}
10+
111
Survey.dxSurveyService.serviceUrl = "http://localhost:5000/api/Service";
212
var accessKey = "";
313
var editor = new SurveyEditor.SurveyEditor("editor");
4-
var url = new URL(document.URL);
5-
var surveyId = url.searchParams.get("id");
14+
var surveyId = getParams()["id"];
615
editor.loadSurvey(surveyId);
716
editor.saveSurveyFunc = function (saveNo, callback) {
817
var xhr = new XMLHttpRequest();

wwwroot/results.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
function getParams() {
2+
var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
3+
var result = {};
4+
url.forEach(function(item) {
5+
var param = item.split("=");
6+
result[param[0]] = param[1];
7+
});
8+
return result;
9+
}
10+
111
function SurveyManager(baseUrl, accessKey) {
212
var self = this;
313
var url = new URL(document.URL);
4-
self.surveyId = url.searchParams.get("id");
14+
self.surveyId = getParams()["id"];
515
self.results = ko.observableArray();
616

717
self.loadResults = function () {

wwwroot/survey.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
function getParams() {
2+
var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
3+
var result = {};
4+
url.forEach(function(item) {
5+
var param = item.split("=");
6+
result[param[0]] = param[1];
7+
});
8+
return result;
9+
}
10+
111
function init() {
212

313
Survey.dxSurveyService.serviceUrl = "http://localhost:5000/api/Service";
414
Survey.defaultBootstrapCss.navigationButton = "btn btn-primary";
515
Survey.Survey.cssType = "bootstrap";
616

717
var url = new URL(document.URL);
8-
var surveyId = url.searchParams.get("id");
18+
var surveyId = getParams()["id"];
919
var model = new Survey.Model({ surveyId: surveyId, surveyPostId: surveyId });
1020
window.survey = model;
1121
model.render("surveyElement");

0 commit comments

Comments
 (0)