3 if (typeof element
== "string") {
4 element
=document
.getElementById(element
);
7 extend_instance(element
,Element
);
11 function extend_instance(instance
,hash
) {
12 for (var name
in hash
) {
13 instance
[name
] = hash
[name
];
19 this.setStyle("display","none")
22 this.setStyle("display","block")
24 "visible": function () {
25 return (this.getStyle("display") != "none");
27 "toggle": function () {
36 function encodeURIComponent(str
) {
37 if (typeof(str
) == "string") {
38 return str
.replace(/=/g,'%3D').replace(/&/g
,'%26');
40 //checkboxes and radio buttons return objects instead of a string
41 else if(typeof(str
) == "object"){
44 return str
[prop
].replace(/=/g,'%3D').replace(/&/g
,'%26');
50 Form
.serialize = function(form_element
) {
51 return $(form_element
).serialize();
54 Ajax
.Updater = function (container
,url
,options
) {
55 this.container
= container
;
57 this.ajax
= new Ajax();
58 this.ajax
.requireLogin
= 1;
59 if (options
["onSuccess"]) {
60 this.ajax
.responseType
= Ajax
.JSON
;
61 this.ajax
.ondone
= options
["onSuccess"];
63 this.ajax
.responseType
= Ajax
.FBML
;
64 this.ajax
.ondone = function(data
) {
65 $(container
).setInnerFBML(data
);
68 if (options
["onFailure"]) {
69 this.ajax
.onerror
= options
["onFailure"];
72 if (!options
['parameters']) {
73 options
['parameters'] = {}
76 // simulate other verbs over post
77 if (options
['method']) {
78 options
['parameters']['_method'] = options
['method'];
81 this.ajax
.post(url
,options
['parameters']);
82 if (options
["onLoading"]) {
83 options
["onLoading"].call()
86 Ajax
.Request = function(url
,options
) {
87 Ajax
.Updater('unused',url
,options
);
90 PeriodicalExecuter = function (callback
, frequency
) {
91 setTimeout(callback
, frequency
*1000);
92 setTimeout(function() { new PeriodicalExecuter(callback
,frequency
); }, frequency
*1000);