As I mentioned in an earlier post, I will be using flot for an upcoming project to generate graphs for a user. I would like to protect the formulas used to generate these graphs, so that someone can't simply copy the javascript. Is there a way to do this and still calculate the values on the fly with the ability for a user to change the graph dynamically. I've thought of obfuscating the javascript, but that doesn't seem to be enough.
+3
A:
You can keep your code on your server, and have the client-side code just make AJAX or JSONP calls to get graph data. If you package up your code so that the browser can fetch and execute it, the user can fetch and study it.
Pointy
2010-06-03 23:12:38
Can you describe in a little detail how to do this with a call to a php script so that I can get back a Javascript array of the data to pass to the graph?
Oren
2010-06-03 23:24:24
Well, client (Javascript) would use either XMLHttpRequest ("Ajax") or else a "JSONP" trick to issue an HTTP request to the server, passing in parameters for the graph data calculation as necessary. The script would run your secret formulas, and then package the return value (probably as JSON regardless of your invocation technique). The client would then unpack that and have a nice Javascript array (or whatever) to work with. I don't know php so I can't provide direct assistance with that part.
Pointy
2010-06-03 23:30:52
Thank you for your help.
Oren
2010-06-03 23:41:25
You're welcome, and thanks for accepting the answer!
Pointy
2010-06-03 23:49:59