DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
QueryString Object
function QueryString(path)
{
this.path = path;
this.toString = function()
{
result = this.path + "?";
for(element in this)
{
if(typeof this[element] != 'function' && element != 'path')
{
result += element + "=" + this[element] + "&";
}
}
return result;
}
this.toLink = function(text)
{
return "<a href=\"" + this.toString() + "\">" + text + "</a>";
}
}
Now i can get rid of mess link this: url = '/pictures/crop?id=<%= @picture.id %>' + '&w=' + dd_picturer.w + '&h=' + dd_picturer.h + '&sx=' + (dd_crop.x - dd_picturer.x) + '&sy=' + (dd_crop.y - dd_picturer.y) + '&ex=' + dd_crop.w + '&ey=' + dd_crop.h; And make it readable like this:
myObj = new QueryString("http://codebehind.dk");
myObj.w = 100;
myObj.rx = 1000;
myObj.ry = 1000;
...
...
document.writeln(myObj.toLink("codebehind.dk"));





