<commit_before><!--<script type="text/javascript" src="//static.cottagelabs.com/d3/d3.v3.min.js"></script>
<script type="text/javascript" src="//static.cottagelabs.com/d3/topojson.v1.min.js"></script>
<script src="/static/map.js"></script>-->

<script>
jQuery(document).ready(function() {
  var api = 'https://api.openaccessbutton.org';
  if (window.location.host.indexOf('openaccessbutton.org') === -1) api = 'https://dev.api.cottagelabs.com/service/oab';

  var result = function(res) {
    var out = '';
    out += '<div class="well" style="background-color:#eee;border-color:#212f3f;overflow:hidden;">';
    // TODO should show the item title here... but what if it is data? need to show we want the data for X, not article X
    out += '<h4><a href="/request/' + res._id + '" style="color:#212f3f;">';
    out += res.title ? res.title : res.url;
    out += '</a></h4>';
    var dt = new Date(res.createdAt).toUTCString().split(', ')[1];
    var rq = '';
    if (res.user) {
      if (res.user.username) {
        rq = ' by ' + res.user.username;
      } else if (res.user.email) {
        rq = ' by ' + res.user.email;
      }
    }
    out += '<p>' + res.type.substring(0,1).toUpperCase() + res.type.substring(1) + ' requested' + rq + ' on ' + dt.substring(0,dt.length-13);
    if (res.count && res.count > 1) out += '. Supported by ' + res.count + ' people.';
    out += '</p>';
    // TODO add a support this request and a share this request buttons
    out += '</div>';
    return out;
  }
  var results = function(data) {
    $('#requestscount').html(data.hits.total);
    var out = '';
    for ( var r in data.hits.hits ) out += result(data.hits.hits[r]._source);
    $('.holder.holder-results').html(out);
    $('#storycount').html(data.hits.total);
  }

  var first = true;
  var scroll = function(data) {
    if (first) {
      first = false;
    } else {
      for ( var r in data.hits.hits ) {
        var res = result(data.hits.hits[r]._source);
        $('.holder.holder-innerresults').append(res);
      }
    }
  }

  var aggregations = function(data) {
    $('.holder.holder-suggestions').html("");
    for ( var f in $('.holder').holder.options.query.aggregations ) {
      if (data.aggregations[f].buckets.length > 1) {
        var disp = '<div style="border-bottom:1px solid #ccc;"><p style="font-size:0.9em;">Filter by ' + f + '</p>';
        for ( var r in data.aggregations[f].buckets ) {
          var j = data.aggregations[f].buckets[r];
          if ( f === 'status' && j.key === 'success' ) $('#requestssuccesscount').html(j.doc_count);
          disp += '<p>' + searchify({class: 'holder label label-default', val: j.key + ' (' + j.doc_count + ')', attrs: {function: 'add', filter: f, value: j.key} }) + '</p>';
        }
        disp += '</div>';
        $('.holder.holder-suggestions').append(disp);
      }
    }
  }

  $('#requests').holder({
    what: "Explore requests",
    url: api + "/query",
    datatype: 'JSON',
    scroll: true,
    defaultquery: {
      sort: [
        {
          createdAt: {order: 'desc'}
        }
      ],
      query: {
        filtered: {
          query: {
            bool: {
              must: []
            }
          },
          filter: {
            bool: {
              //must_not:[{term:{'test':true}}]
            }
          }
        }
      }
    },
    pushstate: true,
    results: {
      default: results,
      scroll: scroll,
      suggestions: aggregations
    },
    size: 50,
    aggregations: {
      status: { terms: { field: "status.exact", size: 100 } },
      type: { terms: { field: "type.exact", size: 100 } }
    }
  });

});
</script>

<style>
#mapspace{
  overflow:hidden;
  width:100%;
  height:700px;
  margin-top:50px;
  margin-bottom:-50px;
}
.country{
  stroke: #fff;
  stroke-width: 0.8px;
}
div.tooltip {
  color: #222;
  background: #fff;
  padding: .5em;
  text-shadow: #f5f5f5 0 1px 0;
  border-radius: 2px;
  box-shadow: 0px 0px 2px 0px #a6a6a6;
  opacity: 0.9;
  position: absolute;
}
</style>

