Created
January 2, 2012 23:26
-
-
Save saadullahsaeed/1552600 to your computer and use it in GitHub Desktop.
Chrome extension to list newest kiva loans
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Kiva Newest Loans - Saad", | |
"version": "0.1", | |
"description": "A small handy extension to view the latest loans on Kiva.", | |
"browser_action": { | |
"default_icon": "icon.png", | |
"popup" : "popup.html" | |
}, | |
"permissions": [ | |
"http://api.kivaws.org/" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
body { | |
min-width:357px; | |
overflow-x:hidden; | |
} | |
span { | |
font-size: 0.8em; | |
} | |
h1{ | |
font-family: arial; | |
color: #6DAFA6 ; | |
} | |
div{ | |
margin-bottom: 5px; | |
background-color: #FFFFFF; | |
border: 1px solid #6DAFA6; | |
-webkit-border-radius: 15px; | |
-moz-border-radius: 15px; | |
border-radius: 15px; | |
background: url(bg.png); | |
padding: 10px 10px; | |
margin-bottom: 15px; | |
-webkit-box-shadow: #482a1b -1px -1px 3px, #482a1b 1px -1px 3px, white 1px 1px 3px, white -1px 1px 3px; | |
-moz-box-shadow: #482a1b -1px -1px 3px, #482a1b 1px -1px 3px, white 1px 1px 3px, white -1px 1px 3px; | |
box-shadow: #482a1b -1px -1px 3px, #482a1b 1px -1px 3px, white 1px 1px 3px, white -1px 1px 3px; | |
} | |
</style> | |
<script> | |
var req = new XMLHttpRequest(); | |
req.open( | |
"GET", | |
"http://api.kivaws.org/v1/loans/newest.json", | |
true); | |
req.onload = showLoans; | |
req.send(null); | |
function showLoans() { | |
var header = document.createElement('h1'); | |
header.innerHTML = 'Kiva Newest Loans'; | |
document.body.appendChild(header); | |
var resp = JSON.parse(req.responseText); | |
resp = resp.loans; | |
for (var i = 0, loan; loan = resp[i]; i++) { | |
document.body.appendChild(loanHTML(loan)); | |
} | |
} | |
function loanHTML(loan){ | |
var div = document.createElement('div'); | |
div.innerHTML = '<a href="http://www.kiva.org/lend/'+loan.id+'" target="_blank">'+loan.name+'</a> <br/>' + | |
'<span>'+loan.location.country+' | '+ loan.sector +'</span>' + | |
'<p>'+loan.use+'</p>'; | |
return div; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment