<commit_before><?php $this->headTitle('Move Classification'); ?>
<?php 
	  $this->layout()->breadcrumbs .= '<a href="' .  $this->url('manage_classification') . '" style="float:left;color:white;"> Classification > </a>' 
	                                . ' Move';
 ?>
<?php
$id;
if ($request->getqueryParams('id') !== null) {
    $params = $request->getqueryParams();
    $action = $params['action'];
    $id = $params['id'];
}
$url_components = parse_url($this->serverUrl());
$url_host = $url_components['scheme'] . '://' . $url_components['host'];
?>
<script>
	var ur = <?php echo json_encode($url_host); ?>;
    _select = '';
    function bindClassificationFolder(context)
    {
        fl_changed = $(_select, context).val();
        var no_of_fl_parent = $('.select_fl').length;
        for (var i = 0; i < no_of_fl_parent; i++)
        {
            if ($('.select_fl').eq(i).val() === fl_changed)
            {
                change_idx = i;
                folder_Id = $('.select_fl').eq(i).val();
                break;
            }
        }
        /*for(i = change_idx + 1; i < no_of_fl_parent; i++)
         {
         $('.label_fl').eq(i).remove();
         $('.inner_div_fl').eq(i).remove();
         $('.select_fl').eq(i).remove();
         }*/

        $('.outer_div_fl').eq(change_idx).nextAll('.outer_div_fl').remove();

        no_of_fl_parent = $('.select_fl').length;

        $.ajax({
            method: 'post',
            //url: 'http://localhost<?= $this->url('get_work_details') ?>',
			url: ur + '<?=$this->url('get_work_details')?>',
            data: {
                folder_Id: folder_Id
            },
            dataType: "json",
            cache: false,
            success: function (data)
            {
                $('.outer_div_fl').eq(no_of_fl_parent - 1).css('background', '#8ec252');

                if (data.folder_children.length > 0)
                {
                    $('.outer_div_fl').eq(no_of_fl_parent - 1).after('<div class="form-group outer_div_fl" name="outer_div_fl" />');
                    $('.outer_div_fl').eq(no_of_fl_parent).append('<label class="col-xs-2 control-label label_fl" name="label_fl">Subject Tree: </label>');
                    $('.outer_div_fl').eq(no_of_fl_parent).append('<div class="col-xs-5 inner_div_fl" name="inner_div_fl" />');

                    _select = $('<select class="form-control select_fl" name="select_fl[]">');
                    to_append = $('<option value="' + '"none"' + '></option>');
                    $.each(data.folder_children, function (key, val) {
                        to_append += '<option value="' + val.id + '">' + val.text_fr + '</option>';
                    });
                    _select.append($('<option />'));
                    _select.append(to_append);
                    $('.inner_div_fl').eq(no_of_fl_parent).append(_select);
                    $('.inner_div_fl').eq(no_of_fl_parent).append('</select>');

                    _select.on('change', function () {
                        bindClassificationFolder(document);
                    });
                }
            },
            error: function (data) {
                //$("#Classification", context).html('<p>No Options</p>');
            }
        });
        return false;
    }

    $(document).ready(function () {
        $("#submit_save").click(function () {
            var fl_id = $("#mv_fl_id").val();
            var $select = $('.select_fl').eq(($('.select_fl').length) - 1);
            fl_moved_id = $select.val();
            if (fl_moved_id === 'none' || fl_moved_id === '')
            {
                $select = $('.select_fl').eq(($('.select_fl').length) - 2);
                fl_moved_id = $select.val();
            }
            if (fl_id === fl_moved_id)
            {
                alert("wrong");
                $('.moveError').show();
                $select.focus();
                return false;
            }
        });

        $(".select_fl").on('change', function () {
            if ($(this).val() == "none") {
                $('.outer_div_fl').eq(0).nextAll('.outer_div_fl').remove();
                $('.select_fl').eq(0).val('none');
                return false;
            } else
            {
                fl_changed = $(this).val();
                var no_of_fl_parent = $('.select_fl').length;

                for (var i = 0; i < no_of_fl_parent; i++)
                {
                    if ($('.select_fl').eq(i).val() === fl_changed)
                    {
                        change_idx = i;
                        folder_Id = $('.select_fl').eq(i).val();
                        break;
                    }
                }

                $('.outer_div_fl').eq(change_idx).nextAll('.outer_div_fl').remove();

                no_of_fl_parent = $('.select_fl').length;

                $.ajax({
                    method: 'post',
                    //url: 'http://localhost<?= $this->url('get_work_details') ?>',
					url: ur + '<?=$this->url('get_work_details')?>',
                    data: {
                        folder_Id: folder_Id
                    },
                    dataType: "json",
                    cache: false,
                    success: function (data)
                    {
                        $('.outer_div_fl').eq(no_of_fl_parent - 1).css('background', '#8ec252');

                        $('.outer_div_fl').eq(no_of_fl_parent - 1).after('<div class="form-group outer_div_fl" name="outer_div_fl" />');
                        $('.outer_div_fl').eq(no_of_fl_parent).append('<label class="col-xs-2 control-label label_fl" name="label_fl">Subject Tree: </label>');
                        $('.outer_div_fl').eq(no_of_fl_parent).append('<div class="col-xs-5 inner_div_fl" name="inner_div_fl" />');

                        _select = $('<select class="form-control select_fl" name="select_fl[]">');
                        to_append = $('<option value="none"></option>');
                        $.each(data.folder_children, function (key, val) {
                            to_append += '<option value="' + val.id + '">' + val.text_fr + '</option>';
                        });
                        _select.append($('<option />'));
                        _select.append(to_append);
                        $('.inner_div_fl').eq(no_of_fl_parent).append(_select);
                        $('.inner_div_fl').eq(no_of_fl_parent).append('</select>');

                        _select.on('change', function () {
                            bindClassificationFolder(document);
                        });
                    },
                    error: function (data) {
                        //$("#Classification", context).html('<p>No Options</p>');
                    }
                });

                return false;
            }
        });
    });
