Rev 2086 | Rev 2102 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 2086 | Rev 2096 | ||
|---|---|---|---|
| 1 | <?php |
1 | <?php |
| 2 | require_once("backend.php"); |
2 | require_once("backend.php"); |
| 3 | require_once("config.php"); |
3 | require_once("config.php"); |
| 4 | ?> |
4 | ?> |
| 5 | <!DOCTYPE HTML> |
5 | <!DOCTYPE HTML> |
| 6 | <html> |
6 | <html> |
| 7 | <head> |
7 | <head> |
| 8 | <meta charset="utf-8"> |
8 | <meta charset="utf-8"> |
| 9 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
9 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 10 | <title>Home Automation Control Center</title> |
10 | <title>Home Automation Control Center</title> |
| 11 | <link rel="stylesheet" href="jquery.mobile-1.1.1.min.css" /> |
11 | <link rel="stylesheet" href="jquery.mobile-1.1.1.min.css" /> |
| 12 | <script src="jquery-1.7.2.min.js"></script> |
12 | <script src="jquery-1.7.2.min.js"></script> |
| 13 | <script src="jquery.mobile-1.1.1.min.js"></script> |
13 | <script src="jquery.mobile-1.1.1.min.js"></script> |
| 14 | <script src="jquery.tmpl.min.js"></script> |
14 | <script src="jquery.tmpl.min.js"></script> |
| 15 | 15 | ||
| 16 | <style> |
16 | <style> |
| 17 | <?php |
17 | <?php |
| 18 | foreach ($pages as $page) |
18 | foreach ($pages as $page) |
| 19 | { |
19 | { |
| 20 | include("pages/" . $page . "/style.css"); |
20 | include("pages/" . $page . "/style.css"); |
| 21 | } |
21 | } |
| 22 | ?> |
22 | ?> |
| - | 23 | ||
| - | 24 | .ui-li-heading { |
|
| - | 25 | white-space: normal; |
|
| - | 26 | } |
|
| 23 | </style> |
27 | </style> |
| 24 | 28 | ||
| 25 | <?php |
29 | <?php |
| 26 | foreach ($pages as $page) |
30 | foreach ($pages as $page) |
| 27 | { |
31 | { |
| 28 | include("pages/" . $page . "/template.html"); |
32 | include("pages/" . $page . "/template.html"); |
| 29 | } |
33 | } |
| 30 | ?> |
34 | ?> |
| 31 | 35 | ||
| 32 | <script id="page-template" type="text/x-jquery-tmpl" data-enhance="false"> |
36 | <script id="page-template" type="text/x-jquery-tmpl" data-enhance="false"> |
| 33 | <div id="page-${name}" data-role="page" data-theme="a"> |
37 | <div id="page-${name}" data-role="page" data-theme="a"> |
| 34 | <div data-role="header"> |
38 | <div data-role="header"> |
| 35 | <a href="#" data-icon="home" data-rel="back" data-direction="reverse">Home</a> |
39 | <a href="#" data-icon="home" data-rel="back" data-direction="reverse">Home</a> |
| 36 | <h1>Home Automation Control Center - ${title}</h1> |
40 | <h1>Home Automation Control Center - ${title}</h1> |
| 37 | </div> |
41 | </div> |
| 38 | <div data-role="content"></div> |
42 | <div data-role="content"></div> |
| 39 | </div> |
43 | </div> |
| 40 | </script> |
44 | </script> |
| 41 | 45 | ||
| 42 | <script id="pagelink-template" type="text/x-jquery-tmpl" data-enhance="false"> |
46 | <script id="pagelink-template" type="text/x-jquery-tmpl" data-enhance="false"> |
| 43 | <span> |
47 | <span> |
| 44 | <a href="#" data-role="button">${title}</a> |
48 | <a href="#" data-role="button">${title}</a> |
| 45 | </span> |
49 | </span> |
| 46 | </script> |
50 | </script> |
| 47 | 51 | ||
| 48 | <script> |
52 | <script> |
| 49 | $.mobile.ignoreContentEnabled = true; |
53 | $.mobile.ignoreContentEnabled = true; |
| - | 54 | $.mobile.transitionFallbacks.pop = "none" |
|
| - | 55 | $.mobile.transitionFallbacks.flip = "none" |
|
| - | 56 | $.mobile.transitionFallbacks.turn = "none" |
|
| - | 57 | $.mobile.transitionFallbacks.flow = "none" |
|
| - | 58 | $.mobile.transitionFallbacks.slidefade = "none" |
|
| - | 59 | $.mobile.transitionFallbacks.slide = "none" |
|
| - | 60 | $.mobile.transitionFallbacks.slideup = "none" |
|
| - | 61 | $.mobile.transitionFallbacks.slidedown = "none" |
|
| - | 62 | $.mobile.defaultPageTransition = "none" |
|
| 50 | 63 | ||
| 51 | function sendCommand(command, callback) |
64 | function sendCommand(command, callback) |
| 52 | { |
65 | { |
| 53 | jQuery.getJSON("backend.php?ajax", { command: command }, callback); |
66 | jQuery.getJSON("backend.php?ajax", { command: command }, callback); |
| 54 | } |
67 | } |
| 55 | </script> |
68 | </script> |
| 56 | 69 | ||
| 57 | <script> |
70 | <script> |
| 58 | var pages = {}; |
71 | var pages = {}; |
| 59 | 72 | ||
| 60 | <?php |
73 | <?php |
| 61 | foreach ($pages as $page) |
74 | foreach ($pages as $page) |
| 62 | { |
75 | { |
| 63 | include("pages/" . $page . "/script.js"); |
76 | include("pages/" . $page . "/script.js"); |
| 64 | } |
77 | } |
| 65 | ?> |
78 | ?> |
| 66 | </script> |
79 | </script> |
| 67 | 80 | ||
| 68 | <script> |
81 | <script> |
| 69 | 82 | ||
| 70 | var aliasNames = <?php echo json_encode($aliasNames); ?>; |
83 | var aliasNames = <?php echo json_encode($aliasNames); ?>; |
| 71 | var pageConfigurations = <?php echo json_encode($pageConfiguration); ?>; |
84 | var pageConfigurations = <?php echo json_encode($pageConfiguration); ?>; |
| 72 | var pageInstances = {}; |
85 | var pageInstances = {}; |
| 73 | 86 | ||
| 74 | $(document).ready(function(event) |
87 | $(document).ready(function(event) |
| 75 | { |
88 | { |
| 76 | jQuery.each(pageConfigurations, function(n, configuration) |
89 | jQuery.each(pageConfigurations, function(n, configuration) |
| 77 | { |
90 | { |
| 78 | var pageName = configuration.page + "_" + n; |
91 | var pageName = configuration.page + "_" + n; |
| 79 | 92 | ||
| 80 | pageInstances[pageName] = configuration; |
93 | pageInstances[pageName] = configuration; |
| 81 | 94 | ||
| 82 | pageInstances[pageName].name = pageName; |
95 | pageInstances[pageName].name = pageName; |
| 83 | 96 | ||
| 84 | pageInstances[pageName].pageElement = $("#page-template").tmpl(pageInstances[pageName]).appendTo($("body")).page(); |
97 | pageInstances[pageName].pageElement = $("#page-template").tmpl(pageInstances[pageName]).appendTo($("body")).page(); |
| 85 | pageInstances[pageName].pageContentElement = pageInstances[pageName].pageElement.find(":jqmData(role=content)"); |
98 | pageInstances[pageName].pageContentElement = pageInstances[pageName].pageElement.find(":jqmData(role=content)"); |
| 86 | 99 | ||
| 87 | pageInstances[pageName].pageElement.find(":jqmData(rel=back)").on("click", function(event) |
100 | pageInstances[pageName].pageElement.find(":jqmData(rel=back)").on("click", function(event) |
| 88 | { |
101 | { |
| 89 | $.mobile.changePage($("#home"), "slide"); |
102 | $.mobile.changePage($("#home"), "slide", true); |
| 90 | event.preventDefault(); |
103 | event.preventDefault(); |
| 91 | }); |
104 | }); |
| 92 | 105 | ||
| 93 | pageInstances[pageName].pageLinkElement = $("#pagelink-template").tmpl(pageInstances[pageName]).appendTo($("#home").find(":jqmData(role=content)")).trigger("create").on("click", function(event) |
106 | pageInstances[pageName].pageLinkElement = $("#pagelink-template").tmpl(pageInstances[pageName]).appendTo($("#home").find(":jqmData(role=content)")).trigger("create").on("click", function(event) |
| 94 | { |
107 | { |
| 95 | $.mobile.changePage(pageInstances[pageName].pageElement, "slide"); |
108 | $.mobile.changePage(pageInstances[pageName].pageElement, "slide"); |
| 96 | event.preventDefault(); |
109 | event.preventDefault(); |
| 97 | }); |
110 | }); |
| 98 | 111 | ||
| 99 | 112 | ||
| 100 | if (pages[configuration.page] && pages[configuration.page].init) |
113 | if (pages[configuration.page] && pages[configuration.page].init) |
| 101 | { |
114 | { |
| 102 | pages[configuration.page].init(pageInstances[pageName]); |
115 | pages[configuration.page].init(pageInstances[pageName]); |
| 103 | } |
116 | } |
| 104 | }); |
117 | }); |
| 105 | 118 | ||
| 106 | $(".ui-page").on("swipeleft", function() |
119 | $(".ui-page").on("swipeleft", function() |
| 107 | { |
120 | { |
| 108 | var nextpage = $(this).nextAll(":jqmData(role=page)"); |
121 | var nextpage = $(this).nextAll(":jqmData(role=page)"); |
| 109 | 122 | ||
| 110 | if (nextpage.length > 0) |
123 | if (nextpage.length > 0) |
| 111 | { |
124 | { |
| 112 | $.mobile.changePage($(nextpage[0]), "slide"); |
125 | $.mobile.changePage($(nextpage[0]), "slide"); |
| 113 | } |
126 | } |
| 114 | }); |
127 | }); |
| 115 | 128 | ||
| 116 | $(".ui-page").on("swiperight", function() |
129 | $(".ui-page").on("swiperight", function() |
| 117 | { |
130 | { |
| 118 | var prevpage = $(this).prevAll(":jqmData(role=page)"); |
131 | var prevpage = $(this).prevAll(":jqmData(role=page)"); |
| 119 | 132 | ||
| 120 | if (prevpage.length > 0) |
133 | if (prevpage.length > 0) |
| 121 | { |
134 | { |
| 122 | $.mobile.changePage($(prevpage[0]), "slide", true); |
135 | $.mobile.changePage($(prevpage[0]), "slide", true); |
| 123 | } |
136 | } |
| 124 | }); |
137 | }); |
| 125 | }); |
138 | }); |
| 126 | 139 | ||
| 127 | </script> |
140 | </script> |
| 128 | </head> |
141 | </head> |
| 129 | 142 | ||
| 130 | <body> |
143 | <body> |
| 131 | <div id="home" data-role="page" data-theme="a"> |
144 | <div id="home" data-role="page" data-theme="a"> |
| 132 | <div data-role="header"><h1>Home Automation Control Center</h1></div> |
145 | <div data-role="header"><h1>Home Automation Control Center</h1></div> |
| 133 | <div data-role="content"></div> |
146 | <div data-role="content"></div> |
| 134 | </div> |
147 | </div> |
| 135 | </body> |
148 | </body> |
| 136 | </html> |
149 | </html> |
| 137 | 150 | ||