<commit_before>/**
 *
 *    File:         regulation.js
 *    Author:       Rathinho
 *    Description:  Main entrance of this application, including initialization of graphiti
 *                  application, configuration window and websocket.
 *
 **/

// document ready
$().ready(function() {
    document.ontouchmove = function(e) {
        e.preventDefault();
    };

    // click header 
    $(".header").click(function() {
        console.log(app.view.figures);
    });

    // toggle left-container
    $(".trigger-left").click(function() {
        var left = $("#left-container").css("left");

        if (parseInt(left) == 0) {
            $("#left-container").css({
                left: '-270px'
            });
        } else {
            $("#left-container").css({
                left: '0px'
            });
        }
    });

    // toggle right-container
    $(".trigger-right").click(function() {
        var right = $("#right-container").css("right");

        if (parseInt(right) == 0) {
            $("#right-container").css({
                right: '-270px'
            });
        } else {
            $("#right-container").css({
                right: '0px'
            });
        }
    });

    $("#content").click(function() {
        $("#left-container").css({
            left: '-270px'
        });

        $("#right-container").css({
            right: '-270px'
        });
    });

    $("#username").click(function() {
        window.location.pathname = "/profile";
    });

    $(".avatar-container").click(function() {
        window.location.pathname = "/profile";
    });

    // logout
    $("#logout").click(function() {
        ws.send(JSON.stringify({
            'request': 'loginOut'
        }));
    });

    // load file list
    $("#myfile").click(function() {
        // ws.send(JSON.stringify({
        //     'request': 'getUserFileList'
        // }));
        // window.location.pathname = "/file_manager";
        canvasToJSON();
		window.location.pathname = "/file_manager";
    });

    // create new biobrick
    $("#create-part").click(function() {
        //var pngwriter = new graphiti.io.png.Writer();
		console.log('create');
        //var png = pngwriter.marshal(app.view);
		window.location.pathname = "/createnewpart";
        // $(".header img").attr('src', png);
    });

    // save file
    $("#save").click(function() {
        var fnInput = $("#fn-input");
        var filename = fnInput.attr('value');
        if (!filename) {
            fnInput.focus();
            fnInput.tooltip('show');

            // check whether filename input has changed 
            var tid = setInterval(function() {
                filename = fnInput.attr('value');
                if (filename) {
                    fnInput.tooltip('destroy');
                    clearInterval(tid);
                }
            }, 1000);
        } else {
            var saveData = JSON.stringify(canvasToSaveData());
            saveData.fileName = filename;
            saveData.fileType = 'rnw';

            ws.send(JSON.stringify({
                'request': 'saveUserData',
                'data': saveData,
                'fileName': filename,
                'fileType': 'regulation'
            }));

            $("#myModalInfo").html("File: " + filename + " is saved!");
            $("#save-trigger").click();
        }
    });
    
    // clear the canvas
    $("#clear").click(function() {
        app.view = new g.View("canvas");
    });

    // save configuration of protein 
    $("#save-protein").click(function(e) {
        e.preventDefault();
        var expressionVal = $("input[name=expressionVal]").val();
        console.log(expressionVal);
    });

    // save configuration of protein 
    $("#save-ef").click(function(e) {
        e.preventDefault();
        var ConcentrationVal = $("input[name=ConcentrationVal]").val();
        console.log(ConcentrationVal);
    });

    // save configuration of protein 
    $("#save-arrow").click(function(e) {<commit_msg>fix bug on clear opeartion<commit_after>/**
 *
 *    File:         regulation.js
 *    Author:       Rathinho
 *    Description:  Main entrance of this application, including initialization of graphiti
 *                  application, configuration window and websocket.
 *
 **/

// document ready
$().ready(function() {
    document.ontouchmove = function(e) {
        e.preventDefault();
    };

    // click header 
    $(".header").click(function() {
        console.log(app.view.figures);
    });

    // toggle left-container
    $(".trigger-left").click(function() {
        var left = $("#left-container").css("left");

        if (parseInt(left) == 0) {
            $("#left-container").css({
                left: '-270px'
            });
        } else {
            $("#left-container").css({
                left: '0px'
            });
        }
    });

    // toggle right-container
    $(".trigger-right").click(function() {
        var right = $("#right-container").css("right");

        if (parseInt(right) == 0) {
            $("#right-container").css({
                right: '-270px'
            });
        } else {
            $("#right-container").css({
                right: '0px'
            });
        }
    });

    $("#content").click(function() {
        $("#left-container").css({
            left: '-270px'
        });

        $("#right-container").css({
            right: '-270px'
        });
    });

    $("#username").click(function() {
        window.location.pathname = "/profile";
    });

    $(".avatar-container").click(function() {
        window.location.pathname = "/profile";
    });

    // logout
    $("#logout").click(function() {
        ws.send(JSON.stringify({
            'request': 'loginOut'
        }));
    });

    // load file list
    $("#myfile").click(function() {
        // ws.send(JSON.stringify({
        //     'request': 'getUserFileList'
        // }));
        // window.location.pathname = "/file_manager";
        canvasToJSON();
		window.location.pathname = "/file_manager";
    });

    // create new biobrick
    $("#create-part").click(function() {
        //var pngwriter = new graphiti.io.png.Writer();
		console.log('create');
        //var png = pngwriter.marshal(app.view);
		window.location.pathname = "/createnewpart";
        // $(".header img").attr('src', png);
    });

    // save file
    $("#save").click(function() {
        var fnInput = $("#fn-input");
        var filename = fnInput.attr('value');
        if (!filename) {
            fnInput.focus();
            fnInput.tooltip('show');

            // check whether filename input has changed 
            var tid = setInterval(function() {
                filename = fnInput.attr('value');
                if (filename) {
                    fnInput.tooltip('destroy');
                    clearInterval(tid);
                }
            }, 1000);
        } else {
            var saveData = JSON.stringify(canvasToSaveData());
            saveData.fileName = filename;
            saveData.fileType = 'rnw';

            ws.send(JSON.stringify({
                'request': 'saveUserData',
                'data': saveData,
                'fileName': filename,
                'fileType': 'regulation'
            }));

            $("#myModalInfo").html("File: " + filename + " is saved!");
            $("#save-trigger").click();
        }
    });
    
    // clear the canvas
    $("#clear").click(function() {
        app = null;
        $("#canvas").remove();

        $("#canvas-mask").append("<div id=\"canvas\"></div>");
        app = new g.Application();
    });

    // save configuration of protein 
    $("#save-protein").click(function(e) {
        e.preventDefault();
        var expressionVal = $("input[name=expressionVal]").val();
        console.log(expressionVal);
    });

    // save configuration of protein 
    $("#save-ef").click(function(e) {
        e.preventDefault();
        var ConcentrationVal = $("input[name=ConcentrationVal]").val();
        console.log(ConcentrationVal);
    });

    // save configuration of protein 
    $("#save-arrow").click(function(e) {
{'fraction_non_alphanumeric': 0.17966267416279638, 'fraction_numerical': 0.0048887802493277925, 'mean_word_length': 1.7140961857379768, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6716606', 'n_tokens_mistral': 2304, 'n_tokens_neox': 2216, 'n_words': 393}