Tuesday, November 13, 2007

Hiding Clientside Source...

One of the problems with 'Silverlight 1.0' is that you can't hide your JavaScript source... One trick you can do is to user the Silverlight downloader to 'download' source when it returns you can pull the text and eval it like you would a 'JSON' array. This way class, controls or other scripted objects can be abstracted from the source and further the HTML will also be cleaner and no one will be able to see the your source without alot more jumping around.

So the code 'might' look like this:

Site.Scene.prototype =
{
handleLoad: function(control, userContext, rootElement)
{
this.control = control;
this.root = control.content.root;

this.downloadControlsXaml();
},

downloadControlsXaml: function()
{
//Menu
var downloader = this.control.createObject("downloader");
downloader.addEventListener("completed", Silverlight.createDelegate(this, this.JScriptObjDownloadCompleted));
downloader.open("GET", "control/object.js");
downloader.send();
},

JScriptObjDownloadCompleted: function(sender, eventArgs)
{
var xamlItem = sender.getResponseText("");

this.Object = eval( xamlItem );
// some more code...

}
}

I'm not saying you should do this... just that it can be done.

No comments:

Post a Comment