更改聊天背景

时间:2018-10-13 09:56:56

标签: javascript jquery

我有这样的代码:

var chat_background = localStorage.getItem("chat_bg")
    var effective_background = undefined
    if(chat_background != undefined) {
        effective_background = chat_background
        $$("#chat-background").css("background", "rgb(" + chat_background + ")")
    }
    else {
        effective_background = app_config['chat_background']
        $$("#chat-background").css("background", "rgb(" + app_config['chat_background'] + ")")
    }
    [bg_red, bg_green, bg_blue] = chat_background.split(",")

    bg_color_temp = light_or_dark(bg_red, bg_green, bg_blue)

    if(last_background_temp != undefined && bg_color_temp != last_background_temp) {
        $("." + last_background_temp + "-timebox").removeClass(last_background_temp + "-timebox").addClass(bg_color_temp + "-timebox")
    }
    last_background_temp = bg_color_temp
    timebox_class = last_background_temp + '-timebox'

我的两个班级是:

.dark-timebox {
    background-color: transparent;
    color: white !important;
    border: none !important;
}

.light-timebox {
    background-color:rgba(255, 255, 255, 0.58);
    color:#a7a7a7 !important;
}

所以我想更改聊天背景,但是当我使用此代码时,它可以在更改背景时起作用,但我也想默认使用它。 我该怎么办?

实际上,如果我不更改聊天背景,则该代码将无效。我该如何解决?

0 个答案:

没有答案