[
  {
    "path": "README.md",
    "content": "# loklak Movie Tweets\n\nThis form uses the [loklak public API](http://loklak.org/) to search the last 100 most recent tweets about the specified films.  \nStyles by [Bootstrap](http://getbootstrap.com/).\n\n## Use\n\nSince it's plain HTML/JS, you only have to download both `index.html` and `script.js` and place them in the same directory.  \nEvery time you change the content of the text box with a new film name and press <kbd>ENTER</kbd>, the results should update automatically. However, if it doesn't work, you can use the *Search!* button at the right.\n\n> Your browser must have JavaScript enabled, and Internet connection\n\nYou can find a live demo [here](http://yagogg.github.io/GCI2015/loklak%20Movie%20Tweets/).  \n*(Hosted by GitHub Pages)*\n\n## Screenshots\n\n![loklak Move Tweets search form](https://raw.githubusercontent.com/YagoGG/GCI2015/gh-pages/loklak%20Movie%20Tweets/Screenshots/Screenshot1.png)\n\n![loklak Move Tweets results for \"star wars\"](https://raw.githubusercontent.com/YagoGG/GCI2015/gh-pages/loklak%20Movie%20Tweets/Screenshots/Screenshot2.png)\n"
  },
  {
    "path": "index.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n  <meta charset=\"utf-8\">\n  <!-- Bootstrap CSS -->\n  <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css\" integrity=\"sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7\" crossorigin=\"anonymous\">\n  <title>GCI | Loklak Movie Tweets</title>\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"page-header\">\n      <h1>Loklak Movie Tweets</h1>\n      <h2><small>Google Code-in - FOSSASIA</small></h2>\n    </div>\n    <h2>Search a movie</h2>\n    <div class=\"row\">\n      <div class=\"col-lg-6\">\n        <div class=\"input-group\">\n          <input type=\"text\" id=\"film\" class=\"form-control\" placeholder=\"e.g.: matrix\" onchange=\"searchTweets();\">\n          <span class=\"input-group-btn\">\n            <button class=\"btn btn-default\" type=\"button\" onclick=\"searchTweets();\">Search!</button>\n          </span>\n        </div>\n        <br>\n        <div id=\"loading\" class=\"well\" style=\"display: none;\">\n          <h4 style=\"text-align: center;\">Loading...</h4>\n          <div class=\"progress\">\n            <div class=\"progress-bar progress-bar-striped active\" role=\"progressbar\" style=\"width: 100%;\">\n            </div>\n          </div>\n        </div>\n      </div>\n    </div><br>\n    <div id=\"resultsBox\" style=\"display: none;\">\n      <h2>Results</h2>\n      <div id=\"tweetCount\" class=\"alert alert-info\"></div>\n      <ul id=\"tweets\" class=\"list-group\">\n      </ul>\n    </div>\n    <footer>\n      <hr>\n      <div class=\"well\">\n        <b>Google Code-in 2015</b> | Made by Yago González with &lt;3, for the Open Source community<br>\n          Powered by <a href=\"http://getbootstrap.com\"><b>Bootstrap</b></a> and the <a href=\"http://loklak.org\"><b>loklak public API</b></a>\n      </div>\n    </footer>\n  </div>\n  <template>\n    <li class=\"list-group-item\">\n      <div class=\"media\">\n        <div class=\"media-left\">\n          <img class=\"media-object\" src=\"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iNjQiIGhlaWdodD0iNjQiIHZpZXdCb3g9IjAgMCA2NCA2NCIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+PCEtLQpTb3VyY2UgVVJMOiBob2xkZXIuanMvNjR4NjQKQ3JlYXRlZCB3aXRoIEhvbGRlci5qcyAyLjYuMC4KTGVhcm4gbW9yZSBhdCBodHRwOi8vaG9sZGVyanMuY29tCihjKSAyMDEyLTIwMTUgSXZhbiBNYWxvcGluc2t5IC0gaHR0cDovL2ltc2t5LmNvCi0tPjxkZWZzPjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+PCFbQ0RBVEFbI2hvbGRlcl8xNTFmMmVkZjk4NSB0ZXh0IHsgZmlsbDojQUFBQUFBO2ZvbnQtd2VpZ2h0OmJvbGQ7Zm9udC1mYW1pbHk6QXJpYWwsIEhlbHZldGljYSwgT3BlbiBTYW5zLCBzYW5zLXNlcmlmLCBtb25vc3BhY2U7Zm9udC1zaXplOjEwcHQgfSBdXT48L3N0eWxlPjwvZGVmcz48ZyBpZD0iaG9sZGVyXzE1MWYyZWRmOTg1Ij48cmVjdCB3aWR0aD0iNjQiIGhlaWdodD0iNjQiIGZpbGw9IiNFRUVFRUUiLz48Zz48dGV4dCB4PSIxNC41IiB5PSIzNi44Ij42NHg2NDwvdGV4dD48L2c+PC9nPjwvc3ZnPg==\">\n        </div>\n        <div class=\"media-body\">\n          <h4>@user <small>(30 Dic 13:37)</small></h4>\n          <span>Text</span>\n        </div>\n      </div>\n    </li>\n  </template>\n  <!-- jQuery JS -->\n  <script src=\"https://code.jquery.com/jquery-2.1.4.min.js\"></script>\n  <!-- Bootstrap JS -->\n  <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js\" integrity=\"sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS\" crossorigin=\"anonymous\"></script>\n  <script src=\"./script.js\"></script>\n  <script id=\"loklakAPICall\"></script>\n</body>\n</html>\n"
  },
  {
    "path": "script.js",
    "content": "function searchTweets() { // Query the loklak.org API\n  var film = document.getElementById('film').value;\n\n  var url = 'http://loklak.org/api/search.json?q=' + film + ' film&minified=true&callback=updateResults';\n\n  document.body.removeChild(document.getElementById('loklakAPICall'));  // Delete old script calls\n\n  // Creation of the new script, to support JSONP\n  var script = document.createElement('script');\n  script.id = 'loklakAPICall';\n  script.src = url;\n  document.body.appendChild(script);\n\n  document.getElementById('loading').style.display = 'block'; // Make loading box visible\n}\n\nfunction updateResults(input) { // Function called to interpret the results from the API, through JSONP\n  var statuses = input.statuses;\n\n  document.getElementById('resultsBox').style.display = 'block';\n\n  var tweetsBox = document.getElementById('tweets');\n\n  while(tweetsBox.childElementCount > 0) { // Empty the tweets box\n    tweetsBox.removeChild(tweetsBox.lastChild);\n  }\n\n  var media, mBody;\n\n  document.getElementById('tweetCount').innerHTML = \"Found \" + statuses.length + \" tweets\"; // Show amount of tweets in the alert\n\n  for(i in statuses) {\n    current = document.getElementsByTagName('template')[0].content.children[0].cloneNode(true);  // Clone the tweet format, from the <template>\n\n    media = current.getElementsByClassName('media')[0];\n    media.getElementsByClassName('media-object')[0].src = statuses[i].user.profile_image_url_https; // Set user's picture\n\n    mBody = media.getElementsByClassName('media-body')[0];\n    mBody.getElementsByTagName('h4')[0].innerHTML = '<a style=\"color: black;\" href=\"https://twitter.com' + statuses[i].screen_name + '/\">@' + statuses[i].screen_name + '</a> <small><a style=\"color: black;\" href=\"' + statuses[i].link + '\">' + new Date(statuses[i].created_at).toUTCString() + '</a></small>';  // Set username and tweet's date\n    mBody.getElementsByTagName('span')[0].innerHTML = statuses[i].text; // Set tweet's content\n\n    tweetsBox.appendChild(current); // Add the complete tweet to the list\n  }\n\n  document.getElementById('loading').style.display = 'none';  // Hide the loading progress bar\n}\n"
  }
]