<!--
<div id="mapspace"></div>
-->
<br>
<div>
<div class="alert alert-info">
<p>Check back soon, we are currently adding 15000 requests to this page. </p>
</div>
</div>

<div class="strap strap-compact" id="requests">
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-12" style="padding-top:40px;padding-bottom:20px;">
        <div class="input-group" style="margin-left:-1px;margin-top:-1px;margin-bottom:-6px;margin-right:-2px;">
          <input type="text" class="form-control holder holder-search holder-function" holder-function="suggest" placeholder="Search to explore open requests" style="font-size:1.6em;height:50px;">
          <div class="input-group-btn">
            <a href="/request" class="btn btn-default" alt="clear all search terms and reset" title="clear all search terms and reset" style="height:50px;font-size:1.5em;">X</a>
          </div>
        </div>
        <div class="holder holder-filters" style="margin:10px -5px 0px -5px;"></div>
      </div>
    </div>
  </div>
</div>

<div class="container-fluid">
  <div class="row">
    <div class="col-md-3">
      <div class="well" style="background-color:#212f3f;border-color:#212f3f;color:white;margin-top:-15px;">
        <h3 style="text-align:center;font-size:60px;color:#f04717;"><span id="requestssuccesscount">0</span><span style="color:#ccc;">/</span><span id="requestscount">X</span></h3>
        <p style="text-align:center;font-size:0.8em;">Successful requests</p>
      </div>
      <a class="btn btn-action btn-block btn-xs" href="/request/new">Create a new request</a>
      <div class="holder holder-suggestions" style="margin-top:15px;"></div>
    </div>

    <div class="col-md-9">
      <div class="holder holder-results"></div>
    </div>
  </div>
</div>
<commit_msg>adding padding, rather than a br to the info bar<commit_after><!--<script type="text/javascript" src="//static.cottagelabs.com/d3/d3.v3.min.js"></script>
<script type="text/javascript" src="//static.cottagelabs.com/d3/topojson.v1.min.js"></script>
<script src="/static/map.js"></script>-->

<script>
jQuery(document).ready(function() {
  var api = 'https://api.openaccessbutton.org';
  if (window.location.host.indexOf('openaccessbutton.org') === -1) api = 'https://dev.api.cottagelabs.com/service/oab';

  var result = function(res) {
    var out = '';
    out += '<div class="well" style="background-color:#eee;border-color:#212f3f;overflow:hidden;">';
    // TODO should show the item title here... but what if it is data? need to show we want the data for X, not article X
    out += '<h4><a href="/request/' + res._id + '" style="color:#212f3f;">';
    out += res.title ? res.title : res.url;
    out += '</a></h4>';
    var dt = new Date(res.createdAt).toUTCString().split(', ')[1];
    var rq = '';
    if (res.user) {
      if (res.user.username) {
        rq = ' by ' + res.user.username;
      } else if (res.user.email) {
        rq = ' by ' + res.user.email;
      }
    }
    out += '<p>' + res.type.substring(0,1).toUpperCase() + res.type.substring(1) + ' requested' + rq + ' on ' + dt.substring(0,dt.length-13);
    if (res.count && res.count > 1) out += '. Supported by ' + res.count + ' people.';
    out += '</p>';
    // TODO add a support this request and a share this request buttons
    out += '</div>';
    return out;
  }
  var results = function(data) {
    $('#requestscount').html(data.hits.total);
    var out = '';
    for ( var r in data.hits.hits ) out += result(data.hits.hits[r]._source);
    $('.holder.holder-results').html(out);
    $('#storycount').html(data.hits.total);
  }

  var first = true;
  var scroll = function(data) {
    if (first) {
      first = false;
    } else {
      for ( var r in data.hits.hits ) {
        var res = result(data.hits.hits[r]._source);
        $('.holder.holder-innerresults').append(res);
      }
    }
  }

  var aggregations = function(data) {
    $('.holder.holder-suggestions').html("");
    for ( var f in $('.holder').holder.options.query.aggregations ) {
      if (data.aggregations[f].buckets.length > 1) {
        var disp = '<div style="border-bottom:1px solid #ccc;"><p style="font-size:0.9em;">Filter by ' + f + '</p>';
        for ( var r in data.aggregations[f].buckets ) {
          var j = data.aggregations[f].buckets[r];
          if ( f === 'status' && j.key === 'success' ) $('#requestssuccesscount').html(j.doc_count);
          disp += '<p>' + searchify({class: 'holder label label-default', val: j.key + ' (' + j.doc_count + ')', attrs: {function: 'add', filter: f, value: j.key} }) + '</p>';
        }
        disp += '</div>';
        $('.holder.holder-suggestions').append(disp);
      }
    }
  }

  $('#requests').holder({
    what: "Explore requests",
    url: api + "/query",
    datatype: 'JSON',
    scroll: true,
    defaultquery: {
      sort: [
        {
          createdAt: {order: 'desc'}
        }
      ],
      query: {
        filtered: {
          query: {
            bool: {
              must: []
            }
          },
          filter: {
            bool: {
              //must_not:[{term:{'test':true}}]
            }
          }
        }
      }
    },
    pushstate: true,
    results: {
      default: results,
      scroll: scroll,
      suggestions: aggregations
    },
    size: 50,
    aggregations: {
      status: { terms: { field: "status.exact", size: 100 } },
      type: { terms: { field: "type.exact", size: 100 } }
    }
  });

});
</script>

