X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=phpfspot.js;h=6671eb2cb1914a49a4da406cf0bd446055358038;hp=d54f8b5403519a997419d21f2fab0a236d9dbd30;hb=f32fe065bf1569d42d4e8921bc0cab0aa98ef782;hpb=3d567f23a4e45ed8b082fbcd160bd0463b643529 diff --git a/phpfspot.js b/phpfspot.js index d54f8b5..6671eb2 100644 --- a/phpfspot.js +++ b/phpfspot.js @@ -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) @@ -97,16 +90,10 @@ function setCheckedValue(condition, value) { } } -function startTagSearch(searchfor) +function startSearch() { - HTML_AJAX.grab(encodeURI('rpc.php?action=tag_search&for=' + searchfor)); - refreshAvailableTags(); - refreshSelectedTags(); - showPhotoIndex(); -} + var searchfor = document.getElementsByName('searchfor')[0].value -function startDateSearch() -{ from_year = document.getElementById('fromyear').value; from_month = document.getElementById('frommonth').value; from_day = document.getElementById('fromday').value; @@ -116,13 +103,42 @@ function startDateSearch() to_day = document.getElementById('today').value; to = to_year +"-"+ to_month +"-"+ to_day; - HTML_AJAX.grab(encodeURI('rpc.php?action=date_search&from='+ from +'&to='+ to)); + var request = 'rpc.php?action=search'; + + if(searchfor != "") { + request = request + '&for=' + searchfor; + } - clearSearch(); + if(document.getElementsByName('consider_date')[0].checked == true) { + request = request + '&from='+ from +'&to='+ to; + } + + var sort_order = document.getElementsByName('sort_order')[0]; + request = request + '&sort_order='+ sort_order.options[sort_order.selectedIndex].value; + + HTML_AJAX.grab(encodeURI(request)); + refreshAvailableTags(); refreshSelectedTags(); - refreshPhotoIndex(); - refreshPhotoIndex(); + showPhotoIndex(); + +} + +function datesearch() +{ + var mode = true; + + if(document.getElementsByName('consider_date')[0].checked == true) { + mode = false; + } + + document.getElementById('fromyear').disabled = mode; + document.getElementById('frommonth').disabled = mode; + document.getElementById('fromday').disabled = mode; + document.getElementById('toyear').disabled = mode; + document.getElementById('tomonth').disabled = mode; + document.getElementById('today').disabled = mode; + } function setViewMode(mode) @@ -135,6 +151,11 @@ function setViewMode(mode) function clearSearch() { document.getElementsByName('searchfor')[0].value = ''; + + if(document.getElementsByName('consider_date')[0].checked == true) { + document.getElementsByName('consider_date')[0].checked = false; + datesearch(); + } } function AskServerWhatToDo() @@ -148,15 +169,11 @@ function init_phpfspot() whattodo = AskServerWhatToDo(); - if(whattodo == 'showpi') { + if(whattodo == 'showpi' || whattodo == 'showpi_date') { showPhotoIndex(); } if(whattodo == 'showpi_tags') { - if(refreshSelectedTags()) { - showPhotoIndex(); - } - } - if(whattodo == 'showpi_date') { + refreshSelectedTags(); showPhotoIndex(); } if(whattodo == 'show_photo') { @@ -192,6 +209,8 @@ function getPhotoToShow() function showCalendar(date_box, click_obj) { var calendar = document.getElementById('calendar'); + var year = document.getElementById(date_box+'year').value; + var month = document.getElementById(date_box+'month').value; if(date_box == 'from') { var xpos = document.getElementById('frompic').offsetLeft; var ypos = document.getElementById('frompic').offsetTop; @@ -202,16 +221,24 @@ function showCalendar(date_box, click_obj) var ypos = document.getElementById('topic').offsetTop; calendar_mode = 'to'; } - calendar.style.left = xpos + 60 + 'px'; + calendar.style.left = xpos + 100 + 'px'; calendar.style.top = ypos + 80 + 'px'; if(calendar.style.visibility == "" || calendar.style.visibility == 'hidden') { calendar.style.visibility = 'visible'; calendar.innerHTML = "Loading..."; - calendar.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_calendar_matrix')); + calendar.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_calendar_matrix&year=' + year + '&month=' + month)); calendar_shown = 1; } else { + hideCalendar(); + } +} + +function hideCalendar() +{ + var calendar = document.getElementById('calendar'); + if(calendar.style.visibility != 'hidden') { calendar.style.visibility = 'hidden'; calendar_shown = 0; } @@ -229,6 +256,7 @@ function setCalendarDate(year, month, day) document.getElementById(calendar_mode+'year').value = year; document.getElementById(calendar_mode+'month').value = month; document.getElementById(calendar_mode+'day').value = day; + hideCalendar(); } function resetAll() @@ -240,6 +268,144 @@ function resetAll() refreshPhotoIndex(); } +function WSR_getElementsByClassName(oElm, strTagName, oClassNames){ + var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName); + var arrReturnElements = new Array(); + var arrRegExpClassNames = new Array(); + if(typeof oClassNames == "object"){ + for(var i=0; i