forked from hermanho/MMM-GooglePhotos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MMM-GooglePhotos.js
56 lines (50 loc) · 1.69 KB
/
MMM-GooglePhotos.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
//
// MMM-GooglePhotos
//
Module.register("MMM-GooglePhotos", {
defaults: {
albumId: "", // your album id from result of `auth_and_test.js`
refreshInterval: 1000*60, // too short refreshing might cause API quota limit. Under 10sec will exhaust your quota(usually total <25000 per day).
scanInterval: 1000*60*60, // too many scans might cause API quota limit also.
sort: "time", //'time', 'reverse', 'random'
showWidth: "800px", // how large the photo will be shown as.
showHeight: "600px",
originalWidthPx: 800, // original size of loaded image. (related with image quality)
originalHeightPx: 600,
mode: "cover", // "cover" or "contain" (https://www.w3schools.com/cssref/css3_pr_background-size.asp)
},
getStyles: function () {
return ["MMM-GooglePhotos.css"]
},
start: function() {
this.sendSocketNotification("INIT", this.config)
},
getDom: function() {
var wrapper = document.createElement("div")
wrapper.id = "GPHOTO"
wrapper.style.width = this.config.showWidth
wrapper.style.height = this.config.showHeight
wrapper.style.minWidth = this.config.showWidth
wrapper.style.minHeight = this.config.showHeight
wrapper.style.backgroundSize = this.config.mode
return wrapper
},
showImage: function(url) {
var h1 = document.getElementById("GPHOTO")
h1.style.backgroundImage = "url('" + url + "')"
},
socketNotificationReceived: function(notification, payload) {
switch(notification) {
case "NEW_IMAGE":
this.showImage(payload.url)
break
}
},
notificationReceived: function(sender, notification, payload) {
switch(notification) {
case "DOM_OBJECTS_CREATED":
// this.initialize()
break
}
}
})