initial commit

This commit is contained in:
Lurkars
2017-12-07 18:18:11 +01:00
commit 8a890a8cd1
21 changed files with 6258 additions and 0 deletions
+2936
View File
File diff suppressed because it is too large Load Diff
+60
View File
@@ -0,0 +1,60 @@
body {
font-family: 'OpenSans', 'Roboto', 'sans-serif', 'sans';
background: #000;
color: #d13d29;
}
h1 {
position: fixed;
bottom: 15px;
left: 15px;
margin: 0;
padding: 0;
z-index: 2;
}
h1 i.fa {
color: #468ac3;
}
a, a:hover {
color: #468ac3;
text-decoration: none;
}
#background {
z-index: 1;
position: fixed;
display: block;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-position: top left;
background-repeat: no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-webkit-transition: all 1.5s ease-in-out;
-moz-transition: all 1.5s ease-in-out;
-o-transition: all 1.5s ease-in-out;
transition: all 1.5s ease-in-out;
opacity: 0;
box-shadow: 0px -150px 150px 0px #000 inset;
}
.unsplash {
position: absolute;
bottom: 0;
right: 0;
padding: 15px;
}
.hidden {
display: none;
}
#description {
font-style: italic;
}
+21
View File
@@ -0,0 +1,21 @@
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="font-awesome.css" />
<link rel="stylesheet" href="splash.css" />
</head>
<body>
<h1><i class="fa fa-television"></i> Muffcast is ready!</h1>
<div id="background">
<div class="unsplash">
<span id="description"></span>
<span id="user-meta">Photo by <a id="user" target="_blank"></a> / </span><a id="unsplash" target="_blank" href="https://unsplash.com/?utm_source=muffcast&utm_medium=referral&utm_campaign=api-credit">Unsplash</a>
</div>
</div>
<script src="splash.js"></script>
<script src="../muffcast-server.js"></script>
</body>
</html>
+107
View File
@@ -0,0 +1,107 @@
/*
browser.tabs.query({
currentWindow: true,
active: true
}).then(function(tabs) {
var tab = tabs[0];
browser.tabs.insertCSS(tab.id, {
code: "@font-face { font-family: 'duospace';" +
"src: url('" + browser.extension.getURL("fonts/iAWriterDuospace-Regular.eot") + "');" +
"src: url('" + browser.extension.getURL("fonts/iAWriterDuospace-Regular.eot") + "?#iefix&v=4.7.0') format('embedded-opentype')," +
"url('" + browser.extension.getURL("fonts/iAWriterDuospace-Regular.woff") + "') format('woff')," +
"url('" + browser.extension.getURL("fonts/iAWriterDuospace-Regular.ttf") + "') format('truetype')," +
"url('" + browser.extension.getURL("fonts/iAWriterDuospace-Regular.svg") + "') format('svg');" +
"font - weight: normal;" +
"font - style: normal;}"
});
})
*/
var interval = 8000;
var unsplash = {};
browser.storage.local.get("muffcast").then(function(result) {
interval = result.muffcast && result.muffcast.unsplashInterval || interval;
unsplash.clientId = result.muffcast && result.muffcast.unsplashClient;
unsplash.credit = result.muffcast && result.muffcast.unsplashCredit;
setInterval(getUnsplash, interval);
})
var splash = {
url: "",
user: "",
userUrl: ""
}
var getUnsplashRandom = function() {
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "https://source.unsplash.com/random/1600x900", true);
xhttp.addEventListener("load", function() {
if (this.readyState == 4) {
splash.url = this.responseURL;
delete splash.description;
delete splash.user;
delete splash.userUrl;
setBackground();
}
});
xhttp.send();
}
var getUnsplash = function() {
var background = document.getElementById("background");
background.style.opacity = 0;
if (unsplash && unsplash.clientId && unsplash.credit) {
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "https://api.unsplash.com/photos/random?w=1600&h=900&client_id=" + unsplash.clientId, true);
xhttp.addEventListener("load", function() {
if (this.readyState == 4) {
if (this.status == 200) {
var response = this.responseText ? JSON.parse(this.responseText) : false;
if (response) {
splash.url = response.urls.custom;
splash.description = response.description;
splash.user = response.user.name;
splash.userUrl = response.user.links.html + "?utm_source=" + unsplash.credit + "&utm_medium=referral&utm_campaign=api-credit";
setBackground();
}
} else {
getUnsplashRandom();
}
}
});
xhttp.setRequestHeader("content-type", "application/json");
xhttp.send();
} else {
getUnsplashRandom();
}
}
var setBackground = function() {
setTimeout(function() {
var background = document.getElementById("background");
background.style['background-image'] = "url('" + splash.url + "')";
background.style.opacity = 1;
var userMeta = document.getElementById("user-meta");
if (splash.user) {
userMeta.classList.remove("hidden");
var user = document.getElementById("user");
user.href = splash.userUrl;
user.innerHTML = splash.user;
} else {
userMeta.classList.add("hidden");
}
var description = document.getElementById("description");
if (splash.description) {
description.innerHTML = splash.description;
} else {
description.innerHTML = "";
}
}, 1500)
}
getUnsplash();