added a permalink and use clean urls
[photo-tags.git] / index.php
index 3014924484f2de1ddbc4fa3cf40959da0ea277e0..5f045433d197bff0dca0c7a0c4ca2803b9605271 100644 (file)
--- a/index.php
+++ b/index.php
@@ -5,13 +5,21 @@ $webbase=$iniarray["webbase"];
 $dbprefix=$iniarray["dbprefix"];
 $admin=$iniarray["admin"];
 $title=$iniarray["title"];
 $dbprefix=$iniarray["dbprefix"];
 $admin=$iniarray["admin"];
 $title=$iniarray["title"];
+$N=$iniarray["pics_per_page"];
 /* end parse ini-file */
 /* end parse ini-file */
+
+/* parse flags */
+if(isset($_REQUEST["page"]))
+  $page = intval($_REQUEST["page"]);
+else
+  $page = 1;
+
 ?>
 <html>
 <title><?php echo htmlspecialchars($title) ?></title>
 ?>
 <html>
 <title><?php echo htmlspecialchars($title) ?></title>
-<script src="d3.min.js"></script>
-<link rel="stylesheet" type="text/css" href="normalize.css" />
-<link rel="stylesheet" type="text/css" href="style.css" />
+<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>
 
 
 <body>
 
@@ -21,6 +29,8 @@ $title=$iniarray["title"];
 <button class="prev" disabled="disabled" onclick="left()"> prev </button>
 <button class="next"   onclick="right()">next </button>
 
 <button class="prev" disabled="disabled" onclick="left()"> prev </button>
 <button class="next"   onclick="right()">next </button>
 
+<div class="permalink"></div>
+
 <div class="pics"> </div>
 
 <footer>
 <div class="pics"> </div>
 
 <footer>
@@ -34,12 +44,12 @@ $title=$iniarray["title"];
 
 var pics = d3.select(".pics").append("ul");
 
 
 var pics = d3.select(".pics").append("ul");
 
-var offset=0;
-var N=30;
+var page=<?php echo $page ?>;
+var N=<?php echo $N ?>;
 var count=0;
 
 var count=0;
 
-function myreload(a,b) {
-  d3.json("<?php echo $webbase?>/getjson.php?O="+a+"&N="+b, function(json) {
+function myreload(a) {
+  d3.json("<?php echo $webbase?>/getjson.php?P="+a, function(json) {
       count=0;
       pics.selectAll("li").remove();
       pics.selectAll("li").data(json)
       count=0;
       pics.selectAll("li").remove();
       pics.selectAll("li").data(json)
@@ -60,22 +70,24 @@ function myreload(a,b) {
       checkbutton();
     });
 
       checkbutton();
     });
 
-  d3.select(".debug").text("O, N= "+a+" "+b+" "+count);
+  permalink="<?php echo $webbase ?>/page/"+page;
+  d3.select(".permalink").html("Permalink: <a href=\""+permalink+"\">"+permalink+"</a>");
+  d3.select(".debug").text("P, count= "+a+" "+count);
 }
 
 function left() {
 }
 
 function left() {
-  if (offset>=N) offset=offset-N;
-  myreload(offset,N);
+  if (page>=2) page=page-1;
+  myreload(page);
 }
 
 function right() {
 }
 
 function right() {
-  offset=offset+N;
-  myreload(offset,N);
+  page=page+1;
+  myreload(page);
 }
 
 function checkbutton() {
 
 }
 
 function checkbutton() {
 
-  if (offset==0)
+  if (page==1)
     { d3.select("button.prev").attr("disabled","disabled");}
   else
     { d3.select("button.prev").attr("disabled", null);};
     { d3.select("button.prev").attr("disabled","disabled");}
   else
     { d3.select("button.prev").attr("disabled", null);};
@@ -86,7 +98,7 @@ function checkbutton() {
     { d3.select("button.next").attr("disabled",null);}
 }
 
     { d3.select("button.next").attr("disabled",null);}
 }
 
-myreload(offset,N);
+myreload(page);
 
 </script>
 
 
 </script>