Compare commits
2 Commits
efe30a1ae9
...
97030af565
Author | SHA1 | Date |
---|---|---|
Stef Dunlap | 97030af565 | |
Tom Dunlap | 6f68a5c0a9 |
|
@ -1,2 +1,4 @@
|
|||
# irl-colour-time
|
||||
|
||||
This is the very hacky source code behind http://chez.kindrobot.ca/puter.html.
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
curl 'https://colour-time-default-rtdb.firebaseio.com/messages.json' -d '{"text": "yo", "red": 1, "green": 2, "blue": 3}'
|
|
@ -0,0 +1,87 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>kindrobot</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
background-color: DarkSlateGray;
|
||||
color: Gainsboro;
|
||||
font-family: courier;
|
||||
max-width: 650px;
|
||||
margin-left: 100px;
|
||||
}
|
||||
a {
|
||||
color: LightGray;
|
||||
}
|
||||
#title {
|
||||
display: inline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>'puter colour picker</h1>
|
||||
<em>Help me decorate my office.</em>
|
||||
|
||||
<form id="colour-change-form">
|
||||
<input type="text" placeholder="red (0-255)" id="colour-change-red"/>
|
||||
<input type="text" placeholder="green (0-255)" id="colour-change-green"/>
|
||||
<input type="text" placeholder="blue (0-255)" id="colour-change-blue"/>
|
||||
<input type="text" placeholder="a nice note" id="colour-change-note"/>
|
||||
<input type="submit" id="colour-change-submit" value="Submit"/>
|
||||
</form>
|
||||
<img src="http://home.kindrobot.ca/puter.png" alt="a computer with some colour" id="img-puter"/>
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", (event) => {
|
||||
const theForm = document.getElementById('colour-change-form');
|
||||
theForm.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
const red = parseInt(document.getElementById('colour-change-red').value);
|
||||
const green = parseInt(document.getElementById('colour-change-green').value);
|
||||
const blue = parseInt(document.getElementById('colour-change-blue').value);
|
||||
const note = document.getElementById('colour-change-note').value;
|
||||
|
||||
if(isNaN(red) || red < 0 || red > 255){
|
||||
alert("red needs to be a number between 0 and 255");
|
||||
return;
|
||||
}
|
||||
if(isNaN(blue) || blue < 0 || blue > 255){
|
||||
alert("blue needs to be a number between 0 and 255");
|
||||
return;
|
||||
}
|
||||
if(isNaN(green) || green < 0 || green > 255){
|
||||
alert("green needs to be a number between 0 and 255");
|
||||
return;
|
||||
}
|
||||
if(!note || note == ""){
|
||||
alert("please provide a note");
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await fetch("https://colour-time-default-rtdb.firebaseio.com/messages.json", {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
cache: 'no-cache',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
redirect: 'follow',
|
||||
body: JSON.stringify({
|
||||
text: note, red, green, blue
|
||||
})
|
||||
});
|
||||
const resultBody = await response.json();
|
||||
console.log(resultBody);
|
||||
alert("Thank you so much! Please stick around for about a minute to see your change.");
|
||||
theForm.reset();
|
||||
|
||||
const img = document.getElementById('img-puter');
|
||||
let count = 0;
|
||||
const looper = setInterval(() => {
|
||||
img.src = `http://home.kindrobot.ca/puter.png?t=${new Date().getTime()}`;
|
||||
if(++count >= 5)
|
||||
clearInterval(looper);
|
||||
}, 15000);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,14 @@
|
|||
$messages = Invoke-WebRequest 'https://colour-time-default-rtdb.firebaseio.com/messages.json?limitToLast=1&orderBy="$key"' | ConvertFrom-Json
|
||||
$message = $messages.PSObject.Properties.Value
|
||||
$red = [int]$message.red
|
||||
$green = [int]$message.green
|
||||
$blue = [int]$message.blue
|
||||
|
||||
echo $red
|
||||
echo $green
|
||||
echo $blue
|
||||
|
||||
$setCmd = "set-all=$red,$green,$blue"
|
||||
echo $setCmd
|
||||
& "C:\Program Files\AlienFX Tools\alienfx-cli.exe" $setCmd
|
||||
& 'C:\Program Files\OpenCamera\openphoto.exe' C:\inetpub\wwwroot\puter.png
|
Loading…
Reference in New Issue