<style>
#mapspace{
  overflow:hidden;
  width:100%;
  height:700px;
  margin-top:50px;
  margin-bottom:-50px;
}
.country{
  stroke: #fff;
  stroke-width: 0.8px;
}
div.tooltip {
  color: #222;
  background: #fff;
  padding: .5em;
  text-shadow: #f5f5f5 0 1px 0;
  border-radius: 2px;
  box-shadow: 0px 0px 2px 0px #a6a6a6;
  opacity: 0.9;
  position: absolute;
}
</style>

<!--
<div id="mapspace"></div>
-->



<div>
<div class="alert alert-info" style="padding-top:10px">
<p>Processing more than 10000 requests is taking some time, keep checking back for more.</p>
</div>
</div>

<div class="strap strap-compact" id="requests">
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-12" style="padding-top:40px;padding-bottom:20px;">
        <div class="input-group" style="margin-left:-1px;margin-top:-1px;margin-bottom:-6px;margin-right:-2px;">
          <input type="text" class="form-control holder holder-search holder-function" holder-function="suggest" placeholder="Search to explore open requests" style="font-size:1.6em;height:50px;">
          <div class="input-group-btn">
            <a href="/request" class="btn btn-default" alt="clear all search terms and reset" title="clear all search terms and reset" style="height:50px;font-size:1.5em;">X</a>
          </div>
        </div>
        <div class="holder holder-filters" style="margin:10px -5px 0px -5px;"></div>
      </div>
    </div>
  </div>
</div>

<div class="container-fluid">
  <div class="row">
    <div class="col-md-3">
      <div class="well" style="background-color:#212f3f;border-color:#212f3f;color:white;margin-top:-15px;">
        <h3 style="text-align:center;font-size:60px;color:#f04717;"><span id="requestssuccesscount">0</span><span style="color:#ccc;">/</span><span id="requestscount">X</span></h3>
        <p style="text-align:center;font-size:0.8em;">Successful requests</p>
      </div>
      <a class="btn btn-action btn-block btn-xs" href="/request/new">Create a new request</a>
      <div class="holder holder-suggestions" style="margin-top:15px;"></div>
    </div>

    <div class="col-md-9">
      <div class="holder holder-results"></div>
    </div>
  </div>
</div>

{'fraction_non_alphanumeric': 0.19542690759612913, 'fraction_numerical': 0.021067054894236534, 'mean_word_length': 2.7179242279528815, 'pattern_counts': {'":': 0, '<': 158, '<?xml version=': 0, '>': 162, 'https://': 4, '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': '6243435', 'n_tokens_mistral': 4207, 'n_tokens_neox': 4010, 'n_words': 842}