Dan’s View

2008/10/25

Life the universe and 99% Javascript Apps

Filed under: Programming — Tags: — dan @ 13:59

So I have been tinkering with creating a web frontend for a simple tool for use at work. On thursday I knocked up the app in vanilla, MySQL+PHP+bTemplate and a few jokes were made about it not being very pritty, etc. So I have spent a few hours getting the logic sorted out for an application that has virtually no HTML. The browser load the HTML, and associated scripts and then all the rest runs in JavaScript. Dynamically generate the login form, handle cookies, etc… Although it is a very simple app it does work very quickly. Dynamically creating DOM/HTML nodes seems so far to be quick enough. Who knows maybe in the future I don’t touch HTML at all!

An example of the HTML is:

<html>
<head>
<script type=”text/javascript” src=”external/JSONError.js”></script>
<script type=”text/javascript” src=”external/JSON.js”></script>
<script type=”text/javascript” src=”js/lib.js”></script>
<script type=”text/javascript” src=”js/handlers.js”></script>
<script type=”text/javascript” src=”js/gui.js”></script>
<script type= “text/javascript”>
/*<![CDATA[*/
var jsonURL = "json.php";
/*]]>*/
</script>
</head>
<body>
<script type=”text/javascript” src=”js/init.js”></script>
</body>
</html>

And an example of init.js:

var body = document.body;

var cookies = new Cookies();
var divs = {};

var login = true;
var t = cookies.read(“LoggedIn”);
if(t != null && t == “1″) {
if(isLoggedIn()) {
login = false;
}
}

if(login == true) {
guiLoginBuild();
} else {
guiMainBuild();
}

Once it’s a bit more completed I will post the app up for people to enjoy.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress