# HG changeset patch # User Nicholas Jillings # Date 1531908689 -3600 # Node ID e9d16f8ea6734219c305e12bd910a775bc50ff7e # Parent b67d33da38670f24fa8aa229fb3a7463ad1e630f Potential workaround for #220 diff -r b67d33da3867 -r e9d16f8ea673 js/core.js --- a/js/core.js Sat Jul 14 15:30:48 2018 +0100 +++ b/js/core.js Wed Jul 18 11:11:29 2018 +0100 @@ -1,6 +1,6 @@ /** * core.js - * + * * Main script to run, calls all other core functions and manages loading/store to backend. * Also contains all global variables. */ @@ -44,6 +44,17 @@ return el.firstChild.href; } +function insertParam(s, key, value) +{ + key = encodeURI(key); value = encodeURI(value); + if (s.split("?").length == 1) { + s = s + ">"; + } else { + s = s + "&"; + } + return s+key+"="+value; +} + // Firefox does not have an XMLDocument.prototype.getElementsByName // and there is no searchAll style command, this custom function will // search all children recusrively for the name. Used for XSD where all @@ -175,6 +186,9 @@ case "returnURL": gReturnURL = value; break; + case "testKey": + storage.sessionLinked = value; + break; case "saveFilenamePrefix": storage.filenamePrefix = value; break; @@ -418,7 +432,7 @@ storage.SessionKey.finish().then(function (resolved) { var converter = new showdown.Converter(); if (typeof specification.returnURL == "string" && specification.returnURL.length > 0) { - window.location = specification.returnURL; + window.location = insertParam(specification.returnURL, "testKey", storage.SessionKey.key); } else { popup.popupContent.innerHTML = converter.makeHtml(specification.exitText); } @@ -2501,7 +2515,7 @@ this.returnDateNode = function () { // Create an XML Node for the Date and Time a test was conducted // Structure is - // + // // DD/MM/YY // // @@ -3786,6 +3800,7 @@ this.document = null; this.root = null; this.state = 0; + var linkedID = undefined; var pFilenamePrefix = "save"; this.initialise = function (existingStore) { @@ -3811,6 +3826,9 @@ if (specification.postTest !== undefined) { this.globalPostTest = new this.surveyNode(this, this.root, specification.postTest); } + if (linkedID) { + this.root.setAttribute("linked", linkedID); + } }; this.SessionKey = (function (parent) { @@ -3954,6 +3972,7 @@ this.parent.finish(); return requestChains.then(postUpdate()).then(function () { console.log("OK"); + return true; }, function () { createProjectSave("local"); }); @@ -4208,6 +4227,20 @@ pFilenamePrefix = value; return value; } + }, + "sessionLinked": { + 'get': function () { + return linkedID; + }, + 'set': function(s) { + if (typeof s == "string") { + linkedID = s; + if (this.root) { + this.root.setAttribute("linked", s); + } + } + return linkedID; + } } }); }