0
0
mirror of https://github.com/Doodle3D/doodle3d-connect.git synced 2024-12-25 18:13:48 +01:00

Various improvements and fixes

This commit is contained in:
peteruithoven 2013-09-30 17:34:27 +02:00
parent 5d5283c254
commit c0ed48b359
6 changed files with 53 additions and 17 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
credentials.php

4
.htaccess Normal file
View File

@ -0,0 +1,4 @@
# don't supress php errors
php_flag display_startup_errors on
php_flag display_errors on
php_flag html_errors on

View File

@ -1,9 +1,9 @@
<?php <?php
require 'credentials.php';
$database = "doodle3d_connect"; $database = "doodle3d_connect";
$dsn = "mysql:host=localhost;dbname=$database"; $dsn = "mysql:host=localhost;dbname=$database";
$username = "root";
$password = "mysql";
$table = "signins"; $table = "signins";
try { try {

View File

@ -2,6 +2,7 @@
require 'connect.php'; require 'connect.php';
try {
// exported structure using phpMyAdmin // exported structure using phpMyAdmin
$createsql = $db->prepare("CREATE TABLE IF NOT EXISTS $table (" . $createsql = $db->prepare("CREATE TABLE IF NOT EXISTS $table (" .
"`id` varchar(151) NOT NULL," . "`id` varchar(151) NOT NULL," .
@ -12,5 +13,12 @@
"`date` datetime NOT NULL," . "`date` datetime NOT NULL," .
"PRIMARY KEY (`id`)" . "PRIMARY KEY (`id`)" .
") ENGINE=InnoDB DEFAULT CHARSET=latin1;"); ") ENGINE=InnoDB DEFAULT CHARSET=latin1;");
$createsql->execute();
if($createsql->execute() == TRUE)
echo "$table created";
} catch (PDOException $e) {
$response = array( "status" => "error",
"msg" => $e->getMessage()." (".$e->getCode().")");
exit(json_encode($response)."\r\n");
}
?> ?>

View File

@ -1,5 +1,6 @@
var retrieveListDelay; // retry setTimout instance var retrieveListDelay; // retry setTimout instance
var retrieveListInterval = 5000; var retrieveListInterval = 5000;
var boxTimeoutTime = 300;
var $list; var $list;
$(function() { $(function() {
@ -10,8 +11,9 @@ $(function() {
}) })
function retrieveList() { function retrieveList() {
$.ajax({ $.ajax({
url: "/list.php", url: "list.php",
dataType: 'json', dataType: 'json',
timeout: boxTimeoutTime,
success: function(response){ success: function(response){
//console.log("retrieveList response: ",response); //console.log("retrieveList response: ",response);
if(response.status == "success") { if(response.status == "success") {
@ -27,9 +29,24 @@ function retrieveList() {
}); });
} }
function updateList(boxes) { function updateList(boxes) {
//console.log("list: ",boxes);
$list.empty(); $list.empty();
jQuery.each(boxes, function (index,box) { jQuery.each(boxes, function (index,box) {
$list.append("<li><a href='/"+box.localip+"'>"+box.wifiboxid+"</a></li>"); checkBox(box);
}); });
} }
function checkBox(box) {
$.ajax({
url: "http://"+box.localip+"/d3dapi/network/status",
dataType: 'json',
success: function(response){
if(response.status == "success") {
var url = "http://"+box.localip;
if(boxIsListed(url)) return;
$list.append("<li><a href='"+url+"'>"+box.wifiboxid+"</a></li>");
}
}
});
}
function boxIsListed(url){
return $list.find("a[href|='"+url+"']").length > 0;
}

View File

@ -15,7 +15,12 @@
exit(json_encode($response)."\r\n"); exit(json_encode($response)."\r\n");
} }
$debug = array( "time" => time(),
"hourago" => $hourago,
"remoteip" => $remoteip);
$response = array( "status" => "success", $response = array( "status" => "success",
"data" => $boxes); "data" => $boxes,
"debug" => $debug);
exit(json_encode($response)."\r\n"); exit(json_encode($response)."\r\n");
?> ?>