move javascript from detector to detector.js