<commit_before>'use strict';

angular.module('impression.atomspaceView', ['ngRoute'])

.config(['$routeProvider', function($routeProvider) {
    $routeProvider.when('/atomspace', {
        templateUrl: 'views/atomspace/atomspace.html',
        controller: 'AtomspaceCtrl'
    });
}])

.controller('AtomspaceCtrl', function($scope, $interval, $routeParams, $http, $location, AtomsFactory) {

    $scope.$on('$destroy', function() {
        $interval.cancel(stop);
        stop = undefined;
        simulation.stop();
        chart.remove();
        AtomsFactory.pollSettings = { 'filterby': 'attentionalfocus', 'includeIncoming': 'true', 'includeOutgoing': 'true' }
    });

    //stuff for options:
    $scope.pollSettings = {
      "filterby": "attentionalfocus",
      "stimin": 1,
      "stimax": 30000,
      "includeIncoming": true,
      "includeOutgoing": true 
    }

    $scope.$watch('pollSettings', function(newValue) {
      console.log("🎑 new filter")
      AtomsFactory.pollSettings = newValue
      AtomsFactory.updateAtoms()
    }, true);

    //bounce back to connect screen if disconnected.
    if(!AtomsFactory.connected) { $location.path("/"); } else {

      //Initialize size for canvas drawing
      var width = document.getElementById("atomspace").clientWidth,
          height = document.getElementById("atomspace").clientHeight;
  
      //Dynamic Resize
      window.addEventListener("resize", function() {
          width = document.getElementById("atomspace").clientWidth;
          height = document.getElementById("atomspace").clientHeight;
          
          chart.attr("width", width).attr("height", height);
          
          simulation.force("center", d3.forceCenter(width / 2, height / 2))
      });
  
      var transform = d3.zoomIdentity; //transform identity for pan/zoom
      var nodeBinding, linkBinding, simulation, nodeEnter, linkEnter;
  
  
      var base = d3.select("#atomspace");
      var chart = base.append("canvas")
          .attr("width", width)
          .attr("height", height)
          .call(d3.zoom().scaleExtent([1 / 2, 8]).on("zoom", zoomed));
        
      var context = chart.node().getContext("2d");
  
      // Create an in memory only element for drawing
      var detachedContainer = document.createElement("custom");
      var dataContainer = d3.select(detachedContainer);
      
      function zoomed() {
          transform = d3.event.transform;
          drawCanvas();
      }
  
      simulation = d3.forceSimulation()
        .force("charge", d3.forceManyBody())
        .force("center", d3.forceCenter(width / 2, height / 2))
        .force("link", d3.forceLink().id(function(d) { return d.id; }).strength(0.5))
        .force("collide",d3.forceCollide(function(d) { return getRadiusForAttentionValue(d)}).iterations(8) )
        .force('X', d3.forceX().strength(function(d) { return getCenterGravityStrengthForAttentionValue(d); }).x(width / 2))
        .force('Y', d3.forceY().strength(function(d) { return getCenterGravityStrengthForAttentionValue(d); }).y(height / 2))
        .on("tick", ticked);
  

      function getRadiusForAttentionValue(d) { 
        if (d.isNode) { 
          return d.attentionvalue.sti*0.095 + 9; 
        } else { 
          return 1; 
        }
      };

      function getCenterGravityStrengthForAttentionValue(d) { 
        if(d.isNode) 
          return d.attentionvalue.sti * 0.025; 
        else 
          return 0; 
      }; 
  
      var atoms = {};
  
      update()
      AtomsFactory.modificationCB = update;

      AtomsFactory.warningCB = function(msg) {
        $scope.warning = msg
      };

      function update() {<commit_msg>initial styling for demo, should be in external json<commit_after>'use strict';

angular.module('impression.atomspaceView', ['ngRoute'])

.config(['$routeProvider', function($routeProvider) {
    $routeProvider.when('/atomspace', {
        templateUrl: 'views/atomspace/atomspace.html',
        controller: 'AtomspaceCtrl'
    });
}])

.controller('AtomspaceCtrl', function($scope, $interval, $routeParams, $http, $location, AtomsFactory) {

    $scope.$on('$destroy', function() {
        $interval.cancel(stop);
        stop = undefined;
        simulation.stop();
        chart.remove();
        AtomsFactory.pollSettings = { 'filterby': 'attentionalfocus', 'includeIncoming': 'true', 'includeOutgoing': 'true' }
    });

    //stuff for options:
    $scope.pollSettings = {
      "filterby": "attentionalfocus",
      "stimin": 1,
      "stimax": 40,
      "includeIncoming": true,
      "includeOutgoing": true 
    }

    $scope.$watch('pollSettings', function(newValue) {
      console.log("🎑 new filter")
      AtomsFactory.pollSettings = newValue
      AtomsFactory.updateAtoms()
    }, true);

    //bounce back to connect screen if disconnected.
    if(!AtomsFactory.connected) { $location.path("/"); } else {

      //Initialize size for canvas drawing
      var width = document.getElementById("atomspace").clientWidth,
          height = document.getElementById("atomspace").clientHeight;
  
      //Dynamic Resize
      window.addEventListener("resize", function() {
          width = document.getElementById("atomspace").clientWidth;
          height = document.getElementById("atomspace").clientHeight;
          
          chart.attr("width", width).attr("height", height);
          
          simulation.force("center", d3.forceCenter(width / 2, height / 2))
      });
  
      var transform = d3.zoomIdentity; //transform identity for pan/zoom
      var nodeBinding, linkBinding, simulation, nodeEnter, linkEnter;
  
  
      var base = d3.select("#atomspace");
      var chart = base.append("canvas")
          .attr("width", width)
          .attr("height", height)
          .call(d3.zoom().scaleExtent([1 / 2, 8]).on("zoom", zoomed));
        
      var context = chart.node().getContext("2d");
  
      // Create an in memory only element for drawing
      var detachedContainer = document.createElement("custom");
      var dataContainer = d3.select(detachedContainer);
      
      function zoomed() {
          transform = d3.event.transform;
          drawCanvas();
      }
  
      simulation = d3.forceSimulation()
        .force("charge", d3.forceManyBody())
        .force("center", d3.forceCenter(width / 2, height / 2))
        .force("link", d3.forceLink().id(function(d) { return d.id; }).strength(0.5))
        .force("collide",d3.forceCollide(function(d) { return getRadiusForAttentionValue(d)}).iterations(8) )
        .force('X', d3.forceX().strength(function(d) { return getCenterGravityStrengthForAttentionValue(d); }).x(width / 2))
        .force('Y', d3.forceY().strength(function(d) { return getCenterGravityStrengthForAttentionValue(d); }).y(height / 2))
        .on("tick", ticked);
  
      simulation.alphaTarget(0.1)

      function getRadiusForAttentionValue(d) { 
        if (d.isNode) { 
          return d.attentionvalue.sti*0.095 + 9; 
        } else { 
          return 1; 
        }
      };

      function getCenterGravityStrengthForAttentionValue(d) { 
        if(d.isNode) 
          return d.attentionvalue.sti * 0.025; 
        else 
          return 0; 
      }; 
  
      var atoms = {};
  
      update()
      AtomsFactory.modificationCB = update;

      AtomsFactory.warningCB = function(msg) {
        $scope.warning = msg
      };

      function update() {
{'fraction_non_alphanumeric': 0.14388197076340012, 'fraction_numerical': 0.011505143475906875, 'mean_word_length': 2.6291748526522594, 'pattern_counts': {'":': 10, '<': 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': '2639725', 'n_tokens_mistral': 2229, 'n_tokens_neox': 2120, 'n_words': 411}