update current room
parent
af8e820c8e
commit
a7d86d9077
|
|
@ -14,6 +14,23 @@ function httpGetAsync(theUrl, callback, failCallback) {
|
|||
xmlHttp.send(null);
|
||||
}
|
||||
|
||||
|
||||
function httpPostAsync(theUrl, data, callback, failCallback) {
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
xmlHttp.onreadystatechange = function () {
|
||||
if (xmlHttp.readyState == 4) {
|
||||
if (xmlHttp.status == 200) {
|
||||
callback(xmlHttp.responseText);
|
||||
} else {
|
||||
failCallback(xmlHttp.status);
|
||||
}
|
||||
}
|
||||
}
|
||||
xmlHttp.open("POST", theUrl, true); // true for asynchronous
|
||||
http.setRequestHeader('Content-type', 'application/json');
|
||||
xmlHttp.send(data);
|
||||
}
|
||||
|
||||
function getCookie(cname) {
|
||||
let name = cname + "=";
|
||||
let decodedCookie = decodeURIComponent(document.cookie);
|
||||
|
|
|
|||
|
|
@ -38,9 +38,10 @@
|
|||
|
||||
|
||||
<div id="headset_details" style="display: none;">
|
||||
<div class="panel">
|
||||
<div class="panel card">
|
||||
<div class="panel-header text-center">
|
||||
<figure class="avatar avatar-lg"><img src="static/favicon/android-chrome-192x192.png" alt="Avatar"></figure>
|
||||
<figure class="avatar avatar-lg"><img src="/static/favicons/android-chrome-192x192.png"
|
||||
alt="Avatar"></figure>
|
||||
<div class="panel-title h5 mt-10">Headset Info</div>
|
||||
<div class="panel-subtitle hw_id">---</div>
|
||||
</div>
|
||||
|
|
@ -51,8 +52,8 @@
|
|||
<input class="btn" type="text" id="current_room" placeholder="----">
|
||||
</div>
|
||||
<div class="tile-action">
|
||||
<button class="btn btn-link btn-action btn-lg tooltip tooltip-left"
|
||||
data-tooltip="Set Room ID"><i class="icon icon-send"></i></button>
|
||||
<button class="btn btn-link btn-action btn-lg tooltip tooltip-left" id="set_room_id"
|
||||
data-tooltip="Set Room ID"><i class="icon icon-check"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tile tile-centered">
|
||||
|
|
@ -67,6 +68,9 @@
|
|||
<div class="tile-subtitle last_used">---</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -81,6 +85,8 @@
|
|||
let headset_details = document.getElementById('headset_details');
|
||||
let hw_id_field = document.getElementById('hw_id');
|
||||
let failure = document.getElementById('failure');
|
||||
let set_room_id = document.getElementById('set_room_id');
|
||||
let current_room = document.getElementById('current_room');
|
||||
|
||||
|
||||
// check cookie
|
||||
|
|
@ -102,6 +108,19 @@
|
|||
failure.style.display = "block";
|
||||
});
|
||||
|
||||
set_room_id.addEventListener('click', () => {
|
||||
httpPostAsync('/api/set_headset_details/' + hw_id,
|
||||
{
|
||||
"current_room": current_room.value
|
||||
},
|
||||
(resp) => {
|
||||
console.log('success');
|
||||
},
|
||||
(status) => {
|
||||
console.log('fail');
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
window.location.href = "/pair";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue