issue50, on date-search don't touch the current tag selection
[phpfspot.git] / phpfspot.js
index f101e6080900209319d927a4e96ceca2f5a5ba0e..068a96f76c0c5427789d538b8c5ff389a42259fa 100644 (file)
@@ -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,12 +110,9 @@ 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();
+
    refreshPhotoIndex();
+   
 }
 
 function setViewMode(mode)
@@ -137,17 +127,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();
       }
    }
 }
@@ -220,6 +221,9 @@ function resetAll()
 {
    HTML_AJAX.grab(encodeURI('rpc.php?action=reset'));
    clearSearch();
+   refreshAvailableTags();
+   refreshSelectedTags();
+   refreshPhotoIndex();
 }
 
 var startup = 1;