mirror of
https://cdm-project.com/CDM-Project/CDRM-Project.git
synced 2026-04-02 21:18:13 +00:00
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
function addLineBreaks(text) {
|
|
// Replace all occurrences of '\n' with '<br>'
|
|
return text.replace(/\n/g, '<br>');
|
|
}
|
|
|
|
// Define decrypt function
|
|
|
|
function sendCache() {
|
|
|
|
// Declare PSSH variable
|
|
let pssh = document.getElementById("cache_pssh");
|
|
|
|
// Declare JSON dictionary and add the values
|
|
let json_dict = {
|
|
'PSSH': pssh.value,
|
|
}
|
|
|
|
// Reset all the fields
|
|
pssh.value = ''
|
|
|
|
// Set request options
|
|
let requestOptions = {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(json_dict)
|
|
}
|
|
|
|
// Send post request
|
|
fetch('/cache', requestOptions)
|
|
|
|
// Process return object
|
|
.then(response => {
|
|
return response.json()
|
|
|
|
// Access JSON info
|
|
.then(data => {
|
|
|
|
// Grab the message
|
|
let message = addLineBreaks(data['Message'])
|
|
|
|
// Make fields visible and update with message
|
|
document.getElementById("cache_results_container").style.display = 'grid'
|
|
document.getElementById("results_paragraph").style.justifySelf = 'center'
|
|
document.getElementById("cache_results").innerHTML = message
|
|
})
|
|
})
|
|
} |