44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
const errors=require("./errors.js");
|
|
|
|
interface selectors
|
|
{
|
|
colCSV: number;
|
|
idElt: string;
|
|
eltDOM?: HTMLElement;
|
|
}
|
|
|
|
export class freeCSV2HTML
|
|
{
|
|
private _datasEltId: string = "";
|
|
private _datasUrl: string = "";
|
|
private _datasSelectors: selectors[] = [];
|
|
|
|
set datasEltId(id: string)
|
|
{
|
|
let checkContainerExist=document.getElementById(id);
|
|
if(checkContainerExist === null)
|
|
throw new Error(errors.elementNotFound+id);
|
|
else
|
|
this._datasEltId=id;
|
|
}
|
|
|
|
set datasUrl(url: string)
|
|
{
|
|
this._datasUrl=url;
|
|
}
|
|
|
|
set datasSelectors(selectors: selectors[])
|
|
{
|
|
let checkContainerExist: HTMLElement;
|
|
for(let i = 0; i < selectors.length; i++)
|
|
{
|
|
checkContainerExist=document.getElementById(selectors[i].idElt);
|
|
if(checkContainerExist === null)
|
|
throw new Error(errors.elementNotFound+selectors[i].idElt);
|
|
else
|
|
selectors[i].eltDOM=checkContainerExist;
|
|
}
|
|
this._datasSelectors=selectors;
|
|
}
|
|
|
|
} |