mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-05 13:27:49 +08:00
-Now able to clear background images
-removed default image -can now use enter to save background image -removed pointless test
This commit is contained in:
parent
e3db19050e
commit
bdfab7caef
3 changed files with 20 additions and 12 deletions
|
@ -113,7 +113,7 @@ let defaultConfig = {
|
|||
monkey: false,
|
||||
repeatQuotes: "off",
|
||||
oppositeShiftMode: "off",
|
||||
customBackground: "https://i.imgur.com/OWbWz6i.jpg",
|
||||
customBackground: "",
|
||||
customBackgroundSize: "cover",
|
||||
};
|
||||
|
||||
|
@ -1349,9 +1349,13 @@ export function setCustomBackground(value, nosave) {
|
|||
if (value == null || value == undefined) {
|
||||
value = "";
|
||||
}
|
||||
config.customBackground = value;
|
||||
ThemeController.applyCustomBackground();
|
||||
if (!nosave) saveToCookie();
|
||||
if( /(https|http):\/\/(www\.|).+\..+\/.+(\.png|\.gif|\.jpeg|\.jpg)/gi.test(value) || value == ""){
|
||||
config.customBackground = value;
|
||||
ThemeController.applyCustomBackground();
|
||||
if (!nosave) saveToCookie();
|
||||
} else {
|
||||
Notifications.add("Invalid custom background URL", 0);
|
||||
}
|
||||
}
|
||||
|
||||
export function setCustomBackgroundSize(value, nosave) {
|
||||
|
|
|
@ -746,4 +746,10 @@ $(".pageSettings .section.customBackground .inputAndButton .cover").on("click",
|
|||
|
||||
$(".pageSettings .section.customBackground .inputAndButton .contain").on("click", (e) => {
|
||||
UpdateConfig.setCustomBackgroundSize("contain");
|
||||
});
|
||||
|
||||
$(".pageSettings .section.customBackground .inputAndButton input").keypress( (e) => {
|
||||
if(e.keyCode == 13){
|
||||
UpdateConfig.setCustomBackground($(".pageSettings .section.customBackground .inputAndButton input").val())
|
||||
}
|
||||
});
|
|
@ -152,14 +152,12 @@ export function clearRandom() {
|
|||
}
|
||||
|
||||
export function applyCustomBackground(){
|
||||
if (Config.customBackground != ""){
|
||||
$("body").css({
|
||||
backgroundImage: `url(${Config.customBackground})`,
|
||||
backgroundRepeat: "no-repeat",
|
||||
backgroundPosition: "center center",
|
||||
backgroundAttachment: "fixed",
|
||||
})
|
||||
}
|
||||
$("body").css({
|
||||
backgroundImage: `url(${Config.customBackground})`,
|
||||
backgroundRepeat: "no-repeat",
|
||||
backgroundPosition: "center center",
|
||||
backgroundAttachment: "fixed",
|
||||
})
|
||||
}
|
||||
|
||||
export function applyCustomBackgroundSize(){
|
||||
|
|
Loading…
Reference in a new issue