Skip to content
tenprint.html 45.1 KiB
Newer Older
<!DOCTYPE html>
<html>
    <head>
        {% for src in js %}
            <script type="text/javascript" src="{{ src }}"></script>
        {% endfor %}
        {% for src in css %}
            <link type="text/css" rel="stylesheet" href="{{ src }}">
        {% endfor %}
        
        <script type="text/javascript" src="{{ url_for( 'files.send_app_files', subpath = 'functions.js' ) }}"></script>
        <link type="text/css" rel="stylesheet" href="{{ url_for( 'files.send_app_files', subpath = 'app.css' ) }}">
            .icnml_button > div > a {
        <script type="text/javascript">
            baseurl = "{{ baseurl }}";
            submission_id = "{{ submission_id }}";
            {% if not admin %}
                var password_local = decrypt( sessionStorage.getItem( "session_key" ), "{{ session_security_key }}" );
                var nickname = decrypt( "{{ nickname }}", password_local );
                var filename = decrypt( "{{ file[ 'filename' ] }}", password_local );
                var note     = decrypt( "{{ file[ 'note' ] }}", password_local );
            {% endif %}
            var zones_array = new Array();
            {% for zone in zones %}
                zones_array.push( {{ zone[ 'fpc' ] }} );
Marco De Donno's avatar
Marco De Donno committed
            {% endfor %}
Marco De Donno's avatar
Marco De Donno committed
            var zonesData = {};
            {% for zone in zones %}
                zonesData[ "{{ zone[ 'fpc' ] }}" ] = {
                    "fpc": {{ zone[ 'fpc' ] }},
                    "x": {{ zone[ 'x' ] }},
                    "y": {{ zone[ 'y' ] }},
                    "width": {{ zone[ 'width' ] }},
                    "height": {{ zone[ 'height' ] }},
                    "orientation": {{ zone[ 'orientation' ] }}
Marco De Donno's avatar
Marco De Donno committed
            
            var segments_position_code = {};
            {% for fpc in segments_position_code %}
                segments_position_code[ "{{ fpc }}" ] = "{{ segments_position_code[ fpc ] }}".replace( "&#39;", "'" );
            var to_annotate = [];
            {% for ta in to_annotate %}
                to_annotate.push( {{ ta }} );
            {% endfor %}
            
            var orientationsData = {};
            {% for zone in zones %}
                orientationsData[ "{{ zone[ 'fpc' ] }}" ] = {{ zone[ 'orientation' ] }};
            {% endfor %}
            
            var update_quality_db = function()
            {
                var quality = $( "#file_{{ file[ 'uuid' ] }}_quality > select > option:checked" ).val();
                
                $.ajax( {
                    url: "{{ url_for( 'submission.submission_tenprint_set_quality', submission_id = submission_id, tenprint_id = file[ 'uuid' ] ) }}",
                    dataType: "json",
                    method: "POST",
                    data: {
                        quality: quality
                    },
                    success: function( data )
                    {
                        if( data.error )
                            toastr.error( "Error while saving the quality value" );
                    },
                    error: function( data )
                    {
                        toastr.error( "Network error" );
                    }
                } );
            }
            
            {% if not admin %}
                var update_note_db = function()
                {
                    var note = $( "#file_note" ).val() || null;
                    note = encrypt( note, password_local );
                    
                    $.ajax( {
                        url: "{{ url_for( 'submission.submission_file_set_note', submission_id = submission_id, tenprint_id = file[ 'uuid' ], file_type = 'tenprint' ) }}",
                        dataType: "json",
                        method: "POST",
                        data: {
                            note: note
                        }
                    } );
                }
            {% endif %}
            var update_coordinates_informations = function()
Marco De Donno's avatar
Marco De Donno committed
            {
                svg_height = $( window ).height() - 100;
                svg_width = svg_height * {{ svg_hw_factor }};
            }
Marco De Donno's avatar
Marco De Donno committed
                $( "#segmentation_button_span_text" ).text( "Segmenting..." );
                $( "#segmentation_button" ).append(
                    $( "<span />" )
                        .attr( "id", "segmentation_button_span_spinner" )
                        .attr( "class", "ld ld-ring ld-cycle" )
                        .css( "position", "absolute" )
                        .css( "right", "20px" )
                )
                
                $( "#segmentation_button" ).off( "click" );
                
                $.ajax( {
                    url: "{{ url_for( 'image.image_tenprint_segmentation', tenprint_id = file[ 'uuid' ] ) }}",
Marco De Donno's avatar
Marco De Donno committed
                    dataType: "json",
                    success: function( data )
                    {
                        $( "#segmentation_button_span_text" ).text( "Segementation updated" );
                        $( "#segmentation_button_span_spinner" ).remove();
                    },
                    error: function( data )
                    {
                        $( "#segmentation_button_span_text" ).text( "Error while segmenting..." );
                        $( "#segmentation_button_span_spinner" ).remove();
                    }
                } );
                $( "#tenprint_svg_div" )
Marco De Donno's avatar
Marco De Donno committed
                    .css( "width", svg_width )
                    .css( "height", svg_height );
                
                $( ".icnml_central" )
                    .css( "width", svg_width * 2 )
                    .css( "height", svg_height );
                
                $( "#zoomed_image" ).attr( "width", svg_width );
                $( "#zoomed_image" ).attr( "height", svg_height );
                
                $( "#tp_polygones" ).empty();
                
                for( var i = 0; i < zones_array.length; i++ )
                {
                    var fpc = zones_array[ i ];
                    var zone = zonesData[ fpc ];
Marco De Donno's avatar
Marco De Donno committed
                    
                    var x = zone[ "x" ] * svg_width;
                    var y = zone[ "y" ] * svg_height;
                    var height = zone[ "height" ] * svg_height;
                    var width = zone[ "width" ] * svg_width;
                    var orientation = zone[ "orientation" ];
                        .append( segment_svg( fpc, x, y, height, width, orientation ) );
Marco De Donno's avatar
Marco De Donno committed
                }
                
                $( "#tp_polygones > g > rect" ).on( "mousewheel", mouse_wheel );
            
            var delete_tenprint = function()
            {
Marco De Donno's avatar
Marco De Donno committed
                $( "<div />" )
                    .attr( "id", "delete_confirmation" )
                    .text( "Do you really want to delete this tenprint card?" )
                    .dialog( {
                        title: "Confirm tenprint deletion",
                        modal: true,
                        buttons: {
                            "OK": function()
Marco De Donno's avatar
Marco De Donno committed
                                $.ajax( {
                                    url: "{{ url_for( 'submission.submission_tenprint_delete', submission_id = submission_id, tenprint_id = file[ 'uuid' ] ) }}",
Marco De Donno's avatar
Marco De Donno committed
                                    dataType: "json",
                                    success: function( data )
                                    {
                                        $( "#delete_confirmation" ).remove();
                                        window.location = "{{ url_for( 'submission.submission_tenprint_list', submission_id = submission_id ) }}";
Marco De Donno's avatar
Marco De Donno committed
                                    },
                                    error: function( data )
                                    {
                                        $( "#delete_confirmation" ).remove();
                                    }
                                } );
Loading
Loading full blame...