function initFunctionalButtonsEvent(){
    // prevent user from entering dots in file name when saved in server
    $('#file-name').keydown(function(e){
        console.log('2')
        if(e.keyCode == 190 || e.keyCode == 110){
            alert('Can Use . For File Name')
            e.preventDefault(); 
        }
    })
    // delete selected operator
    $('#delete_selected_button').click(function () {
        $('#ivr').flowchart('deleteSelected');
    });
    // save the flowchart in server, as json
    $('#server_save_button').click(function () {
        var data = $('#ivr').flowchart('getData');
        //check if there is data in flowchart
        if (Object.keys(data.operators).length == 1) {
            // 1 because of Start Op
            alert('Can Not Save Empty Flow Chart')
            return false
        } else {
            $('#ivr').flowchart('saveFlowchartAsJson', $('#file-name').val());
        }
    });
    // save file for SIP in server (as txt file)
    $('#activate_button').click(function () {
        $('#ivr').flowchart('saveTextForSIP');

    });

    // save data to local storage
    $('#get_data').click(function () {
        var data = $('#ivr').flowchart('getData');
        var JsonData = JSON.stringify(data);
        localStorage.setItem("data", JsonData);

    });
    // get data from localstorage and store it in data
    $('#set_data').click(function () {
        var data = JSON.parse(localStorage.getItem("data"));
        $('#ivr').flowchart('setData', data);
    });
    // delete files from server (json files of older flowcharts)
    $('#delete_button').click(function () {
        var userConfirm = confirm("Are You Sure You Want To Delete These Files?");
        if (userConfirm == false) {
            return false
        }
        var selected = [];
        $('#FlowChartFiles input:checked').each(function () {
            selected.push($(this).val());
        });
        let config = clientConfig();
        /**
         * if you work with local host, else change to config.server
         */
        const jsonUrl = config.local +'DeleteJsonFiles';
        fetch(jsonUrl, {
            method: 'delete',
            body: JSON.stringify(selected),
            headers: {
                'Content-Type': 'application/json',
            }
        })
            .then(res => {
                if (res.statusText == 'OK') {
                    selected.forEach(element => {
                        if ($('#FlowChartDropDown').val() == element) {
                            initEmptyFlowChart()
                        }
                        $("#FlowChartDropDown option[value=" + element + "]").remove();
                    })
                } else {
                    alert('Can Not Delete Files - Internal Server Error')
                }
            }).catch(function () {
                alert('Failed To Get The Exists Flow Charts - Server Is Off')
            })


    });
    $('#clear').click(function () {
        var txt;
        var r = confirm("Save Your State!\n Are You Sure?");
        if (r == true) {
            initEmptyFlowChart()
        }
        $("#printToHTML").empty();
    });
}
/**
 * init all functional buttons events (the button in bottom)
 */
