-
Notifications
You must be signed in to change notification settings - Fork 1
/
sample.js
61 lines (43 loc) · 2.06 KB
/
sample.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
var gravatar = require('./lib/gravatar');
var existingProfile = gravatar.createHash('[email protected]');
var invalidProfile = gravatar.createHash('[email protected]');
console.log("Existing profile hash: " + existingProfile);
console.log("Invalid profile hash: " + invalidProfile);
console.log("Existing profile image:");
console.log(gravatar.imageUrlFor(existingProfile));
console.log("Existing profile image at 120px width and height:");
console.log(gravatar.imageUrlFor(existingProfile, { size: 120 })); // size may be anything between 1px and 512px
console.log("Existing profile image at 100px w/h and a default image URL:");
console.log(gravatar.imageUrlFor(existingProfile, { size: 100, defaultImage: 'http://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg' }));
console.log("Non-existant profile image with a default image URL:");
console.log(gravatar.imageUrlFor(invalidProfile, { defaultImage: 'http://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg'}));
console.log("Non-existant profile image without default image URL:");
console.log(gravatar.imageUrlFor(invalidProfile));
console.log("200px QR Code for existing profile:");
console.log(gravatar.imageUrlFor(existingProfile, { size: 200, format: 'qr' }));
console.log();
console.log("Profile URL:");
console.log(gravatar.profileUrlFor(existingProfile));
console.log("Profile data URL (JSON format):");
console.log(gravatar.profileUrlFor(existingProfile, 'json'));
console.log("Invalid profile data URL (JSON):");
console.log(gravatar.profileUrlFor(invalidProfile, 'json'));
console.log("Profile data URL (JSON format w/ callback name):");
console.log(gravatar.profileUrlFor(existingProfile, 'json', 'changeThisCallbackName'));
console.log();
gravatar.getProfileFor(existingProfile, function(err, data) {
console.log("Profile data (existing profile):");
if (err) {
console.log(err);
return;
}
console.log(data);
});
gravatar.getProfileFor(invalidProfile, function(err, data) {
console.log("Profile data (invalid profile):");
if (err) {
console.log(err);
return;
}
console.log(data);
});