javascript of TG operation