<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html">
<script src="chromez-behaviors.js"></script>

<dom-module id="cz-config">

  <template>
    <template is="dom-repeat" items="{{searchQueries}}">
      <iron-ajax
        auto
        params="{{item.params}}"
        url="{{url}}"
        on-response="handleResponse"
        verbose=true></iron-ajax>
    </template>
    <input id=input placeholder="config.json" on-keyup=updateUrl></input>
  </template>

  <script>
    Polymer({
      is: "cz-config",
      behaviors: [ChromeZBehaviors.AJAXBehavior],

      properties: {
        url: "String"
      },

      registerQuery: function(query, callback) {
        this.addCallbackToQuery({"*":"*"}, "*", data => {
          if (data) {
            this.$.input.hidden = true;
            callback(data[query]);
          }
        }, {});
      },

      updateUrl: function() {
        this.url = this.$.input.value;
      },
    });
  </script>

</dom-module>

<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html">
<script src="chromez-behaviors.js"></script>

<dom-module id="cz-config">

  <template>
    <template is="dom-repeat" items="{{searchQueries}}">
      <iron-ajax
        auto
        params="{{item.params}}"
        url="{{url}}"
        on-response="handleResponse"
        verbose=true></iron-ajax>
    </template>
    <input id=input placeholder="config.json" on-input=updateUrl></input>
  </template>

  <script>
    Polymer({
      is: "cz-config",
      behaviors: [ChromeZBehaviors.AJAXBehavior],

      properties: {
        url: "String"
      },

      attached: function() {
        this.url = location.hash.substring(1);
        addEventListener('hashchange', () => this.url = location.hash.substring(1));
      },

      registerQuery: function(query, callback) {
        this.addCallbackToQuery({"*":"*"}, "*", data => {
          if (data) {
            this.$.input.hidden = true;
            callback(data[query]);
          }
        }, {});
      },

      updateUrl: function() {
        location.hash = this.$.input.value;
      },
    });
  </script>

</dom-module>

Store config url in hash
Store config url in hash
