{"size": 4303, "ext": "js", "max_stars_repo_path": "airline-web/public/javascripts/settings.js", "max_stars_repo_name": "Tempay/airline", "max_stars_repo_stars_event_min_datetime": "2018-07-25T17:12:44.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-26T16:46:18.000Z", "max_issues_repo_path": "airline-web/public/javascripts/settings.js", "max_issues_repo_name": "Tempay/airline", "max_issues_repo_issues_event_min_datetime": "2018-05-19T04:40:55.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-18T16:13:36.000Z", "max_forks_repo_path": "airline-web/public/javascripts/settings.js", "max_forks_repo_name": "Tempay/airline", "max_forks_repo_forks_event_min_datetime": "2018-07-13T22:57:29.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-12T08:53:54.000Z"}
{"max_stars_count": 75, "max_issues_count": 363, "max_forks_count": 51, "avg_line_length": 35.2704918033, "max_line_length": 207, "alphanum_fraction": 0.5440390425}
//determines if the user has a set theme
function showSettings(){
    updateCustomWallpaperPanel()
    $("#settingsModal").fadeIn(500)
}


var wallpaperTemplates = [
    {
        "background" : "linear-gradient(to bottom, rgba(40, 49, 77, 0.8) 30%, rgba(29, 35, 71, 0.8) 50%, rgba(19, 25, 28, 0.8) 80%, rgba(15, 14, 14, .8) 100%), url(assets/images/background/pixel_city_1.gif)"
    },
    {
        "background" : "linear-gradient(to bottom, rgba(40, 49, 77, 0.2) 30%, rgba(29, 35, 71, 0.2) 50%, rgba(19, 25, 28, 0.2) 80%, rgba(15, 14, 14, .2) 100%), url(assets/images/background/pixel_city_2.gif)"
    },
    {
        "background" : "linear-gradient(to bottom, rgba(40, 49, 77, 0.2) 30%, rgba(29, 35, 71, 0.2) 50%, rgba(19, 25, 28, 0.2) 80%, rgba(15, 14, 14, .2) 100%), url(assets/images/background/pixel_city_3.gif)"
    },
    {
        "background" : "linear-gradient(to bottom, rgba(40, 49, 77, 0.2) 30%, rgba(29, 35, 71, 0.2) 50%, rgba(19, 25, 28, 0.2) 80%, rgba(15, 14, 14, .2) 100%), url(assets/images/background/pixel_city_4.gif)"
    }
]

function changeWallpaper() {
    var wallpaperIndex = 0
    if ($.cookie('wallpaperIndex')) {
        wallpaperIndex = parseInt($.cookie('wallpaperIndex'))
    }

    if (activeUser && activeUser.hasWallpaper) {
        removeCustomWallpaper()
    }
    wallpaperIndex = (wallpaperIndex + 1) % wallpaperTemplates.length
    $.cookie('wallpaperIndex', wallpaperIndex, { expires: 9999 })
    refreshWallpaper()
}

function refreshWallpaper() {
    var template
    if (activeUser && activeUser.hasWallpaper) {
        template = {
            "background" : "url(users/" + activeUser.id + "/wallpaper)"
        }
    } else {
        var wallpaperIndex = 0
        if ($.cookie('wallpaperIndex')) {
            wallpaperIndex = parseInt($.cookie('wallpaperIndex'))
        }
        template = wallpaperTemplates[wallpaperIndex]
    }


    $("body").css("background", template.background)
    $("body").css("background-repeat", "no-repeat")
    $("body").css("background-attachment", "fixed")
    $("body").css("background-size", "cover")

}

var wallpaperUploaderObj

function removeCustomWallpaper() {
    activeUser.hasWallpaper = false
    $.ajax({
        type: 'DELETE',
        url: "users/" + activeUser.id + "/wallpaper",
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        success: function() {

        },
        error: function(jqXHR, textStatus, errorThrown) {
                console.log(JSON.stringify(jqXHR));
                console.log("AJAX error: " + textStatus + ' : ' + errorThrown);
        }
    });
}

function updateCustomWallpaperPanel() {
    if (wallpaperUploaderObj) {
        wallpaperUploaderObj.reset()
    }

    if (!activeUser) {
        $('#settingsModal .customWallpaper').hide()
    } else {
        $('#settingsModal .customWallpaper').show()
        $('#settingsModal .customWallpaper .warning').hide()

        if (activeUser.level > 0) {
            wallpaperUploaderObj = $("#settingsModal .customWallpaper .fileuploader").uploadFile({
                        url:"users/" + activeUser.id + "/wallpaper",
                        multiple:false,
                        dragDrop:false,
                        acceptFiles:"image/png,image/gif",
                        fileName:"wallpaperFile",
                        maxFileSize:2 * 1024 * 1024,
                        onSuccess:function(files,data,xhr,pd)
                        {
                            if (data.success) {
                                $('#settingsModal .customWallpaper .warning').hide()
                                wallpaperUploaderObj.reset()
                                activeUser.hasWallpaper = true
                                refreshWallpaper()
                            } else if (data.error) {
                                $('#settingsModal .customWallpaper .warning').text(data.error)
                                $('#settingsModal .customWallpaper .warning').show()
                            }

                        }
                    });
        } else {
              $('#settingsModal .customWallpaper .warning').text("Feature is only avaiable to Patreons")
              $('#settingsModal .customWallpaper .warning').show()
        }
    }





}
