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