</script>
<div class="col-md-7" name="mv_classification" id="mv_classification"><commit_msg>highlighted rows in classification > move for testing purpose, removed it.<commit_after><?php $this->headTitle('Move Classification'); ?>
<?php 
	  $this->layout()->breadcrumbs .= '<a href="' .  $this->url('manage_classification') . '" style="float:left;color:white;"> Classification > </a>' 
	                                . ' Move';
 ?>
<?php
$id;
if ($request->getqueryParams('id') !== null) {
    $params = $request->getqueryParams();
    $action = $params['action'];
    $id = $params['id'];
}
$url_components = parse_url($this->serverUrl());
$url_host = $url_components['scheme'] . '://' . $url_components['host'];
?>
<script>
	var ur = <?php echo json_encode($url_host); ?>;
    _select = '';
    function bindClassificationFolder(context)
    {
        fl_changed = $(_select, context).val();
        var no_of_fl_parent = $('.select_fl').length;
        for (var i = 0; i < no_of_fl_parent; i++)
        {
            if ($('.select_fl').eq(i).val() === fl_changed)
            {
                change_idx = i;
                folder_Id = $('.select_fl').eq(i).val();
                break;
            }
        }
        /*for(i = change_idx + 1; i < no_of_fl_parent; i++)
         {
         $('.label_fl').eq(i).remove();
         $('.inner_div_fl').eq(i).remove();
         $('.select_fl').eq(i).remove();
         }*/

        $('.outer_div_fl').eq(change_idx).nextAll('.outer_div_fl').remove();

        no_of_fl_parent = $('.select_fl').length;

        $.ajax({
            method: 'post',
            //url: 'http://localhost<?= $this->url('get_work_details') ?>',
			url: ur + '<?=$this->url('get_work_details')?>',
            data: {
                folder_Id: folder_Id
            },
            dataType: "json",
            cache: false,
            success: function (data)
            {
                //$('.outer_div_fl').eq(no_of_fl_parent - 1).css('background', '#8ec252');

                if (data.folder_children.length > 0)
                {
                    $('.outer_div_fl').eq(no_of_fl_parent - 1).after('<div class="form-group outer_div_fl" name="outer_div_fl" />');
                    $('.outer_div_fl').eq(no_of_fl_parent).append('<label class="col-xs-2 control-label label_fl" name="label_fl">Subject Tree: </label>');
                    $('.outer_div_fl').eq(no_of_fl_parent).append('<div class="col-xs-5 inner_div_fl" name="inner_div_fl" />');

                    _select = $('<select class="form-control select_fl" name="select_fl[]">');
                    to_append = $('<option value="' + '"none"' + '></option>');
                    $.each(data.folder_children, function (key, val) {
                        to_append += '<option value="' + val.id + '">' + val.text_fr + '</option>';
                    });
                    _select.append($('<option />'));
                    _select.append(to_append);
                    $('.inner_div_fl').eq(no_of_fl_parent).append(_select);
                    $('.inner_div_fl').eq(no_of_fl_parent).append('</select>');

                    _select.on('change', function () {
                        bindClassificationFolder(document);
                    });
                }
            },
            error: function (data) {
                //$("#Classification", context).html('<p>No Options</p>');
            }
        });
        return false;
    }

    $(document).ready(function () {
        $("#submit_save").click(function () {
            var fl_id = $("#mv_fl_id").val();
            var $select = $('.select_fl').eq(($('.select_fl').length) - 1);
            fl_moved_id = $select.val();
            if (fl_moved_id === 'none' || fl_moved_id === '')
            {
                $select = $('.select_fl').eq(($('.select_fl').length) - 2);
                fl_moved_id = $select.val();
            }
            if (fl_id === fl_moved_id)
            {
                alert("wrong");
                $('.moveError').show();
                $select.focus();
                return false;
            }
        });

        $(".select_fl").on('change', function () {
            if ($(this).val() == "none") {
                $('.outer_div_fl').eq(0).nextAll('.outer_div_fl').remove();
                $('.select_fl').eq(0).val('none');
                return false;
            } else
            {
                fl_changed = $(this).val();
                var no_of_fl_parent = $('.select_fl').length;

                for (var i = 0; i < no_of_fl_parent; i++)
                {
                    if ($('.select_fl').eq(i).val() === fl_changed)
                    {
                        change_idx = i;
                        folder_Id = $('.select_fl').eq(i).val();
                        break;
                    }
                }

                $('.outer_div_fl').eq(change_idx).nextAll('.outer_div_fl').remove();

                no_of_fl_parent = $('.select_fl').length;

                $.ajax({
                    method: 'post',
                    //url: 'http://localhost<?= $this->url('get_work_details') ?>',
					url: ur + '<?=$this->url('get_work_details')?>',
                    data: {
                        folder_Id: folder_Id
                    },
                    dataType: "json",
                    cache: false,
                    success: function (data)
                    {
                        //$('.outer_div_fl').eq(no_of_fl_parent - 1).css('background', '#8ec252');

                        $('.outer_div_fl').eq(no_of_fl_parent - 1).after('<div class="form-group outer_div_fl" name="outer_div_fl" />');
                        $('.outer_div_fl').eq(no_of_fl_parent).append('<label class="col-xs-2 control-label label_fl" name="label_fl">Subject Tree: </label>');
                        $('.outer_div_fl').eq(no_of_fl_parent).append('<div class="col-xs-5 inner_div_fl" name="inner_div_fl" />');

                        _select = $('<select class="form-control select_fl" name="select_fl[]">');
                        to_append = $('<option value="none"></option>');
                        $.each(data.folder_children, function (key, val) {
                            to_append += '<option value="' + val.id + '">' + val.text_fr + '</option>';
                        });
                        _select.append($('<option />'));
                        _select.append(to_append);
                        $('.inner_div_fl').eq(no_of_fl_parent).append(_select);
                        $('.inner_div_fl').eq(no_of_fl_parent).append('</select>');

                        _select.on('change', function () {
                            bindClassificationFolder(document);
                        });
                    },
                    error: function (data) {
                        //$("#Classification", context).html('<p>No Options</p>');
                    }
                });

                return false;
            }
        });
    });
</script>
<div class="col-md-7" name="mv_classification" id="mv_classification">
{'fraction_non_alphanumeric': 0.1825402504472272, 'fraction_numerical': 0.0035778175313059034, 'mean_word_length': 1.5227436823104694, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 108, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1546193', 'n_tokens_mistral': 4177, 'n_tokens_neox': 3907, 'n_words': 574}