<commit_before><!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>trivium registry</title>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/rivets.bundled.min.js"></script>
    <script type="text/jsx">
      /** @jsx React.DOM */
      var BindingEntry = React.createClass({
        getInitialState: function(){
      	    var that = this;
            $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({id:this.props.id,command:"status"}),
                success: function(data){
                        that.setState({state:data.state});
                    }
                });
      	  	return {logmessage:''};
      	  },
      	  start: function(){
      	  var that = this;
              $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({id:this.props.id,command:"start"}),
                success: function(data){
                        console.log(data.trim());
                        if(data.length>0)
                             that.setState({state:"running",
                                    logmessage:data});
                    }
                });

      	  },
      	  stop: function(){
      	  var that = this;
      	    $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({id:this.props.id,command:"stop"}),
                success: function(data){
                        console.log(data.trim());
                        if(data.trim()=="true")
                             that.setState({state:"stopped"});
                    }
                });
      	  },
      	  render: function() {
            return (<li>{all[this.props.id]} =&gt;
                {this.state.state=="stopped"?<button onClick={this.start}>start</button>:''}
                {this.state.state=="running"?<button onClick={this.stop}>stop</button>:''}
                {this.state.logmessage.length>0?<p style={{border:'1px solid grey',backgroundColor:'lightgrey',
                    marginLeft:'10px',marginRight:'10px'}}>{this.state.logmessage}</p>:''}
                    </li>);
          }
      });
      var Binding = React.createClass({
      	  getInitialState: function(){
      	    var that = this;
            $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({id:this.props.id,command:"status"}),
                success: function(data){
                        that.setState({state:data.state});
                    }
                });
      	  	return {};
      	  },
          render: function() {
            var entries = this.props.id.map(function(e){ return <BindingEntry key={e} id={e} />; });
            return (<div>Binding: <ul>{entries}</ul></div>);
          }
      });
    </script>
</head>
<body>
    <template id="typeListElement">
        <style>
        </style>
        <tr>
            <td class="typeName"></td>
            <td class="typeAction"><a href="#">show source</a></td>
        </tr>
    </template>
    <template id="taskListElement">
        <style>
        </style>
        <tr>
            <td class="taskName"></td>
            <td class="taskAction"><a href="#">show source</a></td>
        </tr>
    </template>
    <template id="bindingListElement">
        <style>
        </style>
        <tr>
            <td class="bindingName"></td>
            <td class="bindingAction">
                <a href="#" style="display:none;">start</a>
                <a href="#" style="display:none;">stop</a>
            </td>
        </tr>
    </template>
	<h1>trivium registry</h1>
    <div><h3>Type:</h3>
        <table id="typeList">
        </table>
    </div>
    <div><h3>Task:</h3>
        <table id="taskList">
        </table>
    </div>
    <div><h3>Binding:</h3>
        <table id="bindingList">
        </table>
    </div>
</body>
<script>
        $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({"command":"listTypes"}),
                success: function(data){
                    var t = document.querySelector('#typeListElement');
                    for(var idx in data){
                        var clone = t.content.cloneNode(true);
                        clone.querySelector('.typeName').textContent = data[idx]+" ["+idx+"]";
                        clone.querySelector('.typeAction a').href = 'type.html?type='+idx;
                        document.querySelector('#typeList').appendChild(clone);
                    }
                    }
                });
            $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({"command":"listTasks"}),
                success: function(data){
                    var t = document.querySelector('#taskListElement');
                    for(var idx in data){
                        var clone = t.content.cloneNode(true);
                        clone.querySelector('.taskName').textContent = data[idx]+" ["+idx+"]";
                        document.querySelector('#taskList').appendChild(clone);
                    }
                    }
                });
            $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({"command":"listBindings"}),
                success: function(data){
                    var t = document.querySelector('#bindingListElement');
                    for(var idx in data){
                        var clone = t.content.cloneNode(true);
                        clone.querySelector('.bindingName').textContent = data[idx];
                        var start = clone.querySelectorAll('.bindingAction a')[0];
                        start.id=idx+'start';
                        start.addEventListener('click',function(){
                          $.ajax({
                            type: "POST",
                            url: '/ui/RegistryRequestHandler',
                            data: JSON.stringify({id:idx,command:"start"}),
                            success: function(data){
                                console.log('done');
                            }
                          });
                        });
                        clone.querySelectorAll('.bindingAction a')[1].id=idx+'stop';
                        document.querySelector('#bindingList').appendChild(clone);
                        //check state
                        $.ajax({
                            type: "POST",
                            url: '/ui/RegistryRequestHandler',
                            data: JSON.stringify({id:idx,command:"status"}),
                            success: function(data){
                                var id = data.id.replace(/\./g,'\\.');
                                if(data.state=='running'){
                                    $('#'+id+'stop').show();
                                }else{
                                    $('#'+id+'start').show();
                                }
                            }
                        });
                    }
                    }
                });
</script>
</html><commit_msg>fix binding start/stop through gui<commit_after><!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>trivium registry</title>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/rivets.bundled.min.js"></script>
    <script type="text/jsx">
      /** @jsx React.DOM */
      var BindingEntry = React.createClass({
        getInitialState: function(){
      	    var that = this;
            $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({id:this.props.id,command:"status"}),
                success: function(data){
                        that.setState({state:data.state});
                    }
                });
      	  	return {logmessage:''};
      	  },
      	  start: function(){
      	  var that = this;
              $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({id:this.props.id,command:"start"}),
                success: function(data){
                        console.log(data.trim());
                        if(data.length>0)
                             that.setState({state:"running",
                                    logmessage:data});
                    }
                });

      	  },
      	  stop: function(){
      	  var that = this;
      	    $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({id:this.props.id,command:"stop"}),
                success: function(data){
                        console.log(data.trim());
                        if(data.trim()=="true")
                             that.setState({state:"stopped"});
                    }
                });
      	  },
      	  render: function() {
            return (<li>{all[this.props.id]} =&gt;
                {this.state.state=="stopped"?<button onClick={this.start}>start</button>:''}
                {this.state.state=="running"?<button onClick={this.stop}>stop</button>:''}
                {this.state.logmessage.length>0?<p style={{border:'1px solid grey',backgroundColor:'lightgrey',
                    marginLeft:'10px',marginRight:'10px'}}>{this.state.logmessage}</p>:''}
                    </li>);
          }
      });
      var Binding = React.createClass({
      	  getInitialState: function(){
      	    var that = this;
            $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({id:this.props.id,command:"status"}),
                success: function(data){
                        that.setState({state:data.state});
                    }
                });
      	  	return {};
      	  },
          render: function() {
            var entries = this.props.id.map(function(e){ return <BindingEntry key={e} id={e} />; });
            return (<div>Binding: <ul>{entries}</ul></div>);
          }
      });
    </script>
</head>
<body>
    <template id="typeListElement">
        <style>
        </style>
        <tr>
            <td class="typeName"></td>
            <td class="typeAction"><a href="#">show source</a></td>
        </tr>
    </template>
    <template id="taskListElement">
        <style>
        </style>
        <tr>
            <td class="taskName"></td>
            <td class="taskAction"><a href="#">show source</a></td>
        </tr>
    </template>
    <template id="bindingListElement">
        <style>
        </style>
        <tr>
            <td class="bindingName"></td>
            <td class="bindingAction">
                <a href="#" style="display:none;">start</a>
                <a href="#" style="display:none;">stop</a>
            </td>
        </tr>
    </template>
	<h1>trivium registry</h1>
    <div><h3>Type:</h3>
        <table id="typeList">
        </table>
    </div>
    <div><h3>Task:</h3>
        <table id="taskList">
        </table>
    </div>
    <div><h3>Binding:</h3>
        <table id="bindingList">
        </table>
    </div>
</body>
<script>
        $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({"command":"listTypes"}),
                success: function(data){
                    var t = document.querySelector('#typeListElement');
                    for(var idx in data){
                        var clone = t.content.cloneNode(true);
                        clone.querySelector('.typeName').textContent = data[idx]+" ["+idx+"]";
                        clone.querySelector('.typeAction a').href = 'type.html?type='+idx;
                        document.querySelector('#typeList').appendChild(clone);
                    }
                    }
                });
            $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({"command":"listTasks"}),
                success: function(data){
                    var t = document.querySelector('#taskListElement');
                    for(var idx in data){
                        var clone = t.content.cloneNode(true);
                        clone.querySelector('.taskName').textContent = data[idx]+" ["+idx+"]";
                        document.querySelector('#taskList').appendChild(clone);
                    }
                    }
                });
            $.ajax({
                type: "POST",
                url: '/ui/RegistryRequestHandler',
                data: JSON.stringify({"command":"listBindings"}),
                success: function(data){
                    var t = document.querySelector('#bindingListElement');
                    for(var idx in data){
                        var clone = t.content.cloneNode(true);
                        clone.querySelector('.bindingName').textContent = data[idx]+" ["+idx+"]";
                        var start = clone.querySelectorAll('.bindingAction a')[0];
                        start.id=idx+'start';
                        start.addEventListener('click',function(e){
                          var id = this.id;
                          if(/start/g.test(id)){
                            id=id.substr(0,id.length-5);
                          }else{
                            id=id.substr(0,id.length-4);
                          }
                          $.ajax({
                            type: "POST",
                            url: '/ui/RegistryRequestHandler',
                            data: JSON.stringify({id:id,command:"start"}),
                            success: function(data){
                                console.log('done');
                            }
                          });
                        });
                        clone.querySelectorAll('.bindingAction a')[1].id=idx+'stop';
                        document.querySelector('#bindingList').appendChild(clone);
                        //check state
                        $.ajax({
                            type: "POST",
                            url: '/ui/RegistryRequestHandler',
                            data: JSON.stringify({id:idx,command:"status"}),
                            success: function(data){
                                var id = data.id.replace(/\./g,'\\.');
                                if(data.state=='running'){
                                    $('#'+id+'stop').show();
                                }else{
                                    $('#'+id+'start').show();
                                }
                            }
                        });
                    }
                    }
                });
</script>
</html>
{'fraction_non_alphanumeric': 0.15079469328779718, 'fraction_numerical': 0.002627085248916327, 'mean_word_length': 1.1884162115550445, 'pattern_counts': {'":': 6, '<': 181, '<?xml version=': 0, '>': 185, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2557153', 'n_tokens_mistral': 3905, 'n_tokens_neox': 3718, 'n_words': 601}