mirror of
https://github.com/gravesoft/msdl.git
synced 2026-07-25 08:34:28 +00:00
+62
-22
@@ -103,36 +103,48 @@ function onLanguageXhrChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onDownloadsXhrChange() {
|
function onDownloadsXhrChange() {
|
||||||
if (!(this.status == 200))
|
if (!(this.status == 200)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
let j = JSON.parse(this.responseText)
|
let response = JSON.parse(this.responseText)
|
||||||
|
|
||||||
let wasSuccessful = true;
|
let wasSuccessful = true;
|
||||||
if (j["Errors"]) {
|
if (response.Errors || response.ValidationContainer.Errors) {
|
||||||
processingError.style.display = "block";
|
processingError.style.display = "block";
|
||||||
wasSuccessful = false;
|
wasSuccessful = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pleaseWait.style.display != "block")
|
if (pleaseWait.style.display != "block") return;
|
||||||
return;
|
|
||||||
|
|
||||||
msContent.innerHTML = this.responseText;
|
|
||||||
msContent.style.display = "block";
|
|
||||||
|
|
||||||
if (wasSuccessful) {
|
if (wasSuccessful) {
|
||||||
pleaseWait.style.display = "none";
|
pleaseWait.style.display = "none";
|
||||||
if (!sharedSession) {
|
} else if (!sharedSession && shouldUseSharedSession) {
|
||||||
fetch(sessionUrl + sharedSessionGUID);
|
|
||||||
fetch(sessionUrl + "de40cb69-50a5-415e-a0e8-3cf1eed1b7cd");
|
|
||||||
fetch(apiUrl + 'add_session?session_id=' + sessionId.value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!sharedSession && shouldUseSharedSession) {
|
|
||||||
useSharedSession();
|
useSharedSession();
|
||||||
}
|
return;
|
||||||
else {
|
} else {
|
||||||
getFromServer();
|
getFromServer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
msContent.innerHTML = "";
|
||||||
|
msContent.style.display = "block";
|
||||||
|
|
||||||
|
if (response.ProductDownloadOptions && response.ProductDownloadOptions.length > 0) {
|
||||||
|
response.ProductDownloadOptions.forEach(option => {
|
||||||
|
let optionContainer = document.createElement('div');
|
||||||
|
|
||||||
|
let header = document.createElement('h1');
|
||||||
|
header.textContent = `Windows 11 ${option.LocalizedLanguage}`
|
||||||
|
|
||||||
|
let downloadButton = document.createElement('a');
|
||||||
|
downloadButton.href = option.Uri;
|
||||||
|
downloadButton.textContent = `Download ${option.LocalizedProductDisplayName}`;
|
||||||
|
downloadButton.target = "_blank";
|
||||||
|
optionContainer.appendChild(downloadButton);
|
||||||
|
|
||||||
|
msContent.appendChild(optionContainer);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
msContent.innerHTML = "<p>No download options available.</p>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,15 +158,44 @@ function getFromServer() {
|
|||||||
xhr.send();
|
xhr.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFileNameFromLink(link) {
|
||||||
|
let raw_link = link.split('?')[0];
|
||||||
|
return raw_link.split('/').pop();
|
||||||
|
}
|
||||||
|
|
||||||
function displayResponseFromServer() {
|
function displayResponseFromServer() {
|
||||||
pleaseWait.style.display = "none";
|
pleaseWait.style.display = "none";
|
||||||
|
|
||||||
if (!(this.status == 200)) {
|
const response = JSON.parse(this.responseText);
|
||||||
|
|
||||||
|
if (this.status !== 200) {
|
||||||
processingError.style.display = "block";
|
processingError.style.display = "block";
|
||||||
alert(JSON.parse(this.responseText)["Error"])
|
alert(response["Error"])
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
msContent.innerHTML = this.responseText
|
|
||||||
|
msContent.innerHTML = "";
|
||||||
|
msContent.style.display = "block";
|
||||||
|
|
||||||
|
if (response.ProductDownloadOptions && response.ProductDownloadOptions.length > 0) {
|
||||||
|
let header = document.createElement('h2');
|
||||||
|
header.textContent = `${response.ProductDownloadOptions[0].ProductDisplayName} ${response.ProductDownloadOptions[0].LocalizedLanguage}`
|
||||||
|
msContent.appendChild(header);
|
||||||
|
|
||||||
|
response.ProductDownloadOptions.forEach(option => {
|
||||||
|
let downloadButton = document.createElement('a');
|
||||||
|
downloadButton.href = option.Uri;
|
||||||
|
downloadButton.textContent = getFileNameFromLink(option.Uri);
|
||||||
|
downloadButton.target = "_blank";
|
||||||
|
|
||||||
|
let br = document.createElement('br');
|
||||||
|
|
||||||
|
msContent.appendChild(downloadButton);
|
||||||
|
msContent.appendChild(br);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
msContent.innerHTML = "<p>No download options available.</p>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLanguages(productId) {
|
function getLanguages(productId) {
|
||||||
@@ -204,7 +245,6 @@ function retryDownload() {
|
|||||||
xhr.onload = getDownload;
|
xhr.onload = getDownload;
|
||||||
xhr.open("GET", url);
|
xhr.open("GET", url);
|
||||||
xhr.send();
|
xhr.send();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareDownload(id) {
|
function prepareDownload(id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user