b7c6794b5eaa2c5af44be80caa32bf36f79fba83
[phpfspot.git] / phpfspot.js
1 function showImage(id)
2 {
3    content = document.getElementById("content");
4    content.innerHTML = HTML_AJAX.grab('rpc.php?action=showphoto&id=' + id);
5 }
6
7 function showCredits()
8 {
9    content = document.getElementById("content");
10    content.innerHTML = HTML_AJAX.grab('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('rpc.php?action=addtag&id=' + id);
18    }
19    else if(mode == "del") {
20       // del the tag from users session
21       HTML_AJAX.grab('rpc.php?action=deltag&id=' + id);
22    }
23    else if(mode == "reset") {
24       HTML_AJAX.grab('rpc.php?action=resettags');
25    }
26    else if(mode == "condition") {
27       setCheckedValue(id, id.value);
28       HTML_AJAX.grab('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    content = document.getElementById("available_tags");
41    content.innerHTML = HTML_AJAX.grab('rpc.php?action=show_available_tags');
42 }
43
44 function refreshSelectedTags()
45 {
46    // update selected tags
47    content = document.getElementById("selected_tags");
48    content.innerHTML = HTML_AJAX.grab('rpc.php?action=show_selected_tags');
49 }
50
51 function showPhotoIndex()
52 {
53    HTML_AJAX.replace(document.getElementById("content"), 'rpc.php?action=show_photo_index');
54
55 }
56
57 function showBubbleDetails(object, id, direction)
58 {
59    HTML_AJAX.replace(object, 'rpc.php?action=showbubbledetails&id=' + id + '&direction=" + direction');
60 }
61
62 // if photo index is currently shown, refresh it
63 function refreshPhotoIndex()
64 {
65    if(document.getElementById("matrix") != undefined) {
66       showPhotoIndex();
67    }
68 }
69
70 function click(object)
71 {
72    if(object.blur)
73       object.blur();
74
75 }
76
77 // set the radio button with the given value as being checked
78 // do nothing if there are no radio buttons
79 // if the given value does not exist, all the radio buttons
80 // are reset to unchecked
81 function setCheckedValue(condition, value) {
82
83    var count = condition.length;
84    if(count == undefined) {
85       condition.checked = (condition.value == value.toString());
86       return;
87    }
88    for(var i = 0; i < count; i++) {
89       condition[i].checked = false;
90       if(condition[i].value == value.toString()) {
91          condition[i].checked = true;
92       }
93    }
94 }
95
96