diff --git a/public/JS/firstExample.app.js b/public/JS/firstExample.app.js
index ad05226..f1b4696 100644
--- a/public/JS/firstExample.app.js
+++ b/public/JS/firstExample.app.js
@@ -37,7 +37,7 @@ eval("var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPAC
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
-eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _freeDatas2HTML__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./freeDatas2HTML */ \"./src/freeDatas2HTML.ts\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\n\nvar initialise = function () { return __awaiter(void 0, void 0, void 0, function () {\n var converter, mySort, e_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 2, , 3]);\n converter = new _freeDatas2HTML__WEBPACK_IMPORTED_MODULE_0__.freeDatas2HTML();\n converter.datasViewElt = { id: \"datas\" };\n converter.datasSelectors = [{ datasFieldNb: 3, id: \"filtre1\" }, { datasFieldNb: 4, id: \"filtre2\" }, { datasFieldNb: 5, id: \"filtre3\", separator: \",\" }];\n mySort = function (a, b, order) {\n if (order === void 0) { order = \"asc\"; }\n var values = [\"> 100000\", \"> 1 et < 100 000\", \"≤ 1\", \"Traces\", \"Inexistant\"];\n if (order === \"desc\")\n values.reverse();\n if (values.indexOf(a) > values.indexOf(b))\n return -1;\n else if (values.indexOf(a) < values.indexOf(b))\n return 1;\n else\n return 0;\n };\n converter.datasSortingColumns = [{ datasFieldNb: 0 }, { datasFieldNb: 1 }, { datasFieldNb: 2 }, { datasFieldNb: 4 }];\n converter.datasSortingFunctions = [{ datasFieldNb: 4, sort: mySort }];\n converter.pagination =\n {\n selectedValue: 10,\n options: {\n displayElement: { id: \"paginationOptions\" },\n values: [10, 20, 50, 500],\n name: \"Choix de pagination :\"\n },\n pages: {\n displayElement: { id: \"pages\" },\n name: \"Page à afficher :\"\n }\n };\n converter.datasSourceUrl = \"http://localhost:8080/datas/elements-chimiques.csv\";\n return [4, converter.run()];\n case 1:\n _a.sent();\n return [3, 3];\n case 2:\n e_1 = _a.sent();\n console.error(e_1);\n if (document.getElementById(\"datas\") !== null)\n document.getElementById(\"datas\").innerHTML = \"Désolé, mais un problème technique empêche l'affichage des données.\";\n return [3, 3];\n case 3: return [2];\n }\n });\n}); };\ninitialise();\n\n\n//# sourceURL=webpack://freedatas2html/./src/firstExample.ts?");
+eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _freeDatas2HTML__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./freeDatas2HTML */ \"./src/freeDatas2HTML.ts\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\n\nvar initialise = function () { return __awaiter(void 0, void 0, void 0, function () {\n var mySort, converter, pagination, filtre1, filtre2, filtre3, sortingField1, sortingField2, sortingField3, sortingField4, e_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n _a.trys.push([0, 3, , 4]);\n mySort = function (a, b, order) {\n if (order === void 0) { order = \"asc\"; }\n var values = [\"> 100000\", \"> 1 et < 100 000\", \"≤ 1\", \"Traces\", \"Inexistant\"];\n if (order === \"desc\")\n values.reverse();\n if (values.indexOf(a) > values.indexOf(b))\n return -1;\n else if (values.indexOf(a) < values.indexOf(b))\n return 1;\n else\n return 0;\n };\n converter = new _freeDatas2HTML__WEBPACK_IMPORTED_MODULE_0__.FreeDatas2HTML();\n converter.datasViewElt = { id: \"datas\" };\n converter.datasSourceUrl = \"http://localhost:8080/datas/elements-chimiques.csv\";\n return [4, converter.parse()];\n case 1:\n _a.sent();\n converter.datasSortingFunctions = [{ datasFieldNb: 4, sort: mySort }];\n pagination = new _freeDatas2HTML__WEBPACK_IMPORTED_MODULE_0__.Pagination(converter, { id: \"pages\" }, \"Page à afficher :\");\n pagination.options = { displayElement: { id: \"paginationOptions\" }, values: [10, 20, 50, 500], name: \"Choix de pagination :\" };\n pagination.selectedValue = 10;\n converter.pagination = pagination;\n pagination.rend2HTML();\n return [4, converter.run()];\n case 2:\n _a.sent();\n filtre1 = new _freeDatas2HTML__WEBPACK_IMPORTED_MODULE_0__.Selector(converter);\n filtre1.datasViewElt = { id: \"filtre1\" };\n filtre1.datasFieldNb = 3;\n filtre1.selector2HTML();\n filtre2 = new _freeDatas2HTML__WEBPACK_IMPORTED_MODULE_0__.Selector(converter);\n filtre2.datasViewElt = { id: \"filtre2\" };\n filtre2.datasFieldNb = 4;\n filtre2.selector2HTML();\n filtre3 = new _freeDatas2HTML__WEBPACK_IMPORTED_MODULE_0__.Selector(converter);\n filtre3.datasViewElt = { id: \"filtre3\" };\n filtre3.datasFieldNb = 5;\n filtre3.separator = \",\";\n filtre3.selector2HTML();\n converter.datasSelectors = [filtre1, filtre2, filtre3];\n sortingField1 = new _freeDatas2HTML__WEBPACK_IMPORTED_MODULE_0__.SortingField(converter);\n sortingField1.datasFieldNb = 0;\n sortingField1.field2HTML();\n sortingField2 = new _freeDatas2HTML__WEBPACK_IMPORTED_MODULE_0__.SortingField(converter);\n sortingField2.datasFieldNb = 1;\n sortingField2.field2HTML();\n sortingField3 = new _freeDatas2HTML__WEBPACK_IMPORTED_MODULE_0__.SortingField(converter);\n sortingField3.datasFieldNb = 2;\n sortingField3.field2HTML();\n sortingField4 = new _freeDatas2HTML__WEBPACK_IMPORTED_MODULE_0__.SortingField(converter);\n sortingField4.datasFieldNb = 4;\n sortingField4.field2HTML();\n converter.datasSortingFields = [sortingField1, sortingField2, sortingField3, sortingField4];\n return [3, 4];\n case 3:\n e_1 = _a.sent();\n console.error(e_1);\n if (document.getElementById(\"datas\") !== null)\n document.getElementById(\"datas\").innerHTML = \"Désolé, mais un problème technique empêche l'affichage des données.\";\n return [3, 4];\n case 4: return [2];\n }\n });\n}); };\ninitialise();\n\n\n//# sourceURL=webpack://freedatas2html/./src/firstExample.ts?");
/***/ }),
@@ -48,7 +48,40 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _fre
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
-eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"freeDatas2HTML\": () => (/* binding */ freeDatas2HTML)\n/* harmony export */ });\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar Papa = __webpack_require__(/*! papaparse */ \"./node_modules/papaparse/papaparse.min.js\");\nvar errors = __webpack_require__(/*! ./errors.js */ \"./src/errors.js\");\nvar compare = __webpack_require__(/*! natural-orderby */ \"./node_modules/natural-orderby/esm/natural-orderby.js\").compare;\nvar freeDatas2HTML = (function () {\n function freeDatas2HTML() {\n this._datasViewElt = { id: \"\", eltDOM: undefined };\n this.datasHTML = \"\";\n this._datasSelectors = [];\n this._datasSortingColumns = [];\n this._datasSortingFunctions = [];\n this._datasSourceUrl = \"\";\n this.parseMeta = undefined;\n this.parseDatas = [];\n this.parseErrors = [];\n this.stopIfParseErrors = false;\n }\n freeDatas2HTML.isPositiveInteger = function (nb) {\n return (Number.isInteger(nb) === false || nb <= 0) ? false : true;\n };\n freeDatas2HTML.isNaturalNumber = function (nb) {\n return (Number.isInteger(nb) === false || nb < 0) ? false : true;\n };\n Object.defineProperty(freeDatas2HTML.prototype, \"datasViewElt\", {\n set: function (elt) {\n var checkContainerExist = document.getElementById(elt.id);\n if (checkContainerExist === null)\n throw new Error(errors.elementNotFound + elt.id);\n else {\n this._datasViewElt.id = elt.id;\n this._datasViewElt.eltDOM = checkContainerExist;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(freeDatas2HTML.prototype, \"datasSourceUrl\", {\n set: function (url) {\n if (url.trim().length === 0)\n throw new Error(errors.needUrl);\n else\n this._datasSourceUrl = url.trim();\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(freeDatas2HTML.prototype, \"datasSelectors\", {\n get: function () {\n return this._datasSelectors;\n },\n set: function (selectionElts) {\n this._datasSelectors = [];\n var checkContainerExist;\n for (var i in selectionElts) {\n checkContainerExist = document.getElementById(selectionElts[i].id);\n if (checkContainerExist === null)\n console.error(errors.elementNotFound + selectionElts[i].id);\n else if (freeDatas2HTML.isNaturalNumber(selectionElts[i].datasFieldNb) === false)\n console.error(errors.needNaturalNumber);\n else {\n selectionElts[i].eltDOM = checkContainerExist;\n if (selectionElts[i].separator !== undefined && selectionElts[i].separator === \"\")\n selectionElts[i].separator = undefined;\n this._datasSelectors.push(selectionElts[i]);\n }\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(freeDatas2HTML.prototype, \"datasSortingColumns\", {\n get: function () {\n return this._datasSortingColumns;\n },\n set: function (sortingColumns) {\n this._datasSortingColumns = [];\n for (var i = 0; i < sortingColumns.length; i++) {\n if (freeDatas2HTML.isNaturalNumber(sortingColumns[i].datasFieldNb) === false)\n console.error(errors.needNaturalNumber);\n else {\n sortingColumns[i].order = undefined;\n this._datasSortingColumns.push(sortingColumns[i]);\n }\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(freeDatas2HTML.prototype, \"datasSortingFunctions\", {\n set: function (sortingFunctions) {\n this._datasSortingFunctions = [];\n for (var i = 0; i < sortingFunctions.length; i++) {\n if (freeDatas2HTML.isNaturalNumber(sortingFunctions[i].datasFieldNb) === false)\n console.error(errors.needNaturalNumber);\n else\n this._datasSortingFunctions.push(sortingFunctions[i]);\n }\n },\n enumerable: false,\n configurable: true\n });\n freeDatas2HTML.prototype.getSortingFunctionForField = function (datasFieldNb) {\n for (var i in this._datasSortingFunctions) {\n if (this._datasSortingFunctions[i].datasFieldNb === datasFieldNb)\n return this._datasSortingFunctions[i];\n }\n return undefined;\n };\n Object.defineProperty(freeDatas2HTML.prototype, \"pagination\", {\n get: function () {\n return this._pagination;\n },\n set: function (config) {\n this._pagination = {};\n if (config.selectedValue !== undefined || config.options !== undefined) {\n if (config.pages === undefined)\n throw new Error(errors.needPagesSelectorElt);\n var checkContainerExist = document.getElementById(config.pages.displayElement.id);\n if (checkContainerExist === null)\n throw new Error(errors.elementNotFound + config.pages.displayElement.id);\n else {\n this.pagination.pages =\n {\n displayElement: {\n id: config.pages.displayElement.id,\n eltDOM: checkContainerExist\n },\n name: (config.pages.name) ? config.pages.name : \"Pages :\",\n selectedValue: 1,\n };\n }\n }\n if (config.options !== undefined) {\n var checkContainerExist = document.getElementById(config.options.displayElement.id);\n if (checkContainerExist === null)\n throw new Error(errors.elementNotFound + config.options.displayElement.id);\n else {\n for (var i = 0; i < config.options.values.length; i++) {\n if (freeDatas2HTML.isPositiveInteger(config.options.values[i]) === false)\n throw new Error(errors.needPositiveInteger);\n }\n this._pagination.options =\n {\n displayElement: { id: config.options.displayElement.id, eltDOM: checkContainerExist },\n name: (config.options.name) ? config.options.name : \"Pagination :\",\n values: config.options.values\n };\n }\n }\n if (config.selectedValue !== undefined) {\n if (config.options !== undefined && (config.options.values.indexOf(config.selectedValue) === -1))\n throw new Error(errors.needPaginationByDefaultBeInOptions);\n if (freeDatas2HTML.isPositiveInteger(config.selectedValue))\n this._pagination.selectedValue = config.selectedValue;\n else\n throw new Error(errors.needPositiveInteger);\n }\n },\n enumerable: false,\n configurable: true\n });\n freeDatas2HTML.prototype.parse = function () {\n return __awaiter(this, void 0, void 0, function () {\n var converter;\n return __generator(this, function (_a) {\n converter = this;\n return [2, new Promise(function (resolve, reject) {\n if (converter._datasSourceUrl !== \"\") {\n Papa.parse(converter._datasSourceUrl, {\n quoteChar: '\"',\n header: true,\n complete: function (results) {\n converter.parseErrors = results.errors;\n converter.parseDatas = results.data;\n var realFields = [];\n for (var i in results.meta.fields) {\n if (results.meta.fields[i].trim() !== \"\")\n realFields.push(results.meta.fields[i]);\n }\n results.meta.fields = realFields;\n converter.parseMeta = results.meta;\n resolve(true);\n },\n error: function (error) {\n reject(new Error(errors.parserFail));\n },\n download: true,\n skipEmptyLines: true,\n });\n }\n else\n reject(new Error(errors.needUrl));\n })];\n });\n });\n };\n freeDatas2HTML.prototype.run = function () {\n return __awaiter(this, void 0, void 0, function () {\n var converter_1, selectorsHTML, i, values, colName, row, checkedValue, checkedValues, i_1, checkedValue, j, selectElement, values_1, selectorsHTML, j, selectElement_1, indexSelectedValue, i;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (this._datasViewElt.eltDOM === undefined)\n throw new Error(errors.needDatasElt);\n if (this._datasSourceUrl === \"\")\n throw new Error(errors.needUrl);\n return [4, this.parse()];\n case 1:\n _a.sent();\n if (this.parseDatas.length === 0 || this.parseMeta.fields === undefined)\n throw new Error(errors.datasNotFound);\n else if (this.stopIfParseErrors && this.parseErrors.length !== 0)\n console.error(this.parseErrors);\n else {\n converter_1 = this;\n if (this._datasSelectors.length > 0) {\n selectorsHTML = [];\n for (i in this._datasSelectors) {\n if (this._datasSelectors[i].datasFieldNb > (this.parseMeta.fields.length - 1))\n throw new Error(errors.selectorFieldNotFound);\n else {\n values = [], colName = this.parseMeta.fields[this._datasSelectors[i].datasFieldNb];\n for (row in this.parseDatas) {\n if (this._datasSelectors[i].separator === undefined) {\n checkedValue = this.parseDatas[row][colName].trim();\n if (checkedValue !== \"\" && values.indexOf(checkedValue) === -1)\n values.push(checkedValue);\n }\n else {\n checkedValues = this.parseDatas[row][colName].split(this._datasSelectors[i].separator);\n for (i_1 in checkedValues) {\n checkedValue = checkedValues[i_1].trim();\n if (checkedValue !== \"\" && values.indexOf(checkedValue) === -1)\n values.push(checkedValue);\n }\n }\n }\n if (values.length > 0) {\n if (this.getSortingFunctionForField(this._datasSelectors[i].datasFieldNb) !== undefined)\n values.sort(this.getSortingFunctionForField(this._datasSelectors[i].datasFieldNb).sort);\n else\n values.sort(compare());\n this._datasSelectors[i].name = colName;\n this._datasSelectors[i].values = values;\n selectorsHTML[i] = \"\";\n this._datasSelectors[i].eltDOM.innerHTML = selectorsHTML[i];\n selectElement = document.getElementById(\"freeDatas2HTMLSelector\" + i);\n selectElement.addEventListener('change', function (e) {\n converter_1.datasHTML = converter_1.createDatasHTML(converter_1.parseMeta.fields, converter_1.parseDatas);\n converter_1.refreshView();\n });\n }\n }\n }\n }\n if (converter_1.pagination !== undefined && converter_1.pagination.options !== undefined && converter_1.pagination.options.values.length > 0) {\n values_1 = converter_1.pagination.options.values;\n selectorsHTML = \"\";\n converter_1.pagination.options.displayElement.eltDOM.innerHTML = selectorsHTML;\n selectElement_1 = document.getElementById(\"freeDatas2HTMLPaginationSelector\");\n if (converter_1.pagination.selectedValue !== undefined) {\n indexSelectedValue = converter_1.pagination.options.values.indexOf(converter_1.pagination.selectedValue) + 1;\n selectElement_1.value = \"\" + indexSelectedValue;\n }\n selectElement_1.addEventListener('change', function (e) {\n if (selectElement_1.value === \"0\")\n converter_1.pagination.selectedValue = undefined;\n else\n converter_1.pagination.selectedValue = values_1[Number(selectElement_1.value) - 1];\n converter_1.datasHTML = converter_1.createDatasHTML(converter_1.parseMeta.fields, converter_1.parseDatas);\n converter_1.refreshView();\n });\n }\n for (i in this._datasSortingColumns) {\n if (this._datasSortingColumns[i].datasFieldNb > (this.parseMeta.fields.length - 1))\n throw new Error(errors.sortingColumnsFieldNotFound);\n }\n this.datasHTML = this.createDatasHTML(this.parseMeta.fields, this.parseDatas);\n this.refreshView();\n return [2, true];\n }\n return [2];\n }\n });\n });\n };\n freeDatas2HTML.prototype.refreshView = function () {\n if (this._datasViewElt.eltDOM !== undefined) {\n var converter_2 = this;\n this._datasViewElt.eltDOM.innerHTML = this.datasHTML;\n if (this._datasSortingColumns.length > 0) {\n var getTableTh = document.querySelectorAll(\"table th\");\n if (getTableTh !== null) {\n var _loop_1 = function (i) {\n var datasFieldNb = this_1._datasSortingColumns[i].datasFieldNb;\n var htmlContent = getTableTh[datasFieldNb].innerHTML;\n htmlContent = \"\" + htmlContent + \"\";\n getTableTh[datasFieldNb].innerHTML = htmlContent;\n var sortingElement = document.getElementById(\"freeDatas2HTMLSorting\" + datasFieldNb);\n sortingElement.addEventListener(\"click\", function (e) {\n e.preventDefault();\n var order = converter_2.datasSortingColumns[i].order;\n if (order === undefined || order === \"desc\")\n converter_2.datasSortingColumns[i].order = \"asc\";\n else\n converter_2.datasSortingColumns[i].order = \"desc\";\n converter_2._datasSortedColumn = converter_2.datasSortingColumns[i];\n converter_2.datasHTML = converter_2.createDatasHTML(converter_2.parseMeta.fields, converter_2.parseDatas);\n converter_2.refreshView();\n });\n };\n var this_1 = this;\n for (var i in this._datasSortingColumns) {\n _loop_1(i);\n }\n }\n }\n }\n };\n freeDatas2HTML.prototype.createDatasHTML = function (fields, datas) {\n var checkSelectorExist, filters = [];\n for (var i in this._datasSelectors) {\n checkSelectorExist = document.querySelector(\"#\" + this._datasSelectors[i].id + \" select\");\n if (checkSelectorExist != null && checkSelectorExist.selectedIndex != 0)\n filters.push({ field: this._datasSelectors[i].name, value: this._datasSelectors[i].values[checkSelectorExist.selectedIndex - 1], separator: this._datasSelectors[i].separator });\n }\n if (this._datasSortedColumn !== undefined) {\n var col_1 = fields[this._datasSortedColumn.datasFieldNb];\n var colOrder_1 = this._datasSortedColumn.order;\n if (this.getSortingFunctionForField(this._datasSortedColumn.datasFieldNb) !== undefined) {\n var myFunction_1 = this.getSortingFunctionForField(this._datasSortedColumn.datasFieldNb);\n datas.sort(function (a, b) { return myFunction_1.sort(a[col_1], b[col_1], colOrder_1); });\n }\n else\n datas.sort(function (a, b) { return compare({ order: colOrder_1 })(a[col_1], b[col_1]); });\n }\n var firstData = 0;\n if (this.pagination !== undefined && this.pagination.selectedValue !== undefined && this.pagination.pages !== undefined && this.pagination.pages.selectedValue !== undefined)\n firstData = this.pagination.selectedValue * (this.pagination.pages.selectedValue - 1);\n var maxData = (this.pagination !== undefined && this.pagination.selectedValue !== undefined) ? this.pagination.selectedValue : datas.length + 1;\n var datasHTML = \"
\";\n for (var i in fields)\n datasHTML += \"\" + fields[i] + \" | \";\n datasHTML += \"\";\n var nbVisible = 0, nbTotal = 0;\n for (var row in datas) {\n var visible = true;\n if (filters.length !== 0) {\n var i = 0;\n while (filters[i] !== undefined && visible === true) {\n if (filters[i].separator === undefined) {\n if (datas[row][filters[i].field].trim() !== filters[i].value)\n visible = false;\n }\n else {\n visible = false;\n var checkedValues = datas[row][filters[i].field].split(filters[i].separator);\n for (var j in checkedValues) {\n if (checkedValues[j].trim() === filters[i].value) {\n visible = true;\n break;\n }\n }\n }\n i++;\n }\n }\n if (visible && nbTotal >= firstData && nbVisible < maxData) {\n datasHTML += \"\";\n for (var field in datas[row]) {\n if (fields.indexOf(field) !== -1)\n datasHTML += \"\" + datas[row][field] + \" | \";\n }\n datasHTML += \"
\";\n nbVisible++;\n nbTotal++;\n }\n else if (visible)\n nbTotal++;\n }\n datasHTML += \"
\";\n if (this.pagination !== undefined && this.pagination.selectedValue !== undefined && this.pagination.pages !== undefined && nbTotal > this.pagination.selectedValue) {\n var nbPages = Math.ceil(nbTotal / this.pagination.selectedValue);\n var selectorsHTML = \"\";\n this.pagination.pages.displayElement.eltDOM.innerHTML = selectorsHTML;\n var selectElement_2 = document.getElementById(\"freeDatas2HTMLPagesSelector\");\n if (this.pagination.pages.selectedValue !== undefined)\n selectElement_2.value = \"\" + this.pagination.pages.selectedValue;\n var converter_3 = this;\n this.pagination.pages.selectedValue = 1;\n selectElement_2.addEventListener('change', function (e) {\n converter_3.pagination.pages.selectedValue = Number(selectElement_2.value);\n converter_3.datasHTML = converter_3.createDatasHTML(converter_3.parseMeta.fields, converter_3.parseDatas);\n converter_3.refreshView();\n });\n }\n else if (this.pagination !== undefined && this.pagination.pages !== undefined)\n this.pagination.pages.displayElement.eltDOM.innerHTML = \"\";\n return datasHTML;\n };\n return freeDatas2HTML;\n}());\n\n\n\n//# sourceURL=webpack://freedatas2html/./src/freeDatas2HTML.ts?");
+eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"FreeDatas2HTML\": () => (/* binding */ FreeDatas2HTML),\n/* harmony export */ \"Pagination\": () => (/* reexport safe */ _freeDatas2HTMLPagination__WEBPACK_IMPORTED_MODULE_0__.Pagination),\n/* harmony export */ \"Selector\": () => (/* reexport safe */ _freeDatas2HTMLSelector__WEBPACK_IMPORTED_MODULE_1__.Selector),\n/* harmony export */ \"SortingField\": () => (/* reexport safe */ _freeDatas2HTMLSortingField__WEBPACK_IMPORTED_MODULE_2__.SortingField)\n/* harmony export */ });\n/* harmony import */ var _freeDatas2HTMLPagination__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./freeDatas2HTMLPagination */ \"./src/freeDatas2HTMLPagination.ts\");\n/* harmony import */ var _freeDatas2HTMLSelector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeDatas2HTMLSelector */ \"./src/freeDatas2HTMLSelector.ts\");\n/* harmony import */ var _freeDatas2HTMLSortingField__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./freeDatas2HTMLSortingField */ \"./src/freeDatas2HTMLSortingField.ts\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar Papa = __webpack_require__(/*! papaparse */ \"./node_modules/papaparse/papaparse.min.js\");\nvar errors = __webpack_require__(/*! ./errors.js */ \"./src/errors.js\");\nvar compare = __webpack_require__(/*! natural-orderby */ \"./node_modules/natural-orderby/esm/natural-orderby.js\").compare;\nvar FreeDatas2HTML = (function () {\n function FreeDatas2HTML() {\n this._datasViewElt = { id: \"\", eltDOM: undefined };\n this.datasHTML = \"\";\n this._datasSourceUrl = \"\";\n this._datasSortingFunctions = [];\n this.parseMetas = undefined;\n this.parseDatas = [];\n this.parseErrors = [];\n this.stopIfParseErrors = false;\n this.datasSelectors = [];\n this.datasSortingFields = [];\n }\n Object.defineProperty(FreeDatas2HTML.prototype, \"datasViewElt\", {\n set: function (elt) {\n var checkContainerExist = document.getElementById(elt.id);\n if (checkContainerExist === null)\n throw new Error(errors.elementNotFound + elt.id);\n else {\n this._datasViewElt.id = elt.id;\n this._datasViewElt.eltDOM = checkContainerExist;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(FreeDatas2HTML.prototype, \"datasSourceUrl\", {\n set: function (url) {\n if (url.trim().length === 0)\n throw new Error(errors.needUrl);\n else\n this._datasSourceUrl = url.trim();\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(FreeDatas2HTML.prototype, \"datasSortingFunctions\", {\n set: function (SortingFunctions) {\n this._datasSortingFunctions = [];\n for (var i = 0; i < SortingFunctions.length; i++) {\n this._datasSortingFunctions.push(SortingFunctions[i]);\n }\n },\n enumerable: false,\n configurable: true\n });\n FreeDatas2HTML.prototype.getSortingFunctionForField = function (datasFieldNb) {\n for (var i in this._datasSortingFunctions) {\n if (this._datasSortingFunctions[i].datasFieldNb === datasFieldNb)\n return this._datasSortingFunctions[i];\n }\n return undefined;\n };\n FreeDatas2HTML.prototype.parse = function () {\n return __awaiter(this, void 0, void 0, function () {\n var converter;\n return __generator(this, function (_a) {\n converter = this;\n return [2, new Promise(function (resolve, reject) {\n if (converter._datasSourceUrl !== \"\") {\n Papa.parse(converter._datasSourceUrl, {\n quoteChar: '\"',\n header: true,\n complete: function (results) {\n converter.parseErrors = results.errors;\n converter.parseDatas = results.data;\n var realFields = [];\n for (var i in results.meta.fields) {\n if (results.meta.fields[i].trim() !== \"\")\n realFields.push(results.meta.fields[i]);\n }\n results.meta.fields = realFields;\n converter.parseMetas = results.meta;\n resolve(true);\n },\n error: function (error) {\n reject(new Error(errors.parserFail));\n },\n download: true,\n skipEmptyLines: true,\n });\n }\n else\n reject(new Error(errors.needUrl));\n })];\n });\n });\n };\n FreeDatas2HTML.prototype.run = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (this._datasViewElt.eltDOM === undefined)\n throw new Error(errors.needDatasElt);\n if (this._datasSourceUrl === \"\")\n throw new Error(errors.needUrl);\n return [4, this.parse()];\n case 1:\n _a.sent();\n if (this.parseDatas.length === 0 || this.parseMetas.fields === undefined)\n throw new Error(errors.datasNotFound);\n else if (this.stopIfParseErrors && this.parseErrors.length !== 0)\n console.error(this.parseErrors);\n else {\n this.refreshView();\n return [2, true];\n }\n return [2];\n }\n });\n });\n };\n FreeDatas2HTML.prototype.refreshView = function () {\n if (this.parseMetas === undefined || this.parseMetas.fields === undefined || this._datasViewElt.eltDOM === undefined)\n throw new Error(errors.refreshFail);\n this.datasHTML = this.createDatasHTML(this.parseMetas.fields, this.parseDatas);\n this._datasViewElt.eltDOM.innerHTML = this.datasHTML;\n for (var i in this.datasSortingFields) {\n var field = this.datasSortingFields[i];\n field.field2HTML();\n }\n };\n FreeDatas2HTML.prototype.createDatasHTML = function (fields, datas) {\n if (this.datasSortedField !== undefined && this.datasSortedField.datasFieldNb !== undefined) {\n var field_1 = fields[this.datasSortedField.datasFieldNb];\n var fieldOrder_1 = this.datasSortedField.order;\n if (this.getSortingFunctionForField(this.datasSortedField.datasFieldNb) !== undefined) {\n var myFunction_1 = this.getSortingFunctionForField(this.datasSortedField.datasFieldNb);\n datas.sort(function (a, b) { return myFunction_1.sort(a[field_1], b[field_1], fieldOrder_1); });\n }\n else\n datas.sort(function (a, b) { return compare({ order: fieldOrder_1 })(a[field_1], b[field_1]); });\n }\n var firstData = 0;\n if (this.pagination !== undefined && this.pagination.selectedValue !== undefined && this.pagination.pages !== undefined && this.pagination.pages.selectedValue !== undefined)\n firstData = this.pagination.selectedValue * (this.pagination.pages.selectedValue - 1);\n var maxData = (this.pagination !== undefined && this.pagination.selectedValue !== undefined) ? this.pagination.selectedValue : datas.length + 1;\n var datasHTML = \"\";\n for (var i in fields)\n datasHTML += \"\" + fields[i] + \" | \";\n datasHTML += \"\";\n var nbVisible = 0, nbTotal = 0;\n for (var row in datas) {\n var visible = true;\n if (this.datasSelectors.length !== 0) {\n var i = 0;\n while (this.datasSelectors[i] !== undefined && visible === true) {\n visible = this.datasSelectors[i].dataIsOk(datas[row]);\n i++;\n }\n }\n if (visible && nbTotal >= firstData && nbVisible < maxData) {\n datasHTML += \"\";\n for (var field in datas[row]) {\n if (fields.indexOf(field) !== -1)\n datasHTML += \"\" + datas[row][field] + \" | \";\n }\n datasHTML += \"
\";\n nbVisible++;\n nbTotal++;\n }\n else if (visible)\n nbTotal++;\n }\n datasHTML += \"
\";\n if (this.pagination !== undefined)\n this.pagination.creaPageSelector(nbTotal);\n return datasHTML;\n };\n return FreeDatas2HTML;\n}());\n\n\n\n\n\n\n//# sourceURL=webpack://freedatas2html/./src/freeDatas2HTML.ts?");
+
+/***/ }),
+
+/***/ "./src/freeDatas2HTMLPagination.ts":
+/*!*****************************************!*\
+ !*** ./src/freeDatas2HTMLPagination.ts ***!
+ \*****************************************/
+/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
+
+"use strict";
+eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Pagination\": () => (/* binding */ Pagination)\n/* harmony export */ });\nvar errors = __webpack_require__(/*! ./errors.js */ \"./src/errors.js\");\nvar Pagination = (function () {\n function Pagination(converter, pagesElt, pagesName) {\n if (pagesName === void 0) { pagesName = \"Pages\"; }\n if (converter.parseMetas === undefined || converter.parseMetas.fields === undefined)\n throw new Error(errors.paginationNeedDatas);\n else {\n var checkContainerExist = document.getElementById(pagesElt.id);\n if (checkContainerExist === null)\n throw new Error(errors.elementNotFound + pagesElt.id);\n else {\n this._converter = converter;\n this._pages = { displayElement: { id: pagesElt.id, eltDOM: checkContainerExist }, name: pagesName };\n }\n }\n }\n Pagination.isPositiveInteger = function (nb) {\n return (Number.isInteger(nb) === false || nb <= 0) ? false : true;\n };\n Object.defineProperty(Pagination.prototype, \"selectedValue\", {\n get: function () {\n return this._selectedValue;\n },\n set: function (value) {\n if (value === undefined || !Pagination.isPositiveInteger(value))\n throw new Error(errors.needPositiveInteger);\n if (this.options !== undefined && this.options.values.indexOf(value) === -1)\n throw new Error(errors.needPaginationByDefaultBeInOptions);\n this._selectedValue = value;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Pagination.prototype, \"options\", {\n get: function () {\n return this._options;\n },\n set: function (options) {\n if (options !== undefined) {\n var checkContainerExist = document.getElementById(options.displayElement.id);\n if (checkContainerExist === null)\n throw new Error(errors.elementNotFound + options.displayElement.id);\n else\n options.displayElement.eltDOM = checkContainerExist;\n if (options.values.length === 0)\n throw new Error(errors.needPaginationOptionsValues);\n for (var i in options.values) {\n if (!Pagination.isPositiveInteger(options.values[i]))\n throw new Error(errors.needPositiveInteger);\n }\n options.name = (options.name === undefined) ? \"Pagination\" : options.name;\n this._options = options;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Pagination.prototype, \"pages\", {\n get: function () {\n return this._pages;\n },\n enumerable: false,\n configurable: true\n });\n Pagination.prototype.rend2HTML = function () {\n if (this._converter === undefined || this._options === undefined)\n throw new Error(errors.pagination2HTMLFail);\n else {\n var selectorsHTML = \"\";\n this._options.displayElement.eltDOM.innerHTML = selectorsHTML;\n var selectElement_1 = document.getElementById(\"freeDatas2HTMLPaginationSelector\");\n if (this._selectedValue !== undefined) {\n var indexSelectedValue = this._options.values.indexOf(this._selectedValue) + 1;\n selectElement_1.value = \"\" + indexSelectedValue;\n }\n var pagination_1 = this;\n selectElement_1.addEventListener(\"change\", function (e) {\n if (selectElement_1.value === \"0\")\n pagination_1._selectedValue = undefined;\n else\n pagination_1._selectedValue = pagination_1._options.values[Number(selectElement_1.value) - 1];\n pagination_1._converter.refreshView();\n });\n }\n };\n Pagination.prototype.creaPageSelector = function (nbTotal) {\n if (this.selectedValue !== undefined) {\n if (nbTotal > this.selectedValue) {\n var nbPages = Math.ceil(nbTotal / this.selectedValue);\n var selectorsHTML = \"\";\n this.pages.displayElement.eltDOM.innerHTML = selectorsHTML;\n var selectElement_2 = document.getElementById(\"freeDatas2HTMLPagesSelector\");\n if (this.pages.selectedValue !== undefined)\n selectElement_2.value = \"\" + this.pages.selectedValue;\n this.pages.selectedValue = 1;\n var pagination_2 = this;\n selectElement_2.addEventListener('change', function (e) {\n pagination_2.pages.selectedValue = Number(selectElement_2.value);\n pagination_2._converter.refreshView();\n });\n }\n else\n this.pages.displayElement.eltDOM.innerHTML = \"\";\n }\n else\n this.pages.displayElement.eltDOM.innerHTML = \"\";\n };\n return Pagination;\n}());\n\n\n\n//# sourceURL=webpack://freedatas2html/./src/freeDatas2HTMLPagination.ts?");
+
+/***/ }),
+
+/***/ "./src/freeDatas2HTMLSelector.ts":
+/*!***************************************!*\
+ !*** ./src/freeDatas2HTMLSelector.ts ***!
+ \***************************************/
+/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
+
+"use strict";
+eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"Selector\": () => (/* binding */ Selector)\n/* harmony export */ });\nvar compare = __webpack_require__(/*! natural-orderby */ \"./node_modules/natural-orderby/esm/natural-orderby.js\").compare;\nvar errors = __webpack_require__(/*! ./errors.js */ \"./src/errors.js\");\nvar Selector = (function () {\n function Selector(converter) {\n this._datasViewElt = { id: \"\", eltDOM: undefined };\n this.name = \"\";\n this.values = [];\n if (converter.parseMetas === undefined || converter.parseMetas.fields === undefined || converter.parseDatas.length === 0)\n throw new Error(errors.selectorNeedDatas);\n else\n this._converter = converter;\n }\n Object.defineProperty(Selector.prototype, \"datasViewElt\", {\n get: function () {\n return this._datasViewElt;\n },\n set: function (elt) {\n var checkContainerExist = document.getElementById(elt.id);\n if (checkContainerExist === null)\n throw new Error(errors.elementNotFound + elt.id);\n else {\n this._datasViewElt.id = elt.id;\n this._datasViewElt.eltDOM = checkContainerExist;\n }\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Selector.prototype, \"datasFieldNb\", {\n get: function () {\n return this._datasFieldNb;\n },\n set: function (datasFieldNb) {\n if (datasFieldNb !== undefined && this._converter.parseMetas.fields[datasFieldNb] === undefined)\n throw new Error(errors.selectorFieldNotFound);\n else\n this._datasFieldNb = datasFieldNb;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(Selector.prototype, \"separator\", {\n set: function (separator) {\n if (separator === \"\")\n this._separator = undefined;\n else\n this._separator = separator;\n },\n enumerable: false,\n configurable: true\n });\n Selector.prototype.selector2HTML = function () {\n if (this._converter === undefined || this._datasViewElt.eltDOM === undefined || this._datasFieldNb === undefined)\n throw new Error(errors.selector2HTMLFail);\n else {\n this.name = this._converter.parseMetas.fields[this._datasFieldNb];\n for (var row in this._converter.parseDatas) {\n if (this._separator === undefined) {\n var checkedValue = String(this._converter.parseDatas[row][this.name]).trim();\n if (checkedValue !== \"\" && this.values.indexOf(checkedValue) === -1)\n this.values.push(checkedValue);\n }\n else {\n var checkedValues = String(this._converter.parseDatas[row][this.name]).split(this._separator);\n for (var i in checkedValues) {\n var checkedValue = checkedValues[i].trim();\n if (checkedValue !== \"\" && this.values.indexOf(checkedValue) === -1)\n this.values.push(checkedValue);\n }\n }\n }\n if (this.values.length > 0) {\n if (this._converter.getSortingFunctionForField(this._datasFieldNb) !== undefined)\n this.values.sort(this._converter.getSortingFunctionForField(this._datasFieldNb).sort);\n else\n this.values.sort(compare());\n var selectorsHTML = \"\";\n this._datasViewElt.eltDOM.innerHTML = selectorsHTML;\n var selectElement = document.getElementById(\"freeDatas2HTML_\" + this._datasViewElt.id), mySelector_1 = this;\n selectElement.addEventListener(\"change\", function (e) {\n mySelector_1._converter.refreshView();\n });\n }\n }\n };\n Selector.prototype.getSelectionnedId = function () {\n var selectElement = document.getElementById(\"freeDatas2HTML_\" + this._datasViewElt.id);\n if (selectElement === undefined)\n return 0;\n else\n return parseInt(selectElement.value, 10);\n };\n Selector.prototype.dataIsOk = function (data) {\n if (this.name === undefined || this.name === \"\")\n throw new Error(errors.selectorCheckIsOkFail);\n var selectedValue = this.getSelectionnedId();\n if (selectedValue === 0)\n return true;\n else\n selectedValue = selectedValue - 1;\n if (this.values[selectedValue] === undefined)\n throw new Error(errors.selectorSelectedIndexNotFound);\n if (data[this.name] === undefined)\n return false;\n var selectedValueTxt = this.values[selectedValue];\n if (this._separator === undefined) {\n if (data[this.name].trim() !== selectedValueTxt)\n return false;\n else\n return true;\n }\n else {\n var find = false;\n var checkedValues = String(data[this.name]).split(this._separator);\n for (var j in checkedValues) {\n if (checkedValues[j].trim() === selectedValueTxt) {\n find = true;\n break;\n }\n }\n return find;\n }\n };\n return Selector;\n}());\n\n\n\n//# sourceURL=webpack://freedatas2html/./src/freeDatas2HTMLSelector.ts?");
+
+/***/ }),
+
+/***/ "./src/freeDatas2HTMLSortingField.ts":
+/*!*******************************************!*\
+ !*** ./src/freeDatas2HTMLSortingField.ts ***!
+ \*******************************************/
+/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
+
+"use strict";
+eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"SortingField\": () => (/* binding */ SortingField)\n/* harmony export */ });\nvar compare = __webpack_require__(/*! natural-orderby */ \"./node_modules/natural-orderby/esm/natural-orderby.js\").compare;\nvar errors = __webpack_require__(/*! ./errors.js */ \"./src/errors.js\");\nvar SortingField = (function () {\n function SortingField(converter, fieldsDOMSelector) {\n if (fieldsDOMSelector === void 0) { fieldsDOMSelector = \"th\"; }\n this._order = undefined;\n if (converter.parseMetas === undefined || converter.parseMetas.fields === undefined)\n throw new Error(errors.sortingFieldNeedDatas);\n else {\n var fields = document.querySelectorAll(fieldsDOMSelector);\n if (fields === undefined)\n throw new Error(errors.sortingFieldsNotInHTML);\n else if (fields.length !== converter.parseMetas.fields.length)\n throw new Error(errors.sortingFieldsNbFail);\n else {\n this._converter = converter;\n this._fieldsDOMSelector = fieldsDOMSelector;\n }\n }\n }\n Object.defineProperty(SortingField.prototype, \"datasFieldNb\", {\n get: function () {\n return this._datasFieldNb;\n },\n set: function (datasFieldNb) {\n if (datasFieldNb !== undefined && this._converter.parseMetas.fields[datasFieldNb] === undefined)\n throw new Error(errors.sortingFieldFieldNotFound);\n else\n this._datasFieldNb = datasFieldNb;\n },\n enumerable: false,\n configurable: true\n });\n Object.defineProperty(SortingField.prototype, \"order\", {\n get: function () {\n return this._order;\n },\n enumerable: false,\n configurable: true\n });\n SortingField.prototype.field2HTML = function () {\n if (this._converter === undefined || this._fieldsDOMSelector === \"\" || this._datasFieldNb === undefined)\n throw new Error(errors.sortingField2HTMLFail);\n else {\n var fields = document.querySelectorAll(this._fieldsDOMSelector);\n var htmlContent = fields[this._datasFieldNb].innerHTML;\n htmlContent = \"\" + htmlContent + \"\";\n fields[this._datasFieldNb].innerHTML = htmlContent;\n var sortingElement = document.getElementById(\"freeDatas2HTMLSorting\" + this._datasFieldNb), field_1 = this;\n sortingElement.addEventListener(\"click\", function (e) {\n e.preventDefault();\n var order = field_1._order;\n if (order === undefined || order === \"desc\")\n field_1._order = \"asc\";\n else\n field_1._order = \"desc\";\n field_1._converter.datasSortedField = field_1;\n field_1._converter.refreshView();\n });\n }\n };\n return SortingField;\n}());\n\n\n\n//# sourceURL=webpack://freedatas2html/./src/freeDatas2HTMLSortingField.ts?");
/***/ }),
@@ -58,7 +91,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
\***********************/
/***/ ((module) => {
-eval("module.exports =\n{\n datasNotFound : \"Aucune donnée n'a été trouvée.\",\n elementNotFound : \"Aucun élément HTML n'a été trouvé ayant comme \\\"id\\\" : \",\n needDatasElt: \"Merci de fournir un id valide pour l'élément où afficher les données.\",\n needNaturalNumber: \"Merci de fournir un nombre entier supérieur ou égal à zéro pour désigner chaque colonne.\",\n needPagesSelectorElt: \"Merci de fournir l'id de l'élément où afficher le sélecteur de pages.\",\n needPaginationByDefaultBeInOptions: \"La valeur de pagination par défaut doit faire partie des options proposées.\",\n needPositiveInteger: \"Merci de fournir un nombre entier supérieur à zéro pour désigner chaque option de pagination.\",\n needUrl: \"Merci de fournir une url valide pour le fichier CSV à parser.\",\n parserFail: \"La lecture des données du fichier a échoué.\",\n selectorFieldNotFound: \"Au moins une des colonnes devant servir à filtrer les données n'existe pas dans le fichier.\",\n sortingColumnsFieldNotFound: \"Au moins une des colonnes devant servir à classer les données n'existe pas dans le fichier.\",\n};\n\n//# sourceURL=webpack://freedatas2html/./src/errors.js?");
+eval("module.exports =\n{\n datasNotFound : \"Aucune donnée n'a été trouvée.\",\n elementNotFound : \"Aucun élément HTML n'a été trouvé ayant comme \\\"id\\\" : \",\n needDatasElt: \"Merci de fournir un id valide pour l'élément où afficher les données.\",\n needPagesSelectorElt: \"Merci de fournir l'id de l'élément où afficher le sélecteur de pages.\",\n needPaginationByDefaultBeInOptions: \"La valeur de pagination par défaut doit faire partie des options proposées.\",\n needPaginationOptionsValues: \"Vous n'avez fourni aucune options possibles pour la pagination.\", \n needPositiveInteger: \"Merci de fournir un nombre entier supérieur à zéro pour désigner chaque option de pagination.\",\n needUrl: \"Merci de fournir une url valide pour le fichier CSV à parser.\",\n paginationNeedDatas: \"Il ne peut y avoir de pagination, si les données n'ont pas été récupérées.\",\n pagination2HTMLFail : \"Toutes les donnée nécessaires à la création des sélecteurs de pagination n'ont pas été fournies.\",\n parserFail: \"La lecture des données du fichier a échoué.\",\n refreshFail: \"Le nom des champs et l'élement du DOM receveur sont nécessaires à l'affichage des données.\",\n selector2HTMLFail: \"Le création d'un filtre dans le DOM nécessite l'initialisation de l'élément HTML et du numéro du champs à filter.\",\n selectorCheckIsOkFail: \"Le test est lancé sur un filtre incorrectement initialisé ou sur un attribut absent de la donnée à tester.\",\n selectorFieldNotFound: \"Au moins une des colonnes devant servir à filtrer les données n'existe pas dans le fichier.\",\n selectorNeedDatas: \"Le création d'un filtre nécessite la transmission des données à filtrer.\",\n selectorSelectedIndexNotFound: \"La valeur sélectionnée n'a pas été trouvée dans la liste des champs.\",\n sortingField2HTMLFail: \"Toutes les donnée nécessaires à la création du lien de classement n'ont pas été fournies.\",\n sortingFieldNeedDatas: \"Le création d'un champ de classement nécessite la transmission de la liste des champs.\",\n sortingFieldsNbFail: \"Le nombre de champs trouvés dans le DOM ne correspond pas à celui des données à classer.\",\n sortingFieldsNotInHTML: \"Les champs pouvant servir à classer les données n'ont pas été trouvés dans le DOM.\",\n};\n\n//# sourceURL=webpack://freedatas2html/./src/errors.js?");
/***/ })
diff --git a/src/build/firstExample.js b/src/build/firstExample.js
index 429fbac..8e3720d 100644
--- a/src/build/firstExample.js
+++ b/src/build/firstExample.js
@@ -34,16 +34,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
-import { freeDatas2HTML } from "./freeDatas2HTML";
+import { FreeDatas2HTML, Pagination, Selector, SortingField } from "./freeDatas2HTML";
var initialise = function () { return __awaiter(void 0, void 0, void 0, function () {
- var converter, mySort, e_1;
+ var mySort, converter, pagination, filtre1, filtre2, filtre3, sortingField1, sortingField2, sortingField3, sortingField4, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
- _a.trys.push([0, 2, , 3]);
- converter = new freeDatas2HTML();
- converter.datasViewElt = { id: "datas" };
- converter.datasSelectors = [{ datasFieldNb: 3, id: "filtre1" }, { datasFieldNb: 4, id: "filtre2" }, { datasFieldNb: 5, id: "filtre3", separator: "," }];
+ _a.trys.push([0, 3, , 4]);
mySort = function (a, b, order) {
if (order === void 0) { order = "asc"; }
var values = ["> 100000", "> 1 et < 100 000", "≤ 1", "Traces", "Inexistant"];
@@ -56,33 +53,56 @@ var initialise = function () { return __awaiter(void 0, void 0, void 0, function
else
return 0;
};
- converter.datasSortingColumns = [{ datasFieldNb: 0 }, { datasFieldNb: 1 }, { datasFieldNb: 2 }, { datasFieldNb: 4 }];
- converter.datasSortingFunctions = [{ datasFieldNb: 4, sort: mySort }];
- converter.pagination =
- {
- selectedValue: 10,
- options: {
- displayElement: { id: "paginationOptions" },
- values: [10, 20, 50, 500],
- name: "Choix de pagination :"
- },
- pages: {
- displayElement: { id: "pages" },
- name: "Page à afficher :"
- }
- };
+ converter = new FreeDatas2HTML();
+ converter.datasViewElt = { id: "datas" };
converter.datasSourceUrl = "http://localhost:8080/datas/elements-chimiques.csv";
- return [4, converter.run()];
+ return [4, converter.parse()];
case 1:
_a.sent();
- return [3, 3];
+ converter.datasSortingFunctions = [{ datasFieldNb: 4, sort: mySort }];
+ pagination = new Pagination(converter, { id: "pages" }, "Page à afficher :");
+ pagination.options = { displayElement: { id: "paginationOptions" }, values: [10, 20, 50, 500], name: "Choix de pagination :" };
+ pagination.selectedValue = 10;
+ converter.pagination = pagination;
+ pagination.rend2HTML();
+ return [4, converter.run()];
case 2:
+ _a.sent();
+ filtre1 = new Selector(converter);
+ filtre1.datasViewElt = { id: "filtre1" };
+ filtre1.datasFieldNb = 3;
+ filtre1.selector2HTML();
+ filtre2 = new Selector(converter);
+ filtre2.datasViewElt = { id: "filtre2" };
+ filtre2.datasFieldNb = 4;
+ filtre2.selector2HTML();
+ filtre3 = new Selector(converter);
+ filtre3.datasViewElt = { id: "filtre3" };
+ filtre3.datasFieldNb = 5;
+ filtre3.separator = ",";
+ filtre3.selector2HTML();
+ converter.datasSelectors = [filtre1, filtre2, filtre3];
+ sortingField1 = new SortingField(converter);
+ sortingField1.datasFieldNb = 0;
+ sortingField1.field2HTML();
+ sortingField2 = new SortingField(converter);
+ sortingField2.datasFieldNb = 1;
+ sortingField2.field2HTML();
+ sortingField3 = new SortingField(converter);
+ sortingField3.datasFieldNb = 2;
+ sortingField3.field2HTML();
+ sortingField4 = new SortingField(converter);
+ sortingField4.datasFieldNb = 4;
+ sortingField4.field2HTML();
+ converter.datasSortingFields = [sortingField1, sortingField2, sortingField3, sortingField4];
+ return [3, 4];
+ case 3:
e_1 = _a.sent();
console.error(e_1);
if (document.getElementById("datas") !== null)
document.getElementById("datas").innerHTML = "Désolé, mais un problème technique empêche l'affichage des données.";
- return [3, 3];
- case 3: return [2];
+ return [3, 4];
+ case 4: return [2];
}
});
}); };
diff --git a/src/build/freeDatas2HTML.js b/src/build/freeDatas2HTML.js
index 95fce9e..7a7e9e3 100644
--- a/src/build/freeDatas2HTML.js
+++ b/src/build/freeDatas2HTML.js
@@ -37,26 +37,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
var Papa = require("papaparse");
var errors = require("./errors.js");
var compare = require('natural-orderby').compare;
-var freeDatas2HTML = (function () {
- function freeDatas2HTML() {
+var FreeDatas2HTML = (function () {
+ function FreeDatas2HTML() {
this._datasViewElt = { id: "", eltDOM: undefined };
this.datasHTML = "";
- this._datasSelectors = [];
- this._datasSortingColumns = [];
- this._datasSortingFunctions = [];
this._datasSourceUrl = "";
- this.parseMeta = undefined;
+ this._datasSortingFunctions = [];
+ this.parseMetas = undefined;
this.parseDatas = [];
this.parseErrors = [];
this.stopIfParseErrors = false;
+ this.datasSelectors = [];
+ this.datasSortingFields = [];
}
- freeDatas2HTML.isPositiveInteger = function (nb) {
- return (Number.isInteger(nb) === false || nb <= 0) ? false : true;
- };
- freeDatas2HTML.isNaturalNumber = function (nb) {
- return (Number.isInteger(nb) === false || nb < 0) ? false : true;
- };
- Object.defineProperty(freeDatas2HTML.prototype, "datasViewElt", {
+ Object.defineProperty(FreeDatas2HTML.prototype, "datasViewElt", {
set: function (elt) {
var checkContainerExist = document.getElementById(elt.id);
if (checkContainerExist === null)
@@ -69,7 +63,7 @@ var freeDatas2HTML = (function () {
enumerable: true,
configurable: true
});
- Object.defineProperty(freeDatas2HTML.prototype, "datasSourceUrl", {
+ Object.defineProperty(FreeDatas2HTML.prototype, "datasSourceUrl", {
set: function (url) {
if (url.trim().length === 0)
throw new Error(errors.needUrl);
@@ -79,122 +73,24 @@ var freeDatas2HTML = (function () {
enumerable: true,
configurable: true
});
- Object.defineProperty(freeDatas2HTML.prototype, "datasSelectors", {
- get: function () {
- return this._datasSelectors;
- },
- set: function (selectionElts) {
- this._datasSelectors = [];
- var checkContainerExist;
- for (var i in selectionElts) {
- checkContainerExist = document.getElementById(selectionElts[i].id);
- if (checkContainerExist === null)
- console.error(errors.elementNotFound + selectionElts[i].id);
- else if (freeDatas2HTML.isNaturalNumber(selectionElts[i].datasFieldNb) === false)
- console.error(errors.needNaturalNumber);
- else {
- selectionElts[i].eltDOM = checkContainerExist;
- if (selectionElts[i].separator !== undefined && selectionElts[i].separator === "")
- selectionElts[i].separator = undefined;
- this._datasSelectors.push(selectionElts[i]);
- }
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(freeDatas2HTML.prototype, "datasSortingColumns", {
- get: function () {
- return this._datasSortingColumns;
- },
- set: function (sortingColumns) {
- this._datasSortingColumns = [];
- for (var i = 0; i < sortingColumns.length; i++) {
- if (freeDatas2HTML.isNaturalNumber(sortingColumns[i].datasFieldNb) === false)
- console.error(errors.needNaturalNumber);
- else {
- sortingColumns[i].order = undefined;
- this._datasSortingColumns.push(sortingColumns[i]);
- }
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(freeDatas2HTML.prototype, "datasSortingFunctions", {
- set: function (sortingFunctions) {
+ Object.defineProperty(FreeDatas2HTML.prototype, "datasSortingFunctions", {
+ set: function (SortingFunctions) {
this._datasSortingFunctions = [];
- for (var i = 0; i < sortingFunctions.length; i++) {
- if (freeDatas2HTML.isNaturalNumber(sortingFunctions[i].datasFieldNb) === false)
- console.error(errors.needNaturalNumber);
- else
- this._datasSortingFunctions.push(sortingFunctions[i]);
+ for (var i = 0; i < SortingFunctions.length; i++) {
+ this._datasSortingFunctions.push(SortingFunctions[i]);
}
},
enumerable: true,
configurable: true
});
- freeDatas2HTML.prototype.getSortingFunctionForField = function (datasFieldNb) {
+ FreeDatas2HTML.prototype.getSortingFunctionForField = function (datasFieldNb) {
for (var i in this._datasSortingFunctions) {
if (this._datasSortingFunctions[i].datasFieldNb === datasFieldNb)
return this._datasSortingFunctions[i];
}
return undefined;
};
- Object.defineProperty(freeDatas2HTML.prototype, "pagination", {
- get: function () {
- return this._pagination;
- },
- set: function (config) {
- this._pagination = {};
- if (config.selectedValue !== undefined || config.options !== undefined) {
- if (config.pages === undefined)
- throw new Error(errors.needPagesSelectorElt);
- var checkContainerExist = document.getElementById(config.pages.displayElement.id);
- if (checkContainerExist === null)
- throw new Error(errors.elementNotFound + config.pages.displayElement.id);
- else {
- this.pagination.pages =
- {
- displayElement: {
- id: config.pages.displayElement.id,
- eltDOM: checkContainerExist
- },
- name: (config.pages.name) ? config.pages.name : "Pages :",
- selectedValue: 1,
- };
- }
- }
- if (config.options !== undefined) {
- var checkContainerExist = document.getElementById(config.options.displayElement.id);
- if (checkContainerExist === null)
- throw new Error(errors.elementNotFound + config.options.displayElement.id);
- else {
- for (var i = 0; i < config.options.values.length; i++) {
- if (freeDatas2HTML.isPositiveInteger(config.options.values[i]) === false)
- throw new Error(errors.needPositiveInteger);
- }
- this._pagination.options =
- {
- displayElement: { id: config.options.displayElement.id, eltDOM: checkContainerExist },
- name: (config.options.name) ? config.options.name : "Pagination :",
- values: config.options.values
- };
- }
- }
- if (config.selectedValue !== undefined) {
- if (config.options !== undefined && (config.options.values.indexOf(config.selectedValue) === -1))
- throw new Error(errors.needPaginationByDefaultBeInOptions);
- if (freeDatas2HTML.isPositiveInteger(config.selectedValue))
- this._pagination.selectedValue = config.selectedValue;
- else
- throw new Error(errors.needPositiveInteger);
- }
- },
- enumerable: true,
- configurable: true
- });
- freeDatas2HTML.prototype.parse = function () {
+ FreeDatas2HTML.prototype.parse = function () {
return __awaiter(this, void 0, void 0, function () {
var converter;
return __generator(this, function (_a) {
@@ -213,7 +109,7 @@ var freeDatas2HTML = (function () {
realFields.push(results.meta.fields[i]);
}
results.meta.fields = realFields;
- converter.parseMeta = results.meta;
+ converter.parseMetas = results.meta;
resolve(true);
},
error: function (error) {
@@ -229,9 +125,8 @@ var freeDatas2HTML = (function () {
});
});
};
- freeDatas2HTML.prototype.run = function () {
+ FreeDatas2HTML.prototype.run = function () {
return __awaiter(this, void 0, void 0, function () {
- var converter_1, selectorsHTML, i, values, colName, row, checkedValue, checkedValues, i_1, checkedValue, j, selectElement, values_1, selectorsHTML, j, selectElement_1, indexSelectedValue, i;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
@@ -242,81 +137,11 @@ var freeDatas2HTML = (function () {
return [4, this.parse()];
case 1:
_a.sent();
- if (this.parseDatas.length === 0 || this.parseMeta.fields === undefined)
+ if (this.parseDatas.length === 0 || this.parseMetas.fields === undefined)
throw new Error(errors.datasNotFound);
else if (this.stopIfParseErrors && this.parseErrors.length !== 0)
console.error(this.parseErrors);
else {
- converter_1 = this;
- if (this._datasSelectors.length > 0) {
- selectorsHTML = [];
- for (i in this._datasSelectors) {
- if (this._datasSelectors[i].datasFieldNb > (this.parseMeta.fields.length - 1))
- throw new Error(errors.selectorFieldNotFound);
- else {
- values = [], colName = this.parseMeta.fields[this._datasSelectors[i].datasFieldNb];
- for (row in this.parseDatas) {
- if (this._datasSelectors[i].separator === undefined) {
- checkedValue = this.parseDatas[row][colName].trim();
- if (checkedValue !== "" && values.indexOf(checkedValue) === -1)
- values.push(checkedValue);
- }
- else {
- checkedValues = this.parseDatas[row][colName].split(this._datasSelectors[i].separator);
- for (i_1 in checkedValues) {
- checkedValue = checkedValues[i_1].trim();
- if (checkedValue !== "" && values.indexOf(checkedValue) === -1)
- values.push(checkedValue);
- }
- }
- }
- if (values.length > 0) {
- if (this.getSortingFunctionForField(this._datasSelectors[i].datasFieldNb) !== undefined)
- values.sort(this.getSortingFunctionForField(this._datasSelectors[i].datasFieldNb).sort);
- else
- values.sort(compare());
- this._datasSelectors[i].name = colName;
- this._datasSelectors[i].values = values;
- selectorsHTML[i] = "";
- this._datasSelectors[i].eltDOM.innerHTML = selectorsHTML[i];
- selectElement = document.getElementById("freeDatas2HTMLSelector" + i);
- selectElement.addEventListener('change', function (e) {
- converter_1.datasHTML = converter_1.createDatasHTML(converter_1.parseMeta.fields, converter_1.parseDatas);
- converter_1.refreshView();
- });
- }
- }
- }
- }
- if (converter_1.pagination !== undefined && converter_1.pagination.options !== undefined && converter_1.pagination.options.values.length > 0) {
- values_1 = converter_1.pagination.options.values;
- selectorsHTML = "";
- converter_1.pagination.options.displayElement.eltDOM.innerHTML = selectorsHTML;
- selectElement_1 = document.getElementById("freeDatas2HTMLPaginationSelector");
- if (converter_1.pagination.selectedValue !== undefined) {
- indexSelectedValue = converter_1.pagination.options.values.indexOf(converter_1.pagination.selectedValue) + 1;
- selectElement_1.value = "" + indexSelectedValue;
- }
- selectElement_1.addEventListener('change', function (e) {
- if (selectElement_1.value === "0")
- converter_1.pagination.selectedValue = undefined;
- else
- converter_1.pagination.selectedValue = values_1[Number(selectElement_1.value) - 1];
- converter_1.datasHTML = converter_1.createDatasHTML(converter_1.parseMeta.fields, converter_1.parseDatas);
- converter_1.refreshView();
- });
- }
- for (i in this._datasSortingColumns) {
- if (this._datasSortingColumns[i].datasFieldNb > (this.parseMeta.fields.length - 1))
- throw new Error(errors.sortingColumnsFieldNotFound);
- }
- this.datasHTML = this.createDatasHTML(this.parseMeta.fields, this.parseDatas);
this.refreshView();
return [2, true];
}
@@ -325,55 +150,26 @@ var freeDatas2HTML = (function () {
});
});
};
- freeDatas2HTML.prototype.refreshView = function () {
- if (this._datasViewElt.eltDOM !== undefined) {
- var converter_2 = this;
- this._datasViewElt.eltDOM.innerHTML = this.datasHTML;
- if (this._datasSortingColumns.length > 0) {
- var getTableTh = document.querySelectorAll("table th");
- if (getTableTh !== null) {
- var _loop_1 = function (i) {
- var datasFieldNb = this_1._datasSortingColumns[i].datasFieldNb;
- var htmlContent = getTableTh[datasFieldNb].innerHTML;
- htmlContent = "" + htmlContent + "";
- getTableTh[datasFieldNb].innerHTML = htmlContent;
- var sortingElement = document.getElementById("freeDatas2HTMLSorting" + datasFieldNb);
- sortingElement.addEventListener("click", function (e) {
- e.preventDefault();
- var order = converter_2.datasSortingColumns[i].order;
- if (order === undefined || order === "desc")
- converter_2.datasSortingColumns[i].order = "asc";
- else
- converter_2.datasSortingColumns[i].order = "desc";
- converter_2._datasSortedColumn = converter_2.datasSortingColumns[i];
- converter_2.datasHTML = converter_2.createDatasHTML(converter_2.parseMeta.fields, converter_2.parseDatas);
- converter_2.refreshView();
- });
- };
- var this_1 = this;
- for (var i in this._datasSortingColumns) {
- _loop_1(i);
- }
- }
- }
+ FreeDatas2HTML.prototype.refreshView = function () {
+ if (this.parseMetas === undefined || this.parseMetas.fields === undefined || this._datasViewElt.eltDOM === undefined)
+ throw new Error(errors.refreshFail);
+ this.datasHTML = this.createDatasHTML(this.parseMetas.fields, this.parseDatas);
+ this._datasViewElt.eltDOM.innerHTML = this.datasHTML;
+ for (var i in this.datasSortingFields) {
+ var field = this.datasSortingFields[i];
+ field.field2HTML();
}
};
- freeDatas2HTML.prototype.createDatasHTML = function (fields, datas) {
- var checkSelectorExist, filters = [];
- for (var i in this._datasSelectors) {
- checkSelectorExist = document.querySelector("#" + this._datasSelectors[i].id + " select");
- if (checkSelectorExist != null && checkSelectorExist.selectedIndex != 0)
- filters.push({ field: this._datasSelectors[i].name, value: this._datasSelectors[i].values[checkSelectorExist.selectedIndex - 1], separator: this._datasSelectors[i].separator });
- }
- if (this._datasSortedColumn !== undefined) {
- var col_1 = fields[this._datasSortedColumn.datasFieldNb];
- var colOrder_1 = this._datasSortedColumn.order;
- if (this.getSortingFunctionForField(this._datasSortedColumn.datasFieldNb) !== undefined) {
- var myFunction_1 = this.getSortingFunctionForField(this._datasSortedColumn.datasFieldNb);
- datas.sort(function (a, b) { return myFunction_1.sort(a[col_1], b[col_1], colOrder_1); });
+ FreeDatas2HTML.prototype.createDatasHTML = function (fields, datas) {
+ if (this.datasSortedField !== undefined && this.datasSortedField.datasFieldNb !== undefined) {
+ var field_1 = fields[this.datasSortedField.datasFieldNb];
+ var fieldOrder_1 = this.datasSortedField.order;
+ if (this.getSortingFunctionForField(this.datasSortedField.datasFieldNb) !== undefined) {
+ var myFunction_1 = this.getSortingFunctionForField(this.datasSortedField.datasFieldNb);
+ datas.sort(function (a, b) { return myFunction_1.sort(a[field_1], b[field_1], fieldOrder_1); });
}
else
- datas.sort(function (a, b) { return compare({ order: colOrder_1 })(a[col_1], b[col_1]); });
+ datas.sort(function (a, b) { return compare({ order: fieldOrder_1 })(a[field_1], b[field_1]); });
}
var firstData = 0;
if (this.pagination !== undefined && this.pagination.selectedValue !== undefined && this.pagination.pages !== undefined && this.pagination.pages.selectedValue !== undefined)
@@ -386,23 +182,10 @@ var freeDatas2HTML = (function () {
var nbVisible = 0, nbTotal = 0;
for (var row in datas) {
var visible = true;
- if (filters.length !== 0) {
+ if (this.datasSelectors.length !== 0) {
var i = 0;
- while (filters[i] !== undefined && visible === true) {
- if (filters[i].separator === undefined) {
- if (datas[row][filters[i].field].trim() !== filters[i].value)
- visible = false;
- }
- else {
- visible = false;
- var checkedValues = datas[row][filters[i].field].split(filters[i].separator);
- for (var j in checkedValues) {
- if (checkedValues[j].trim() === filters[i].value) {
- visible = true;
- break;
- }
- }
- }
+ while (this.datasSelectors[i] !== undefined && visible === true) {
+ visible = this.datasSelectors[i].dataIsOk(datas[row]);
i++;
}
}
@@ -420,31 +203,13 @@ var freeDatas2HTML = (function () {
nbTotal++;
}
datasHTML += "";
- if (this.pagination !== undefined && this.pagination.selectedValue !== undefined && this.pagination.pages !== undefined && nbTotal > this.pagination.selectedValue) {
- var nbPages = Math.ceil(nbTotal / this.pagination.selectedValue);
- var selectorsHTML = "";
- this.pagination.pages.displayElement.eltDOM.innerHTML = selectorsHTML;
- var selectElement_2 = document.getElementById("freeDatas2HTMLPagesSelector");
- if (this.pagination.pages.selectedValue !== undefined)
- selectElement_2.value = "" + this.pagination.pages.selectedValue;
- var converter_3 = this;
- this.pagination.pages.selectedValue = 1;
- selectElement_2.addEventListener('change', function (e) {
- converter_3.pagination.pages.selectedValue = Number(selectElement_2.value);
- converter_3.datasHTML = converter_3.createDatasHTML(converter_3.parseMeta.fields, converter_3.parseDatas);
- converter_3.refreshView();
- });
- }
- else if (this.pagination !== undefined && this.pagination.pages !== undefined)
- this.pagination.pages.displayElement.eltDOM.innerHTML = "";
+ if (this.pagination !== undefined)
+ this.pagination.creaPageSelector(nbTotal);
return datasHTML;
};
- return freeDatas2HTML;
+ return FreeDatas2HTML;
}());
-export { freeDatas2HTML };
+export { FreeDatas2HTML };
+export { Pagination } from "./freeDatas2HTMLPagination";
+export { Selector } from "./freeDatas2HTMLSelector";
+export { SortingField } from "./freeDatas2HTMLSortingField";
diff --git a/src/build/freeDatas2HTMLInterfaces.js b/src/build/freeDatas2HTMLInterfaces.js
index e69de29..092bc2b 100644
--- a/src/build/freeDatas2HTMLInterfaces.js
+++ b/src/build/freeDatas2HTMLInterfaces.js
@@ -0,0 +1 @@
+;
diff --git a/src/build/freeDatas2HTMLPagination.js b/src/build/freeDatas2HTMLPagination.js
new file mode 100644
index 0000000..0a295f7
--- /dev/null
+++ b/src/build/freeDatas2HTMLPagination.js
@@ -0,0 +1,119 @@
+var errors = require("./errors.js");
+var Pagination = (function () {
+ function Pagination(converter, pagesElt, pagesName) {
+ if (pagesName === void 0) { pagesName = "Pages"; }
+ if (converter.parseMetas === undefined || converter.parseMetas.fields === undefined)
+ throw new Error(errors.paginationNeedDatas);
+ else {
+ var checkContainerExist = document.getElementById(pagesElt.id);
+ if (checkContainerExist === null)
+ throw new Error(errors.elementNotFound + pagesElt.id);
+ else {
+ this._converter = converter;
+ this._pages = { displayElement: { id: pagesElt.id, eltDOM: checkContainerExist }, name: pagesName };
+ }
+ }
+ }
+ Pagination.isPositiveInteger = function (nb) {
+ return (Number.isInteger(nb) === false || nb <= 0) ? false : true;
+ };
+ Object.defineProperty(Pagination.prototype, "selectedValue", {
+ get: function () {
+ return this._selectedValue;
+ },
+ set: function (value) {
+ if (value === undefined || !Pagination.isPositiveInteger(value))
+ throw new Error(errors.needPositiveInteger);
+ if (this.options !== undefined && this.options.values.indexOf(value) === -1)
+ throw new Error(errors.needPaginationByDefaultBeInOptions);
+ this._selectedValue = value;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(Pagination.prototype, "options", {
+ get: function () {
+ return this._options;
+ },
+ set: function (options) {
+ if (options !== undefined) {
+ var checkContainerExist = document.getElementById(options.displayElement.id);
+ if (checkContainerExist === null)
+ throw new Error(errors.elementNotFound + options.displayElement.id);
+ else
+ options.displayElement.eltDOM = checkContainerExist;
+ if (options.values.length === 0)
+ throw new Error(errors.needPaginationOptionsValues);
+ for (var i in options.values) {
+ if (!Pagination.isPositiveInteger(options.values[i]))
+ throw new Error(errors.needPositiveInteger);
+ }
+ options.name = (options.name === undefined) ? "Pagination" : options.name;
+ this._options = options;
+ }
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(Pagination.prototype, "pages", {
+ get: function () {
+ return this._pages;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Pagination.prototype.rend2HTML = function () {
+ if (this._converter === undefined || this._options === undefined)
+ throw new Error(errors.pagination2HTMLFail);
+ else {
+ var selectorsHTML = "";
+ this._options.displayElement.eltDOM.innerHTML = selectorsHTML;
+ var selectElement_1 = document.getElementById("freeDatas2HTMLPaginationSelector");
+ if (this._selectedValue !== undefined) {
+ var indexSelectedValue = this._options.values.indexOf(this._selectedValue) + 1;
+ selectElement_1.value = "" + indexSelectedValue;
+ }
+ var pagination_1 = this;
+ selectElement_1.addEventListener("change", function (e) {
+ if (selectElement_1.value === "0")
+ pagination_1._selectedValue = undefined;
+ else
+ pagination_1._selectedValue = pagination_1._options.values[Number(selectElement_1.value) - 1];
+ pagination_1._converter.refreshView();
+ });
+ }
+ };
+ Pagination.prototype.creaPageSelector = function (nbTotal) {
+ if (this.selectedValue !== undefined) {
+ if (nbTotal > this.selectedValue) {
+ var nbPages = Math.ceil(nbTotal / this.selectedValue);
+ var selectorsHTML = "";
+ this.pages.displayElement.eltDOM.innerHTML = selectorsHTML;
+ var selectElement_2 = document.getElementById("freeDatas2HTMLPagesSelector");
+ if (this.pages.selectedValue !== undefined)
+ selectElement_2.value = "" + this.pages.selectedValue;
+ this.pages.selectedValue = 1;
+ var pagination_2 = this;
+ selectElement_2.addEventListener('change', function (e) {
+ pagination_2.pages.selectedValue = Number(selectElement_2.value);
+ pagination_2._converter.refreshView();
+ });
+ }
+ else
+ this.pages.displayElement.eltDOM.innerHTML = "";
+ }
+ else
+ this.pages.displayElement.eltDOM.innerHTML = "";
+ };
+ return Pagination;
+}());
+export { Pagination };
diff --git a/src/build/freeDatas2HTMLSelector.js b/src/build/freeDatas2HTMLSelector.js
new file mode 100644
index 0000000..e44d6bc
--- /dev/null
+++ b/src/build/freeDatas2HTMLSelector.js
@@ -0,0 +1,129 @@
+var compare = require('natural-orderby').compare;
+var errors = require("./errors.js");
+var Selector = (function () {
+ function Selector(converter) {
+ this._datasViewElt = { id: "", eltDOM: undefined };
+ this.name = "";
+ this.values = [];
+ if (converter.parseMetas === undefined || converter.parseMetas.fields === undefined || converter.parseDatas.length === 0)
+ throw new Error(errors.selectorNeedDatas);
+ else
+ this._converter = converter;
+ }
+ Object.defineProperty(Selector.prototype, "datasViewElt", {
+ get: function () {
+ return this._datasViewElt;
+ },
+ set: function (elt) {
+ var checkContainerExist = document.getElementById(elt.id);
+ if (checkContainerExist === null)
+ throw new Error(errors.elementNotFound + elt.id);
+ else {
+ this._datasViewElt.id = elt.id;
+ this._datasViewElt.eltDOM = checkContainerExist;
+ }
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(Selector.prototype, "datasFieldNb", {
+ get: function () {
+ return this._datasFieldNb;
+ },
+ set: function (datasFieldNb) {
+ if (datasFieldNb !== undefined && this._converter.parseMetas.fields[datasFieldNb] === undefined)
+ throw new Error(errors.selectorFieldNotFound);
+ else
+ this._datasFieldNb = datasFieldNb;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(Selector.prototype, "separator", {
+ set: function (separator) {
+ if (separator === "")
+ this._separator = undefined;
+ else
+ this._separator = separator;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Selector.prototype.selector2HTML = function () {
+ if (this._converter === undefined || this._datasViewElt.eltDOM === undefined || this._datasFieldNb === undefined)
+ throw new Error(errors.selector2HTMLFail);
+ else {
+ this.name = this._converter.parseMetas.fields[this._datasFieldNb];
+ for (var row in this._converter.parseDatas) {
+ if (this._separator === undefined) {
+ var checkedValue = String(this._converter.parseDatas[row][this.name]).trim();
+ if (checkedValue !== "" && this.values.indexOf(checkedValue) === -1)
+ this.values.push(checkedValue);
+ }
+ else {
+ var checkedValues = String(this._converter.parseDatas[row][this.name]).split(this._separator);
+ for (var i in checkedValues) {
+ var checkedValue = checkedValues[i].trim();
+ if (checkedValue !== "" && this.values.indexOf(checkedValue) === -1)
+ this.values.push(checkedValue);
+ }
+ }
+ }
+ if (this.values.length > 0) {
+ if (this._converter.getSortingFunctionForField(this._datasFieldNb) !== undefined)
+ this.values.sort(this._converter.getSortingFunctionForField(this._datasFieldNb).sort);
+ else
+ this.values.sort(compare());
+ var selectorsHTML = "";
+ this._datasViewElt.eltDOM.innerHTML = selectorsHTML;
+ var selectElement = document.getElementById("freeDatas2HTML_" + this._datasViewElt.id), mySelector_1 = this;
+ selectElement.addEventListener("change", function (e) {
+ mySelector_1._converter.refreshView();
+ });
+ }
+ }
+ };
+ Selector.prototype.getSelectionnedId = function () {
+ var selectElement = document.getElementById("freeDatas2HTML_" + this._datasViewElt.id);
+ if (selectElement === undefined)
+ return 0;
+ else
+ return parseInt(selectElement.value, 10);
+ };
+ Selector.prototype.dataIsOk = function (data) {
+ if (this.name === undefined || this.name === "")
+ throw new Error(errors.selectorCheckIsOkFail);
+ var selectedValue = this.getSelectionnedId();
+ if (selectedValue === 0)
+ return true;
+ else
+ selectedValue = selectedValue - 1;
+ if (this.values[selectedValue] === undefined)
+ throw new Error(errors.selectorSelectedIndexNotFound);
+ if (data[this.name] === undefined)
+ return false;
+ var selectedValueTxt = this.values[selectedValue];
+ if (this._separator === undefined) {
+ if (data[this.name].trim() !== selectedValueTxt)
+ return false;
+ else
+ return true;
+ }
+ else {
+ var find = false;
+ var checkedValues = String(data[this.name]).split(this._separator);
+ for (var j in checkedValues) {
+ if (checkedValues[j].trim() === selectedValueTxt) {
+ find = true;
+ break;
+ }
+ }
+ return find;
+ }
+ };
+ return Selector;
+}());
+export { Selector };
diff --git a/src/build/freeDatas2HTMLSortingField.js b/src/build/freeDatas2HTMLSortingField.js
new file mode 100644
index 0000000..f44128a
--- /dev/null
+++ b/src/build/freeDatas2HTMLSortingField.js
@@ -0,0 +1,64 @@
+var compare = require('natural-orderby').compare;
+var errors = require("./errors.js");
+var SortingField = (function () {
+ function SortingField(converter, fieldsDOMSelector) {
+ if (fieldsDOMSelector === void 0) { fieldsDOMSelector = "th"; }
+ this._order = undefined;
+ if (converter.parseMetas === undefined || converter.parseMetas.fields === undefined)
+ throw new Error(errors.sortingFieldNeedDatas);
+ else {
+ var fields = document.querySelectorAll(fieldsDOMSelector);
+ if (fields === undefined)
+ throw new Error(errors.sortingFieldsNotInHTML);
+ else if (fields.length !== converter.parseMetas.fields.length)
+ throw new Error(errors.sortingFieldsNbFail);
+ else {
+ this._converter = converter;
+ this._fieldsDOMSelector = fieldsDOMSelector;
+ }
+ }
+ }
+ Object.defineProperty(SortingField.prototype, "datasFieldNb", {
+ get: function () {
+ return this._datasFieldNb;
+ },
+ set: function (datasFieldNb) {
+ if (datasFieldNb !== undefined && this._converter.parseMetas.fields[datasFieldNb] === undefined)
+ throw new Error(errors.sortingFieldFieldNotFound);
+ else
+ this._datasFieldNb = datasFieldNb;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(SortingField.prototype, "order", {
+ get: function () {
+ return this._order;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ SortingField.prototype.field2HTML = function () {
+ if (this._converter === undefined || this._fieldsDOMSelector === "" || this._datasFieldNb === undefined)
+ throw new Error(errors.sortingField2HTMLFail);
+ else {
+ var fields = document.querySelectorAll(this._fieldsDOMSelector);
+ var htmlContent = fields[this._datasFieldNb].innerHTML;
+ htmlContent = "" + htmlContent + "";
+ fields[this._datasFieldNb].innerHTML = htmlContent;
+ var sortingElement = document.getElementById("freeDatas2HTMLSorting" + this._datasFieldNb), field_1 = this;
+ sortingElement.addEventListener("click", function (e) {
+ e.preventDefault();
+ var order = field_1._order;
+ if (order === undefined || order === "desc")
+ field_1._order = "asc";
+ else
+ field_1._order = "desc";
+ field_1._converter.datasSortedField = field_1;
+ field_1._converter.refreshView();
+ });
+ }
+ };
+ return SortingField;
+}());
+export { SortingField };