Skip to content
Browse files

branch update

  • Loading branch information...
1 parent ca3ae8c commit c1256cba8a1f8e7a4c09b16698bad54a4f6aac9c @vansteki committed
Showing with 90 additions and 23 deletions.
  1. +90 −23 index.php
View
113 index.php
@@ -14,6 +14,10 @@
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript' src='http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.0/js/bootstrap.min.js'></script>
<script type='text/javascript' src='lib/masonry.js'></script>
+<script type="text/javascript" src="https://www.google.com/jsapi"></script>
+<script type="text/javascript">
+
+</script>
<style type="text/css">
@@ -33,66 +37,85 @@
h5{
color: green;
}
-
</style>
</head>
<body>
+
+<?php
+$nav_bar = <<<HERE
+
+<div id='nav_bar' class="navbar navbar-inverse">
+ <div class="navbar-inner">
+<!-- <a class="brand" href="#">BeautyGrid</a> -->
+ <ul class="nav">
+ <a data-toggle="modal" href="#myModal" class="btn" href="#"><i class="icon-th-large"></i></a>
+ <a id='remove_bar' class="btn" href="#"><i class="icon-remove"></i></a>
+ </ul>
+ </div>
+</div>
+
+HERE;
+?>
+
<a id='github-badge' href="https://github.com/vansteki/BeautyGrid"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png" alt="Fork me on GitHub"></a>
<a id='cc-badge' rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/tw/deed.zh_TW"><img alt="創用 CC 授權條款" style="position: absolute; bottom: 50px; right: 0; border: 0; border-width:0;" src="http://i.creativecommons.org/l/by-nc-sa/3.0/tw/88x31.png" /></a>
<?php
- if($user_id) {
+ if($user_id) {
+ echo $nav_bar;
echo "<script>$('#github-badge').hide(); $('#cc-badge').hide(); </script>";
-
+ echo "<script>$('#remove_bar').click(function(){ $('#nav_bar').hide(); }); </script>";
try {
$fql = "SELECT uid, first_name, name,pic, pic_square, profile_url, friend_count FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me() ) and sex= 'female' ";
+ $fql2 = "SELECT uid, first_name, name,pic, pic_square, profile_url, friend_count FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me() ) and sex= 'male' ";
+
$ret_obj = $facebook->api(array(
- 'method' => 'fql.query',
- 'query' => $fql,
+ 'method' => 'fql.query',
+ 'query' => $fql
+ ));
+
+ $ret_obj2 = $facebook->api(array(
+ 'method' => 'fql.query',
+ 'query' => $fql2,
));
- // var_export($ret_obj);
+
+ $female_count = count($ret_obj);
+ $male_count = count($ret_obj2);
echo "<div id='container'>";
- foreach($ret_obj as $key => $val){
- echo "<a class='box' href=https://www.facebook.com/".$val['uid'].">"."<img src=".$val['pic']." class='img-polaroid'/>"."</a>";
- }
+ foreach($ret_obj as $key => $val){
+ echo "<a class='box' href=https://www.facebook.com/".$val['uid'].">"."<img src=".$val['pic']." class='img-polaroid'/>"."</a>";
+ }
echo "</div>";
$user_profile = $facebook->api('/me','GET');
echo "<br><a> Name: " . $user_profile['name']."</a>";
echo "<br><a href='logout.php'>logout</a></li> ";
- } catch(FacebookApiException $e) {
- // If the user is logged out, you can have a
- // user ID even though the access token is invalid.
- // In this case, we'll get an exception, so we'll
- // just ask the user to login again here.
-
+ } catch(FacebookApiException $e) {
+
echo "<center><h1>BeautyGrid</h1><h5>branch: dev</h5></center>";
- $login_url = $facebook->getLoginUrl( array(
+ $login_url = $facebook->getLoginUrl( array(
array('scope' => 'user_status,publish_stream,user_photos','photo_upload','user_relationships')
));
echo '<br><center><a>For Beauty!.</a><a href="' . $login_url . '"><br><img src=assets/img/fb_login_btn.png></a></center>';
+
// error_log($e->getType());
// error_log($e->getMessage());
echo "<hr>$e<hr>";
}
} else {
- // No user, print a link for the user to login
- // To post to a user's wall, we need publish_stream permission
- // We'll use the current URL as the redirect_uri, so we don't
- // need to specify it here.
echo "<center><h1>BeautyGrid</h1><h5>branch: dev</h5></center>";
- $login_url = $facebook->getLoginUrl(
+ $login_url = $facebook->getLoginUrl(
array('scope' => 'user_status,publish_stream,user_photos','photo_upload','user_relationships')
- );
- echo '<br><center><a>For Beauty!</a><a href="' . $login_url . '"><br><img src=assets/img/fb_login_btn.png></a></center>';
+ );
+ echo '<br><center><a>For Beauty!</a><a href="' . $login_url . '"><br><img src=assets/img/fb_login_btn.png></a></center>';
}
?>
@@ -109,7 +132,51 @@
});
</script>
+<script type="text/javascript">
+
+ // Load the Visualization API library and the piechart library.
+ google.load('visualization', '1.0', {'packages':['corechart']});
+ google.setOnLoadCallback(drawChart);
+ // ... draw the chart...
+ function drawChart() {
+ // Create the data table.
+ var data = new google.visualization.DataTable();
+ data.addColumn('string', 'Topping');
+ data.addColumn('number', 'Slices');
+ data.addRows([
+ ["<?php echo '女生 '.$female_count. ''; ?>", <?php echo $female_count; ?>],
+ ["<?php echo '男生 '.$male_count. ''; ?>", <?php echo $male_count; ?>]
+ ]);
+
+ // Set chart options
+ var options = {'title':'同異性朋友比例',
+ 'width':400,
+ 'height':300};
+
+ // Instantiate and draw our chart, passing in some options.
+ var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
+ chart.draw(data, options);
+ }
+
+</script>
+<!-- MODAL -->
+<div id="myModal" class="modal hide fade in" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false" style="display: none; ">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
+ <h3 id="myModalLabel">Evil Dash~board~</h3>
+ </div>
+ <div class="modal-body">
+
+ <!-- MODAL CONTENT -->
+ <div id='chart_div'></div>
+ <!-- MODAL CONTENT END -->
+ </div>
+ <div class="modal-footer">
+ <button class="btn" data-dismiss="modal">Close</button>
+ </div>
+ </div>​
+<!-- MODAL END -->
</body>
</html>

0 comments on commit c1256cb

Please sign in to comment.
Something went wrong with that request. Please try again.