use DBD::SQLite;
use Data::Dumper;
use YAML::XS;
+use URI::Escape;
#use KCatch;
}
$confdata = YAML::XS::LoadFile($confpath);
-$mode = "";
-$mode = decode( 'utf-8', $cgi->param('mode') );
-$pdfpath = decode( 'utf-8', $cgi->param('pdfpath') );
-$pagenum = int( $cgi->param('pagenum') );
-$bpage = $pagenum - 1;
-$npage = $pagenum + 1;
+$mode = decode( 'utf-8', $cgi->param('mode') );
+$pagenum = int( $cgi->param('pagenum') );
+$title_row = $cgi->param('title');
+$title_row = uri_unescape($title_row);
+$title_group = decode( 'utf-8', $title_row );
+$title_uri = uri_escape($title_row);
$height = $cgi->param("height");
$width = $cgi->param("width");
-$jpeglink =
-"jpegserver.pl?pdfpath=\"$pdfpath\"&pagenum=$pagenum&mode=$mode&height=$height&width=$width";
-$blink =
- "htmlserver.pl?pdfpath=$pdfpath&mode=$mode&width=$width&height=$height";
-$nlink = $blink . "&pagenum=" . $npage;
-$blink = $blink . "&pagenum=" . $bpage;
-
$dbpath = $confdata->{dburl};
+
$dbi =
DBI->connect( "dbi:SQLite:dbname=$dbpath", "", "",
{ RaiseError => 1, AutoCommit => 1 } );
$multi_maxpage = 0;
-$multi_nowpage = 0;
-$sql = "SELECT id,page,title,startpage,part FROM pdffile WHERE id='$pdfpath'";
+
+$sql =
+"SELECT id,title,part,startpage,endpage FROM pdffile WHERE title = '$title_group' ORDER BY part DESC LIMIT 1";
$dbs = $dbi->prepare($sql);
$dbs->execute();
-$dbh1 = $dbs->fetchrow_hashref;
-$title_group = $dbh1->{'title'};
-$part_now = $dbh1->{'part'};
+$dbh = $dbs->fetchrow_hashref;
+$multi_maxpage = $dbh->{'endpage'};
+
$sql2 =
-"SELECT id,title,part,startpage,endpage FROM pdffile WHERE title = '$title_group' ORDER BY part DESC LIMIT 1";
+"SELECT id,startpage FROM pdffile WHERE title = '$title_group' AND startpage < $pagenum AND endpage > $pagenum";
$dbs2 = $dbi->prepare($sql2);
$dbs2->execute();
-$dbh2 = $dbs2->fetchrow_hashref;
-$multi_nowpage = $dbh1->{'startpage'} + $pagenum;
-$multi_maxpage = $dbh2->{'endpage'};
+$dbh2 = $dbs2->fetchrow_hashref;
+$single_pagenum = $pagenum - $dbh2->{'startpage'};
+$pdfpath = $dbh2->{'id'};
+
+$bpage = $pagenum - 1;
+$blink =
+"htmlserver.pl?title=$title_uri&mode=$mode&width=$width&height=$height&pagenum=$bpage";
+$npage = $pagenum + 1;
+$nlink =
+"htmlserver.pl?title=$title_uri&mode=$mode&width=$width&height=$height&pagenum=$npage";
-if ( ( $pagenum == 1 ) && ( $part_now > 1 ) ) {
- $part_b = $part_now - 1;
- $sqlb =
-"SELECT id,page FROM pdffile WHERE title = '$title_group' AND part ='$part_b'";
- $dbs3 = $dbi->prepare($sqlb);
- $dbs3->execute();
- $dbh3 = $dbs3->fetchrow_hashref;
- $bpage = $dbh3->{'page'};
- $blink =
- "htmlserver.pl?pdfpath="
- . $dbh3->{'id'}
- . "&mode=$mode&width=$width&height=$height&pagenum=$bpage";
-}
-if ( $pagenum == $dbh1->{'page'} ) {
- $part_n = $part_now + 1;
- $sqln =
-"SELECT id,page FROM pdffile WHERE title = '$title_group' AND part ='$part_n'";
- $dbs4 = $dbi->prepare($sqln);
- $dbs4->execute();
- $dbh4 = $dbs4->fetchrow_hashref;
- $npage = 1;
- $nlink =
- "htmlserver.pl?pdfpath="
- . $dbh4->{'id'}
- . "&mode=$mode&width=$width&height=$height&pagenum=$npage";
-}
$dbi->disconnect;
$height = $cgi->param("height");
$width = $cgi->param("width");
$jpeglink =
-"jpegserver.pl?pdfpath=\"$pdfpath\"&pagenum=$pagenum&mode=$mode&height=$height&width=$width";
+"jpegserver.pl?pdfpath=\"$pdfpath\"&pagenum=$single_pagenum&mode=$mode&height=$height&width=$width";
print $cgi->header( -charset => 'utf-8' );
print "<!DOCTYPE html>
<html lang='ja'>
<head>
<meta charset='utf-8'>
- <meta name='viewport' content='width=device-width, initial-scale=1'>
+ <meta name='viewport' content='width=device-width'>
<link rel='stylesheet' href='http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css' />
<script src='http://code.jquery.com/jquery-1.9.1.min.js'></script>
<script src='http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js'></script>
//console.log(e.keycode);
if(e.keyCode == 13){
\$.mobile.changePage(\"pdfsearch.pl?mode=$mode&width=$width&height=$height&search_text=\\\"\" + \$('#search-text').val() + \"\\\"\",{transition:'slide'});
+ \$.mobile.metaViewportContent = 'width-device-width,user-scalable=yes';
}
});
});
print "
<div id='page' data-role='page'>
<div data-role='header' data-position='fixed'>
- <h3>$multi_nowpage / $multi_maxpage</h3>
- <a href='$blink' data-role='button' data-icon='arrow-l' data-iconpos='left' class='ui-btn-left'>前へ</a>
- <a href='$nlink' data-role='button' data-icon='arrow-r' data-iconpos='right' class='ui-btn-right'>次へ</a>
+ <h3>$pagenum / $multi_maxpage</h3>
+ <div data-type='horizontal' data-role='controlgroup' class='ui-btn-left'>
+ <a href='$blink' data-role='button' data-icon='arrow-l' data-iconpos='left'>前へ</a>
+ <a href='pdfsearch.pl' data-role='button' data-icon='home' data-iconpos='left' >トップ</a>
+ </div>
+ <div data-type='horizontal' data-role='controlgroup' class='ui-btn-right'>
+ <a href='pdfsearch.pl' data-role='button' data-icon='forward' data-iconpos='left' >移動</a>
+ <a href='$nlink' data-role='button' data-icon='arrow-r' data-iconpos='right'>次へ</a>
+ </div>
+
</div>
";
print "