In daily development, such a situation often arises. There are a number of functions that are generic. And every JavaScript is written once, which is very disturbing for maintenance. Therefore, the public functions need to be written in an external JS file. In this case, we need to introduce external public files. The following is the introduction of external public JS files in the JavaScript component in the conversion.
//Load JS fileLoadscriptfile (getvariable ("Internal.Transformation.Filename.Directory", "") + "/common_functions.js");varMptype = getvariable ("Mptype", "" ");varCyclecount = Str2Num (getvariable ("Collect_cycle_count", "1"));varPrevcycle = Str2Num (getvariable ("Cycle_prev_value", "0"));//invoking a method in a JS filevarColinfo =initcycletime (Mptype, prevcycle, cyclecount);varStartTime = Date2str (Colinfo[0], "Yyyy-mm-dd HH:mm:ss");varEndTime = Date2str (colinfo[1], "Yyyy-mm-dd HH:mm:ss"); WriteToLog ("M", "Time:" +starttime+ "," +endtime);
Kettle convert JavaScript to load external JS file