some javascript code snippets