1 function showImage(id, scrollup)
3 if(!document.getElementById('content'))
6 var content = document.getElementById('content');
9 if(scrollup != undefined) {
10 content.innerHTML = "";
13 HTML_AJAX.replace(content, encodeURI('rpc.php?action=showphoto&id=' + id));
15 /* scroll the window up to the top */
16 if(scrollup != undefined) {
20 /* delete some global vars */
21 delete(origHeight); origHeight = undefined;
22 delete(origWidth); origWidth = undefined;
23 delete(photo_details_pos); photo_details_pos = undefined;
26 function moveToThumb(thumb_id)
28 if(thumb_id == undefined)
31 if(thumbimg = document.getElementById('thumbimg' + thumb_id)) {
32 window.scrollTo(0, findPos(thumbimg,'top')-100);
37 function findPos(obj, direction) {
39 if (obj.offsetParent) {
41 if(direction == 'left')
42 cur += obj.offsetLeft;
43 if(direction == 'top')
45 } while (obj = obj.offsetParent);
50 function showCredits()
52 var credits = document.getElementById("content");
53 credits.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=showcredits'));
56 function Tags(mode, id)
58 var objTemp = new Object();
61 // add tag to users session
62 objTemp['action'] = 'addtag';
65 else if(mode == "del") {
66 // del tag from users session
67 objTemp['action'] = 'deltag';
70 else if(mode == "condition") {
71 setCheckedValue(id, id.value);
72 objTemp['action'] = 'tagcondition';
73 objTemp['mode'] = id.value;
76 var retr = HTML_AJAX.post('rpc.php', objTemp);
78 refreshAvailableTags();
79 refreshSelectedTags();
83 window.alert("Server message: "+ retr);
88 function refreshAvailableTags()
90 // update available tags
91 var avail_tags = document.getElementById('available_tags');
92 avail_tags.innerHTML = "Loading...";
93 avail_tags.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=show_available_tags'));
96 function refreshSelectedTags()
98 // update selected tags
99 var selected_tags = document.getElementById("selected_tags");
100 selected_tags.innerHTML = "Loading...";
101 selected_tags.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=show_selected_tags'));
104 function showPhotoIndex(begin_with, last_photo)
106 var url = "rpc.php?action=show_photo_index";
107 if(begin_with != undefined)
108 url = url + '&begin_with=' + begin_with;
109 if(last_photo != undefined)
110 url = url + '&last_photo=' + last_photo;
112 HTML_AJAX.replace(document.getElementById("content"), encodeURI(url));
114 } // showPhotoIndex()
116 // if photo index is currently shown, refresh it
117 function refreshPhotoIndex()
119 if(document.getElementById("index") != undefined || startup == 1) {
125 function click(object)
132 // set the radio button with the given value as being checked
133 // do nothing if there are no radio buttons
134 // if the given value does not exist, all the radio buttons
135 // are reset to unchecked
136 function setCheckedValue(condition, value) {
138 var count = condition.length;
139 if(count == undefined) {
140 condition.checked = (condition.value == value.toString());
143 for(var i = 0; i < count; i++) {
144 condition[i].checked = false;
145 if(condition[i].value == value.toString()) {
146 condition[i].checked = true;
151 function startSearch()
153 from_year = document.getElementById('fromyear').value;
154 from_month = document.getElementById('frommonth').value;
155 from_day = document.getElementById('fromday').value;
156 from = from_year +"-"+ from_month +"-"+ from_day;
157 to_year = document.getElementById('toyear').value;
158 to_month = document.getElementById('tomonth').value;
159 to_day = document.getElementById('today').value;
160 to = to_year +"-"+ to_month +"-"+ to_day;
162 var objTemp = new Object();
163 objTemp['action'] = 'search';
165 if(document.getElementsByName('searchfor_tag')[0].value != "") {
166 objTemp['for_tag'] = document.getElementsByName('searchfor_tag')[0].value;
168 if(document.getElementsByName('searchfor_name')[0].value != "") {
169 objTemp['for_name'] = document.getElementsByName('searchfor_name')[0].value;
171 if(document.getElementsByName('consider_date')[0].checked == true) {
172 objTemp['from'] = from;
176 var retr = HTML_AJAX.post('rpc.php', objTemp);
178 refreshAvailableTags();
179 refreshSelectedTags();
183 window.alert("Server message: "+ retr);
188 function datesearch()
192 if(document.getElementsByName('consider_date')[0].checked == true) {
196 document.getElementById('fromyear').disabled = mode;
197 document.getElementById('frommonth').disabled = mode;
198 document.getElementById('fromday').disabled = mode;
199 document.getElementById('toyear').disabled = mode;
200 document.getElementById('tomonth').disabled = mode;
201 document.getElementById('today').disabled = mode;
205 function setViewMode(mode)
207 var exprt = document.getElementById('output');
208 exprt.innerHTML = "Loading...";
209 exprt.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_export&mode=' + mode));
212 function clearSearch()
214 document.getElementsByName('searchfor_tag')[0].value = '';
215 document.getElementsByName('searchfor_name')[0].value = '';
217 if(document.getElementsByName('consider_date')[0].checked == true) {
218 document.getElementsByName('consider_date')[0].checked = false;
223 function AskServerWhatToDo()
225 return HTML_AJAX.grab(encodeURI('rpc.php?action=what_to_do'));
228 function init_phpfspot(mode)
230 /* always load list of available tags */
231 refreshAvailableTags();
233 /* ask the server what we are currently displaying */
234 whattodo = AskServerWhatToDo();
236 if(whattodo == 'showpi' || whattodo == 'showpi_date') {
239 if(whattodo == 'showpi_tags') {
240 refreshSelectedTags();
243 if(whattodo == 'show_photo') {
244 if(photo = getPhotoToShow()) {
246 refreshSelectedTags();
251 function setBackGrdColor(item, color)
253 if(color == 'mouseover')
254 item.style.backgroundColor='#c6e9ff';
255 if(color == 'mouseout')
256 item.style.backgroundColor='#eeeeee';
257 if(color == 'mouseclick')
258 item.style.backgroundColor='#93A8CA';
261 function getPhotoToShow()
263 // update selected tags
264 var photo_to_show = HTML_AJAX.grab(encodeURI('rpc.php?action=get_photo_to_show'));
266 // if no image needs to be shown, return false from here
267 if(photo_to_show == "")
270 return photo_to_show;
280 /* internet explorer */
281 if(document.images['photo'].width)
282 photo = document.images['photo'];
285 if(photo == undefined && document.getElementById('photo').width)
286 photo = document.getElementById('photo');
288 if(photo != undefined) {
290 if(origWidth == undefined)
291 origWidth = photo.width;
292 if(origHeight == undefined)
293 origHeight = photo.height;
296 new_w = photo.width * (1 + mod/100);
297 new_h = photo.height * (1 + mod/100);
299 photo.height = new_h;
301 if(photo_details_pos == undefined) {
302 photo_details_pos = findPos(document.getElementById('photo_details'),'left');
305 if((photo.offsetLeft + new_w) >= photo_details_pos-20) {
306 hidePhotoDetails('true');
309 hidePhotoDetails('false');
313 photo.width = origWidth;
314 photo.height = origHeight;
315 hidePhotoDetails('false');
321 function hidePhotoDetails(mode)
325 if(photo_details = document.getElementById('photo_details')) {
327 photo_details.style.visibility = 'hidden';
328 photo_details.style.display = 'none';
331 photo_details.style.visibility = 'visible';
332 photo_details.style.display = '';
335 } // hidePhotoDetails()
337 function showCalendar(date_box, click_obj)
339 var calendar = document.getElementById('calendar');
340 var year = document.getElementById(date_box+'year').value;
341 var month = document.getElementById(date_box+'month').value;
342 if(date_box == 'from') {
343 var xpos = document.getElementById('frompic').offsetLeft;
344 var ypos = document.getElementById('frompic').offsetTop;
345 calendar_mode = 'from';
347 if(date_box == 'to') {
348 var xpos = document.getElementById('topic').offsetLeft;
349 var ypos = document.getElementById('topic').offsetTop;
350 calendar_mode = 'to';
352 calendar.style.left = xpos + 100 + 'px';
353 calendar.style.top = ypos + 80 + 'px';
355 if(calendar.style.visibility == "" || calendar.style.visibility == 'hidden') {
356 calendar.style.visibility = 'visible';
357 calendar.innerHTML = "Loading...";
358 calendar.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_calendar_matrix&year=' + year + '&month=' + month));
366 function hideCalendar()
368 var calendar = document.getElementById('calendar');
369 if(calendar.style.visibility != 'hidden') {
370 calendar.style.visibility = 'hidden';
375 function setMonth(year, month, day)
377 var calendar = document.getElementById('calendar');
378 calendar.innerHTML = "Loading...";
379 calendar.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_calendar_matrix&year='+ year +'&month='+ month +'&day='+ day));
382 function setCalendarDate(year, month, day)
384 document.getElementById(calendar_mode+'year').value = year;
385 document.getElementById(calendar_mode+'month').value = month;
386 document.getElementById(calendar_mode+'day').value = day;
392 HTML_AJAX.grab(encodeURI('rpc.php?action=reset'));
394 refreshAvailableTags();
395 refreshSelectedTags();
399 function WSR_getElementsByClassName(oElm, strTagName, oClassNames){
400 var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
401 var arrReturnElements = new Array();
402 var arrRegExpClassNames = new Array();
403 if(typeof oClassNames == "object"){
404 for(var i=0; i<oClassNames.length; i++){
405 arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames[i].replace(/-/g, "\-") + "(\s|$)"));
409 arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames.replace(/-/g, "\-") + "(\s|$)"));
413 for(var j=0; j<arrElements.length; j++){
414 oElement = arrElements[j];
416 for(var k=0; k<arrRegExpClassNames.length; k++){
417 if(!arrRegExpClassNames[k].test(oElement.className)){
423 arrReturnElements.push(oElement);
426 return (arrReturnElements)
430 function preloadPhotos(image_url) {
437 lbImg=WSR_getElementsByClassName(document,"img","thumb");
438 for(i=0;i<lbImg.length;i++){
439 lbImg[i].src=image_url[i];
440 // to not bomb the server with requests, give the page some time
441 // to load the images one by one. if a image exceeds the timeout,
442 // the next image will be loaded.
443 if(lbImg[i].complete != undefined && lbImg[i].complete != true) {
445 while(lbImg[i].complete != true && counting < timeout) {
446 window.setTimeout("noop()", waiting);
453 /* a function that does nothing */
456 function startSlideShow()
459 HTML_AJAX.grab(encodeURI('rpc.php?action=reset_slideshow'));
461 sliding = setInterval("nextSlide()", sliding_time*1000);
462 document.getElementById('stop_ico').src = "resources/32_stop.png";
465 clearInterval(sliding);
467 document.getElementById('stop_ico').src = "resources/32_play.png";
473 var next_img = HTML_AJAX.grab(encodeURI('rpc.php?action=get_next_slideshow_img'));
474 document.getElementById('slide_img').src = next_img;
479 var prev_img = HTML_AJAX.grab(encodeURI('rpc.php?action=get_prev_slideshow_img'));
480 document.getElementById('slide_img').src = prev_img;
483 function pauseSlideShow()
485 if(!sliding_paused) {
487 clearInterval(sliding);
488 document.getElementById('pause_ico').src = "resources/32_play.png";
492 sliding = setInterval("nextSlide()", sliding_time*1000);
493 document.getElementById('pause_ico').src = "resources/32_pause.png";
497 function startAutoBrowse()
501 autobrowse = setInterval("autoBrowse()", 5000);
504 clearInterval(autobrowse);
506 document.getElementById('autobrowse_ico').src = "resources/32_play.png";
509 } // startAutoBrowser()
511 function autoBrowse()
513 if(document.getElementById('next_link')) {
514 var next_link = document.getElementById('next_link').href;
515 window.location.href = next_link;
516 document.getElementById('autobrowse_ico').src = "resources/32_pause.png";
518 /* we have reached the last photo */
520 if(ab_ico = document.getElementById('autobrowse_ico'))
521 ab_ico.src = "resources/32_play.png";
522 clearInterval(autobrowse);
527 function initSlider()
529 var sliderEl = document.getElementById ? document.getElementById("slider-1") : null;
530 var inputEl = document.forms[0]["slider-input-1"];
531 var s = new Slider(sliderEl, inputEl);
534 s.setValue(sliding_time);
535 document.getElementById("current_slide_time").innerHTML = sliding_time + "s Interval";
536 s.onchange = function () {
537 sliding_time = s.getValue();
538 document.getElementById("current_slide_time").innerHTML = sliding_time + "s Interval";
539 if(!sliding_paused && sliding) {
540 clearInterval(sliding);
541 sliding = setInterval("nextSlide()", sliding_time*1000);
544 window.onresize = function () {
550 function update_sort_order(obj)
552 var objTemp = new Object();
553 objTemp['value'] = obj.options[obj.selectedIndex].value;
555 var retr = HTML_AJAX.post('rpc.php?action=update_sort_order', objTemp);
561 window.alert("Server message: "+ retr);
564 } // update_sort_order()
567 function keyDown(e) {
568 var evt = (e) ? e:(window.event) ? window.event:null;
571 var key = (evt.charCode) ? evt.charCode :
572 ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
575 if(key == 37) /* left curosr */ {
576 if(document.getElementById('prev_link')) {
577 var prev_link = document.getElementById('prev_link').href;
578 window.location.href = prev_link;
582 if(key == 38) /* up cursor */ {
584 if(key == 39) /* right curosr */ {
585 if(document.getElementById('next_link')) {
586 var next_link = document.getElementById('next_link').href;
587 window.location.href = next_link;
591 if(key == 73 && evt.altKey && evt.ctrlKey) /* ctrl+alt+i */ {
595 if(key == 82 && evt.altKey && evt.ctrlKey) /* ctrl+alt+r */ {
602 document.onkeydown=keyDown;
603 if(document.layers) {
604 document.captureEvents(Event.KEYDOWN);
608 var calendar_shown = 0;
609 var calendar_mode = '';
612 var sliding_paused = 0;
613 var sliding_time = 3;
616 var photo_details_pos;