Subversion Repositories HomeAutomation

Rev

Rev 2057 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 2057 Rev 2058
Line 1... Line 1...
1
<?php
1
<?php
2
$aliasesDimmer = array("bardisk_tv", "TakSovrum");
2
$aliasesDimmer = array("bardisk_tv", "TakSovrum");
3
$aliasesOther = array("Power", "PowerBRF");
3
$aliasesOther = array("Power", "PowerBRF", "PID");
4
 
4
 
5
require 'atom_interface.php';
5
require 'atom_interface.php';
6
require 'getSetData.php';
6
require 'getSetData.php';
7
 
7
 
8
$response = array();
8
$response = array();
Line 17... Line 17...
17
  SetDimmerValue($_GET["alias"], $_GET["strength"]);
17
  SetDimmerValue($_GET["alias"], $_GET["strength"]);
18
 
18
 
19
  echo json_encode($response);
19
  echo json_encode($response);
20
  exit(0);
20
  exit(0);
21
}
21
}
22
else if (isset($_GET["getvalue"]))
-
 
23
{
-
 
24
  foreach ($_GET["alias"] as $alias)
-
 
25
  {
-
 
26
    $response[$alias] = GetLastValue($alias);
-
 
27
  }
-
 
28
 
-
 
29
  echo json_encode($response);
-
 
30
  exit(0);
-
 
31
}
-
 
32
else if (isset($_GET["getdata"]))
22
else if (isset($_GET["getdata"]))
33
{
23
{
34
  foreach ($_GET["alias"] as $alias)
24
  foreach ($_GET["alias"] as $alias)
35
  {
25
  {
36
    $responseData = GetLastData($alias);
26
    $responseData = GetLastData($alias);
37
 
27
 
38
    foreach ($responseData as $name => $value)
28
    foreach ($responseData as $name => $value)
39
    {
29
    {
40
      $response[$name] = $value;
30
      $response[$name] = $value;
41
    }
31
    }
42
  }
32
  }
43
 
33
 
44
  echo json_encode($response);
34
  echo json_encode($response);
45
  exit(0);
35
  exit(0);
46
}
36
}
47
?>
37
?>
48
 
38
 
Line 62... Line 52...
62
//  <script src="jquery.mobile-1.0b1.min.js"></script> 
52
//  <script src="jquery.mobile-1.0b1.min.js"></script> 
63
?>
53
?>
64
  <script>
54
  <script>
65
 
55
 
66
    $(document).bind("pagecreate", function(event, ui)
56
    $(document).bind("pagecreate", function(event, ui)
67
    {
57
    {
68
      <?php
58
      <?php
69
      foreach ($aliasesDimmer as $alias)
59
      foreach ($aliasesDimmer as $alias)
70
      {
60
      {
71
      ?>
61
      ?>
72
        $('#slider<?php  echo $alias?>' ).bind('change', function(event, ui){ makeAjaxChange("<?php  echo $alias?>"); });
62
        $('#slider<?php  echo $alias?>' ).bind('change', function(event, ui){ makeAjaxChange("<?php  echo $alias?>"); });
Line 92... Line 82...
92
    var timer = null;
82
    var timer = null;
93
 
83
 
94
    function checkCurrentValue()
84
    function checkCurrentValue()
95
    {
85
    {
96
      updating_current = true;
86
      updating_current = true;
97
      jQuery.getJSON("?getvalue=1", "<? echo "alias[]=" . implode("&alias[]=", $aliasesDimmer)?>", function(data)
87
      jQuery.getJSON("?getdata=1", "<? echo "alias[]=" . implode("&alias[]=", $aliasesDimmer)?>", function(data)
98
      {
88
      {
99
       
89
       
100
       
90
       
101
        jQuery.each(data, function(alias, value)
91
        jQuery.each(data, function(alias, value)
102
        {
92
        {
103
          current_value[alias] = value;
93
          current_value[alias] = value.Level.value;
104
          $('#slider' + alias).val(value).slider("refresh");
94
          $('#slider' + alias).val(value.Level.value).slider("refresh");
105
        });
95
        });
106
       
96
       
107
        updating_current = false;
97
        updating_current = false;
108
      });
98
      });
109
      jQuery.getJSON("?getdata=1", "<? echo "alias[]=" . implode("&alias[]=", $aliasesOther)?>", function(data)
99
      jQuery.getJSON("?getdata=1", "<? echo "alias[]=" . implode("&alias[]=", $aliasesOther)?>", function(data)
110
      {
100
      {
111
      var element = $("#current-information");
101
      var element = $("#current-information");
112
 
102
 
113
      element.empty();
103
      element.empty();
114
 
104
 
115
      var text = "";
105
      var text = "";
116
 
106
 
117
      jQuery.each(data, function(alias, aliasData)
107
      jQuery.each(data, function(alias, aliasData)
118
      {
108
      {
119
        text += "<b>" + alias + "</b><br/>";
109
        text += "<b>" + alias + "</b><br/>";
120
 
110
 
121
        jQuery.each(aliasData, function(name, value)
111
        jQuery.each(aliasData, function(name, value)
122
        {
112
        {
-
 
113
          if (typeof value.value == "string")
-
 
114
          {
123
          text += name + "=" + value.value + "<br/>";
115
        text += name + "=" + value.value + "<br/>";
-
 
116
          }
-
 
117
          else
-
 
118
          {
-
 
119
        text += name + "<br/>";
-
 
120
        jQuery.each(value.value, function(name2, value2)
-
 
121
        {
-
 
122
          text += "&nbsp;&nbsp;" + name2 + "=" + value2 + "<br/>";
-
 
123
        });
-
 
124
          }
124
        });
125
        });
125
 
126
 
126
        text += "<br/>";
127
        text += "<br/>";
127
      });
128
      });
128
 
129