diff --git a/app/static/js/cqi/api/client.js b/app/static/js/cqi/api/client.js index 14bf3690bea8e279fba770d1e7be46244aee6bd0..23695987057aaba1c9e07af927f5a3784250718a 100644 --- a/app/static/js/cqi/api/client.js +++ b/app/static/js/cqi/api/client.js @@ -524,7 +524,7 @@ cqi.api.APIClient = class APIClient { /** * Dump the values of <field> for match ranges <first> .. <last> - * in <subcorpus>. <field> is one of the CQI_CONST_FIELD_* constants. + * in <subcorpus>. <field> is one of the cqi.constants.FIELD_* constants. * * @param {string} subcorpus * @param {number} field @@ -561,9 +561,9 @@ cqi.api.APIClient = class APIClient { * * returns <n> (id, frequency) pairs flattened into a list of size 2*<n> * field is one of - * - CQI_CONST_FIELD_MATCH - * - CQI_CONST_FIELD_TARGET - * - CQI_CONST_FIELD_KEYWORD + * - cqi.constants.FIELD_MATCH + * - cqi.constants.FIELD_TARGET + * - cqi.constants.FIELD_KEYWORD * * NB: pairs are sorted by frequency desc. * diff --git a/app/static/js/cqi/constants.js b/app/static/js/cqi/constants.js new file mode 100644 index 0000000000000000000000000000000000000000..d888e240f1b1462498012c6d7979735b41f47a13 --- /dev/null +++ b/app/static/js/cqi/constants.js @@ -0,0 +1,6 @@ +cqi.constants = {}; + +cqi.constants.FIELD_KEYWORD = 9; +cqi.constants.FIELD_MATCH = 16; +cqi.constants.FIELD_MATCHEND = 17; +cqi.constants.FIELD_TARGET = 0; diff --git a/app/static/js/cqi/index.js b/app/static/js/cqi/index.js index 1558b3081a91a759a85f7e367213d2aa0aeda1f3..d941a870e8e163f0579648d31764af2147e124e7 100644 --- a/app/static/js/cqi/index.js +++ b/app/static/js/cqi/index.js @@ -1,6 +1 @@ var cqi = {}; - -cqi.CONST_FIELD_KEYWORD = 9; -cqi.CONST_FIELD_MATCH = 16; -cqi.CONST_FIELD_MATCHEND = 17; -cqi.CONST_FIELD_TARGET = 0; diff --git a/app/static/js/cqi/models/subcorpora.js b/app/static/js/cqi/models/subcorpora.js index 86e6cf67ec6d267ad94cf3231cd0c42c6b2973c1..aeba94856fca515a828867e566da18494957db60 100644 --- a/app/static/js/cqi/models/subcorpora.js +++ b/app/static/js/cqi/models/subcorpora.js @@ -145,17 +145,17 @@ cqi.models.subcorpora.SubcorpusCollection = class SubcorpusCollection extends cq let apiName = `${this.corpus.apiName}:${subcorpusName}`; /** @type {object} */ let fields = {}; - if (await this.client.api.cqp_subcorpus_has_field(apiName, cqi.CONST_FIELD_MATCH)) { - fields.match = cqi.CONST_FIELD_MATCH; + if (await this.client.api.cqp_subcorpus_has_field(apiName, cqi.constants.FIELD_MATCH)) { + fields.match = cqi.constants.FIELD_MATCH; } - if (await this.client.api.cqp_subcorpus_has_field(apiName, cqi.CONST_FIELD_MATCHEND)) { - fields.matchend = cqi.CONST_FIELD_MATCHEND + if (await this.client.api.cqp_subcorpus_has_field(apiName, cqi.constants.FIELD_MATCHEND)) { + fields.matchend = cqi.constants.FIELD_MATCHEND } - if (await this.client.api.cqp_subcorpus_has_field(apiName, cqi.CONST_FIELD_TARGET)) { - fields.target = cqi.CONST_FIELD_TARGET + if (await this.client.api.cqp_subcorpus_has_field(apiName, cqi.constants.FIELD_TARGET)) { + fields.target = cqi.constants.FIELD_TARGET } - if (await this.client.api.cqp_subcorpus_has_field(apiName, cqi.CONST_FIELD_KEYWORD)) { - fields.keyword = cqi.CONST_FIELD_KEYWORD + if (await this.client.api.cqp_subcorpus_has_field(apiName, cqi.constants.FIELD_KEYWORD)) { + fields.keyword = cqi.constants.FIELD_KEYWORD } return { api_name: apiName, diff --git a/app/templates/_scripts.html.j2 b/app/templates/_scripts.html.j2 index 2b84659a78b6f99df3fb1e8c72ab0eba22aa2694..8e8dd343ee41e5d82830d319448efbf97dc61613 100644 --- a/app/templates/_scripts.html.j2 +++ b/app/templates/_scripts.html.j2 @@ -18,6 +18,7 @@ filters='rjsmin', output='gen/cqi.%(version)s.js', 'js/cqi/index.js', + 'js/cqi/constants.js', 'js/cqi/errors.js', 'js/cqi/status.js', 'js/cqi/api/index.js',