Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

enable paging #32

Merged
merged 2 commits into from

1 participant

OCHIAI Hiromu
OCHIAI Hiromu
Owner

pagingできるようにしせり

OCHIAI Hiromu otiai10 merged commit 0770862 into from
OCHIAI Hiromu otiai10 referenced this pull request
Closed

enable paging #30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 2, 2013
  1. TODO flag

    authored
Commits on Apr 3, 2013
  1. enable paging : issue #30

    authored
This page is out of date. Refresh to see the latest.
15 fuel/app/classes/controller/stream.php
View
@@ -4,9 +4,13 @@ class Controller_Stream extends Controller_Template
{
public function action_index()
{
-
$limit = 20;
- $query = 'SELECT * FROM animes ORDER BY unlikes DESC, created_at, likes LIMIT 0, '.$limit;
+ $page = $this->param('page');
+ if(empty($page) || $page < 0){
+ $page = 1;
+ }
+ $offset = $page -1;
+ $query = 'SELECT * FROM animes ORDER BY unlikes DESC, created_at, likes LIMIT '.($limit*$offset).', '.$limit;
$list = DB::query($query)->execute()->as_array();
foreach($list as $k => $anime){
@@ -16,6 +20,7 @@ public function action_index()
$this->template->content = View::forge('stream/index');
$this->template->content->animes = $list;
+ $this->template->content->page = $page;
}
private function _getVideoFromYouTube($anime_title, $category='OP')
@@ -28,6 +33,12 @@ private function _getVideoFromYouTube($anime_title, $category='OP')
$res = $req->send();
$rows = json_decode($res->getBody(), true);
+ /**
+ * choose the best entry : see category term ?= Music or so
+ **/
+ //{{{
+ // TODO
+ //}}}
$info = (array)$rows['feed']['entry'][0];
$elms = explode('/',$info['id']['$t']);
2  fuel/app/config/routes.php
View
@@ -3,6 +3,6 @@
'_root_' => 'top/index', // The default route
'_404_' => 'top/404', // The main 404 route
- 'stream(/:page)?' => array('stream/index', 'page' => '1'),
+ 'stream(/:page)?' => 'stream/index',
'hello(/:name)?' => array('top/hello', 'name' => 'hello'),
);
7 fuel/app/views/stream/index.php
View
@@ -23,15 +23,16 @@
<a tabindex='1' id="cont-next" class="play-next btn btn-large">Next</a>
</div>
</div>
-<div class="row">
+<div class="row streaming-contents">
<div class="span8">
- <h2>page 1</h2>
+ <div class="pull-right"><a class="replace-loader" href="/stream/<?php echo $page + 1; ?>">next page</a></div>
+ <h2>playlist</h2>
<table class="table">
<?php for($i=0; $i<count($animes); $i++){
echo '<tr id="index_'.$i.'" class="animetr"><td>' . $animes[$i]['title'] .'</td>';
echo '<td><a tabindex="1" class="anime play-direct" seq="'.$i.'" hash="'.$animes[$i]['hash'].'" atitle="'.$animes[$i]['title'].'" aurl="' .$animes[$i]['url'].'">'.$animes[$i]['vtitle'] . '</a></td></tr>';
} ?>
- <tr><td colspan="2" style="text-align:center">&lt&lt PagingHere &gt&gt</td></tr>
+ <tr><td colspan="2" style="text-align:center">&lt&lt page<?echo $page; ?> &gt&gt</td></tr>
</table>
</div>
<div class="span4">
1  fuel/app/views/template.php
View
@@ -7,6 +7,7 @@
<?php echo Asset::css('bootstrap.css'); ?>
<?php echo Asset::css('common.css'); ?>
<?php echo Asset::js('swfobject.js'); ?>
+ <?php echo Asset::js('effect.js'); ?>
<?php echo Asset::js('player.js'); ?>
</head>
<body onload="init();">
1  fuel/app/views/top/index.php
View
@@ -6,6 +6,7 @@
<title>あにきゃっち.net</title>
<?php echo Asset::css('bootstrap.css'); ?>
<?php echo Asset::css('common.css'); ?>
+ <?php echo Asset::js('effect.js'); ?>
<?php echo Asset::js('top.js'); ?>
</head>
<body onload="init()">
4 public/assets/css/common.css
View
@@ -134,3 +134,7 @@ div.loader.middle {
border-radius: 30px;
}
}
+
+div.row.streaming-contents {
+ margin-top: 20px;
+}
BIN  public/assets/img/twitter-logo.png
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 public/assets/js/effect.js
View
@@ -0,0 +1,16 @@
+function registReplaceBtns(){
+ var replaceBtns = document.getElementsByClassName('replace-loader');
+ for(var i=0; i<replaceBtns.length; i++){
+ replaceBtns[i].addEventListener('click', function(){
+ replaceLoader(this);
+ });
+ }
+}
+
+function replaceLoader(dom){
+ dom.className = (' ' + dom.className + ' ')
+ .replace(' btn ','')
+ .replace(' btn-primary ','')
+ .replace(' btn-large ','');
+ dom.innerHTML = '<div class="loader middle"></div>Now Loading...';
+}
5 public/assets/js/player.js
View
@@ -19,10 +19,11 @@ function init(){
initPlaylist(__playlist);
initPlayer(__playlist[__index]['hash']);
displayInfo();
- registControleButtons();
+ registControleBtns();
+ registReplaceBtns();
}
-function registControleButtons(){
+function registControleBtns(){
var prevBtns = document.getElementsByClassName('play-prev');
for(var i=0; i<prevBtns.length; i++){
14 public/assets/js/top.js
View
@@ -7,18 +7,6 @@ function init(){
}
function registEffectiveBtns(){
- var replaceBtns = document.getElementsByClassName('replace-loader');
- for(var i=0; i<replaceBtns.length; i++){
- replaceBtns[i].addEventListener('click', function(){
- replaceLoader(this);
- });
- }
+ registReplaceBtns();
}
-function replaceLoader(dom){
- dom.className = (' ' + dom.className + ' ')
- .replace(' btn ','')
- .replace(' btn-primary ','')
- .replace(' btn-large ','');
- dom.innerHTML = '<div class="loader middle"></div>Now Loading...';
-}
Something went wrong with that request. Please try again.