favicon
[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=reset'));
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 = "Loading...";
42    avail_tags.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=show_available_tags'));
43 }
44
45 function refreshSelectedTags()
46 {
47    // update selected tags
48    var selected_tags = document.getElementById("selected_tags");
49    selected_tags.innerHTML = "Loading...";
50    selected_tags.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=show_selected_tags'));
51 }
52
53 function showPhotoIndex(begin_with)
54 {
55    if(begin_with == undefined)
56       HTML_AJAX.replace(document.getElementById("content"), encodeURI('rpc.php?action=show_photo_index'));
57    else
58       HTML_AJAX.replace(document.getElementById("content"), encodeURI('rpc.php?action=show_photo_index&begin_with=' + begin_with));
59 }
60
61 function showBubbleDetails(object, id, direction)
62 {
63    HTML_AJAX.replace(object, encodeURI('rpc.php?action=showbubbledetails&id=' + id + '&direction=" + direction'));
64 }
65
66 // if photo index is currently shown, refresh it
67 function refreshPhotoIndex()
68 {
69    if(document.getElementById("matrix") != undefined) {
70       showPhotoIndex();
71    }
72 }
73
74 function click(object)
75 {
76    if(object.blur)
77       object.blur();
78
79 }
80
81 // set the radio button with the given value as being checked
82 // do nothing if there are no radio buttons
83 // if the given value does not exist, all the radio buttons
84 // are reset to unchecked
85 function setCheckedValue(condition, value) {
86
87    var count = condition.length;
88    if(count == undefined) {
89       condition.checked = (condition.value == value.toString());
90       return;
91    }
92    for(var i = 0; i < count; i++) {
93       condition[i].checked = false;
94       if(condition[i].value == value.toString()) {
95          condition[i].checked = true;
96       }
97    }
98 }
99
100 function startTagSearch(searchfor)
101 {
102    HTML_AJAX.grab(encodeURI('rpc.php?action=tag_search&for=' + searchfor));
103    refreshAvailableTags();
104    refreshSelectedTags();
105    showPhotoIndex();
106
107 }
108
109 function clearSearch()
110 {
111    document.getElementsByName('searchfor')[0].value = '';
112 }