issue103, ensure showPhotoIndex() returns to the right page
[phpfspot.git] / phpfspot.js
index c90d80e1365e337fb730ff4abed673d02d23c8c3..21a027af970748a4c54afdab1b561274b58d8e31 100644 (file)
@@ -1,7 +1,11 @@
-function showImage(id)
+function showImage(id, scrollup)
 {
 {
-   var image_div = document.getElementById("content");
-   image_div.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=showphoto&id=' + id));
+   HTML_AJAX.replace(document.getElementById("content"), encodeURI('rpc.php?action=showphoto&id=' + id));
+
+   /* scroll the window up to the top */
+   if(scrollup != undefined) {
+      window.scrollTo(0,0);
+   }
 }
 
 function showCredits()
 }
 
 function showCredits()
@@ -12,24 +16,35 @@ function showCredits()
 
 function Tags(mode, id)
 {
 
 function Tags(mode, id)
 {
+   var objTemp = new Object();
+
    if(mode == "add") {
    if(mode == "add") {
-      // add the tag to users session
-      HTML_AJAX.grab(encodeURI('rpc.php?action=addtag&id=' + id));
+      // add tag to users session
+      objTemp['action'] = 'addtag';
+      objTemp['id'] = id;
    }
    else if(mode == "del") {
    }
    else if(mode == "del") {
-      // del the tag from users session
-      HTML_AJAX.grab(encodeURI('rpc.php?action=deltag&id=' + id));
+      // del tag from users session
+      objTemp['action'] = 'deltag';
+      objTemp['id'] = id;
    }
    else if(mode == "condition") {
       setCheckedValue(id, id.value);
    }
    else if(mode == "condition") {
       setCheckedValue(id, id.value);
-      HTML_AJAX.grab(encodeURI('rpc.php?action=tagcondition&mode=' + id.value));
+      objTemp['action'] = 'tagcondition';
+      objTemp['mode'] = id.value;
    }
 
    }
 
-   refreshAvailableTags();
-   refreshSelectedTags();
-   refreshPhotoIndex();
+   var retr = HTML_AJAX.post('rpc.php', objTemp);
+   if(retr == "ok") {
+      refreshAvailableTags();
+      refreshSelectedTags();
+      refreshPhotoIndex();
+   }
+   else {
+      window.alert(retr);
+   }
 
 
-}
+} // Tags()
 
 function refreshAvailableTags()
 {
 
 function refreshAvailableTags()
 {
@@ -101,7 +116,6 @@ function startSearch()
    to_day = document.getElementById('today').value;
    to = to_year +"-"+ to_month +"-"+ to_day;
 
    to_day = document.getElementById('today').value;
    to = to_year +"-"+ to_month +"-"+ to_day;
 
-   // Create object with values of the form
    var objTemp = new Object();
    objTemp['action'] = 'search';
 
    var objTemp = new Object();
    objTemp['action'] = 'search';