Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi,

    Yes of course, please read the answer to the question: “Q: How to include my own javascript files to implement my own operations?”, in the FAQ page of the plugin:

    https://wordpress.org/plugins/calculated-fields-form/faq/

    Best regards.

    Thread Starter hotcore

    (@hotcore)

    Supplementary question:

    I wanted to add this function:

    function norm(cd, v2, kd, f){
    var rc = 0;
    var yd = 0;
    if (f != 0) {
    yd = FLOOR(ABS(cd – f) / 365);
    if (yd > 17) {rc = rc + v2;} else {rc = rc + kd;};
    }
    return rc;
    }

    So, I created a norm.js file in the public js directory as described in the FAQ, but it does not work.

    In the predefined .js files there is a special syntax. Do I need that? Is it described somewhere?

    Thanks very much for the help. Hope i’ll get the hang of it soon.

    Best, Arie

    Plugin Author codepeople

    (@codepeople)

    Hi,

    If you want the function has a global scope, define it like:

    window[ ‘norm’ ] = function (cd, v2, kd, f){
    var rc = 0;
    var yd = 0;
    if (f != 0) {
    yd = FLOOR(ABS(cd – f) / 365);
    if (yd > 17) {rc = rc + v2;} else {rc = rc + kd;};
    }
    return rc;
    }

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Define extra Javascript functions’ is closed to new replies.