mirror of
https://github.com/Doodle3D/doodle3d-connect.git
synced 2024-12-25 01:53:48 +01:00
Various improvements and fixes
This commit is contained in:
parent
5d5283c254
commit
c0ed48b359
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
credentials.php
|
4
.htaccess
Normal file
4
.htaccess
Normal 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
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
require 'credentials.php';
|
||||
|
||||
$database = "doodle3d_connect";
|
||||
$dsn = "mysql:host=localhost;dbname=$database";
|
||||
$username = "root";
|
||||
$password = "mysql";
|
||||
$table = "signins";
|
||||
|
||||
try {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
require 'connect.php';
|
||||
|
||||
try {
|
||||
// exported structure using phpMyAdmin
|
||||
$createsql = $db->prepare("CREATE TABLE IF NOT EXISTS $table (" .
|
||||
"`id` varchar(151) NOT NULL," .
|
||||
@ -12,5 +13,12 @@
|
||||
"`date` datetime NOT NULL," .
|
||||
"PRIMARY KEY (`id`)" .
|
||||
") 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");
|
||||
}
|
||||
?>
|
||||
|
23
js/main.js
23
js/main.js
@ -1,5 +1,6 @@
|
||||
var retrieveListDelay; // retry setTimout instance
|
||||
var retrieveListInterval = 5000;
|
||||
var boxTimeoutTime = 300;
|
||||
var $list;
|
||||
|
||||
$(function() {
|
||||
@ -10,8 +11,9 @@ $(function() {
|
||||
})
|
||||
function retrieveList() {
|
||||
$.ajax({
|
||||
url: "/list.php",
|
||||
url: "list.php",
|
||||
dataType: 'json',
|
||||
timeout: boxTimeoutTime,
|
||||
success: function(response){
|
||||
//console.log("retrieveList response: ",response);
|
||||
if(response.status == "success") {
|
||||
@ -27,9 +29,24 @@ function retrieveList() {
|
||||
});
|
||||
}
|
||||
function updateList(boxes) {
|
||||
//console.log("list: ",boxes);
|
||||
$list.empty();
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user