267 lines
No EOL
9.2 KiB
HTML
267 lines
No EOL
9.2 KiB
HTML
<html>
|
|
|
|
<head>
|
|
<title>App</title>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link href="https://fonts.googleapis.com/css?family=Raleway:300,400,600,700" rel="stylesheet">
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
|
|
<script src="https://cdn.pubnub.com/sdk/javascript/pubnub.4.12.0.js"></script>
|
|
<script src="app.js"></script>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
width: 100%;
|
|
font-family: 'Raleway', sans-serif;
|
|
color: white;
|
|
background: linear-gradient(#2b2b2b, #0f212e);
|
|
}
|
|
|
|
.top-bar {
|
|
height: 90px;
|
|
background: linear-gradient(#2b2b2b, #1e1e1e);
|
|
font-weight: bold;
|
|
padding-left: 30px;
|
|
padding-right: 30px;
|
|
display: flex;
|
|
align-items: center;
|
|
position: fixed;
|
|
width: 480px;
|
|
top: 0;
|
|
z-index: 1;
|
|
}
|
|
|
|
.content {
|
|
margin-top: 90px;
|
|
padding: 30px;
|
|
}
|
|
|
|
input[type=button] {
|
|
font-family: 'Raleway';
|
|
font-weight: bold;
|
|
font-size: 13px;
|
|
text-transform: uppercase;
|
|
vertical-align: top;
|
|
height: 28px;
|
|
min-width: 120px;
|
|
padding: 0px 18px;
|
|
margin-right: 6px;
|
|
border-radius: 5px;
|
|
border: none;
|
|
color: #fff;
|
|
background-color: #000;
|
|
background: linear-gradient(#343434 20%, #000 100%);
|
|
cursor: pointer;
|
|
}
|
|
|
|
input[type=button].red {
|
|
color: #fff;
|
|
background-color: #94132e;
|
|
background: linear-gradient(#d42043 20%, #94132e 100%);
|
|
}
|
|
|
|
input[type=button].blue {
|
|
color: #fff;
|
|
background-color: #1080b8;
|
|
background: linear-gradient(#00b4ef 20%, #1080b8 100%);
|
|
}
|
|
|
|
input[type=button].white {
|
|
color: #121212;
|
|
background-color: #afafaf;
|
|
background: linear-gradient(#fff 20%, #afafaf 100%);
|
|
}
|
|
|
|
input[type=button]:enabled:hover {
|
|
background: linear-gradient(#000, #000);
|
|
border: none;
|
|
}
|
|
|
|
input[type=button].red:enabled:hover {
|
|
background: linear-gradient(#d42043, #d42043);
|
|
border: none;
|
|
}
|
|
|
|
input[type=button].blue:enabled:hover {
|
|
background: linear-gradient(#00b4ef, #00b4ef);
|
|
border: none;
|
|
}
|
|
|
|
input[type=button].white:enabled:hover {
|
|
background: linear-gradient(#fff, #fff);
|
|
border: none;
|
|
}
|
|
|
|
input[type=button]:active {
|
|
background: linear-gradient(#343434, #343434);
|
|
}
|
|
|
|
input[type=button].red:active {
|
|
background: linear-gradient(#94132e, #94132e);
|
|
}
|
|
|
|
input[type=button].blue:active {
|
|
background: linear-gradient(#1080b8, #1080b8);
|
|
}
|
|
|
|
input[type=button].white:active {
|
|
background: linear-gradient(#afafaf, #afafaf);
|
|
}
|
|
|
|
input[type=button]:disabled {
|
|
color: #252525;
|
|
background: linear-gradient(#575757 20%, #252525 100%);
|
|
}
|
|
|
|
input[type=button][pressed=pressed] {
|
|
color: #00b4ef;
|
|
}
|
|
</style>
|
|
<script>
|
|
|
|
</script>
|
|
</head>
|
|
|
|
<body onload="load()">
|
|
<div id="header" class="top-bar">
|
|
<h3> Emoji Broadcaster Configuration </h3>
|
|
</div>
|
|
<div id="instructions" class="content">
|
|
<text> This app allows you to manage and control emojis that your viewers on Twitch and YouTube can send to you in-world.
|
|
</text>
|
|
<h4> Select Emojis </h4>
|
|
<input type="checkbox" class="emoji" value="heart"> Heart </input>
|
|
<input type="checkbox" class="emoji" value="poo"> Poo </input>
|
|
<input type="checkbox" class="emoji" value="flowers"> Flowers </input>
|
|
<input type="checkbox" class="emoji" value="pizza"> Pizza </input><br>
|
|
<input type="checkbox" class="emoji" value="pickle"> Pickle </input>
|
|
<input type="checkbox" class="emoji" value="fireworks"> Fireworks </input>
|
|
<input type="checkbox" class="emoji" value="smile"> Smile </input><br>
|
|
<h4> Emoji Settings </h4>
|
|
<p>
|
|
<p> Lifetime: <i> How long emojis should last </i></p>
|
|
<input type="range" class="slider" name="lifetime" value="60" min="10" max="360">
|
|
<text id="lifetimelabel"> 60 seconds</text>
|
|
</input>
|
|
<p> Frequency:
|
|
<i> How often to check for new emojis </i></p>
|
|
<input type="range" class="slider2" value="30" min="5" max="60">
|
|
<text id="frequencylabel"> 30 seconds</text>
|
|
</input>
|
|
</p>
|
|
<input type="checkbox" id="useNames" checked="true"> Show usernames on emojis </input><br><br>
|
|
<input type="button" id="placeSpawner" class="blue" value="Set Location"> </input>
|
|
<input type="button" id="startBtn" class="white" value="Start"> </input>
|
|
<input type="button" id="stopBtn" class="red" value="Stop" hidden="true"></input>
|
|
</div>
|
|
|
|
<script>
|
|
var channel = [];
|
|
var username;
|
|
var isBroadcasting;
|
|
var pubnub;
|
|
|
|
function load() {
|
|
var sessionData = window.location.href.split("?")[1];
|
|
var params = sessionData.split("&"); // ?username&isBroadcasting
|
|
username = params[0];
|
|
isBroadcasting = params[1];
|
|
channel.push(username);
|
|
|
|
// If we are broadcasting, we need the "Stop" button showing"
|
|
if(isBroadcasting) {
|
|
$("#stopBtn").toggle();
|
|
$("#startBtn").toggle();
|
|
}
|
|
|
|
pubnub = new PubNub({
|
|
subscribeKey: "sub-c-14abc55e-6b09-11e7-9aa9-02ee2ddab7fe"
|
|
})
|
|
|
|
pubnub.addListener({
|
|
status: function (statusEvent) {
|
|
if (statusEvent.category === "PNConnectedCategory") {
|
|
var eventData = {
|
|
"type": "ConnectToPN"
|
|
};
|
|
EventBridge.emitWebEvent(JSON.stringify(eventData));
|
|
} else if (statusEvent.category === "PNUnknownCategory") {
|
|
var newState = {
|
|
new: 'error'
|
|
};
|
|
pubnub.setState(
|
|
{
|
|
state: newState
|
|
},
|
|
function (status) {
|
|
var eventData = {
|
|
"type": "UnknownPNMsg",
|
|
"data": statusEvent.errorData.message
|
|
}
|
|
EventBridge.emitWebEvent(JSON.stringify(eventData));
|
|
}
|
|
);
|
|
}
|
|
},
|
|
message: function (message) {
|
|
var eventData = {
|
|
type: "receivedMsg",
|
|
data: message,
|
|
text: message.text
|
|
}
|
|
EventBridge.emitWebEvent(JSON.stringify(eventData));
|
|
}
|
|
})
|
|
}
|
|
$(".slider").on("input", function () {
|
|
$("#lifetimelabel").html(this.value + " seconds");
|
|
});
|
|
$(".slider2").on("input", function () {
|
|
$("#frequencylabel").html(this.value + " seconds");
|
|
});
|
|
$("#startBtn").on("click", function () {
|
|
var selectedEmojis = [];
|
|
$(".emoji:checkbox:checked").each(function () {
|
|
selectedEmojis.push($(this).val());
|
|
});
|
|
|
|
var clickEvent = {
|
|
"type": "submit",
|
|
"data": {
|
|
"emojis": selectedEmojis,
|
|
"lifetime": $(".slider").val(),
|
|
"frequency": $(".slider2").val(),
|
|
"useNames": $("#useNames").is(":checked")
|
|
}
|
|
}
|
|
EventBridge.emitWebEvent(JSON.stringify(clickEvent));
|
|
|
|
$("#startBtn").toggle();
|
|
$("#stopBtn").toggle();
|
|
pubnub.subscribe({
|
|
channels: channel
|
|
});
|
|
});
|
|
|
|
$("#stopBtn").on("click", function () {
|
|
var clickEvent = {
|
|
"type": "stop"
|
|
}
|
|
EventBridge.emitWebEvent(JSON.stringify(clickEvent));
|
|
$("#stopBtn").toggle();
|
|
$("#startBtn").toggle();
|
|
pubnub.unsubscribe({
|
|
channels: channel
|
|
})
|
|
});
|
|
|
|
$("#placeSpawner").on("click", function () {
|
|
var clickEvent = {
|
|
"type": "setLoc"
|
|
}
|
|
EventBridge.emitWebEvent(JSON.stringify(clickEvent));
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html> |