<commit_before><!DOCTYPE html>
<!--
Copyright 2016 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<!--
An element displaying basic information about a display item in a list view.
-->
<dom-module id='tr-ui-e-chrome-cc-display-item-list-item'>
  <template>
    <style>
      :host {
        border-bottom: 1px solid #555;
        display: block;
        font-size: 12px;
        padding: 3px 5px;
      }

      :host(:hover) {
        background-color: #f0f0f0;
        cursor: pointer;
      }

      .header {
        font-weight: bold;
        margin: 2px 0;
      }

      .header > .extra {
        background-color: #777;
        border-radius: 4px;
        color: white;
        margin: 0 6px;
        text-decoration: none;
        padding: 2px 4px;
      }

      .raw-details {
        white-space: pre-wrap;
      }

      .details > dl {
        margin: 0;
      }

      :host(:not([selected])) .details {
        display: none;
      }
    </style>
    <div class="header">
      {{name}}
      <template is="dom-if" if="{{_computeIf(richDetails)}}">
        <a class="extra" href$="{{_computeHref(richDetails)}}"
           download="drawing.skp" on-click="{{stopPropagation}}">SKP</a>
      </template>
    </div>
    <div class="details">
      <template if="{{rawDetails}}">
        <div class="raw-details">{{rawDetails}}</div>
      </template>
      <template is="dom-if" if="{{richDetails}}" bind="{{richDetails}}">
        <dl>
          <template is="dom-if" if="{{cullRect}}" bind="{{cullRect}}">
            <dt>Cull rect</dt>
            <dd>{{x}},{{y}} {{width}}&times;{{height}}</dd>
          </template>
          <template is="dom-if" if="{{visualRect}}" bind="{{visualRect}}">
            <dt>Visual rect</dt>
            <dd>{{x}},{{y}} {{width}}&times;{{height}}</dd>
          </template>
        </dl>
      </template>
    </div>
  </template>
<script>
'use strict';
(function() {
  // Extracts the "type" and "details" parts of the unstructured (plaintext)
  // display item format, even if the details span multiple lines.
  // For example, given "FooDisplayItem type=hello\nworld", produces
  // "FooDisplayItem" as the first capture and "type=hello\nworld" as the
  // second. Either capture could be the empty string, but this regex will
  // still successfully match.
  var DETAILS_SPLIT_REGEX = /^(\S*)\s*([\S\s]*)$/;

  Polymer({
    is: 'tr-ui-e-chrome-cc-display-item-list-item',

    created: function() {
      this.name = '';
      this.rawDetails = '';
      this.richDetails = undefined;
      this.data_ = undefined;
    },

    get data() {
      return this.data_;
    },

    set data(data) {
      this.data_ = data;

      if (!data) {
        this.name = 'DATA MISSING';
        this.rawDetails = '';
        this.richDetails = undefined;<commit_msg>[polymer] Uses setAttribute() in DisplayItemListItem.created()<commit_after><!DOCTYPE html>
<!--
Copyright 2016 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<!--
An element displaying basic information about a display item in a list view.
-->
<dom-module id='tr-ui-e-chrome-cc-display-item-list-item'>
  <template>
    <style>
      :host {
        border-bottom: 1px solid #555;
        display: block;
        font-size: 12px;
        padding: 3px 5px;
      }

      :host(:hover) {
        background-color: #f0f0f0;
        cursor: pointer;
      }

      .header {
        font-weight: bold;
        margin: 2px 0;
      }

      .header > .extra {
        background-color: #777;
        border-radius: 4px;
        color: white;
        margin: 0 6px;
        text-decoration: none;
        padding: 2px 4px;
      }

      .raw-details {
        white-space: pre-wrap;
      }

      .details > dl {
        margin: 0;
      }

      :host(:not([selected])) .details {
        display: none;
      }
    </style>
    <div class="header">
      {{name}}
      <template is="dom-if" if="{{_computeIf(richDetails)}}">
        <a class="extra" href$="{{_computeHref(richDetails)}}"
           download="drawing.skp" on-click="{{stopPropagation}}">SKP</a>
      </template>
    </div>
    <div class="details">
      <template if="{{rawDetails}}">
        <div class="raw-details">{{rawDetails}}</div>
      </template>
      <template is="dom-if" if="{{richDetails}}" bind="{{richDetails}}">
        <dl>
          <template is="dom-if" if="{{cullRect}}" bind="{{cullRect}}">
            <dt>Cull rect</dt>
            <dd>{{x}},{{y}} {{width}}&times;{{height}}</dd>
          </template>
          <template is="dom-if" if="{{visualRect}}" bind="{{visualRect}}">
            <dt>Visual rect</dt>
            <dd>{{x}},{{y}} {{width}}&times;{{height}}</dd>
          </template>
        </dl>
      </template>
    </div>
  </template>
<script>
'use strict';
(function() {
  // Extracts the "type" and "details" parts of the unstructured (plaintext)
  // display item format, even if the details span multiple lines.
  // For example, given "FooDisplayItem type=hello\nworld", produces
  // "FooDisplayItem" as the first capture and "type=hello\nworld" as the
  // second. Either capture could be the empty string, but this regex will
  // still successfully match.
  var DETAILS_SPLIT_REGEX = /^(\S*)\s*([\S\s]*)$/;

  Polymer({
    is: 'tr-ui-e-chrome-cc-display-item-list-item',

    created: function() {
      // TODO(charliea): Why is setAttribute necessary here but not below? We
      // should reach out to the Polymer team to figure out.
      this.setAttribute('name', '');
      this.setAttribute('rawDetails', '');
      this.setAttribute('richDetails', undefined);
      this.setAttribute('data_', undefined);
    },

    get data() {
      return this.data_;
    },

    set data(data) {
      this.data_ = data;

      if (!data) {
        this.name = 'DATA MISSING';
        this.rawDetails = '';
        this.richDetails = undefined;
{'fraction_non_alphanumeric': 0.1651829871414441, 'fraction_numerical': 0.008572370590174745, 'mean_word_length': 2.253083109919571, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3871601', 'n_tokens_mistral': 1977, 'n_tokens_neox': 1877, 'n_words': 479}