<commit_before>//Display error
function mayError(errObj){
    if (errObj.error){
        console.log(errObj)
        $("#error strong").text(errObj.error);
        $("#error em").text(errObj.details);
        $("#error").show()
        return 1;
    } else {
        return 0;
    }
}

//Blanks the cards
function newCard(){
    var blankCard = LZString.compressToBase64(JSON.stringify({
        classes: "card pony maleFemale unicorn s0",
        name: "",
        attrs: "",
        effect: "",
        flavour: "",
        copyright: "",
    }))
    updateFields({card:blankCard})
}

//Loads a card
function load(string){
    var data = JSON.parse(LZString.decompressFromBase64(string))
    $(".card").attr("class",data.classes)
    $(".card .nameInput").val(data.name)
    $(".card .attrs").val(data.attrs)
    $(".card .effect").val(data.effect)
    $(".card .flavour").val(data.flavour)
    $(".card .copyright").val(data.copyright)
}

//Saves a card
function save(){
    var newString = LZString.compressToBase64(JSON.stringify({
        classes: $(".card").attr("class"),
        name: $(".card .nameInput").val(),
        attrs: $(".card .attrs").val(),
        effect: $(".card .effect").val(),
        flavour: $(".card .flavour").val(),
        copyright: $(".card .copyright").val(),
    }))
    updateFields({card:newString})
}

function cardSetup(){
    //On card button clicks, remove other classes and add new ones.
    //Unless it is changeling, special case, just toggle.
    $(".card button").click(function(){
        if ($(this).attr("value") == "changeling"){
            $(".card").toggleClass($(this).attr("value"));
        } else {
            $(this).parent().children("button").each(function(){
                if ($(this).attr("value") != "changeling"){
                    $(".card").removeClass($(this).attr("value"));
                }
            })
            $(".card").addClass($(this).attr("value"));
        }
    })

    //On Window resize we use css transformation to scale the card to fix
    //Yes it seems horrible but the alternative was somehting even more horrible!<commit_msg>added hook to state:adjust<commit_after>//Display error
function mayError(errObj){
    if (errObj.error){
        console.log(errObj)
        $("#error strong").text(errObj.error);
        $("#error em").text(errObj.details);
        $("#error").show()
        return 1;
    } else {
        return 0;
    }
}

//Blanks the cards
function newCard(){
    var blankCard = LZString.compressToBase64(JSON.stringify({
        classes: "card pony maleFemale unicorn s0",
        name: "",
        attrs: "",
        effect: "",
        flavour: "",
        copyright: "",
    }))
    updateFields({card:blankCard})
}

//Loads a card
function load(string){
    var data = JSON.parse(LZString.decompressFromBase64(string))
    $(".card").attr("class",data.classes)
    $(".card .nameInput").val(data.name)
    $(".card .attrs").val(data.attrs)
    $(".card .effect").val(data.effect)
    $(".card .flavour").val(data.flavour)
    $(".card .copyright").val(data.copyright)
}
$(document).on("state:adjust",function(event,get,oldGet){
    if (get.card != oldGet.card){
        load(get.card)
    }
})

//Saves a card
function save(){
    var newString = LZString.compressToBase64(JSON.stringify({
        classes: $(".card").attr("class"),
        name: $(".card .nameInput").val(),
        attrs: $(".card .attrs").val(),
        effect: $(".card .effect").val(),
        flavour: $(".card .flavour").val(),
        copyright: $(".card .copyright").val(),
    }))
    updateFields({card:newString},true)
}

function cardSetup(){
    //On card button clicks, remove other classes and add new ones.
    //Unless it is changeling, special case, just toggle.
    $(".card button").click(function(){
        if ($(this).attr("value") == "changeling"){
            $(".card").toggleClass($(this).attr("value"));
        } else {
            $(this).parent().children("button").each(function(){
                if ($(this).attr("value") != "changeling"){
                    $(".card").removeClass($(this).attr("value"));
                }
            })
            $(".card").addClass($(this).attr("value"));
        }
    })

    //On Window resize we use css transformation to scale the card to fix
    //Yes it seems horrible but the alternative was somehting even more horrible!
{'fraction_non_alphanumeric': 0.19148451730418944, 'fraction_numerical': 0.004098360655737705, 'mean_word_length': 2.4920508744038155, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1802779', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1282, 'n_words': 289}