9
0
mirror of https://github.com/donlon/cloudflare-error-page.git synced 2025-12-29 03:39:17 +00:00

editor: support editing from other shared pages

This commit is contained in:
Anthony Donlon
2025-11-20 21:54:39 +08:00
parent 57f730dc23
commit baff5fee5c
2 changed files with 43 additions and 3 deletions

View File

@@ -41,7 +41,8 @@
}
})
const initialConfig = {
// can be changed if specified by '?from=<name>'
let initialConfig = {
"html_title": "cloudflare.com | 500: Internal server error",
"title": "Internal server error",
"error_code": 500,
@@ -139,6 +140,30 @@
},
};
const urlParams = new URLSearchParams(window.location.search);
const defaultPresetName = urlParams.get('from');
if (defaultPresetName && defaultPresetName.indexOf('/') < 0) {
fetch(`../s/${defaultPresetName}`, {
headers: {
'Accept': 'application/json'
},
})
.then(response => {
if (!response.ok) {
throw new Error('failed to get preset');
}
return response.json();
})
.then(result => {
if (result.status != 'ok') {
return
}
console.log(result.parameters)
initialConfig = result.parameters
loadConfig(initialConfig);
})
}
/* Utilities */
function $(id) { return document.getElementById(id); }