Browse Source

fix javascript

main
Hendrik Langer 4 years ago
parent
commit
9b5135920d
  1. 2
      raspberry/roberto/views/frontend/templates/gamepad.js
  2. 34
      raspberry/roberto/views/frontend/templates/index.html

2
raspberry/roberto/views/frontend/templates/gamepad.js

@ -97,6 +97,8 @@ if (haveEvents) {
// Virtual Joystick // Virtual Joystick
var joystick = nipplejs.create({ var joystick = nipplejs.create({
zone: document.getElementById('controls'), zone: document.getElementById('controls'),
mode: 'static',
position: {left: '50%', top: '50%'},
color: 'blue' color: 'blue'
}); });
/* /*

34
raspberry/roberto/views/frontend/templates/index.html

@ -26,6 +26,7 @@
right: 0; right: 0;
width: 100%; width: 100%;
height: 33%; height: 33%;
pointer-events: all;
} }
p { p {
position: relative; position: relative;
@ -45,12 +46,9 @@
opacity: 0.6; opacity: 0.6;
z-index: 1; z-index: 1;
} }
#textoverlay, #controls, .stats-box { #textoverlay, .stats-box {
pointer-events: none; pointer-events: none;
} }
#controls canvas {
pointer-events: all;
}
</style> </style>
</head> </head>
<body> <body>
@ -199,24 +197,26 @@ socket.on('battery', (data) => {
}; };
statsInterval = window.setInterval(getConnectionStats, 1000);
function getConnectionStats() { function getConnectionStats() {
webrtcPeerConnection.getStats(null).then(stats => { if (webrtcPeerConnection) {
var statsOutput = ""; webrtcPeerConnection.getStats(null).then(stats => {
var statsOutput = "";
stats.forEach(report => {
if (report.type === "inbound-rtp" && report.kind === "video") {
Object.keys(report).forEach(statName => {
statsOutput += `<strong>${statName}:</strong> ${report[statName]}<br>\n`;
});
}
});
stats.forEach(report => { document.querySelector(".stats-box").innerHTML = statsOutput;
if (report.type === "inbound-rtp" && report.kind === "video") {
Object.keys(report).forEach(statName => {
statsOutput += `<strong>${statName}:</strong> ${report[statName]}<br>\n`;
});
}
}); });
}
document.querySelector(".stats-box").innerHTML = statsOutput;
});
} }
var statsInterval = window.setInterval(getConnectionStats, 1000);
</script> </script>
<script src="{{ url_for('frontend.gamepad_js') }}"></script> <script src="{{ url_for('frontend.gamepad_js') }}"></script>

Loading…
Cancel
Save