50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
import { freeDatas2HTML } from "./freeDatas2HTML";
|
|
|
|
const initialise = async () =>
|
|
{
|
|
try
|
|
{
|
|
let converter=new freeDatas2HTML();
|
|
converter.datasViewElt={ id:"datas" };
|
|
converter.datasSelectors=[{ datasFieldNb:3, id:"filtre1"}, { datasFieldNb:4, id:"filtre2"},{ datasFieldNb:5, id:"filtre3", separator:"," }];
|
|
|
|
const mySort = (a: any, b: any, order: "asc"|"desc" = "asc") =>
|
|
{
|
|
const values = [ "> 100000", "> 1 et < 100 000", "≤ 1", "Traces", "Inexistant"];
|
|
if(order === "desc")
|
|
values.reverse();
|
|
if(values.indexOf(a) > values.indexOf(b))
|
|
return -1;
|
|
else if(values.indexOf(a) < values.indexOf(b))
|
|
return 1;
|
|
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.datasSourceUrl="http://localhost:8080/datas/elements-chimiques.csv";
|
|
await converter.run();
|
|
}
|
|
catch(e)
|
|
{
|
|
console.error(e);
|
|
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>";
|
|
}
|
|
}
|
|
initialise(); |