copied directive javascript  change to the new format