forked from termie/visivotab
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flickrset.js
55 lines (49 loc) · 1.54 KB
/
flickrset.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
var cachedImages = JSON.parse(localStorage["photoCache"]);
var whichImage = Math.round(Math.random() * (cachedImages.length - 1));
var cached = cachedImages[whichImage];
document.body.style.backgroundImage = "url(" + cached.src + ")";
document.body.style.backgroundSize = "cover";
var byline = document.getElementById("wrapper");
byline.href =
'https://www.flickr.com/photos/' + cached.owner + '/' + cached.id;
if (false && localStorage['showTitle']) {
var title = document.createElement("span");
title.setAttribute("class", "title");
if (cached.title) {
var escapedTitle = cached.title.replace(
'&', '&').replace(
'<', '<').replace(
'>', '>');
title.innerHTML = escapedTitle;
} else {
title.innerHTML = "untitled";
}
byline.appendChild(title);
if (localStorage['showOwner']) {
var owner = document.createElement("span");
owner.setAttribute("class", "owner");
var escapedOwnername = cached.ownername.replace(
'&', '&').replace(
'<', '<').replace(
'>', '>');
owner.innerHTML = " by " + escapedOwnername;
byline.appendChild(owner);
}
} else {
byline.innerHTML = "view in photostream";
}
window.onbeforeunload = function () {
document.body.onmousemove = null;
}
window.setTimeout(function () {
var mouseX = 0;
document.body.onmousemove = function (evt) {
if (mouseX == 0) {
mouseX = evt.pageX;
}
if (!mouseX != evt.pageX) {
byline.style.opacity = 0.6;
document.body.onmousemove = null;
}
}
}, 200);