codejoust/session.js — pull request #8 by jhermsmeier (2012-01-07 18:21:47+00:00)
Title: Code read- and maintainability

In my (humble) opinion the code currently looks kind of cluttered, and is hard to read. So I thought I might take a shot a rewriting the whole thing and try to make it more readable (and easier to maintain)... In the process I also came up with a few changes:

### Changes

- the major change is how the options are set and (previously) `session_loaded` gets called. I think the example below explains this best:

```javascript
window.session = {
options: {
HTML5Location: false,
SessionTimeout: 5
},
start: function( data ) {
document.getElementsByTagName('pre')[0].innerHTML = JSONf.stringify( data, undefined, 2 );
}
};
```

- camel cased methods and option keys
- I got rid of some utility methods (`each`, `find`, `search`, `any`) by using normal `for` loops which eleminates the overhead that these utility methods cause (several function calls per object/array key/value pair)
- added `util.merge` for object merging (stolen from jQuery, but without the deep copy option)
- restructured the browser detection object
- renamed `utils` to `util`
- `utils.parse_json` and `utils.stringify_json` are now `json.parse` and `json.stringify`
- added `util.trim`