-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingly_get.js
28 lines (28 loc) · 949 Bytes
/
singly_get.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var https = require('https');
var whitelist = ["gcal", "twitter", "facebook", "foursquare", "linkedin", "tumblr"]
/* Generate the login icons */
var req = https.request({
hostname: 'api.singly.com', path: '/services'
}, function(res) {
var data = "";
res.on('data', function (chunk) {
data += chunk;
});
res.on('end', function () {
var services = {};
data = JSON.parse(data);
for (var i in data) {
var service = data[i];
if (!!service.icons && !!service.hasTestKeys && whitelist.indexOf(i) !== -1) {
services[i] = {name: service.name, icon: service.icons[2].source};
}
}
for (var i in whitelist) {
var service = services[whitelist[i]];
var name = service.name;
var icon = service.icon;
console.log('<a target="_new" title="' + name + '" href="<%- login_prefix %>' + whitelist[i] + '"><img src="' + icon + '" width="32" height="32"></a>');
}
});
})
req.end();