1 | <!DOCTYPE html> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <title> graph show </title> |
---|
5 | <meta charset="UTF-8"> |
---|
6 | <link type="text/css" href="css/start/jquery-ui-1.8.16.custom.css" rel="stylesheet" /> |
---|
7 | <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script> |
---|
8 | <script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script> |
---|
9 | <style> |
---|
10 | #demo-frame > div.demo { padding: 10px !important; }; |
---|
11 | </style> |
---|
12 | <script> |
---|
13 | |
---|
14 | $(function() { |
---|
15 | $( "#radio" ).buttonset(); |
---|
16 | }); |
---|
17 | |
---|
18 | $(function() { |
---|
19 | $( "input:submit, a, button", ".demo" ).button(); |
---|
20 | $( "a", ".demo" ).click(function() { return false; }); |
---|
21 | }); |
---|
22 | $(function() { |
---|
23 | var select = $( "#minbeds" ); |
---|
24 | var slider = $( "<div id='slider'></div>" ).insertAfter( select ).slider({ |
---|
25 | min: 1, |
---|
26 | max: 6, |
---|
27 | range: "min", |
---|
28 | value: select[ 0 ].selectedIndex + 1, |
---|
29 | slide: function( event, ui ) { |
---|
30 | select[ 0 ].selectedIndex = ui.value - 1; |
---|
31 | } |
---|
32 | }); |
---|
33 | $( "#minbeds" ).change(function() { |
---|
34 | slider.slider( "value", this.selectedIndex + 1 ); |
---|
35 | }); |
---|
36 | }); |
---|
37 | </script> |
---|
38 | </head> |
---|
39 | |
---|
40 | <body> |
---|
41 | |
---|
42 | <div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0pt 0.7em;"> |
---|
43 | <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: 0.3em;"></span> |
---|
44 | Pickup a Date </p> |
---|
45 | </div> |
---|
46 | |
---|
47 | |
---|
48 | |
---|
49 | <?php |
---|
50 | |
---|
51 | $key_space = 'png'; |
---|
52 | $column_family = 'png'; |
---|
53 | $column_family_date = 'date'; |
---|
54 | |
---|
55 | $style=""; |
---|
56 | $date=""; |
---|
57 | $hour=""; |
---|
58 | $mon_act=""; |
---|
59 | if(isset($_GET['style'])){ |
---|
60 | $style = trim($_GET['style']); |
---|
61 | // echo $style; |
---|
62 | } |
---|
63 | if(isset($_GET['date'])){ |
---|
64 | $date = intval($_GET['date']); |
---|
65 | // echo $date; |
---|
66 | } |
---|
67 | if(isset($_GET['hour'])){ |
---|
68 | $hour = $_GET['hour']; |
---|
69 | // echo $hour; |
---|
70 | } |
---|
71 | if(isset($_GET['mon_act'])){ |
---|
72 | $mon_act = $_GET['mon_act']; |
---|
73 | // echo $hour; |
---|
74 | } |
---|
75 | |
---|
76 | require_once 'Cassandra.php'; |
---|
77 | // list of seed servers to randomly connect to |
---|
78 | // all the parameters are optional and default to given values |
---|
79 | $servers = array( |
---|
80 | array( |
---|
81 | 'host' => '127.0.0.1', |
---|
82 | 'port' => 9160, |
---|
83 | 'use-framed-transport' => true, |
---|
84 | 'send-timeout-ms' => 1000, |
---|
85 | 'receive-timeout-ms' => 1000 |
---|
86 | ) |
---|
87 | ); |
---|
88 | $cassandra = Cassandra::createInstance($servers); |
---|
89 | $cassandra->useKeyspace($key_space); |
---|
90 | $cassandra->setMaxCallRetries(5); |
---|
91 | |
---|
92 | |
---|
93 | $target = $cassandra->cf($column_family_date)->getKeyRange(); |
---|
94 | $arr = $target->getAll(); |
---|
95 | // echo print_r($arr, true); // show all |
---|
96 | |
---|
97 | echo "<div id=\"accordion\">"; |
---|
98 | |
---|
99 | $name_arr = array(); |
---|
100 | foreach($arr as $k => $v){ |
---|
101 | //echo "<a href=png_show.php?date=$k>".$k."</a> "; |
---|
102 | $name_arr[] += $k; |
---|
103 | // sort key by month |
---|
104 | }// foreach the date show |
---|
105 | |
---|
106 | sort($name_arr); |
---|
107 | $pre_month = "00"; |
---|
108 | $mon_count = 0; |
---|
109 | $break_line = false; |
---|
110 | foreach ($name_arr as $k){ |
---|
111 | $this_month = substr($k, 4, 2); |
---|
112 | $this_date = substr($k, 6,2); |
---|
113 | if($pre_month != $this_month ) { |
---|
114 | $break_line = true; |
---|
115 | |
---|
116 | if ($pre_month == "00") echo "<h3><a href=\"#\"> $this_month Month </a></h3><div>"; |
---|
117 | else { |
---|
118 | echo " </p></div><h3><a href=\"#\"> $this_month Month </a></h3><div>"; |
---|
119 | $mon_count ++; |
---|
120 | } |
---|
121 | |
---|
122 | $pre_month = $this_month; // determine change month or not |
---|
123 | }else{ |
---|
124 | $break_line = false; |
---|
125 | } |
---|
126 | |
---|
127 | ?> |
---|
128 | |
---|
129 | |
---|
130 | <button id="button<?echo $k?>"><?echo $this_date?></button> |
---|
131 | <script> |
---|
132 | $("#button<?echo $k?>").click(function () { |
---|
133 | <!-- 傳送到 png_show.php?date=<?echo $k?>"); --> |
---|
134 | $(window.location).attr('href', "./png_show.php?date=<?echo $k?>&mon_act=<?echo $mon_count?>"); |
---|
135 | }); |
---|
136 | </script> |
---|
137 | |
---|
138 | <? |
---|
139 | }// foreach $name_arr |
---|
140 | |
---|
141 | echo "</div></div> ";// div pdiv , accordion |
---|
142 | |
---|
143 | if ( $date != null ){ |
---|
144 | |
---|
145 | |
---|
146 | ?> |
---|
147 | <div class="ui-state-error ui-corner-all" style="padding: 0pt 0.7em;"> |
---|
148 | <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: 0.3em;"></span> |
---|
149 | <strong>Date = <?echo $date;?> </strong> |
---|
150 | |
---|
151 | <button id="clear">Clear</button> |
---|
152 | <script> |
---|
153 | $("#clear").click(function () { |
---|
154 | <!-- 傳送到 png_show.php?date=<?echo $k?>"); --> |
---|
155 | $(window.location).attr('href', "./png_show.php"); |
---|
156 | }); |
---|
157 | </script> |
---|
158 | </p> |
---|
159 | </div> |
---|
160 | |
---|
161 | <div class="ui-state-highlight ui-corner-all" style="margin-top: 5px; padding: 0pt 0.7em;"> |
---|
162 | <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: 0.3em;"></span> |
---|
163 | ! Choose clock </p> |
---|
164 | </div> |
---|
165 | <? |
---|
166 | $target = $cassandra->cf($column_family_date)->get($date); |
---|
167 | if ($target == null){ |
---|
168 | echo "no this date <br>"; |
---|
169 | header( 'Location: png_show.php' ); |
---|
170 | |
---|
171 | }else{ |
---|
172 | // echo 'value: <pre>'.print_r($target,true).'</pre><hr/>'; |
---|
173 | |
---|
174 | // the web |
---|
175 | echo "<form><div id=\"radio\">"; |
---|
176 | |
---|
177 | foreach($target as $k => $v){ |
---|
178 | if ($v == "1"){ |
---|
179 | ?> |
---|
180 | |
---|
181 | <input type="radio" id="radio<?echo $k?>" name="radio" /><label for="radio<?echo $k?>"><?echo $k?></label> |
---|
182 | <script> |
---|
183 | $("#radio<?echo $k?>").click(function () { |
---|
184 | $("#graph").html("<img src=\"png_out.php?date=<?echo $date?>&hour=<?echo $k?>\" />"); |
---|
185 | }); |
---|
186 | </script> |
---|
187 | |
---|
188 | <? |
---|
189 | }//if |
---|
190 | }// foreach |
---|
191 | ?> |
---|
192 | </div><!-- End radio --> |
---|
193 | </form><!-- End demo --> |
---|
194 | <? |
---|
195 | } |
---|
196 | }//if date not null |
---|
197 | ?> |
---|
198 | |
---|
199 | <div id="graph"></div> |
---|
200 | <p></p> |
---|
201 | |
---|
202 | <script> |
---|
203 | // init |
---|
204 | $('#accordion').accordion( |
---|
205 | { |
---|
206 | autoHeight: false, |
---|
207 | navigation: true |
---|
208 | } |
---|
209 | ); |
---|
210 | |
---|
211 | </script> |
---|
212 | |
---|
213 | <? |
---|
214 | if ($mon_act != "" ) echo "<script> $( '#accordion' ).accordion( 'option', 'active', $mon_act );</script>"; |
---|
215 | ?> |
---|
216 | </body> |
---|
217 | </html> |
---|