Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 85f1b1bf5f
Fetching contributors…

Cannot retrieve contributors at this time

243 lines (202 sloc) 14.664 kB
<html>
<head>
<title>WorldBank Millennium Development Goals</title>
<link type='text/css' rel='stylesheet' href='/styles.css' />
<script type="text/javascript" charset="utf-8" src="http://yui.yahooapis.com/3.2.0/build/yui/yui-min.js"></script>
<!-- google fonts -->
<link href='http://fonts.googleapis.com/css?family=Nobile&subset=latin' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Reenie+Beanie&subset=latin' rel='stylesheet' type='text/css'>
<script type="text/javascript" charset="utf-8">
results_per_msg = 3;
// Millenium Development Goals (MDGS) in correct order from 1-8
mdgs = [
"Eradicate extreme poverty and hunger",
"Achieve universal primary education",
"Promote gender equality and empower women",
"Reduce child mortality",
"Improve maternal health",
"Combat HIV AIDS, malaria, and other diseases",
"Ensure environmental sustainability",
"Develop a global partnership for development"
];
function init_mdgs(mdgs,country) {
var mdgs_data = [];
for (var counter = 0; counter < mdgs.length; counter++) {
if (country != null) {
query = "'" + mdgs[counter] + "' " + country;
}
else {
query = "'" + mdgs[counter] + "'";
}
// console.log(query);
mdgs_data['mdg_' + (counter+1)] = Array(50, query);
}
return mdgs_data;
}
// create data used for the iteration of the news search
mdgs_data = init_mdgs(mdgs,null);
// console.log(mdgs_data);
// https://developer.yahoo.com/yui/3/examples/yql/yql-oauth.html
// key and secret for oAuth of application from https://developer.apps.yahoo.com/projects
function query_for_mdg(mdg_id) {
YUI({ gallery: 'gallery-2010.08.11-20-39' }).use('node', 'yql', 'gallery-oauth', function(Y) {
//Using with YQL oAuth Gallery module
Y.oAuth.ready(function() {
// build the query. exluce some common domains that appear too often to make it more interesting
var yql_query = 'SELECT * FROM search.web(' + mdgs_data[mdg_id][0] + ',' + 10 + ') WHERE query="' + mdgs_data[mdg_id][1] + '"' + " AND view='keyterms' AND url NOT MATCHES '.*(worldbank.org|undp|unicef).*' LIMIT "+ results_per_msg +" | unique(field='url')";
var target_div = "#" + mdg_id + "_results";
// console.log(yql_query);
// console.log(target_div);
Y.YQL(yql_query, function(response) {
Y.one(target_div).get('childNodes').remove();
Y.each(response.query.results.result, function(result) {
Y.one(target_div).append(style_results(result));
});
}, {
key: 'dj0yJmk9QWpTNFZ0V1kzUm9aJmQ9WVdrOU5FWndjM2RDTkdFbWNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD04MA--',
secret: 'de7c1e5af73001498e926bc9ef1659b770524c25',
base: '://query.yahooapis.com/v1/yql?'
});
// increase the offset for the next round
mdgs_data[mdg_id][0] = mdgs_data[mdg_id][0] + results_per_msg;
// });
});
});
}
// create the layouted box for one rearch result as retrieved from Yahoo BOSS
function style_results(result){
// console.log(result);
my_keyterms = Array();
if (result.keyterms.terms.term != null) {
for (var i = 0; i < result.keyterms.terms.term.length && i < 5; i++) {
my_keyterms[my_keyterms.length] = result.keyterms.terms.term[i];
}
}
my_keyterms = my_keyterms.join(", ");
// console.log(my_keyterms);
styled_result = '<div class="result">';
styled_result += '<a href="' + result.url +'">' + result.title + '</a> (' + result.date + ') <br />';
styled_result += '<span class="keywords">Keywords: <i> '+ my_keyterms +' </i> </span> <br />';
styled_result += '<span class="abstract">' + result.abstract + '</span>';
styled_result += '</div>';
return styled_result;
}
// create random delay
function generate_random_delay(){
random_number = 10000 + Math.round(Math.random() * 10000);
return random_number;
}
function fill_mdgs_with_articles() {
YUI().use('yql','node', function(Y) {
Y.later(generate_random_delay(), null, query_for_mdg, Array("mdg_1"), false);
Y.later(generate_random_delay(), null, query_for_mdg, Array("mdg_2"), false);
Y.later(generate_random_delay(), null, query_for_mdg, Array("mdg_3"), false);
Y.later(generate_random_delay(), null, query_for_mdg, Array("mdg_4"), false);
Y.later(generate_random_delay(), null, query_for_mdg, Array("mdg_5"), false);
Y.later(generate_random_delay(), null, query_for_mdg, Array("mdg_6"), false);
Y.later(generate_random_delay(), null, query_for_mdg, Array("mdg_7"), false);
Y.later(generate_random_delay(), null, query_for_mdg, Array("mdg_8"), false);
});
}
// fill all news boxes with an initial set of news
function start_article_rotation() {
query_for_mdg("mdg_1");
query_for_mdg("mdg_2");
query_for_mdg("mdg_3");
query_for_mdg("mdg_4");
query_for_mdg("mdg_5");
query_for_mdg("mdg_6");
query_for_mdg("mdg_7");
query_for_mdg("mdg_8");
}
// start_article_rotation();
// // initialize the randomness of news reloads
// YUI().use('yql','node', function(Y) {
// Y.later(30000, null, fill_mdgs_with_articles, null, true);
// });
// create click event for #mdg_search_country_button
YUI().use('yql','node', function(Y) {
Y.one('#mdg_search_country_button').subscribe(
'click',
function(e) {
selected_country = Y.one("#countries").get("value");
mdgs_data = init_mdgs(mdgs,selected_country);
// console.log(selected_country);
start_article_rotation();
Y.later(10000, null, fill_mdgs_with_articles, null, true);
}
);
});
</script>
</head>
<body>
<div id='container'>
<h1>WorldBank Millennium Development Goals</h1>
<div class="description">
Choose a country to see automatically updating search results for the <a href="http://www.worldbank.org/mdgs">Millennium Development Goals</a> in the chosen country.
</div>
<div id="country_selection">
Select a Country:
<select id="countries"> <option>Aruba</option><option>Andorra</option><option>Afghanistan</option><option>Angola</option><option>Albania</option><option>Netherlands Antilles</option><option>United Arab Emirates</option><option>Argentina</option><option>Armenia</option><option>American Samoa</option><option>Antigua and Barbuda</option><option>Australia</option><option>Austria</option><option>Azerbaijan</option><option>Burundi</option><option>Belgium</option><option>Benin</option><option>Burkina Faso</option><option>Bangladesh</option><option>Bulgaria</option><option>Bahrain</option><option>Bahamas, The</option><option>Bosnia and Herzegovina</option><option>Belarus</option><option>Belize</option><option>Bermuda</option><option>Bolivia</option><option>Brazil</option><option>Barbados</option><option>Brunei Darussalam</option><option>Bhutan</option><option>Botswana</option><option>Central African Republic</option><option>Canada</option><option>Switzerland</option><option>Channel Islands</option><option>Chile</option><option>China</option><option>Cote d'Ivoire</option><option>Cameroon</option><option>Congo, Rep.</option><option>Colombia</option><option>Comoros</option><option>Cape Verde</option><option>Costa Rica</option><option>Cuba</option><option>Cayman Islands</option><option>Cyprus</option><option>Czech Republic</option><option>Germany</option><option>Djibouti</option><option>Dominica</option><option>Denmark</option><option>Dominican Republic</option><option>Algeria</option><option>Ecuador</option><option>Egypt, Arab Rep.</option><option>Euro area</option><option>Eritrea</option><option>Spain</option><option>Estonia</option><option>Ethiopia</option><option>Finland</option><option>Fiji</option><option>France</option><option>Faeroe Islands</option><option>Micronesia, Fed. Sts.</option><option>Gabon</option><option>United Kingdom</option><option>Georgia</option><option>Ghana</option><option>Gibraltar</option><option>Guinea</option><option>Gambia, The</option><option>Guinea-Bissau</option><option>Equatorial Guinea</option><option>Greece</option><option>Grenada</option><option>Greenland</option><option>Guatemala</option><option>Guam</option><option>Guyana</option><option>Hong Kong SAR, China</option><option>Honduras</option><option>Croatia</option><option>Haiti</option><option>Hungary</option><option>Indonesia</option><option>Isle of Man</option><option>India</option><option>Ireland</option><option>Iran, Islamic Rep.</option><option>Iraq</option><option>Iceland</option><option>Israel</option><option>Italy</option><option>Jamaica</option><option>Jordan</option><option>Japan</option><option>Kazakhstan</option><option>Kenya</option><option>Kyrgyz Republic</option><option>Cambodia</option><option>Kiribati</option><option>St. Kitts and Nevis</option><option>Korea, Rep.</option><option>Kosovo</option><option>Kuwait</option><option>Lao PDR</option><option>Lebanon</option><option>Liberia</option><option>Libya</option><option>St. Lucia</option><option>Liechtenstein</option><option>Sri Lanka</option><option>Lesotho</option><option>Lithuania</option><option>Luxembourg</option><option>Latvia</option><option>Macao SAR, China</option><option>Morocco</option><option>Monaco</option><option>Moldova</option><option>Madagascar</option><option>Maldives</option><option>Mexico</option><option>Marshall Islands</option><option>Middle income</option><option>Macedonia, FYR</option><option>Mali</option><option>Malta</option><option>Myanmar</option><option>Montenegro</option><option>Mongolia</option><option>Northern Mariana Islands</option><option>Mozambique</option><option>Mauritania</option><option>Mauritius</option><option>Malawi</option><option>Malaysia</option><option>Mayotte</option><option>North America</option><option>Namibia</option><option>New Caledonia</option><option>Niger</option><option>Nigeria</option><option>Nicaragua</option><option>Netherlands</option><option>Norway</option><option>Nepal</option><option>New Zealand</option><option>Oman</option><option>Pakistan</option><option>Panama</option><option>Peru</option><option>Philippines</option><option>Palau</option><option>Papua New Guinea</option><option>Poland</option><option>Puerto Rico</option><option>Korea, Dem. Rep.</option><option>Portugal</option><option>Paraguay</option><option>French Polynesia</option><option>Qatar</option><option>Romania</option><option>Russian Federation</option><option>Rwanda</option><option>South Asia</option><option>Saudi Arabia</option><option>Sudan</option><option>Senegal</option><option>Singapore</option><option>Solomon Islands</option><option>Sierra Leone</option><option>El Salvador</option><option>San Marino</option><option>Somalia</option><option>Serbia</option><option>Sao Tome and Principe</option><option>Suriname</option><option>Slovak Republic</option><option>Slovenia</option><option>Sweden</option><option>Swaziland</option><option>Seychelles</option><option>Syrian Arab Republic</option><option>Turks and Caicos Islands</option><option>Chad</option><option>Togo</option><option>Thailand</option><option>Tajikistan</option><option>Turkmenistan</option><option>Timor-Leste</option><option>Tonga</option><option>Trinidad and Tobago</option><option>Tunisia</option><option>Turkey</option><option>Tuvalu</option><option>Tanzania</option><option>Uganda</option><option>Ukraine</option><option>Upper middle income</option><option>Uruguay</option><option>United States</option><option>Uzbekistan</option><option>St. Vincent and the Grenadines</option><option>Venezuela, RB</option><option>Virgin Islands (U.S.)</option><option>Vietnam</option><option>Vanuatu</option><option>West Bank and Gaza</option><option>World</option><option>Samoa</option><option>Yemen, Rep.</option><option>South Africa</option><option>Congo, Dem. Rep.</option><option>Zambia</option><option>Zimbabwe</option>
</select>
<input type="submit" value="Search" id="mdg_search_country_button" />
</div>
<div class="description">
Please support <a href="http://www.worldbank.org/">The World Bank</a> in any way you can. If you are a developer, take part in the <a href="http://appsfordevelopment.challengepost.com">Apps for Development</a> contest. Raise awareness, be active.
</div>
<h2>1. Eradicate extreme poverty and hunger</h2>
<div class="result_box" id="mdg_1_results">
</div>
<h2>2. Achieve universal primary education</h2>
<div class="result_box" id="mdg_2_results">
</div>
<h2>3. Promote gender equality and empower women</h2>
<div class="result_box" id="mdg_3_results">
</div>
<h2>4. Reduce child mortality</h2>
<div class="result_box" id="mdg_4_results">
</div>
<h2>5. Improve maternal health</h2>
<div class="result_box" id="mdg_5_results">
</div>
<h2>6. Combat HIV/AIDS, malaria, and other disease</h2>
<div class="result_box" id="mdg_6_results">
</div>
<h2>7. Ensure environmental sustainability</h2>
<div class="result_box" id="mdg_7_results">
</div>
<h2>8. Develop a global partnership for development</h2>
<div class="result_box" id="mdg_8_results">
</div>
<div style="clear:both; text-align:right;">
Please support <a href="http://appsfordevelopment.challengepost.com">Apps for Development</a> and
<a href="http://www.worldbank.org/">The World Bank</a>.
&copy; 2010 <a href="http://twitter.com/#!/sebastianspier">Sebastian Spier</a>
</div>
</div>
<script type="text/javascript" charset="utf-8">
var is_ssl = ("https:" == document.location.protocol);
var asset_host = is_ssl ? "https://s3.amazonaws.com/getsatisfaction.com/" : "http://s3.amazonaws.com/getsatisfaction.com/";
document.write(unescape("%3Cscript src='" + asset_host + "javascripts/feedback-v2.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript" charset="utf-8">
var feedback_widget_options = {};
feedback_widget_options.display = "overlay";
feedback_widget_options.company = "apps4devideas";
feedback_widget_options.placement = "right";
feedback_widget_options.color = "#222";
feedback_widget_options.style = "idea";
var feedback_widget = new GSFN.feedback_widget(feedback_widget_options);
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1782093-5']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.