|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <link type="text/css" rel="stylesheet" href="css/bootstrap.css" /> |
| 5 | + <script src="js/jquery-2.1.4.js" type="text/javascript"></script> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 7 | + <style type="text/css"> |
| 8 | + .row { |
| 9 | + padding-top:1.5em; |
| 10 | + } |
| 11 | + </style> |
| 12 | + <script> |
| 13 | + |
| 14 | + //Kazan: 551487 |
| 15 | + //SF: 5391959 |
| 16 | + |
| 17 | + var openWeatherAppId = '2de143494c0b295cca9337e1e96b00e0', |
| 18 | + openWeatherUrl = 'http://api.openweathermap.org/data/2.5/forecast' |
| 19 | + /* |
| 20 | + Rapid Prototyping with JS is a JavaScript and Node.js book that will teach you how to build mobile and web apps fast. — Read more at |
| 21 | + http://rapidprototypingwithjs.com. |
| 22 | + */ |
| 23 | + |
| 24 | + $(document).ready(function(){ |
| 25 | + $('#btn').click(function() { |
| 26 | + //replace loading image |
| 27 | + var cityName = $('#city-name').val() |
| 28 | + //make ajax call, callback |
| 29 | + debugger |
| 30 | + if (cityName && cityName != ''){ |
| 31 | + cityName = cityName.trim() |
| 32 | + getData(openWeatherUrl, cityName, openWeatherAppId) |
| 33 | + } |
| 34 | + else { |
| 35 | + alert('Please enter the city name') |
| 36 | + } |
| 37 | + }) |
| 38 | + }) |
| 39 | + function getData (url, cityName, appId) { |
| 40 | + var request = $.ajax({ |
| 41 | + url: url, |
| 42 | + dataType: "json", |
| 43 | + data: {q: cityName, appid: appId, units: 'metric'}, |
| 44 | + jsonpCallback: "fetchData", |
| 45 | + type: "GET" |
| 46 | + }) |
| 47 | + } |
| 48 | + function fetchData (m) { |
| 49 | + console.log(m) |
| 50 | + } |
| 51 | + </script> |
| 52 | +</head> |
| 53 | +<body> |
| 54 | + <div class="container"> |
| 55 | + <div class="row"> |
| 56 | + <div class="span6 offset1"><input class="span4" type="text" placeholder="Enter the city name" id="city-name" value=""/> |
| 57 | + </div> |
| 58 | + |
| 59 | + </div> |
| 60 | + <div class="row"> |
| 61 | + <div class="span6 offset1"><input type="button" class="primary btn" id="btn" value="Show words in last 1000 tweets"/> |
| 62 | + </div> |
| 63 | + <div class="span3"> |
| 64 | + <p id="info"></p> |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + <div class="row"> |
| 71 | + <div class="span6 offset1"> |
| 72 | + <textarea id="log" cols="20" rows="20">Nothing to show yet</textarea> |
| 73 | + </div> |
| 74 | + <div class="span4 offset 3"> |
| 75 | + <h2>Task</h2> |
| 76 | + <p>This page prints the words in a given twitter user’s last 0-200 tweets sorted by frequency of use.
For example, if @jack had tweeted:
“hello world”,
“hello everyone and world” and
“hi world”
The result could be:
world,
hello,
and,
hi,
everyone.</p> |
| 77 | + <hr/> |
| 78 | + <p>Requests are broken into 5 pieces. Please open console for more information.</p> |
| 79 | + <p>Azat Mardanov (<a href="http://twitter.com/azat_co">@azat_co</a>)</p> |
| 80 | + </div> |
| 81 | + </div> |
| 82 | + |
| 83 | + </div> |
| 84 | +</body> |
| 85 | +</html> |