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