mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-23 19:43:48 +01:00
3bacee2072
index page now checks if doodle boxes are alive before displaying them
80 lines
1.8 KiB
HTML
80 lines
1.8 KiB
HTML
<!DOCTYPE HTML>
|
|
<html lang="en">
|
|
<head>
|
|
<title>Doedel Drie Dee</title>
|
|
<script src="library/jquery.js"></script>
|
|
<script src="src/utils.js"></script>
|
|
<script src="src/box.js"></script>
|
|
|
|
<style>
|
|
.hidden {display: none;}
|
|
</style>
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<script>
|
|
var api = "http://connect.doodle3d.com/api/";
|
|
var printers = [];
|
|
|
|
$(document).ready(function () {
|
|
"use strict";
|
|
|
|
var known = [];
|
|
|
|
var listSliceTest = $("#printers-slicetest");
|
|
var listSliceWebworker = $("#printers-webworker");
|
|
|
|
function addPrinter (name, localip) {
|
|
known.push(localip);
|
|
|
|
var slice = $("<li class='hidden'><a href='slice_test.html#" + localip + "'>" + name + "</a></li>");
|
|
var webworker = $("<li class='hidden'><a href='webworker_test.html#" + localip + "'>" + name + "</a></li>");
|
|
|
|
listSliceTest.append(slice);
|
|
listSliceWebworker.append(webworker);
|
|
|
|
var box = new D3D.Box(localip).init();
|
|
box.onconnect = function () {
|
|
slice.removeClass('hidden');
|
|
webworker.removeClass('hidden');
|
|
};
|
|
box.ondisconnect = function () {
|
|
slice.addClass('hidden');
|
|
webworker.addClass('hidden');
|
|
};
|
|
}
|
|
|
|
function checkNewBoxes () {
|
|
getAPI(api + "list.php", function (error, boxes) {
|
|
if (error) {
|
|
console.warn('It appears that you are not connected to the internet, or the Doodle3D servers are down');
|
|
return;
|
|
}
|
|
|
|
for (var i = 0; i < boxes.length; i ++) {
|
|
var box = boxes[i];
|
|
if (known.indexOf(box.localip) === -1) {
|
|
|
|
addPrinter(box.wifiboxid, box.localip);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
addPrinter('Wired Printer', '192.168.5.1');
|
|
addPrinter('Node Server', window.location.host + ":3000");
|
|
|
|
setInterval(checkNewBoxes, 10000);
|
|
checkNewBoxes();
|
|
});
|
|
</script>
|
|
|
|
<p>Slice Test</p>
|
|
<ul id="printers-slicetest"></ul>
|
|
|
|
<p>Webworkers</p>
|
|
<ul id="printers-webworker"></ul>
|
|
|
|
</body>
|
|
</html> |