<commit_before>angular.module('devslate.codebox', ['ui.codemirror'])

.controller('CodeboxCtrl', function (Socket, $scope) {
  var api = Socket;
   $scope.editorOptions = {
        lineWrapping : true,
        lineNumbers: true,
        mode: 'javascript',
        value: 'asdasdas',
        theme: 'solarized light',
        tabSize: 2,
        keyMap: 'sublime'
    };



  $scope.send = function () {
    Socket.emit('code-text', $scope.code);
  };



  $scope.codebox = function (_editor) {
     // Editor part
      var _doc = _editor.getDoc();
      _editor.focus();

      // Options
      // _editor.setOption('firstLineNumber', 10);
      _doc.markClean();

      var copy = _doc.linkedDoc();

      api.on('code-text', function (data) {
        copy.setValue(data);
         });

     //  // Events
     //  _editor.on("beforeChange", function(){ ... });
     //  _editor.on("change", function(){ ... });
    };


});<commit_msg>attempted adding ot.js<commit_after>angular.module('devslate.codebox', ['ui.codemirror'])

.controller('CodeboxCtrl', function(Socket, $scope) {
  // set socket.io instance var
  var ioApi = Socket;

  // options for loading codemirror
  $scope.editorOptions = {
    lineWrapping: true,
    lineNumbers: true,
    mode: 'javascript',
    value: 'asdasdas',
    theme: 'solarized light',
    tabSize: 2,
    keyMap: 'sublime'
  };

  /**
   * codebox instance
   * @param   {obj}  _cm  cm instance
   */
  $scope.codebox = function(_cm) {
    var cmClient;
    
    /**
     * initializes operational transform library
     * @param   {str}  str            the initial text for doc
     * @param   {??}  revision       revision number to track updates
     * @param   {??}  clients        [description]
     * @param   {[type]}  serverAdapter  [description]
     * @return  {[type]}                 [description]
     */
    var init = function(str, revision, clients, serverAdapter) {
      _cm.setValue(str);
      cmClient = new ot.EditorClient(revision, clients, serverAdapter, new ot.CodeMirrorAdapter(cm));
    };

    //define cm doc
    var _doc = _cm.getDoc();
    _cm.focus();

    // Options
    // _cm.setOption('firstLineNumber', 10);
    _doc.markClean();

    var copy = _doc.linkedDoc();

  };

  /**
   * initialize cm text with ot on socket recieving doc
   */
  ioApi.on('doc', function(obj) {
    init(obj.str, obj.revision, obj.clients, new ot.SocketIOAdapter(ioApi));
  });

});
{'fraction_non_alphanumeric': 0.15258408531583265, 'fraction_numerical': 0.002461033634126333, 'mean_word_length': 2.3828016643550622, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4013856', 'n_tokens_mistral': 804, 'n_tokens_neox': 779, 'n_words': 172}