fcc5766a2506f9b304bfb86c8d8d588bc4d9f06e
[phpfspot.git] / phpfspot.js
1 function showImage(id)
2 {
3    var image_div = document.getElementById("content");
4    image_div.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=showphoto&id=' + id));
5 }
6
7 function showCredits()
8 {
9    var credits = document.getElementById("content");
10    credits.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=showcredits'));
11 }
12
13 function Tags(mode, id)
14 {
15    if(mode == "add") {
16       // add the tag to users session
17       HTML_AJAX.grab(encodeURI('rpc.php?action=addtag&id=' + id));
18    }
19    else if(mode == "del") {
20       // del the tag from users session
21       HTML_AJAX.grab(encodeURI('rpc.php?action=deltag&id=' + id));
22    }
23    else if(mode == "reset") {
24       HTML_AJAX.grab(encodeURI('rpc.php?action=resettags'));
25    }
26    else if(mode == "condition") {
27       setCheckedValue(id, id.value);
28       HTML_AJAX.grab(encodeURI('rpc.php?action=tagcondition&mode=' + id.value));
29    }
30    
31    refreshAvailableTags();
32    refreshSelectedTags();
33    refreshPhotoIndex();
34
35 }
36
37 function refreshAvailableTags()
38 {
39    // update available tags
40    var avail_tags = document.getElementById('available_tags');
41    avail_tags.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=show_available_tags'));
42 }
43
44 function refreshSelectedTags()
45 {
46    // update selected tags
47    var selected_tags = document.getElementById("selected_tags");
48    selected_tags.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=show_selected_tags'));
49 }
50
51 function showPhotoIndex(begin_with)
52 {
53    if(begin_with == undefined)
54       HTML_AJAX.replace(document.getElementById("content"), encodeURI('rpc.php?action=show_photo_index'));
55    else
56       HTML_AJAX.replace(document.getElementById("content"), encodeURI('rpc.php?action=show_photo_index&begin_with=' + begin_with));
57 }
58
59 function showBubbleDetails(object, id, direction)
60 {
61    HTML_AJAX.replace(object, encodeURI('rpc.php?action=showbubbledetails&id=' + id + '&direction=" + direction'));
62 }
63
64 // if photo index is currently shown, refresh it
65 function refreshPhotoIndex()
66 {
67    if(document.getElementById("matrix") != undefined) {
68       showPhotoIndex();
69    }
70 }
71
72 function click(object)
73 {
74    if(object.blur)
75       object.blur();
76
77 }
78
79 // set the radio button with the given value as being checked
80 // do nothing if there are no radio buttons
81 // if the given value does not exist, all the radio buttons
82 // are reset to unchecked
83 function setCheckedValue(condition, value) {
84
85    var count = condition.length;
86    if(count == undefined) {
87       condition.checked = (condition.value == value.toString());
88       return;
89    }
90    for(var i = 0; i < count; i++) {
91       condition[i].checked = false;
92       if(condition[i].value == value.toString()) {
93          condition[i].checked = true;
94       }
95    }
96 }
97
98 function startSearch(searchfor)
99 {
100    HTML_AJAX.grab(encodeURI('rpc.php?action=search&for=' + searchfor));
101    showPhotoIndex();
102
103 }
104
105 function clearSearch()
106 {
107    document.getElementsByName('searchfor')[0].value = '';
108 }