fix export, web_path was not set correctly
[phpfspot.git] / phpfspot.js
index be62cfbe8d4910e931443e2a0419fbc9be8af859..ebe124225f169a182530acda770bdccc46c22f72 100644 (file)
@@ -277,17 +277,21 @@ function startSearch()
    var objTemp = new Object();
    objTemp['action'] = 'search';
 
-   if(document.getElementsByName('searchfor_tag')[0].value != "") {
+   if(document.getElementsByName('searchfor_tag')[0] != undefined &&
+      document.getElementsByName('searchfor_tag')[0].value != "") {
       objTemp['for_tag'] = document.getElementsByName('searchfor_tag')[0].value;
    }
-   if(document.getElementsByName('searchfor_name')[0].value != "") {
+   if(document.getElementsByName('searchfor_name')[0] != undefined &&
+      document.getElementsByName('searchfor_name')[0].value != "") {
       objTemp['for_name'] = document.getElementsByName('searchfor_name')[0].value;
    }
-   if(document.getElementsByName('consider_date')[0].checked == true) {
+   if(document.getElementsByName('consider_date')[0] != undefined &&
+      document.getElementsByName('consider_date')[0].checked == true) {
       objTemp['from'] = from;
       objTemp['to'] = to;
    }
-   if(document.getElementsByName('consider_rate')[0].checked == true) {
+   if(document.getElementsByName('consider_rate')[0] != undefined &&
+      document.getElementsByName('consider_rate')[0].checked == true) {
       objTemp['rate_from'] = rate_search['from'];
       objTemp['rate_to'] = rate_search['to'];
    }
@@ -333,8 +337,13 @@ function datesearch()
  * called for photo-index export. will return the
  * selected mode via AJAX from the server.
  */
-function setViewMode(mode)
+function setViewMode(srv_webpath, mode)
 {
+   if(srv_webpath != undefined)
+      web_path = srv_webpath;
+   else
+      web_path = '';
+
    var exprt = document.getElementById('output');
    exprt.innerHTML = "Loading...";
    exprt.innerHTML = HTML_AJAX.grab(encodeURI(web_path + '/rpc.php?action=get_export&mode=' + mode));
@@ -346,16 +355,19 @@ function setViewMode(mode)
  */
 function clearSearch()
 {
-   document.getElementsByName('searchfor_tag')[0].value = '';
-   document.getElementsByName('searchfor_name')[0].value = '';
+   if(document.getElementsByName('searchfor_tag')[0] != undefined)
+      document.getElementsByName('searchfor_tag')[0].value = '';
+   if(document.getElementsByName('searchfor_name')[0] != undefined)
+      document.getElementsByName('searchfor_name')[0].value = '';
 
-   if(document.getElementsByName('consider_date')[0].checked == true) {
+   if(document.getElementsByName('consider_date')[0] != undefined &&
+      document.getElementsByName('consider_date')[0].checked == true) {
       document.getElementsByName('consider_date')[0].checked = false;
       datesearch();
    }
-   if(document.getElementsByName('consider_rate')[0].checked == true) {
+   if(document.getElementsByName('consider_rate')[0] != undefined &&
+      document.getElementsByName('consider_rate')[0].checked == true) {
       document.getElementsByName('consider_rate')[0].checked = false;
-      datesearch();
    }
 
 } // clearSearch()
@@ -671,8 +683,13 @@ function noop() {}
 /**
  * start slideshow
  */
-function startSlideShow()
+function startSlideShow(srv_webpath)
 {
+   if(srv_webpath != undefined)
+      web_path = srv_webpath;
+   else
+      web_path = '';
+
    if(!sliding) {
       HTML_AJAX.grab(encodeURI(web_path + '/rpc.php?action=reset_slideshow'));
       nextSlide();