<commit_before><%= javascript_include_tag 'prototype' %>

<script type="text/javascript">

function queryTwitter() {
  var req = new Ajax.Request("http://search.twitter.com/trends.json", {
          method: 'GET', 
          onFailure: function(request) {
            alert('AJAX doesnt work.');
          }, 
          onComplete: function(request) {
            receiveTwitterResponse( request.responseText);
          }
      });
}

function receiveTwitterResponse(results) {
  var result = JSON.parse(results);
  var point = document.getElementById('twittertrends');
  for (var i = 0; i < result.trends.length; i++) {
    point.append(document.createTextNode( result.trends[i].name ));
  }
}

Event.observe(window, 'load', function() {
  alert('page loaded');
  queryTwitter();
});

</script>
<h1>Current Twitter Trends</h1>
<div id="twittertrends">
</div>
<div id="status">
</div><commit_msg>Make sure the page doesn't crash when loading if we get a duff AJAX response.<commit_after><%= javascript_include_tag 'prototype' %>

<script type="text/javascript">

function queryTwitter() {
  var req = new Ajax.Request("http://search.twitter.com/trends.json", {
          method: 'GET', 
          onFailure: function(request) {
            alert('AJAX doesnt work.');
          }, 
          onComplete: function(request) {
            receiveTwitterResponse( request.responseText);
          }
      });
}

function receiveTwitterResponse(results) {
  if (results != "") {
    showStatus("done.");
    var result = JSON.parse(results);
    var point = document.getElementById('twittertrends');
    for (var i = 0; i < result.trends.length; i++) {
      point.append(document.createTextNode( result.trends[i].name ));
    }
  }
  else {
    showStatus("Bad AJAX results");
  }
}

function showStatus(message) {
  var status = document.getElementById('status');
  status.innerHTML = message;
}

Event.observe(window, 'load', function() {
  showStatus("Querying twitter...");
  queryTwitter();
});

</script>
<h1>Current Twitter Trends</h1>
<div id="twittertrends">
</div>
<div id="status">
</div>
{'fraction_non_alphanumeric': 0.15744274809160305, 'fraction_numerical': 0.0028625954198473282, 'mean_word_length': 3.341614906832298, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, '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': '3417256', 'n_tokens_mistral': 669, 'n_tokens_neox': 626, 'n_words': 137}