minucias
This commit is contained in:
@@ -1,16 +1,15 @@
|
|||||||
package Dojo::Controller::Data;
|
package Dojo::Controller::Data;
|
||||||
use Mojo::Base 'Mojolicious::Controller';
|
use Mojo::Base 'Mojolicious::Controller';
|
||||||
use Dojo::Support qw{ dmph merge_hash load_module };
|
use Dojo::Support qw{ dmph merge_hash load_module };
|
||||||
use Dojo::Conf;
|
|
||||||
use Net::Telnet;
|
use Net::Telnet;
|
||||||
|
|
||||||
my $server_name = $Dojo::Conf::chat->{chat_srv};
|
my $server_name = "";
|
||||||
our $t; #telnet server object
|
our $t; #telnet server object
|
||||||
sub simple{
|
sub simple{
|
||||||
my $c=shift;
|
my $c=shift;
|
||||||
my $n=$c->param("dreq")//"";
|
my $n=$c->param("dreq")//"";
|
||||||
my $json = {status => "304"};
|
my $json = {status => "304"};
|
||||||
$json = \%Dojo::Conf::radio if $n =~m/^radio$/ ;
|
$json = { srv =>$c->config->{radio_server} } if $n =~m/^radio$/ ;
|
||||||
$json = candy() if $n =~m/^candy$/ ;
|
$json = candy() if $n =~m/^candy$/ ;
|
||||||
$c->render(json=>$json);
|
$c->render(json=>$json);
|
||||||
}
|
}
|
||||||
@@ -29,6 +28,7 @@ sub admin{
|
|||||||
sub candy{
|
sub candy{
|
||||||
my $c=shift;
|
my $c=shift;
|
||||||
my $r="-1";
|
my $r="-1";
|
||||||
|
$server_name = $c->config->{chat_srv};
|
||||||
if (connectT()) {
|
if (connectT()) {
|
||||||
$r = isOn() if ($c->param("command") =~/^isOn$/);
|
$r = isOn() if ($c->param("command") =~/^isOn$/);
|
||||||
$r = turnOn() if ($c->param("command") =~/^on$/);
|
$r = turnOn() if ($c->param("command") =~/^on$/);
|
||||||
@@ -37,7 +37,6 @@ sub candy{
|
|||||||
}
|
}
|
||||||
else {$r="connection error";};
|
else {$r="connection error";};
|
||||||
$c->render(json => {a=>$r});
|
$c->render(json => {a=>$r});
|
||||||
# $c->render(json => {a=>$server_name});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub turnOff{
|
sub turnOff{
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ d3.select("#clink").on("click",function(){
|
|||||||
var ciface ="/json/candy/";
|
var ciface ="/json/candy/";
|
||||||
d3.json(ciface+"isOn" ,function(d){
|
d3.json(ciface+"isOn" ,function(d){
|
||||||
if(d != undefined){
|
if(d != undefined){
|
||||||
if (d.a==1) { on(); }
|
if (d.a=="1") { on(); }
|
||||||
else if (d.a==0) { off(); }}
|
else if (d.a=="0") { off(); }
|
||||||
|
else if (d.a=="connection error") { cerror(); }}
|
||||||
else {console.error(ciface+"isOn");}
|
else {console.error(ciface+"isOn");}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -17,9 +18,10 @@ d3.select("#myonoffswitch")
|
|||||||
});
|
});
|
||||||
|
|
||||||
function on(){
|
function on(){
|
||||||
d3.select("#clink").style("visibility","visible");
|
d3.select("#clink").style("visibility","visible");
|
||||||
d3.json(ciface+"on",function(d){
|
d3.json(ciface+"on",function(d){
|
||||||
if (d.a==1){
|
if (d.a=="connection error"){ cerror();}
|
||||||
|
else if (d.a=="1"){
|
||||||
d3.select("#clink").style("visibility","visible");
|
d3.select("#clink").style("visibility","visible");
|
||||||
d3.select("#myonoffswitch").property("checked","checked"); }
|
d3.select("#myonoffswitch").property("checked","checked"); }
|
||||||
else {
|
else {
|
||||||
@@ -27,15 +29,21 @@ function on(){
|
|||||||
}}); }
|
}}); }
|
||||||
|
|
||||||
function off(){
|
function off(){
|
||||||
d3.select("#clink").style("visibility","hidden");
|
d3.select("#clink").style("visibility","hidden");
|
||||||
d3.json(ciface+"off",function(d){
|
d3.json(ciface+"off",function(d){
|
||||||
if (d.a==1){
|
if (d.a=="connection error"){ cerror();}
|
||||||
|
else if (d.a=="1"){
|
||||||
d3.select("#clink").style("visibility","hidden");
|
d3.select("#clink").style("visibility","hidden");
|
||||||
d3.select("#myonoffswitch").property("checked",""); }
|
d3.select("#myonoffswitch").property("checked",""); }
|
||||||
else {
|
else {
|
||||||
d3.select("#myonoffswitch").property("checked","checked");
|
d3.select("#myonoffswitch").property("checked","checked");
|
||||||
}}); }
|
}}); }
|
||||||
|
|
||||||
|
function cerror(){
|
||||||
|
console.error("prosody connection error");
|
||||||
|
d3.select("#clink").style("visibility","hidden");
|
||||||
|
d3.select("#myonoffswitch").property("checked","");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ checkChat();
|
|||||||
function checkChat(){
|
function checkChat(){
|
||||||
d3.json("/json/candy/isOn",function(d){
|
d3.json("/json/candy/isOn",function(d){
|
||||||
if(d != undefined){
|
if(d != undefined){
|
||||||
if (d.a==1) { d3.select("#clink").style("visibility","visible");}
|
if (d.a=="connection error"){
|
||||||
else if (d.a==0) { d3.select("#clink").style("visibility","hidden");}
|
d3.select("#clink").style("visibility","hidden");}
|
||||||
|
else if (d.a=="1") { d3.select("#clink").style("visibility","visible");}
|
||||||
|
else if (d.a=="0") { d3.select("#clink").style("visibility","hidden");}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
d3.select("#clink").style("visibility","hidden");
|
d3.select("#clink").style("visibility","hidden");
|
||||||
|
|||||||
@@ -31,4 +31,5 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
let radio_server="<%= $config->{radio_server} %>";
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user