replaced func and moved library

moved library and replaced local code with library func
moved library

moved js library into js directory