make number of pictures/page a config option; replace "offset" with "page"
[photo-tags.git] / index.php
1 <?php
2 /* parse ini -file */
3 $iniarray=parse_ini_file("config.ini");
4 $webbase=$iniarray["webbase"];
5 $dbprefix=$iniarray["dbprefix"];
6 $admin=$iniarray["admin"];
7 $title=$iniarray["title"];
8 $N=$iniarray["pics_per_page"];
9 /* end parse ini-file */
10 ?>
11 <html>
12 <title><?php echo htmlspecialchars($title) ?></title>
13 <script src="d3.min.js"></script>
14 <link rel="stylesheet" type="text/css" href="normalize.css" />
15 <link rel="stylesheet" type="text/css" href="style.css" />
16
17 <body>
18
19 <div class="debug">test</div>
20 <h1><?php echo htmlspecialchars($title) ?></h1>
21
22 <button class="prev" disabled="disabled" onclick="left()"> prev </button>
23 <button class="next"   onclick="right()">next </button>
24
25 <div class="pics"> </div>
26
27 <footer>
28   This gallery belongs to <?php echo htmlspecialchars($admin) ?>.
29   <div class="copyright"> code: copyright 2011 Arun Persaud arun@nubati.net, code available at nubati.net/git/f-spot-gallery</div>
30 </footer>
31
32
33 <script type="text/javascript" >
34
35
36 var pics = d3.select(".pics").append("ul");
37
38 var page=0;
39 var N=<?php echo $N?>;
40 var count=0;
41
42 function myreload(a) {
43   d3.json("<?php echo $webbase?>/getjson.php?P="+a, function(json) {
44       count=0;
45       pics.selectAll("li").remove();
46       pics.selectAll("li").data(json)
47         .enter().append("li")
48         .append("a")
49         .attr("href",function(d) {
50             s= d.base_uri+'/'+d.filename;
51             s = s.replace('file:\/\/<?php echo "".str_replace("/","\/",$dbprefix); ?>','<?php echo $webbase; ?>/Photos-small/');
52             return s;
53           })
54         .append("img")
55         .attr("src",function(d) {
56             count++;
57             s= d.base_uri+'/'+d.filename;
58             s = s.replace('file:\/\/<?php echo "".str_replace("/","\/",$dbprefix); ?>','<?php echo $webbase?>/Photos-tiny/');
59             return s;
60           });
61       checkbutton();
62     });
63
64   d3.select(".debug").text("P, count= "+a+" "+count);
65 }
66
67 function left() {
68   if (page>=1) page=page-1;
69   myreload(page);
70 }
71
72 function right() {
73   page=page+1;
74   myreload(page);
75 }
76
77 function checkbutton() {
78
79   if (page==0)
80     { d3.select("button.prev").attr("disabled","disabled");}
81   else
82     { d3.select("button.prev").attr("disabled", null);};
83
84   if (count<N)
85     { d3.select("button.next").attr("disabled","disabled");}
86   else
87     { d3.select("button.next").attr("disabled",null);}
88 }
89
90 myreload(page);
91
92 </script>
93
94 </body>
95 </html>