init all functional buttons events (the button in bottom)
init all functional buttons events ( the button in bottom )
function initFunctionalButtonsEvent(){
    $('#file-name').keydown(function(e){
        console.log('2')
        if(e.keyCode == 190 || e.keyCode == 110){
            alert('Can Use . For File Name')
            e.preventDefault(); 
        }
    })
    $('#delete_selected_button').click(function () {
        $('#ivr').flowchart('deleteSelected');
    });
    $('#server_save_button').click(function () {
        var data = $('#ivr').flowchart('getData');
        if (Object.keys(data.operators).length == 1) {
            alert('Can Not Save Empty Flow Chart')
            return false
        } else {
            $('#ivr').flowchart('saveFlowchartAsJson', $('#file-name').val());
        }
    });
    $('#activate_button').click(function () {
        $('#ivr').flowchart('saveTextForSIP');
    });
    $('#get_data').click(function () {
        var data = $('#ivr').flowchart('getData');
        var JsonData = JSON.stringify(data);
        localStorage.setItem("data", JsonData);
    });
    $('#set_data').click(function () {
        var data = JSON.parse(localStorage.getItem("data"));
        $('#ivr').flowchart('setData', data);
    });
    $('#delete_button').click(function () {
        var userConfirm = confirm("Are You Sure You Want To Delete These Files?");
        if (userConfirm == false) {
            return false
        }
        var selected = [];
        $('#FlowChartFiles input:checked').each(function () {
            selected.push($(this).val());
        });
        let config = clientConfig();
        const jsonUrl = config.local +'DeleteJsonFiles';
        fetch(jsonUrl, {
            method: 'delete',
            body: JSON.stringify(selected),
            headers: {
                'Content-Type': 'application/json',
            }
        })
            .then(res => {
                if (res.statusText == 'OK') {
                    selected.forEach(element => {
                        if ($('#FlowChartDropDown').val() == element) {
                            initEmptyFlowChart()
                        }
                        $("#FlowChartDropDown option[value=" + element + "]").remove();
                    })
                } else {
                    alert('Can Not Delete Files - Internal Server Error')
                }
            }).catch(function () {
                alert('Failed To Get The Exists Flow Charts - Server Is Off')
            })
    });
    $('#clear').click(function () {
        var txt;
        var r = confirm("Save Your State!\n Are You Sure?");
        if (r == true) {
            initEmptyFlowChart()
        }
        $("#printToHTML").empty();
    });
}
function initFunctionalButtonsEvent ( ) { $ ( '#file-name' ) . keydown ( function ( e ) { console . log ( '2' ) if ( e . keyCode == 190 || e . keyCode == 110 ) { alert ( 'Can Use . For File Name' ) e . preventDefault ( ) ; } } ) $ ( '#delete_selected_button' ) . click ( function ( ) { $ ( '#ivr' ) . flowchart ( 'deleteSelected' ) ; } ) ; $ ( '#server_save_button' ) . click ( function ( ) { var data = $ ( '#ivr' ) . flowchart ( 'getData' ) ; if ( Object . keys ( data . operators ) . length == 1 ) { alert ( 'Can Not Save Empty Flow Chart' ) return false } else { $ ( '#ivr' ) . flowchart ( 'saveFlowchartAsJson' , $ ( '#file-name' ) . val ( ) ) ; } } ) ; $ ( '#activate_button' ) . click ( function ( ) { $ ( '#ivr' ) . flowchart ( 'saveTextForSIP' ) ; } ) ; $ ( '#get_data' ) . click ( function ( ) { var data = $ ( '#ivr' ) . flowchart ( 'getData' ) ; var JsonData = JSON . stringify ( data ) ; localStorage . setItem ( "data" , JsonData ) ; } ) ; $ ( '#set_data' ) . click ( function ( ) { var data = JSON . parse ( localStorage . getItem ( "data" ) ) ; $ ( '#ivr' ) . flowchart ( 'setData' , data ) ; } ) ; $ ( '#delete_button' ) . click ( function ( ) { var userConfirm = confirm ( "Are You Sure You Want To Delete These Files?" ) ; if ( userConfirm == false ) { return false } var selected = [ ] ; $ ( '#FlowChartFiles input:checked' ) . each ( function ( ) { selected . push ( $ ( this ) . val ( ) ) ; } ) ; let config = clientConfig ( ) ; const jsonUrl = config . local + 'DeleteJsonFiles' ; fetch ( jsonUrl , { method : 'delete' , body : JSON . stringify ( selected ) , headers : { 'Content-Type' : 'application/json' , } } ) . then ( res => { if ( res . statusText == 'OK' ) { selected . forEach ( element => { if ( $ ( '#FlowChartDropDown' ) . val ( ) == element ) { initEmptyFlowChart ( ) } $ ( "#FlowChartDropDown option[value=" + element + "]" ) . remove ( ) ; } ) } else { alert ( 'Can Not Delete Files - Internal Server Error' ) } } ) . catch ( function ( ) { alert ( 'Failed To Get The Exists Flow Charts - Server Is Off' ) } ) } ) ; $ ( '#clear' ) . click ( function ( ) { var txt ; var r = confirm ( "Save Your State!\n Are You Sure?" ) ; if ( r == true ) { initEmptyFlowChart ( ) } $ ( "#printToHTML" ) . empty ( ) ; } ) ; }
init all functional buttons events (the button in bottom)
init all functional buttons events ( the button in bottom )
// prevent user from entering dots in file name when saved in server // delete selected operator // save the flowchart in server, as json //check if there is data in flowchart // 1 because of Start Op // save file for SIP in server (as txt file) // save data to local storage // get data from localstorage and store it in data // delete files from server (json files of older flowcharts) /**
         * if you work with local host, else change to config.server
         */