function Buddy(hack){
this.hack = hack;
this.getHack = function(){return this.hack;}
this.setHack = function(hack){this.hack = hack;}
this.classUrl = '/scripts/classes/starters/startsimulator/Buddy.jsp';
this.save = function(func){
var t = this;
var req = new XMLHttpRequest();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4 && (req.status == 200 || req.status == 304)) {
var xml = req.responseXML;
if (xml.documentElement) {
if (func) eval(func);
}
}
}
}
var params = "";
params+= "&hack="+this.escape(this.strip(this.hack));
req.open('POST', this.classUrl+'?ac=save&noCache='+new Date().getTime()); //asynchroon
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-15');
req.setRequestHeader("Content-length", params.length);
req.setRequestHeader("Connection", "close");
req.send(params);
};
this.strip = function(str){
//return str.replace(/<script[^>]*?>.*?<\/script[^>]*?>/,'');
str = str.replace(/\n/gi,'');
str = str.replace(/\r/gi,'');
//alert(str.replace(/<script[^>]*?>.*?<\/script>/gi,''));
return str.replace(/<script[^>]*?>.*?<\/script>/gi,'');
};
//this.escape = function(str){ return escape(str).replace(/\+/gi,'%2B');}
this.escape = function(str){return encodeURIComponent(str);};
}
