<commit_before>/*
@license
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/

import '../data-explorer.js';
import Xen from '../xen/xen.js';

// notes:
// Xen memoizes template parsing when given a <template> instead of String
// Xen.Template.html converts a String to a <template>
// we assign to `html` so syntax-highlighters treat the literals as HTML
const html = Xen.Template.html;

const template = html`
  <style>
    button {
      margin: 8px;
    }
    [banner] {
      padding: 6px 4px;
      background-color: whitesmoke;
      margin-bottom: 8px;
      border-top: 1px dotted silver;
    }
  </style>

  <div><button on-click="_onUpdate">Update</button></div>

  <div banner>Arc Handles</div>
  <div style="padding: 8px;">{{arcHandles}}</div>

  <div banner>Context Handles</div>
  <div style="padding: 8px;">{{contextHandles}}</div>
`;

const handleTemplate = html`
  <!--<div style="margin-bottom: 8px;">
    <span>{{name}}</span>
    <a href="{{href}}" target="_blank"><i class="material-icons" style="font-size: 0.8em; vertical-align: middle;">open_in_new</i></a>
  </div>-->
  <data-explorer style="font-size: 0.8em;" object="{{data}}"></data-explorer>
  <br>
`;

class HandleExplorer extends Xen.Base {
  static get observedAttributes() { return ['arc']; }
  get template() {
    return template;
  }
  _wouldChangeProp() {
    return true;
  }
  _willReceiveProps(props, state) {
    state.needsQuery = true;
  }
  _update(props, state) {
    if (props.arc && state.needsQuery) {
      state.needsQuery = false;
      //this._setState({arcHandles: null, contextHandles: null});
      this._queryHandles(props.arc);
    }
  }
  _render(props, state) {
    return {
      arcHandles: {
        template: handleTemplate,
        models: state.arcHandles
      },
      contextHandles: {
        template: handleTemplate,
        models: state.contextHandles<commit_msg>Fix template in handle-explorer.js (#1464)<commit_after>/*
@license
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/

import '../data-explorer.js';
import Xen from '../xen/xen.js';

// notes:
// Xen memoizes template parsing when given a <template> instead of String
// Xen.Template.html converts a String to a <template>
// we assign to `html` so syntax-highlighters treat the literals as HTML
const html = Xen.Template.html;

const template = html`
  <style>
    button {
      margin: 8px;
    }
    [banner] {
      padding: 6px 4px;
      background-color: whitesmoke;
      margin-bottom: 8px;
      border-top: 1px dotted silver;
    }
  </style>

  <div><button on-click="_onUpdate">Update</button></div>

  <div banner>Arc Handles</div>
  <div style="padding: 8px;">{{arcHandles}}</div>

  <div banner>Context Handles</div>
  <div style="padding: 8px;">{{contextHandles}}</div>
`;

const handleTemplate = html`
  <div style="border-bottom: 1px dashed silver; padding-bottom: 8px; margin-bottom: 8px;">
    <data-explorer style="font-size: 0.8em;" object="{{data}}"></data-explorer>
  </div>
`;

class HandleExplorer extends Xen.Base {
  static get observedAttributes() { return ['arc']; }
  get template() {
    return template;
  }
  _wouldChangeProp() {
    return true;
  }
  _willReceiveProps(props, state) {
    state.needsQuery = true;
  }
  _update(props, state) {
    if (props.arc && state.needsQuery) {
      state.needsQuery = false;
      //this._setState({arcHandles: null, contextHandles: null});
      this._queryHandles(props.arc);
    }
  }
  _render(props, state) {
    return {
      arcHandles: {
        template: handleTemplate,
        models: state.arcHandles
      },
      contextHandles: {
        template: handleTemplate,
        models: state.contextHandles
{'fraction_non_alphanumeric': 0.13343524787071412, 'fraction_numerical': 0.00786197859794715, 'mean_word_length': 3.3869731800766285, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 51, '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': '7141330', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1400, 'n_words': 413}