summaryrefslogtreecommitdiffstats
path: root/index.php
blob: 018beddc3578929e0915c7f3b23aa5fce66a7f29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/* parse ini -file */
$iniarray=parse_ini_file("config.ini");
$webbase=$iniarray["webbase"];
$dbprefix=$iniarray["dbprefix"];
$admin=$iniarray["admin"];
$title=$iniarray["title"];
$N=$iniarray["pics_per_page"];
/* end parse ini-file */

/* parse flags */
if(isset($_REQUEST["page"]))
  $page = intval($_REQUEST["page"]);
else
  $page = 1;

?>
<html>
<title><?php echo htmlspecialchars($title) ?></title>
<script src="<?php echo $webbase?>/d3.min.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $webbase?>/normalize.css" />
<link rel="stylesheet" type="text/css" href="<?php echo $webbase?>/style.css" />

<body>

<div class="debug">test</div>
<h1><?php echo htmlspecialchars($title) ?></h1>

<button class="prev" disabled="disabled" onclick="left()"> prev </button>
<button class="next"   onclick="right()">next </button>

<div class="permalink"></div>
<div class="index"></div>
<div class="pics"> </div>

<footer>
  This gallery belongs to <?php echo htmlspecialchars($admin) ?>.
  <div class="copyright"> code: copyright 2011 Arun Persaud arun@nubati.net, code available at nubati.net/git/f-spot-gallery</div>
</footer>


<script type="text/javascript" >


var pics = d3.select(".pics").append("ul");

var page=<?php echo $page ?>;
var N=<?php echo $N ?>;
var count=0;

function myreload(a) {
  d3.json("<?php echo $webbase?>/getjson.php?T=1", function(json) {
      s="page ";
      n = json[0].total/N;
      for(i=1;i<=n+1;i++)
	{
	  s+=" <a href=\"<?php echo $webbase?>/page/"+i+"\">"+i+"</a>";
	}
      d3.select(".index").html(s);
    });
  d3.json("<?php echo $webbase?>/getjson.php?P="+a, function(json) {
      count=0;
      pics.selectAll("li").remove();
      pics.selectAll("li").data(json)
	.enter().append("li")
	.append("a")
	.attr("href",function(d) {
	    s= d.base_uri+'/'+d.filename;
	    s = s.replace('file:\/\/<?php echo "".str_replace("/","\/",$dbprefix); ?>','<?php echo $webbase; ?>/Photos-small/');
	    return s;
	  })
	.append("img")
	.attr("src",function(d) {
	    count++;
	    s= d.base_uri+'/'+d.filename;
	    s = s.replace('file:\/\/<?php echo "".str_replace("/","\/",$dbprefix); ?>','<?php echo $webbase?>/Photos-tiny/');
	    return s;
	  });
      checkbutton();
    });

  permalink="<?php echo $webbase ?>/page/"+page;
  d3.select(".permalink").html("Permalink: <a href=\""+permalink+"\">"+permalink+"</a>");
  d3.select(".debug").text("P,N ="+a+" "+N);
}

function left() {
  if (page>=2) page=page-1;
  myreload(page);
}

function right() {
  page=page+1;
  myreload(page);
}

function checkbutton() {

  if (page==1)
    { d3.select("button.prev").attr("disabled","disabled");}
  else
    { d3.select("button.prev").attr("disabled", null);};

  if (count<N)
    { d3.select("button.next").attr("disabled","disabled");}
  else
    { d3.select("button.next").attr("disabled",null);}
}

myreload(page);

</script>

</body>
</html>