From 12944a770301ddd482ae2e7b69ecda26f809be3e Mon Sep 17 00:00:00 2001 From: Lyssa Date: Sat, 21 Dec 2024 14:43:05 +0000 Subject: [PATCH 1/3] ?????????????????????????????????????????????????????????????????? --- js/msdl.js | 57 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/js/msdl.js b/js/msdl.js index 5227734..dec53fa 100644 --- a/js/msdl.js +++ b/js/msdl.js @@ -103,23 +103,41 @@ function onLanguageXhrChange() { } function onDownloadsXhrChange() { - if (!(this.status == 200)) - return; + if (!(this.status == 200)) return; - let j = JSON.parse(this.responseText) + let response = JSON.parse(this.responseText) let wasSuccessful = true; - if (j["Errors"]) { + if (response.ValidationContainer && response.ValidationContainer.Errors.length > 0) { processingError.style.display = "block"; wasSuccessful = false; } - if (pleaseWait.style.display != "block") - return; + if (pleaseWait.style.display != "block") return; - msContent.innerHTML = this.responseText; + msContent.innerHTML = ""; msContent.style.display = "block"; + if (response.ProductDownloadOptions && response.ProductDownloadOptions.length > 0) { + response.ProductDownloadOptions.forEach(option => { + let optionContainer = document.createElement('div'); + + let downloadButton = document.createElement('a'); + downloadButton.href = option.Uri; + downloadButton.textContent = `Download ${option.LocalizedProductDisplayName}`; + downloadButton.target = "_blank"; + optionContainer.appendChild(downloadButton); + + let info = document.createElement('p'); + info.textContent = `Language: ${option.LocalizedLanguage}`; + optionContainer.appendChild(info); + + msContent.appendChild(optionContainer); + }); + } else { + msContent.innerHTML = "

No download options available.

"; + } + if (wasSuccessful) { pleaseWait.style.display = "none"; if (!sharedSession) { @@ -149,12 +167,33 @@ function getFromServer() { function displayResponseFromServer() { pleaseWait.style.display = "none"; - if (!(this.status == 200)) { + if (this.status !== 200) { processingError.style.display = "block"; alert(JSON.parse(this.responseText)["Error"]) return; } - msContent.innerHTML = this.responseText + msContent.innerHTML = ""; + + if (response.ProductDownloadOptions && response.ProductDownloadOptions.length > 0) { + response.ProductDownloadOptions.forEach(option => { + let optionContainer = document.createElement('div'); + + let downloadButton = document.createElement('a'); + downloadButton.href = option.Uri; + downloadButton.textContent = `Download ${option.LocalizedProductDisplayName}`; + downloadButton.target = "_blank"; + optionContainer.appendChild(downloadButton); + + let info = document.createElement('p'); + info.textContent = `Language: ${option.LocalizedLanguage}`; + optionContainer.appendChild(info); + + msContent.appendChild(optionContainer); + }); + } else { + msContent.innerHTML = "

No download options available.

"; + } + } function getLanguages(productId) { From 89d7ea77faee09fae82bfc0248363c0e867d56e3 Mon Sep 17 00:00:00 2001 From: Lyssa Date: Sat, 21 Dec 2024 15:15:09 +0000 Subject: [PATCH 2/3] fix --- js/msdl.js | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/js/msdl.js b/js/msdl.js index dec53fa..b8a0125 100644 --- a/js/msdl.js +++ b/js/msdl.js @@ -108,13 +108,23 @@ function onDownloadsXhrChange() { let response = JSON.parse(this.responseText) let wasSuccessful = true; - if (response.ValidationContainer && response.ValidationContainer.Errors.length > 0) { + if (response.Errors || response.ValidationContainer.Errors) { processingError.style.display = "block"; wasSuccessful = false; } if (pleaseWait.style.display != "block") return; + if (wasSuccessful) { + pleaseWait.style.display = "none"; + } else if (!sharedSession && shouldUseSharedSession) { + useSharedSession(); + return; + } else { + getFromServer(); + return; + } + msContent.innerHTML = ""; msContent.style.display = "block"; @@ -137,21 +147,6 @@ function onDownloadsXhrChange() { } else { msContent.innerHTML = "

No download options available.

"; } - - if (wasSuccessful) { - pleaseWait.style.display = "none"; - if (!sharedSession) { - fetch(sessionUrl + sharedSessionGUID); - fetch(sessionUrl + "de40cb69-50a5-415e-a0e8-3cf1eed1b7cd"); - fetch(apiUrl + 'add_session?session_id=' + sessionId.value) - } - } - else if (!sharedSession && shouldUseSharedSession) { - useSharedSession(); - } - else { - getFromServer(); - } } function getFromServer() { @@ -167,12 +162,16 @@ function getFromServer() { function displayResponseFromServer() { pleaseWait.style.display = "none"; + const response = JSON.parse(this.responseText); + if (this.status !== 200) { processingError.style.display = "block"; - alert(JSON.parse(this.responseText)["Error"]) + alert(response["Error"]) return; } + msContent.innerHTML = ""; + msContent.style.display = "block"; if (response.ProductDownloadOptions && response.ProductDownloadOptions.length > 0) { response.ProductDownloadOptions.forEach(option => { @@ -193,7 +192,6 @@ function displayResponseFromServer() { } else { msContent.innerHTML = "

No download options available.

"; } - } function getLanguages(productId) { @@ -243,7 +241,6 @@ function retryDownload() { xhr.onload = getDownload; xhr.open("GET", url); xhr.send(); - } function prepareDownload(id) { From 47d05509092ec50156d499280bf42f52e7896a2d Mon Sep 17 00:00:00 2001 From: Lyssa Date: Sat, 21 Dec 2024 15:50:06 +0000 Subject: [PATCH 3/3] Fix MSDL (kinda) --- js/msdl.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/js/msdl.js b/js/msdl.js index b8a0125..6897fa0 100644 --- a/js/msdl.js +++ b/js/msdl.js @@ -132,16 +132,15 @@ function onDownloadsXhrChange() { 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); - let info = document.createElement('p'); - info.textContent = `Language: ${option.LocalizedLanguage}`; - optionContainer.appendChild(info); - msContent.appendChild(optionContainer); }); } else { @@ -159,6 +158,11 @@ function getFromServer() { xhr.send(); } +function getFileNameFromLink(link) { + let raw_link = link.split('?')[0]; + return raw_link.split('/').pop(); +} + function displayResponseFromServer() { pleaseWait.style.display = "none"; @@ -174,20 +178,20 @@ function displayResponseFromServer() { 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 optionContainer = document.createElement('div'); - let downloadButton = document.createElement('a'); downloadButton.href = option.Uri; - downloadButton.textContent = `Download ${option.LocalizedProductDisplayName}`; + downloadButton.textContent = getFileNameFromLink(option.Uri); downloadButton.target = "_blank"; - optionContainer.appendChild(downloadButton); - - let info = document.createElement('p'); - info.textContent = `Language: ${option.LocalizedLanguage}`; - optionContainer.appendChild(info); - - msContent.appendChild(optionContainer); + + let br = document.createElement('br'); + + msContent.appendChild(downloadButton); + msContent.appendChild(br); }); } else { msContent.innerHTML = "

No download options available.

";