pxt-calliope/pxtwapp/pxtwapp/msapp-error.js
Guillaume Jenkins 4b45ecea87 Winrt (#545)
* initial winrt work

* Add new vid/pid

* E2E working

* Remove wrong hid selector
2017-10-04 22:37:13 -07:00

48 lines
1.5 KiB
JavaScript

(function () {
var validParameterNames = ["httpStatus", "failureName", "failureUrl"];
function parseQueryParameters() {
var query = location.search.slice(1);
return query.split("&").reduce(function (queryParameters, rawPair) {
var pair = rawPair.split("=").map(decodeURIComponent);
queryParameters[pair[0]] = pair[1];
return queryParameters;
}, {});
}
function initialize() {
var queryParameters = parseQueryParameters();
var url = queryParameters["failureUrl"];
var retryButton = document.getElementById("retryButton");
if (url) {
retryButton.addEventListener("click", (e) => {
window.location.href = url;
});
} else {
retryButton.style.display = none;
}
validParameterNames.forEach(function (parameterName) {
var parameterValue = queryParameters[parameterName];
if (parameterValue) {
document.getElementById(parameterName + "Value").textContent = parameterValue;
} else {
document.getElementById(parameterName).remove();
}
});
}
function updateOnlineStatus(e) {
var queryParameters = parseQueryParameters();
var url = queryParameters["failureUrl"];
if (url) {
window.location.href = url;
}
}
window.addEventListener("online", updateOnlineStatus);
document.addEventListener("DOMContentLoaded", initialize);
}());