<commit_before>// View model for the courses page
function pageViewModel(gvm) {
    // Page specific i18n bindings
    gvm.title = ko.computed(function(){i18n.setLocale(gvm.lang()); return gvm.app() + ' - ' + i18n.__("CoursesTitle");}, gvm);
    gvm.pageHeader = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("CoursesHeader");}, gvm);
    gvm.projectname = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("ProjectName");}, gvm);

    gvm.availableLocations = ko.observableArray([]);
    gvm.availableTrainings = ko.observableArray([]);
    gvm.availableCourses = ko.observableArray([]);
    
    /*
     * Update the location dropdown list
     */
    gvm.updateLocations = function() {      
        $.getJSON('/api/locations', function(data) {
            gvm.availableLocations.removeAll();
            $.each(data, function(i, item) {
                /* Put item in list */
                gvm.availableLocations.push(item);
                
                /* Add listener to listitem */
                $("#locbtn-" + item.id).click(function(){
                    gvm.updateTrainings(item.id);
                });
            });
        });
        
    }
    
    /*
     * Update the training data
     */
    gvm.updateTrainings = function(id) {   
        $.getJSON('/api/trainings/' + id, function(data) {
            gvm.availableTrainings.removeAll();
            $.each(data, function(i, item) {
                gvm.availableTrainings.push(item);
                
                /* Add listener to listitem */
                $("#trainingbtn-" + item.id).click(function(){
                    gvm.updateCourses(item.id);
                });
            });
        });
    }
    
    /*
     * Update available courses
     */
    gvm.updateCourses = function(id) { 
        $.getJSON('/api/courses/' + id, function(data) {
            gvm.availableCourses.removeAll();
            $.each(data, function(i, item) {
                gvm.availableCourses.push(item);
                
                /* Add listener to listitem */
                $("#coursebtn-" + item.id).click(function(){
                    alert("You selected course: " + item.name);
                });
            });
        });
    }
}

function initPage() {
    viewModel.updateLocations();
    $(".dropdown-location li a").click(function() {
        $(".btn-location").text($(this).text);
    });
}<commit_msg>courses page dropdown menu<commit_after>// View model for the courses page
function pageViewModel(gvm) {
    // Page specific i18n bindings
    gvm.title = ko.computed(function(){i18n.setLocale(gvm.lang()); return gvm.app() + ' - ' + i18n.__("CoursesTitle");}, gvm);
    gvm.pageHeader = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("CoursesHeader");}, gvm);
    gvm.projectname = ko.computed(function(){i18n.setLocale(gvm.lang()); return i18n.__("ProjectName");}, gvm);

    gvm.availableLocations = ko.observableArray([]);
    gvm.availableTrainings = ko.observableArray([]);
    gvm.availableCourses = ko.observableArray([]);
    
    /*
     * Update the location dropdown list
     */
    gvm.updateLocations = function() {      
        $.getJSON('/api/locations', function(data) {
            gvm.availableLocations.removeAll();
            $.each(data, function(i, item) {
                /* Put item in list */
                gvm.availableLocations.push(item);
                
                /* Add listener to listitem */
                $("#locbtn-" + item.id).click(function(){
                    gvm.updateTrainings(item.id);
                });
            });
        });
        
    }
    
    /*
     * Update the training data
     */
    gvm.updateTrainings = function(id) {   
        $.getJSON('/api/trainings/' + id, function(data) {
            gvm.availableTrainings.removeAll();
            $.each(data, function(i, item) {
                gvm.availableTrainings.push(item);
                
                /* Add listener to listitem */
                $("#trainingbtn-" + item.id).click(function(){
                    gvm.updateCourses(item.id);
                });
            });
        });
    }
    
    /*
     * Update available courses
     */
    gvm.updateCourses = function(id) { 
        $.getJSON('/api/courses/' + id, function(data) {
            gvm.availableCourses.removeAll();
            $.each(data, function(i, item) {
                gvm.availableCourses.push(item);
                
                /* Add listener to listitem */
                $("#coursebtn-" + item.id).click(function(){
                    alert("You selected course: " + item.name);
                });
            });
        });
    }
}

function initPage() {
    viewModel.updateLocations();
    $(".dropdown-location li a").click(function() {
        console.log("clicked");
        $(".btn-location").text($(this).text);
    });
}
{'fraction_non_alphanumeric': 0.15553299492385786, 'fraction_numerical': 0.005685279187817259, 'mean_word_length': 1.7366666666666666, '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': '78985', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1390, 'n_words': 226}