diff --git a/doodle.html b/doodle.html
deleted file mode 100644
index 0f5f4e4..0000000
--- a/doodle.html
+++ /dev/null
@@ -1,149 +0,0 @@
-
-
-
-Doedel Drie Dee
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/index.html b/index.html
index 9d1b3a8..d0fda5b 100644
--- a/index.html
+++ b/index.html
@@ -3,10 +3,12 @@
Doedel Drie Dee
-
-
+
+
@@ -18,66 +20,61 @@ var printers = [];
$(document).ready(function () {
"use strict";
- var listDoodle = $("#printers-doodle");
+ var known = [];
+
var listSliceTest = $("#printers-slicetest");
var listSliceWebworker = $("#printers-webworker");
- listDoodle.append("Wired Printer");
- listSliceTest.append("Wired Printer");
- listSliceWebworker.append("Wired Printer");
+ function addPrinter (name, localip) {
+ known.push(localip);
- listDoodle.append("Node Server");
- listSliceTest.append("Node Server");
- listSliceWebworker.append("Node Server");
+ var slice = $("" + name + "");
+ var webworker = $("" + name + "");
+
+ listSliceTest.append(slice);
+ listSliceWebworker.append(webworker);
- /*
- printers.push({
- name: "wired box",
- d3dbox: new D3D.Box("192.168.5.1")
- });
- */
-
- getAPI(api + "list.php", function (boxes) {
- for (var i = 0; i < boxes.length; i ++) {
- var box = boxes[i];
+ 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');
+ };
+ }
- /*
- printers.push({
- name: box.wifiboxid,
- d3dbox: new D3D.Box(box.localip)
- });
- */
+ 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;
+ }
- listDoodle.append("" + box.wifiboxid + "");
- listSliceTest.append("" + box.wifiboxid + "");
- listSliceWebworker.append("" + box.wifiboxid + "");
- }
- });
+ 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();
});
-Doodle
-
-
Slice Test
Webworkers
-