<commit_before>var Profile = {

    MapColorSquares:{
        init:function () {
            $(".selectable", "#map-colors").selectable({
                filter:"div",
                selected:Profile.MapColorSquares.selectedListener
            });

            //TODO: Diese Werte müssen aus der DB kommen
            $(".ui-selectee").css("background-color", "rgb(127, 127, 127)");

            // hover-effect for Squares
            $(".ui-selectee").mouseenter(
                function () {
                    $(this).addClass("map-colors-hover");
                }).mouseleave(function () {
                    $(this).removeClass("map-colors-hover");
                });
        },

        selectedListener:function (event, ui) {
            var bgColor = $("#" + ui.selected.id).css("background-color");

            var values = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(bgColor);
            var red = parseInt(values[2]);
            var green = parseInt(values[3]);
            var blue = parseInt(values[4]);

            Profile.MapColorPicker.updateSlider(red, green, blue);
        }
    },

    MapColorPicker:{
        init:function () {
            $("#red, #green, #blue").slider({
                orientation:"horizontal",
                range:"min",
                max:255,
                value:127,
                slide:Profile.MapColorPicker.updatePreview,
                change:Profile.MapColorPicker.updatePreview
            });
        },

        updateSlider:function (red, green, blue) {
            $("#red").slider("value", red);
            $("#green").slider("value", green);
            $("#blue").slider("value", blue);
        },

        updatePreview:function (event, ui) {
            var red = $("#red").slider("value"),
                green = $("#green").slider("value"),
                blue = $("#blue").slider("value"),
                hex = Profile.MapColorPicker.toHex(red, green, blue);
            $(".ui-selected").css("background-color", "#" + hex);
        },

        toHex:function (red, green, blue) {
            var hex = [red.toString(16), green.toString(16), blue.toString(16)];
            $.each(hex, function (index, value) {
                if (value.length === 1) {
                    hex[index] = "0" + value;
                }
            });
            return hex.join("").toUpperCase();
        }
    }
}

$(document).ready(function () {
    Profile.MapColorSquares.init();
    Profile.MapColorPicker.init();
});<commit_msg>ungetestete Touch Optimierung<commit_after>var Profile = {

    MapColorSquares:{
        init:function () {
            $("#map-colors > .selectable").selectable({
                filter:"div",
                selected:Profile.MapColorSquares.selectedListener
            });

            //TODO: Diese Werte müssen aus der DB kommen
            $(".ui-selectee").css("background-color", "rgb(127, 127, 127)");

            // hover-effect for Squares
            $(".ui-selectee").mouseenter(
                function () {
                    $(this).addClass("map-colors-hover");
                }).mouseleave(function () {
                    $(this).removeClass("map-colors-hover");
                });
        },

        selectedListener:function (event, ui) {
            var bgColor = $("#" + ui.selected.id).css("background-color");

            var values = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(bgColor);
            var red = parseInt(values[2]);
            var green = parseInt(values[3]);
            var blue = parseInt(values[4]);

            Profile.MapColorPicker.updateSlider(red, green, blue);
        }
    },

    MapColorPicker:{
        init:function () {
            $("#red, #green, #blue").slider({
                orientation:"horizontal",
                range:"min",
                max:255,
                value:127,
                slide:Profile.MapColorPicker.updatePreview,
                change:Profile.MapColorPicker.updatePreview
            });
            $("#red > .ui-slider-handle",
                "#green > .ui-slider-handle",
                "#blue > .ui-slider-handle").bind("touchmove", Profile.MapColorPicker.updateSliderHandle);
        },

        updateSlider:function (red, green, blue) {
            $("#red").slider("value", red);
            $("#green").slider("value", green);
            $("#blue").slider("value", blue);
        },

        updatePreview:function (event, ui) {
            var red = $("#red").slider("value"),
                green = $("#green").slider("value"),
                blue = $("#blue").slider("value"),
                hex = Profile.MapColorPicker.toHex(red, green, blue);
            $(".ui-selected").css("background-color", "#" + hex);
        },

        /* iPad-Optimierung
         * @author <NAME>
         * http://www.advitum.de/blog/2011/09/nutzeroberflachen-furs-ipad-jquery-ui-slider/ [Stand 21.05.2012]
         * TODO: Testen!!
         */
        updateSliderHandle:function (event, ui) {
            // x- und y-Position des Fingers, jQuery unterstützt diese Eigenschaft noch nicht, deshalb brauchen wir das Original-Event
            var e = event.originalEvent;

            // Position des Sliders
            var left = $(ui).parent().offset().left;
            var right = left + $(ui).parent().width();

            // Minimaler und maximaler Wert des Sliders
            var min = $(ui).parent().slider('option', 'min');
            var max = $(ui).parent().slider('option', 'max');

            // Mithilfe von einfachem Dreisatz können wir berechnen, welchen Wert die neue Position ergibt
            var newvalue = min + (e.touches.item(0).clientX - left) / (right - left) * (max - min);

            // Jetzt setzen wir den neuen Wert
            $(ui).parent().slider('value', newvalue);
        },

        toHex:function (red, green, blue) {
            var hex = [red.toString(16), green.toString(16), blue.toString(16)];
            $.each(hex, function (index, value) {
                if (value.length === 1) {
                    hex[index] = "0" + value;
                }
            });
            return hex.join("").toUpperCase();
        }
    }
}

$(document).ready(function () {
    Profile.MapColorSquares.init();
    Profile.MapColorPicker.init();
});
{'fraction_non_alphanumeric': 0.16563344460340168, 'fraction_numerical': 0.010650135113654428, 'mean_word_length': 1.6831556503198295, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '5241604', 'n_tokens_mistral': 1772, 'n_tokens_neox': 1683, 'n_words': 317}