2022-07-16 21:00:02 +00:00
|
|
|
function post(url) {
|
|
|
|
const xhr = new XMLHttpRequest();
|
|
|
|
xhr.open("POST", url);
|
|
|
|
xhr.setRequestHeader('xhr', 'xhr');
|
2022-07-23 08:57:53 +00:00
|
|
|
const form = new FormData()
|
2022-07-16 21:00:02 +00:00
|
|
|
form.append("formkey", formkey());
|
2023-03-10 03:21:02 +00:00
|
|
|
xhr.onload = function() {location.reload();};
|
2022-07-16 21:00:02 +00:00
|
|
|
xhr.send(form);
|
|
|
|
};
|
|
|
|
|
|
|
|
function updatebgselection(){
|
2022-12-04 15:40:32 +00:00
|
|
|
const bgselector = document.getElementById("backgroundSelector");
|
2022-07-16 21:00:02 +00:00
|
|
|
const backgrounds = [
|
2022-11-27 16:15:15 +00:00
|
|
|
{
|
|
|
|
folder: "glitter",
|
2023-01-01 11:36:20 +00:00
|
|
|
backgrounds:
|
2022-11-27 16:15:15 +00:00
|
|
|
[
|
|
|
|
"1.webp",
|
|
|
|
"2.webp",
|
|
|
|
"3.webp",
|
|
|
|
"4.webp",
|
|
|
|
"5.webp",
|
|
|
|
]
|
|
|
|
},
|
2022-07-16 21:00:02 +00:00
|
|
|
{
|
|
|
|
folder: "anime",
|
|
|
|
backgrounds:
|
|
|
|
[
|
|
|
|
"1.webp",
|
|
|
|
"2.webp",
|
|
|
|
"3.webp",
|
|
|
|
"4.webp",
|
|
|
|
"5.webp",
|
2022-11-27 18:50:34 +00:00
|
|
|
"6.webp",
|
2022-07-16 21:00:02 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
folder: "fantasy",
|
2022-09-04 23:15:37 +00:00
|
|
|
backgrounds:
|
2022-07-16 21:00:02 +00:00
|
|
|
[
|
|
|
|
"1.webp",
|
|
|
|
"2.webp",
|
|
|
|
"3.webp",
|
|
|
|
"4.webp",
|
|
|
|
"5.webp",
|
|
|
|
"6.webp",
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
folder: "solarpunk",
|
2022-09-04 23:15:37 +00:00
|
|
|
backgrounds:
|
2022-07-16 21:00:02 +00:00
|
|
|
[
|
|
|
|
"1.webp",
|
|
|
|
"2.webp",
|
|
|
|
"3.webp",
|
|
|
|
"4.webp",
|
|
|
|
"5.webp",
|
|
|
|
"6.webp",
|
|
|
|
"7.webp",
|
|
|
|
"8.webp",
|
|
|
|
"9.webp",
|
|
|
|
"10.webp",
|
|
|
|
"11.webp",
|
|
|
|
"12.webp",
|
|
|
|
"13.webp",
|
|
|
|
"14.webp",
|
|
|
|
"15.webp",
|
|
|
|
"16.webp",
|
|
|
|
"17.webp",
|
|
|
|
"18.webp",
|
|
|
|
"19.webp",
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
folder: "pixelart",
|
|
|
|
backgrounds:
|
|
|
|
[
|
|
|
|
"1.webp",
|
|
|
|
"2.webp",
|
|
|
|
"3.webp",
|
|
|
|
"4.webp",
|
|
|
|
"5.webp",
|
|
|
|
]
|
|
|
|
},
|
|
|
|
]
|
|
|
|
let bgContainer = document.getElementById(`bgcontainer`);
|
|
|
|
let str = '';
|
|
|
|
let bgsToDisplay = backgrounds[bgselector.selectedIndex].backgrounds;
|
|
|
|
let bgsDir = backgrounds[bgselector.selectedIndex].folder;
|
|
|
|
for (i=0; i < bgsToDisplay.length; i++) {
|
|
|
|
let onclickPost = bgsDir + "/" + bgsToDisplay[i];
|
2023-07-22 16:24:16 +00:00
|
|
|
str += `<button class="btn btn-secondary bg-button"><img loading="lazy" class='bg-image' src="${SITE_FULL_IMAGES}/i/backgrounds/${bgsDir}/${bgsToDisplay[i]}?x=6" alt="${bgsToDisplay[i]}-background" data-nonce="${nonce}" data-onclick="post('/settings/personal?background=${onclickPost}')"></button>`;
|
2022-07-16 21:00:02 +00:00
|
|
|
}
|
|
|
|
bgContainer.innerHTML = str;
|
2023-01-01 10:55:30 +00:00
|
|
|
|
|
|
|
if (typeof register_new_elements === "function") {
|
|
|
|
register_new_elements(bgContainer)
|
|
|
|
}
|
2022-07-16 21:00:02 +00:00
|
|
|
}
|
|
|
|
updatebgselection();
|