Nouvelles compilations en JS des scripts + site démo.

This commit is contained in:
Fabrice PENHOËT 2021-11-09 16:49:36 +01:00
parent 6998eb67aa
commit 7053679a49
11 changed files with 55 additions and 47 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -67,7 +67,7 @@ var FreeDatas2HTML = (function () {
break;
}
if (datas2Parse.trim() !== "")
this.parser.datas2Parse = datas2Parse.trim();
this.parser.datas2Parse = datas2Parse;
else if (datasRemoteSource !== undefined)
this.parser.setRemoteSource(datasRemoteSource);
}
@ -219,12 +219,6 @@ var FreeDatas2HTML = (function () {
enumerable: true,
configurable: true
});
FreeDatas2HTML.prototype.datasCounter2HTML = function () {
if (this.datasCounterElt !== undefined) {
this.datasCounterElt = FreeDatas2HTML.checkInDOMById(this.datasCounterElt);
this.datasCounterElt.eltDOM.textContent = "" + this._nbDatasValid;
}
};
FreeDatas2HTML.prototype.refreshView = function () {
if (this._fields.length === 0 || this._datasViewElt === undefined)
throw new Error(errors.converterRefreshFail);
@ -245,6 +239,12 @@ var FreeDatas2HTML = (function () {
this.pagination.pages2HTML();
}
};
FreeDatas2HTML.prototype.datasCounter2HTML = function () {
if (this.datasCounterElt !== undefined) {
this.datasCounterElt = FreeDatas2HTML.checkInDOMById(this.datasCounterElt);
this.datasCounterElt.eltDOM.textContent = "" + this._nbDatasValid;
}
};
FreeDatas2HTML.prototype.datas2HTML = function () {
if (this.datasSortedField !== undefined) {
var field_1 = this._fields[this.datasSortedField.datasFieldNb];
@ -278,13 +278,12 @@ var FreeDatas2HTML = (function () {
}
this._nbDatasValid = nbTotal;
if (this._fields2Rend.length !== 0) {
var newDatas2Display = [];
var realFields = this.realFields2Rend(), newDatas2Display = [];
for (var row in datas2Display) {
var i = 0, newData = {};
var newData = {};
for (var field in datas2Display[row]) {
if (this._fields2Rend.indexOf(i) !== -1)
if (realFields.indexOf(field) !== -1)
newData[field] = datas2Display[row][field];
i++;
}
newDatas2Display.push(newData);
}

View File

@ -120,8 +120,6 @@ var ParserForJSON = (function () {
}
}
fields = goodFields;
console.log(datasParsed.fields);
console.log(goodFields);
if (fields.length === 0)
throw new Error(errors.parserFail);
for (i = 0; i < nbDatas; i++) {

View File

@ -21,16 +21,16 @@ var SortingField = (function () {
enumerable: true,
configurable: true
});
Object.defineProperty(SortingField.prototype, "fieldsDOMSelector", {
Object.defineProperty(SortingField.prototype, "datasFieldNb", {
get: function () {
return this._fieldsDOMSelector;
return this._datasFieldNb;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SortingField.prototype, "datasFieldNb", {
Object.defineProperty(SortingField.prototype, "fieldsDOMSelector", {
get: function () {
return this._datasFieldNb;
return this._fieldsDOMSelector;
},
enumerable: true,
configurable: true
@ -49,8 +49,8 @@ var SortingField = (function () {
else if (fields.length !== this._converter.realFields2Rend().length)
throw new Error(errors.sortingFieldsNbFail);
else {
var index = this._converter.getFieldDisplayRank(this._datasFieldNb);
var htmlContent = void 0;
var index = this._converter.getFieldDisplayRank(this._datasFieldNb);
htmlContent = fields[index].innerHTML;
htmlContent = "<a href='#freeDatas2HTMLSorting" + this._datasFieldNb + "' id='freeDatas2HTMLSorting" + this._datasFieldNb + "'>" + htmlContent + "</a>";
fields[index].innerHTML = htmlContent;

View File

@ -88,7 +88,7 @@ var initialise = function () { return __awaiter(void 0, void 0, void 0, function
filtre2.filter2HTML();
filtre3 = new Selector(converter, 5, { id: "filtre3" }, ",");
filtre3.filter2HTML();
mySearch = new SearchEngine(converter, { id: "search" }, [1, 3, 5]);
mySearch = new SearchEngine(converter, { id: "search" });
mySearch.label = "Qui cherche trouve ?";
mySearch.btnTxt = "Va chercher !";
mySearch.automaticSearch = true;
@ -110,11 +110,11 @@ var initialise = function () { return __awaiter(void 0, void 0, void 0, function
case 2:
e_1 = _a.sent();
console.error(e_1);
if (document.getElementById("datas") !== null)
document.getElementById("datas").innerHTML = "<strong>Désolé, mais un problème technique empêche l'affichage des données.</strong>";
document.getElementById("datas").innerHTML = "<div class=\"alert alert-warning\">D\u00E9sol\u00E9, mais un probl\u00E8me technique emp\u00EAche l'affichage des donn\u00E9es.</div>";
return [3, 3];
case 3: return [2];
}
});
}); };
console.log("Hello, ami développeur :-)\nLe code source TypeScript utilisé pour faire fonctionner cette page est lisible ici : :\nhttps://forge.chapril.org/Fab_Blab/freeDatas2HTML/src/branch/master/src/demo/exampleWithCSV.ts\nUn bug ? Une suggestion ? => fabrice@le-fab-lab.com");
initialise();

View File

@ -65,7 +65,7 @@ var initialise = function () { return __awaiter(void 0, void 0, void 0, function
}
pagination = new Pagination(converter, { id: "pages" }, "Page à afficher :");
pagination.options = { displayElement: { id: "paginationOptions" }, values: [15, 30, 50], name: "Nombre de lignes par page :" };
pagination.selectedValue = 30;
pagination.selectedValue = 15;
converter.pagination = pagination;
pagination.options2HTML();
filtre1 = new Selector(converter, 3, { id: "filtre1" });
@ -77,17 +77,16 @@ var initialise = function () { return __awaiter(void 0, void 0, void 0, function
converter.datasSortingFields = [sortingField1, sortingField2];
}
converter.datasViewElt = { id: "datas" };
converter.datasCounterElt = { id: "compteur" };
converter.refreshView();
return [3, 3];
case 2:
e_1 = _a.sent();
console.error(e_1);
if (document.getElementById("datas") !== null)
document.getElementById("datas").innerHTML = "<strong>Désolé, mais un problème technique empêche l'affichage des données.</strong>";
document.getElementById("datas").innerHTML = "<div class=\"alert alert-warning\">D\u00E9sol\u00E9, mais un probl\u00E8me technique emp\u00EAche l'affichage des donn\u00E9es.</div>";
return [3, 3];
case 3: return [2];
}
});
}); };
console.log("Hello, ami développeur :-)\nLe code source TypeScript utilisé pour faire fonctionner cette page est lisible ici : :\nhttps://forge.chapril.org/Fab_Blab/freeDatas2HTML/src/branch/master/src/demo/exampleWithHTML.ts\nUn bug ? Une suggestion ? => fabrice@le-fab-lab.com");
initialise();

View File

@ -34,15 +34,15 @@ 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, Pagination, Render, Selector, SortingField } from "../FreeDatas2HTML";
import { FreeDatas2HTML, Pagination, Render, SearchEngine, Selector, SortingField } from "../FreeDatas2HTML";
var initialise = function () { return __awaiter(void 0, void 0, void 0, function () {
var converter, myRender, pagination, sortingField1, sortingField2, sortingField3, filtre1, e_1;
var converter, myRender, pagination, sortingField1, sortingField2, sortingField3, filtre1, mySearch, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
converter = new FreeDatas2HTML("JSON");
converter.parser.setRemoteSource({ url: "http://localhost:8080/datas/posts.json", withCredentials: true, headers: [{ key: "Authorization", value: "Token YWxhZGRpbjpvcGVuc2VzYW1l" }] });
converter.parser.setRemoteSource({ url: "http://localhost:8080/datas/posts2.json", withCredentials: true, headers: [{ key: "Authorization", value: "Token YWxhZGRpbjpvcGVuc2VzYW1l" }] });
return [4, converter.run()];
case 1:
_a.sent();
@ -65,7 +65,7 @@ var initialise = function () { return __awaiter(void 0, void 0, void 0, function
converter.datasRender = myRender;
}
pagination = new Pagination(converter, { id: "pages" }, "Page à afficher :");
pagination.options = { displayElement: { id: "paginationOptions" }, values: [15, 30, 50, 100], name: "Nombre de lignes par page :" };
pagination.options = { displayElement: { id: "paginationOptions" }, values: [15, 30, 90, 150], name: "Nombre de lignes par page :" };
pagination.selectedValue = 15;
converter.pagination = pagination;
pagination.options2HTML();
@ -77,7 +77,14 @@ var initialise = function () { return __awaiter(void 0, void 0, void 0, function
}
filtre1 = new Selector(converter, 0, { id: "filtre1" });
filtre1.filter2HTML();
converter.datasFilters = [filtre1];
mySearch = new SearchEngine(converter, { id: "search" }, [2, 3]);
mySearch.label = "Qui cherche trouve ?";
mySearch.btnTxt = "Va chercher !";
mySearch.automaticSearch = true;
mySearch.nbCharsForSearch = 2;
mySearch.placeholder = "Tapes en NB, chef !";
mySearch.filter2HTML();
converter.datasFilters = [filtre1, mySearch];
converter.datasViewElt = { id: "datas" };
converter.datasCounterElt = { id: "compteur" };
converter.refreshView();
@ -85,11 +92,11 @@ var initialise = function () { return __awaiter(void 0, void 0, void 0, function
case 2:
e_1 = _a.sent();
console.error(e_1);
if (document.getElementById("datas") !== null)
document.getElementById("datas").innerHTML = "<strong>Désolé, mais un problème technique empêche l'affichage des données.</strong>";
document.getElementById("datas").innerHTML = "<div class=\"alert alert-warning\">D\u00E9sol\u00E9, mais un probl\u00E8me technique emp\u00EAche l'affichage des donn\u00E9es.</div>";
return [3, 3];
case 3: return [2];
}
});
}); };
console.log("Hello, ami développeur :-)\nLe code source TypeScript utilisé pour faire fonctionner cette page est lisible ici : :\nhttps://forge.chapril.org/Fab_Blab/freeDatas2HTML/src/branch/master/src/demo/exampleWithJSON.ts\nUn bug ? Une suggestion ? => fabrice@le-fab-lab.com");
initialise();

View File

@ -46,18 +46,15 @@ var initialise = function () {
var searchElt_1 = document.getElementById("search");
if (dataDisplayElt_1 === null || dataDisplayOptionsElt_1 === null || myFile_1 === null || myForm === null || pagesElt_1 === null || paginationElt_1 === null || searchElt_1 === null)
throw new Error("Tous les éléments HTML nécessaires au fonctionnement n'ont pas été trouvés dans la page;");
var reInitialise_1 = function () {
var converter_1;
var myRender_1 = new Render();
myRender_1.settings.allBegining = "<table class='table-hover'><caption>Nombre de résultats : <span id='counter'></span></caption>";
myFile_1.addEventListener("change", function (e) {
dataDisplayElt_1.innerHTML = "";
dataDisplayOptionsElt_1.innerHTML = "";
pagesElt_1.innerHTML = "";
paginationElt_1.innerHTML = "";
searchElt_1.innerHTML = "";
};
var converter_1;
var myRender_1 = new Render();
myRender_1.settings.allBegining = "<table class='table-hover'><caption>Nombre de résultats : <span id='counter'></span></caption>";
myFile_1.addEventListener("change", function (e) {
reInitialise_1();
converter_1 = new FreeDatas2HTML("CSV");
converter_1.datasRender = myRender_1;
var selectedFiles = myFile_1.files;
@ -103,7 +100,7 @@ var initialise = function () {
}
}
if (fields2Rend.length === 0)
dataDisplayElt_1.innerHTML = "<p class='text-danger'>Vous n'avez s\u00E9lectionn\u00E9 aucun champ \u00E0 afficher !</p>";
dataDisplayElt_1.innerHTML = "<p class='text-danger'>Merci de s\u00E9lectionner les champs que vous souhaitez afficher !</p>";
else {
converter_1.fields2Rend = fields2Rend;
converter_1.datasViewElt = { id: "datas" };
@ -116,8 +113,8 @@ var initialise = function () {
mySearch.filter2HTML();
converter_1.datasFilters = [mySearch];
var pagination = new Pagination(converter_1, { id: "pages" }, "Page à afficher :");
pagination.options = { displayElement: { id: "paginationOptions" }, values: [10, 20, 50, 500], name: "Choix de pagination :" };
pagination.selectedValue = 10;
pagination.options = { displayElement: { id: "paginationOptions" }, values: [10, 20, 50, 100, 500], name: "Choix de pagination :" };
pagination.selectedValue = 20;
converter_1.pagination = pagination;
pagination.options2HTML();
converter_1.datasCounterElt = { id: "counter" };
@ -128,12 +125,20 @@ var initialise = function () {
converter_1.datasSortingFields.push(sortingField);
}
converter_1.refreshView();
var here = window.location;
if (window.location.hash !== "") {
window.location.hash = "";
window.location.assign(here + "paginationOptions");
}
else
window.location.assign(here + "#paginationOptions");
}
});
}
catch (e) {
console.error(e);
document.getElementById("datas").innerHTML = "<strong>D\u00E9sol\u00E9, mais un probl\u00E8me impr\u00E9vu emp\u00EAche l'affichage des donn\u00E9es.</strong>";
document.getElementById("datas").innerHTML = "<div class=\"alert alert-warning\">D\u00E9sol\u00E9, mais un probl\u00E8me technique emp\u00EAche le fonctionnement normal de cette page.</div>";
}
};
console.log("Hello, ami développeur :-)\nLe code source TypeScript utilisé pour faire fonctionner cette page est lisible ici : :\nhttps://forge.chapril.org/Fab_Blab/freeDatas2HTML/src/branch/master/src/demo/exampleWithUserFile.ts\nUn bug ? Une suggestion ? => fabrice@le-fab-lab.com");
initialise();