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 */
23 delete(photo_details_pos);
26 function moveToThumb(thumb_id)
28 if(thumb_id == undefined)
31 if(thumbimg = document.getElementById('thumbimg' + thumb_id)) {
32 window.scrollTo(0, thumbimg.offsetTop-100);
37 function showCredits()
39 var credits = document.getElementById("content");
40 credits.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=showcredits'));
43 function Tags(mode, id)
45 var objTemp = new Object();
48 // add tag to users session
49 objTemp['action'] = 'addtag';
52 else if(mode == "del") {
53 // del tag from users session
54 objTemp['action'] = 'deltag';
57 else if(mode == "condition") {
58 setCheckedValue(id, id.value);
59 objTemp['action'] = 'tagcondition';
60 objTemp['mode'] = id.value;
63 var retr = HTML_AJAX.post('rpc.php', objTemp);
65 refreshAvailableTags();
66 refreshSelectedTags();
75 function refreshAvailableTags()
77 // update available tags
78 var avail_tags = document.getElementById('available_tags');
79 avail_tags.innerHTML = "Loading...";
80 avail_tags.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=show_available_tags'));
83 function refreshSelectedTags()
85 // update selected tags
86 var selected_tags = document.getElementById("selected_tags");
87 selected_tags.innerHTML = "Loading...";
88 selected_tags.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=show_selected_tags'));
91 function showPhotoIndex(begin_with, last_photo)
93 var url = "rpc.php?action=show_photo_index";
94 if(begin_with != undefined)
95 url = url + '&begin_with=' + begin_with;
96 if(last_photo != undefined)
97 url = url + '&last_photo=' + last_photo;
99 HTML_AJAX.replace(document.getElementById("content"), encodeURI(url));
101 } // showPhotoIndex()
103 // if photo index is currently shown, refresh it
104 function refreshPhotoIndex()
106 if(document.getElementById("index") != undefined || startup == 1) {
112 function click(object)
119 // set the radio button with the given value as being checked
120 // do nothing if there are no radio buttons
121 // if the given value does not exist, all the radio buttons
122 // are reset to unchecked
123 function setCheckedValue(condition, value) {
125 var count = condition.length;
126 if(count == undefined) {
127 condition.checked = (condition.value == value.toString());
130 for(var i = 0; i < count; i++) {
131 condition[i].checked = false;
132 if(condition[i].value == value.toString()) {
133 condition[i].checked = true;
138 function startSearch()
140 from_year = document.getElementById('fromyear').value;
141 from_month = document.getElementById('frommonth').value;
142 from_day = document.getElementById('fromday').value;
143 from = from_year +"-"+ from_month +"-"+ from_day;
144 to_year = document.getElementById('toyear').value;
145 to_month = document.getElementById('tomonth').value;
146 to_day = document.getElementById('today').value;
147 to = to_year +"-"+ to_month +"-"+ to_day;
149 var objTemp = new Object();
150 objTemp['action'] = 'search';
152 if(document.getElementsByName('searchfor_tag')[0].value != "") {
153 objTemp['for_tag'] = document.getElementsByName('searchfor_tag')[0].value;
155 if(document.getElementsByName('searchfor_name')[0].value != "") {
156 objTemp['for_name'] = document.getElementsByName('searchfor_name')[0].value;
158 if(document.getElementsByName('consider_date')[0].checked == true) {
159 objTemp['from'] = from;
163 var retr = HTML_AJAX.post('rpc.php', objTemp);
165 refreshAvailableTags();
166 refreshSelectedTags();
175 function datesearch()
179 if(document.getElementsByName('consider_date')[0].checked == true) {
183 document.getElementById('fromyear').disabled = mode;
184 document.getElementById('frommonth').disabled = mode;
185 document.getElementById('fromday').disabled = mode;
186 document.getElementById('toyear').disabled = mode;
187 document.getElementById('tomonth').disabled = mode;
188 document.getElementById('today').disabled = mode;
192 function setViewMode(mode)
194 var exprt = document.getElementById('output');
195 exprt.innerHTML = "Loading...";
196 exprt.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_export&mode=' + mode));
199 function clearSearch()
201 document.getElementsByName('searchfor_tag')[0].value = '';
202 document.getElementsByName('searchfor_name')[0].value = '';
204 if(document.getElementsByName('consider_date')[0].checked == true) {
205 document.getElementsByName('consider_date')[0].checked = false;
210 function AskServerWhatToDo()
212 return HTML_AJAX.grab(encodeURI('rpc.php?action=what_to_do'));
215 function init_phpfspot(mode)
217 /* always load list of available tags */
218 refreshAvailableTags();
220 /* ask the server what we are currently displaying */
221 whattodo = AskServerWhatToDo();
223 if(whattodo == 'showpi' || whattodo == 'showpi_date') {
226 if(whattodo == 'showpi_tags') {
227 refreshSelectedTags();
230 if(whattodo == 'show_photo') {
231 if(photo = getPhotoToShow()) {
233 refreshSelectedTags();
238 function setBackGrdColor(item, color)
240 if(color == 'mouseover')
241 item.style.backgroundColor='#c6e9ff';
242 if(color == 'mouseout')
243 item.style.backgroundColor='#eeeeee';
244 if(color == 'mouseclick')
245 item.style.backgroundColor='#93A8CA';
248 function getPhotoToShow()
250 // update selected tags
251 var photo_to_show = HTML_AJAX.grab(encodeURI('rpc.php?action=get_photo_to_show'));
253 // if no image needs to be shown, return false from here
254 if(photo_to_show == "")
257 return photo_to_show;
265 if(photo = document.getElementById('photo')) {
267 if(origWidth == undefined)
268 origWidth = photo.width;
269 if(origHeight == undefined)
270 origHeight = photo.height;
273 new_w = photo.width * (1 + mod/100);
274 new_h = photo.height * (1 + mod/100);
276 photo.height = new_h;
278 if(photo_details_pos == undefined) {
279 photo_details_pos = document.getElementById('photo_details').offsetLeft;
282 if((photo.offsetLeft + new_w) >= photo_details_pos-20) {
283 hidePhotoDetails('true');
286 hidePhotoDetails('false');
290 photo.width = origWidth;
291 photo.height = origHeight;
292 hidePhotoDetails('false');
298 function hidePhotoDetails(mode)
300 if(photo_details = document.getElementById('photo_details')) {
302 photo_details.style.visibility = 'hidden';
303 photo_details.style.display = 'none';
306 photo_details.style.visibility = 'visible';
307 photo_details.style.display = 'inline';
310 } // hidePhotoDetails()
312 function showCalendar(date_box, click_obj)
314 var calendar = document.getElementById('calendar');
315 var year = document.getElementById(date_box+'year').value;
316 var month = document.getElementById(date_box+'month').value;
317 if(date_box == 'from') {
318 var xpos = document.getElementById('frompic').offsetLeft;
319 var ypos = document.getElementById('frompic').offsetTop;
320 calendar_mode = 'from';
322 if(date_box == 'to') {
323 var xpos = document.getElementById('topic').offsetLeft;
324 var ypos = document.getElementById('topic').offsetTop;
325 calendar_mode = 'to';
327 calendar.style.left = xpos + 100 + 'px';
328 calendar.style.top = ypos + 80 + 'px';
330 if(calendar.style.visibility == "" || calendar.style.visibility == 'hidden') {
331 calendar.style.visibility = 'visible';
332 calendar.innerHTML = "Loading...";
333 calendar.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_calendar_matrix&year=' + year + '&month=' + month));
341 function hideCalendar()
343 var calendar = document.getElementById('calendar');
344 if(calendar.style.visibility != 'hidden') {
345 calendar.style.visibility = 'hidden';
350 function setMonth(year, month, day)
352 var calendar = document.getElementById('calendar');
353 calendar.innerHTML = "Loading...";
354 calendar.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_calendar_matrix&year='+ year +'&month='+ month +'&day='+ day));
357 function setCalendarDate(year, month, day)
359 document.getElementById(calendar_mode+'year').value = year;
360 document.getElementById(calendar_mode+'month').value = month;
361 document.getElementById(calendar_mode+'day').value = day;
367 HTML_AJAX.grab(encodeURI('rpc.php?action=reset'));
369 refreshAvailableTags();
370 refreshSelectedTags();
374 function WSR_getElementsByClassName(oElm, strTagName, oClassNames){
375 var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
376 var arrReturnElements = new Array();
377 var arrRegExpClassNames = new Array();
378 if(typeof oClassNames == "object"){
379 for(var i=0; i<oClassNames.length; i++){
380 arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames[i].replace(/-/g, "\-") + "(\s|$)"));
384 arrRegExpClassNames.push(new RegExp("(^|\s)" + oClassNames.replace(/-/g, "\-") + "(\s|$)"));
388 for(var j=0; j<arrElements.length; j++){
389 oElement = arrElements[j];
391 for(var k=0; k<arrRegExpClassNames.length; k++){
392 if(!arrRegExpClassNames[k].test(oElement.className)){
398 arrReturnElements.push(oElement);
401 return (arrReturnElements)
405 function preloadPhotos(lbImg) {
410 d.photos=new Array();
412 var i, j=d.photos.length;
414 lbImg=WSR_getElementsByClassName(document,"img","thumb");
415 for(i=0;i<lbImg.length;i++){
416 d.photos[j]=new Image;
417 d.photos[j].src=lbImg[i].src;
422 function startSlideShow()
425 HTML_AJAX.grab(encodeURI('rpc.php?action=reset_slideshow'));
427 sliding = setInterval("nextSlide()", sliding_time*1000);
428 document.getElementById('stop_ico').src = "resources/32_stop.png";
431 clearInterval(sliding);
433 document.getElementById('stop_ico').src = "resources/32_play.png";
439 var next_img = HTML_AJAX.grab(encodeURI('rpc.php?action=get_next_slideshow_img'));
440 document.getElementById('slide_img').src = next_img;
445 var prev_img = HTML_AJAX.grab(encodeURI('rpc.php?action=get_prev_slideshow_img'));
446 document.getElementById('slide_img').src = prev_img;
449 function pauseSlideShow()
451 if(!sliding_paused) {
453 clearInterval(sliding);
454 document.getElementById('pause_ico').src = "resources/32_play.png";
458 sliding = setInterval("nextSlide()", sliding_time*1000);
459 document.getElementById('pause_ico').src = "resources/32_pause.png";
463 function startAutoBrowse()
467 autobrowse = setInterval("autoBrowse()", 5000);
470 clearInterval(autobrowse);
472 document.getElementById('autobrowse_ico').src = "resources/32_play.png";
475 } // startAutoBrowser()
477 function autoBrowse()
479 if(document.getElementById('next_link')) {
480 var next_link = document.getElementById('next_link').href;
481 window.location.href = next_link;
482 document.getElementById('autobrowse_ico').src = "resources/32_pause.png";
484 /* we have reached the last photo */
486 if(ab_ico = document.getElementById('autobrowse_ico'))
487 ab_ico.src = "resources/32_play.png";
488 clearInterval(autobrowse);
493 function initSlider()
495 var sliderEl = document.getElementById ? document.getElementById("slider-1") : null;
496 var inputEl = document.forms[0]["slider-input-1"];
497 var s = new Slider(sliderEl, inputEl);
500 s.setValue(sliding_time);
501 document.getElementById("current_slide_time").innerHTML = sliding_time + "s Interval";
502 s.onchange = function () {
503 sliding_time = s.getValue();
504 document.getElementById("current_slide_time").innerHTML = sliding_time + "s Interval";
505 if(!sliding_paused && sliding) {
506 clearInterval(sliding);
507 sliding = setInterval("nextSlide()", sliding_time*1000);
510 window.onresize = function () {
516 function update_sort_order(obj)
518 var objTemp = new Object();
519 objTemp['value'] = obj.options[obj.selectedIndex].value;
521 var retr = HTML_AJAX.post('rpc.php?action=update_sort_order', objTemp);
530 } // update_sort_order()
533 function keyDown(e) {
534 var evt = (e) ? e:(window.event) ? window.event:null;
537 var key = (evt.charCode) ? evt.charCode :
538 ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
541 if(key == 37) /* left curosr */ {
542 if(document.getElementById('prev_link')) {
543 var prev_link = document.getElementById('prev_link').href;
544 window.location.href = prev_link;
548 if(key == 38) /* up cursor */ {
550 if(key == 39) /* right curosr */ {
551 if(document.getElementById('next_link')) {
552 var next_link = document.getElementById('next_link').href;
553 window.location.href = next_link;
557 if(key == 73 && evt.altKey && evt.ctrlKey) /* ctrl+alt+i */ {
561 if(key == 82 && evt.altKey && evt.ctrlKey) /* ctrl+alt+r */ {
568 document.onkeydown=keyDown;
569 if(document.layers) {
570 document.captureEvents(Event.KEYDOWN);
574 var calendar_shown = 0;
575 var calendar_mode = '';
578 var sliding_paused = 0;
579 var sliding_time = 3;
582 var photo_details_pos;