issue48, make sure no pending comma is shown at the end of the available-tags
[phpfspot.git] / phpfspot.js
index 40d676187f0c409f0a9d65940cf44dbea4a23fb8..3813d09d2a2e68f3fad544a9b1a4f28f0c87e838 100644 (file)
@@ -24,7 +24,7 @@ function Tags(mode, id)
       setCheckedValue(id, id.value);
       HTML_AJAX.grab(encodeURI('rpc.php?action=tagcondition&mode=' + id.value));
    }
-   
+
    refreshAvailableTags();
    refreshSelectedTags();
    refreshPhotoIndex();
@@ -45,13 +45,6 @@ function refreshSelectedTags()
    var selected_tags = document.getElementById("selected_tags");
    selected_tags.innerHTML = "Loading...";
    selected_tags.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=show_selected_tags'));
-
-   // if no tags are currently selected, return false from here
-   if(selected_tags.innerHTML == "")
-      return false;
-   
-   return true;
-
 }
 
 function showPhotoIndex(begin_with)
@@ -117,7 +110,8 @@ function startDateSearch()
    to = to_year +"-"+ to_month +"-"+ to_day;
 
    HTML_AJAX.grab(encodeURI('rpc.php?action=date_search&from='+ from +'&to='+ to));
-
+   
+   clearSearch();
    refreshAvailableTags();
    refreshSelectedTags();
    refreshPhotoIndex();
@@ -136,17 +130,28 @@ function clearSearch()
    document.getElementsByName('searchfor')[0].value = '';
 }
 
+function AskServerWhatToDo()
+{
+   return HTML_AJAX.grab(encodeURI('rpc.php?action=what_to_do'));
+}
+
 function init_phpfspot()
 {
    refreshAvailableTags();
 
-   if(photo = getPhotoToShow()) {
-      showImage(photo)
+   whattodo = AskServerWhatToDo();
+
+   if(whattodo == 'showpi' || whattodo == 'showpi_date') {
+      showPhotoIndex();
+   }
+   if(whattodo == 'showpi_tags') {
       refreshSelectedTags();
+      showPhotoIndex();
    }
-   else {
-      if(refreshSelectedTags()) {
-         showPhotoIndex();
+   if(whattodo == 'show_photo') {
+      if(photo = getPhotoToShow()) {
+         showImage(photo)
+         refreshSelectedTags();
       }
    }
 }
@@ -219,6 +224,9 @@ function resetAll()
 {
    HTML_AJAX.grab(encodeURI('rpc.php?action=reset'));
    clearSearch();
+   refreshAvailableTags();
+   refreshSelectedTags();
+   refreshPhotoIndex();
 }
 
 var startup = 1;