diff --git a/public/JS/exampleWithMixedFields.app.js b/public/JS/exampleWithMixedFields.app.js new file mode 100644 index 0000000..6ee99d7 --- /dev/null +++ b/public/JS/exampleWithMixedFields.app.js @@ -0,0 +1,2 @@ +/*! For license information please see exampleWithMixedFields.app.js.LICENSE.txt */ +(()=>{var e={196:(e,t,r)=>{"use strict";r.d(t,{q:()=>k});var n=function(e,t){return et?1:0},i=/(^0x[\da-fA-F]+$|^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?!\.\d+)(?=\D|\s|$))|\d+)/g,s=/^\s+|\s+$/g,a=/\s+/g,o=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,l=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[/-]\d{1,4}[/-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0+[1-9]{1}[0-9]*$/,d=/[^\x00-\x80]/,c=function(e,t){var r=e.localeCompare(t);return r?r/Math.abs(r):0},h=function(e,t){return et?1:0},f=function(e){if(0!==e.length){var t=Number(e);if(!Number.isNaN(t))return t}},p=function(e){return e.replace(a," ").replace(s,"")},g=function(e,t,r){if(o.test(e)&&(!u.test(e)||0===t||"."!==r[t-1]))return f(e)||0},m=function(e,t,r){return{parsedNumber:g(e,t,r),normalizedString:p(e)}},v=function(e){var t=function(e){return e.replace(i,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0")}(e).map(m);return t},_=function(e){return"function"==typeof e},b=function(e){return Number.isNaN(e)||e instanceof Number&&Number.isNaN(e.valueOf())},y=function(e){return null===e},w=function(e){return!(null===e||"object"!=typeof e||Array.isArray(e)||e instanceof Number||e instanceof String||e instanceof Boolean||e instanceof Date)},E=function(e){return"symbol"==typeof e},S=function(e){return void 0===e},F=function(e){if("string"==typeof e||e instanceof String||("number"==typeof e||e instanceof Number)&&!b(e)||"boolean"==typeof e||e instanceof Boolean||e instanceof Date){var t=function(e){return"boolean"==typeof e||e instanceof Boolean?Number(e).toString():"number"==typeof e||e instanceof Number?e.toString():e instanceof Date?e.getTime().toString():"string"==typeof e||e instanceof String?e.toLowerCase().replace(s,""):""}(e),r=function(e){var t=f(e);return void 0!==t?t:function(e){if(l.test(e)){var t=Date.parse(e);if(!Number.isNaN(t))return t}}(e)}(t);return{parsedNumber:r,chunks:v(r?""+r:t),value:e}}return{isArray:Array.isArray(e),isFunction:_(e),isNaN:b(e),isNull:y(e),isObject:w(e),isSymbol:E(e),isUndefined:S(e),value:e}},O=function(e){return"string"==typeof e&&("asc"===e||"desc"===e)};function k(e){var t,r;return function(e){return function(t,r){return function(e,t){return e.value===t.value?0:void 0!==e.parsedNumber&&void 0!==t.parsedNumber?n(e.parsedNumber,t.parsedNumber):e.chunks&&t.chunks?function(e,t){for(var r=e.length,i=t.length,s=Math.min(r,i),a=0;as||i>s?r<=s?-1:1:0}(e.chunks,t.chunks):function(e,t){return(e.chunks?!t.chunks:t.chunks)?e.chunks?-1:1:(e.isNaN?!t.isNaN:t.isNaN)?e.isNaN?-1:1:(e.isSymbol?!t.isSymbol:t.isSymbol)?e.isSymbol?-1:1:(e.isObject?!t.isObject:t.isObject)?e.isObject?-1:1:(e.isArray?!t.isArray:t.isArray)?e.isArray?-1:1:(e.isFunction?!t.isFunction:t.isFunction)?e.isFunction?-1:1:(e.isNull?!t.isNull:t.isNull)?e.isNull?-1:1:0}(e,t)}(F(t),F(r))*("desc"===e.order?-1:1)}}((r="asc","string"==typeof(t=e)&&O(t)?r=t:t&&"object"==typeof t&&t.order&&O(t.order)&&(r=t.order),{order:r}))}},460:function(e,t){var r,n;r=function e(){"use strict";var t="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t?t:{},r=!t.document&&!!t.postMessage,n=r&&/blob:/i.test((t.location||{}).protocol),i={},s=0,a={parse:function(r,n){var o=(n=n||{}).dynamicTyping||!1;if(w(o)&&(n.dynamicTypingFunction=o,o={}),n.dynamicTyping=o,n.transform=!!w(n.transform)&&n.transform,n.worker&&a.WORKERS_SUPPORTED){var l=function(){if(!a.WORKERS_SUPPORTED)return!1;var r,n,o=(r=t.URL||t.webkitURL||null,n=e.toString(),a.BLOB_URL||(a.BLOB_URL=r.createObjectURL(new Blob(["(",n,")();"],{type:"text/javascript"})))),l=new t.Worker(o);return l.onmessage=m,l.id=s++,i[l.id]=l}();return l.userStep=n.step,l.userChunk=n.chunk,l.userComplete=n.complete,l.userError=n.error,n.step=w(n.step),n.chunk=w(n.chunk),n.complete=w(n.complete),n.error=w(n.error),delete n.worker,void l.postMessage({input:r,config:n,workerId:l.id})}var f=null;return a.NODE_STREAM_INPUT,"string"==typeof r?f=n.download?new u(n):new c(n):!0===r.readable&&w(r.read)&&w(r.on)?f=new h(n):(t.File&&r instanceof File||r instanceof Object)&&(f=new d(n)),f.stream(r)},unparse:function(e,t){var r=!1,n=!0,i=",",s="\r\n",o='"',l=o+o,u=!1,d=null,c=!1;!function(){if("object"==typeof t){if("string"!=typeof t.delimiter||a.BAD_DELIMITERS.filter((function(e){return-1!==t.delimiter.indexOf(e)})).length||(i=t.delimiter),("boolean"==typeof t.quotes||"function"==typeof t.quotes||Array.isArray(t.quotes))&&(r=t.quotes),"boolean"!=typeof t.skipEmptyLines&&"string"!=typeof t.skipEmptyLines||(u=t.skipEmptyLines),"string"==typeof t.newline&&(s=t.newline),"string"==typeof t.quoteChar&&(o=t.quoteChar),"boolean"==typeof t.header&&(n=t.header),Array.isArray(t.columns)){if(0===t.columns.length)throw new Error("Option columns is empty");d=t.columns}void 0!==t.escapeChar&&(l=t.escapeChar+o),"boolean"==typeof t.escapeFormulae&&(c=t.escapeFormulae)}}();var h=new RegExp(p(o),"g");if("string"==typeof e&&(e=JSON.parse(e)),Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return f(null,e,u);if("object"==typeof e[0])return f(d||Object.keys(e[0]),e,u)}else if("object"==typeof e)return"string"==typeof e.data&&(e.data=JSON.parse(e.data)),Array.isArray(e.data)&&(e.fields||(e.fields=e.meta&&e.meta.fields),e.fields||(e.fields=Array.isArray(e.data[0])?e.fields:"object"==typeof e.data[0]?Object.keys(e.data[0]):[]),Array.isArray(e.data[0])||"object"==typeof e.data[0]||(e.data=[e.data])),f(e.fields||[],e.data||[],u);throw new Error("Unable to serialize unrecognized input");function f(e,t,r){var a="";"string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t));var o=Array.isArray(e)&&0=this._config.preview;if(n)t.postMessage({results:o,workerId:a.WORKER_ID,finished:u});else if(w(this._config.chunk)&&!r){if(this._config.chunk(o,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);o=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(o.data),this._completeResults.errors=this._completeResults.errors.concat(o.errors),this._completeResults.meta=o.meta),this._completed||!u||!w(this._config.complete)||o&&o.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),u||o&&o.meta.paused||this._nextChunk(),o}this._halted=!0},this._sendError=function(e){w(this._config.error)?this._config.error(e):n&&this._config.error&&t.postMessage({workerId:a.WORKER_ID,error:e,finished:!1})}}function u(e){var t;(e=e||{}).chunkSize||(e.chunkSize=a.RemoteChunkSize),l.call(this,e),this._nextChunk=r?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),r||(t.onload=y(this._chunkLoaded,this),t.onerror=y(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!r),this._config.downloadRequestHeaders){var e=this._config.downloadRequestHeaders;for(var n in e)t.setRequestHeader(n,e[n])}if(this._config.chunkSize){var i=this._start+this._config.chunkSize-1;t.setRequestHeader("Range","bytes="+this._start+"-"+i)}try{t.send(this._config.downloadRequestBody)}catch(e){this._chunkError(e.message)}r&&0===t.status&&this._chunkError()}},this._chunkLoaded=function(){4===t.readyState&&(t.status<200||400<=t.status?this._chunkError():(this._start+=this._config.chunkSize?this._config.chunkSize:t.responseText.length,this._finished=!this._config.chunkSize||this._start>=function(e){var t=e.getResponseHeader("Content-Range");return null===t?-1:parseInt(t.substring(t.lastIndexOf("/")+1))}(t),this.parseChunk(t.responseText)))},this._chunkError=function(e){var r=t.statusText||e;this._sendError(new Error(r))}}function d(e){var t,r;(e=e||{}).chunkSize||(e.chunkSize=a.LocalChunkSize),l.call(this,e);var n="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,r=e.slice||e.webkitSlice||e.mozSlice,n?((t=new FileReader).onload=y(this._chunkLoaded,this),t.onerror=y(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function c(e){var t;l.call(this,e=e||{}),this.stream=function(e){return t=e,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var e,r=this._config.chunkSize;return r?(e=t.substring(0,r),t=t.substring(r)):(e=t,t=""),this._finished=!t,this.parseChunk(e)}}}function h(e){l.call(this,e=e||{});var t=[],r=!0,n=!1;this.pause=function(){l.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){l.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){n&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):r=!0},this._streamData=y((function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),r&&(r=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}}),this),this._streamError=y((function(e){this._streamCleanUp(),this._sendError(e)}),this),this._streamEnd=y((function(){this._streamCleanUp(),n=!0,this._streamData("")}),this),this._streamCleanUp=y((function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)}),this)}function f(e){var t,r,n,i=Math.pow(2,53),s=-i,o=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,l=/^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))$/,u=this,d=0,c=0,h=!1,f=!1,m=[],v={data:[],errors:[],meta:{}};if(w(e.step)){var _=e.step;e.step=function(t){if(v=t,S())E();else{if(E(),0===v.data.length)return;d+=t.data.length,e.preview&&d>e.preview?r.abort():(v.data=v.data[0],_(v,u))}}}function y(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function E(){if(v&&n&&(O("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),n=!1),e.skipEmptyLines)for(var t=0;t=m.length?"__parsed_extra":m[n]),e.transform&&(a=e.transform(a,s)),a=F(s,a),"__parsed_extra"===s?(i[s]=i[s]||[],i[s].push(a)):i[s]=a}return e.header&&(n>m.length?O("FieldMismatch","TooManyFields","Too many fields: expected "+m.length+" fields but parsed "+n,c+r):n=n.length/2?"\r\n":"\r"}(i,l)),n=!1,e.delimiter)w(e.delimiter)&&(e.delimiter=e.delimiter(i),v.meta.delimiter=e.delimiter);else{var u=function(t,r,n,i,s){var o,l,u,d;s=s||[",","\t","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var c=0;c=o)return I(!0)}else for(x=d,d++;;){if(-1===(x=e.indexOf(t,x+1)))return h||y.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:b.length,index:d}),C();if(x===f-1)return C(e.substring(d,x).replace(N,t));if(t!==u||e[x+1]!==u){if(t===u||0===x||e[x-1]!==u){-1!==k&&k=o)return I(!0);break}y.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:b.length,index:d}),x++}}else x++}return C();function M(e){b.push(e),S=d}function T(t){var r=0;if(-1!==t){var n=e.substring(x+1,t);n&&""===n.trim()&&(r=n.length)}return r}function C(t){return h||(void 0===t&&(t=e.substring(d)),E.push(t),d=f,M(E),_&&V()),I()}function P(t){d=t,M(E),E=[],R=e.indexOf(n,d)}function I(e){return{data:b,errors:y,meta:{delimiter:r,linebreak:n,aborted:c,truncated:!!e,cursor:S+(a||0)}}}function V(){s(I()),b=[],y=[]}},this.abort=function(){c=!0},this.getCharIndex=function(){return d}}function m(e){var t=e.data,r=i[t.workerId],n=!1;if(t.error)r.userError(t.error,t.file);else if(t.results&&t.results.data){var s={abort:function(){n=!0,v(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:_,resume:_};if(w(r.userStep)){for(var a=0;a{e.exports={converterElementNotFound:'Aucun élément HTML n\'a été trouvé ayant comme "id" : ',converterFieldNotFound:"Le champ n'existe pas dans les données ou les données n'ont pas encore été chargées.",converterNeedDatasElt:"Merci de fournir un id valide pour l'élément où afficher les données.",converterRefreshFail:"Le nom des champs et l'élement du DOM receveur sont nécessaires à l'affichage des données.",filterNeedDatas:"Le création d'un filtre nécessite la présence des données à filtrer.",pagination2HTMLFail:"Toutes les donnée nécessaires à la création des sélecteurs de pagination n'ont pas été fournies.",paginationNeedByfaultValueBeInOptions:"La valeur de pagination par défaut doit faire partie des options proposées.",paginationNeedDatas:"Il ne peut y avoir de pagination, si les données n'ont pas été récupérées.",paginationNeedOptionsValues:"Vous n'avez fourni aucune options possibles pour la pagination.",paginationOptionsDuplicatedValues:"Une valeur en doublon a été trouvée dans les options de pagination.",paginationNeedPositiveInteger:"Merci de fournir un nombre entier supérieur à zéro pour désigner chaque option de pagination.",parserDatasNotFound:"Aucune donnée n'a été trouvée.",parserElementsNotFound:"Aucun élément trouvé dans le document pour le sélecteur fourni : ",parserFail:"La lecture des données a échoué.",parserFieldNameFail:"Les noms de champs fournis doivent être uniques et ne peuvent être vides.",parserFieldsNotFound:"Aucun nom de champs n'a été trouvé par le parseur.",parserLineWithoutDatas:"Une ligne ne contenant aucune donnée valide a été trouvée.",parserMeetErrors:"Au moins une erreur a été rencontrée durant le traitement des données.",parserNeedDatas:"Merci de fournir une chaîne de caractères valide à parser.",parserNeedSource:"Merci de fournir une chaîne de caractères où une url pour les données à parser.",parserNumberOfFieldsFail:"Il n'y a pas le nombre de champs attendu pour cet enregistrement.",parserRemoteFail:"Erreur rencontrée durant l'accès aux données distantes.",parserSelectorsIsEmpty:"Les sélecteurs CSS ne peuvent pas être une chaîne vide.",parserTypeError:"Une donnée a été trouvée avec un type imprévu : ",remoteSourceHeaderUnallowed:"Le nom d'une des entêtes passées n'est pas autorisé.",remoteSourceNeedUrl:"Merci de fournir une url valide pour la source distante de données.",remoteSourceUrlFail:"L'url fournie ne semble pas valide.",renderNeedFields:"Les noms de champs doivent être fournis avant de demander l'affichage des données.",searchFieldNotFound:"Au moins un des champs devant être utilisés par le moteur de recherche n'existe pas dans les données.",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.",selectorFieldIsEmpty:"Aucune donnée trouvée pour le champ du filtre",selectorFieldNotFound:"Au moins un des champs devant servir à filtrer les données n'existe pas dans le fichier.",selectorSelectedIndexNotFound:"La valeur sélectionnée n'a pas été trouvée dans la liste des champs.",sortingFieldNeedDatas:"La création d'un champ de classement nécessite la transmission de la liste des champs.",sortingFieldNotFound:"Au moins un des champs devant permettre de classer les données n'existe pas dans ceux à afficher.",sortingFieldsNbFail:"Le nombre de champs trouvés dans le DOM ne correspond pas à celui des données à classer.",sortingFieldsNotInHTML:"Les champs pouvant servir à classer les données n'ont pas été trouvés dans le DOM."}}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e,t,n,i,s=r(658),a=function(){function e(e){this.allowedUrlProtocol=["https:","http:"],this._url="",this._headers=[],this._withCredentials=!1,""!==e.url&&(this.url=e.url),void 0!==e.headers&&(this.headers=e.headers),void 0!==e.withCredentials&&(this.withCredentials=e.withCredentials)}return Object.defineProperty(e.prototype,"url",{get:function(){return this._url},set:function(e){if(0===e.trim().length)throw new Error(s.remoteSourceNeedUrl);try{var t=new URL(e);if(-1===this.allowedUrlProtocol.indexOf(t.protocol))throw new Error}catch(e){throw console.error(e),new Error(s.remoteSourceUrlFail)}this._url=e.trim()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"headers",{get:function(){return this._headers},set:function(e){for(var t=["Accept-Charset","Accept-Encoding","Access-Control-Request-Headers","Access-Control-Request-Method","Connection","Content-Length","Cookie","Cookie2","Date","DNT","Expect","Host","Keep-Alive","Origin","Referer","TE","Trailer","Transfer-Encoding","Upgrade","Via"],r=0,n=e;r0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]",allEnding:"",fieldsBegining:"",fieldsEnding:"",fieldDisplaying:"#FIELDNAME",linesBegining:"",linesEnding:"",lineBegining:"",lineEnding:"",dataDisplaying:"#VALUE"},e}(),m=r(658),v=(function(){function e(e,t,r){if(void 0===r&&(r="Pages"),0===e.fields.length)throw new Error(m.paginationNeedDatas);this._pages={displayElement:O.checkInDOMById(t),name:r},this._converter=e}e.isPositiveInteger=function(e){return!(!1===Number.isInteger(e)||e<=0)},Object.defineProperty(e.prototype,"selectedValue",{get:function(){return this._selectedValue},set:function(t){if(void 0!==t){if(!e.isPositiveInteger(t))throw new Error(m.needPositiveInteger);if(void 0!==this.options&&-1===this.options.values.indexOf(t))throw new Error(m.paginationNeedByfaultValueBeInOptions)}this._selectedValue=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"options",{get:function(){return this._options},set:function(t){if(void 0!==t){t.displayElement=O.checkInDOMById(t.displayElement);for(var r=[],n=0,i=t.values;n",this._options.displayElement.eltDOM.innerHTML=e;var r=document.getElementById("freeDatas2HTMLPaginationSelector");void 0!==this._selectedValue&&(r.value=""+(this._options.values.indexOf(this._selectedValue)+1));var n=this;r.addEventListener("change",(function(e){"0"===r.value?n._selectedValue=void 0:n._selectedValue=n._options.values[Number(r.value)-1],n._converter.refreshView()}))},e.prototype.pages2HTML=function(){if(void 0===this._selectedValue||this._converter.nbDatasValid<=this._selectedValue)this.pages.displayElement.eltDOM.innerHTML="";else{var e=Math.ceil(this._converter.nbDatasValid/this._selectedValue),t="",this.pages.displayElement.eltDOM.innerHTML=t;var n=document.getElementById("freeDatas2HTMLPagesSelector");this.pages.selectedValue=1;var i=this;n.addEventListener("change",(function(e){i.pages.selectedValue=Number(n.value),i._converter.refreshView()}))}}}(),r(658)),_=(function(){function e(e,t,r){if(this._datasViewElt={id:"",eltDOM:void 0},this._btnTxt="Search",this._fields2Search=[],this.label="",this.nbCharsForSearch=0,this.placeholder="",this.automaticSearch=!1,this._inputValue="",0===e.fields.length||0===e.datas.length)throw new Error(v.filterNeedDatas);if(this._datasViewElt=O.checkInDOMById(t),this._converter=e,void 0!==r&&0!==r.length)for(var n=0,i=r;n0&&""===this.placeholder&&(this.placeholder="Please enter at least NB characters.");var e='
';""!==this.label&&(e+='")),e+='0?e+=' placeholder="'.concat(this.placeholder.replace("NB",""+this.nbCharsForSearch),'"'):""!==this.placeholder&&(e+=' placeholder="'.concat(this.placeholder,'"')),e+='> 
'),this._datasViewElt.eltDOM.innerHTML=e;var t=document.getElementById("freeDatas2HTMLSearchTxt"),r=this;t.addEventListener("input",(function(e){e.preventDefault(),r._inputValue=t.value;var n=t.value.length;r.automaticSearch&&(0===r.nbCharsForSearch||0===n||n>=r.nbCharsForSearch)&&r._converter.refreshView()})),document.getElementById("freeDatas2HTMLSearchBtn").addEventListener("click",(function(e){e.preventDefault();var n=t.value.length;(0===r.nbCharsForSearch||0===n||n>=r.nbCharsForSearch)&&r._converter.refreshView()}))},e.prototype.dataIsOk=function(e){if(0===this._inputValue.length)return!0;for(var t in e)if(-1!==this._fields2Search.indexOf(t)&&-1!==e[t].toLowerCase().indexOf(this._inputValue.toLowerCase()))return!0;return!1}}(),r(196).q),b=r(658),y=function(){function e(e,t,r,n){if(this._datasViewElt={id:"",eltDOM:void 0},this._selectedValues=[],this._values=[],this._name="",this.isMultiple=!1,0===e.fields.length||0===e.datas.length)throw new Error(b.filterNeedDatas);if(!e.checkFieldExist(Number(t)))throw new Error(b.selectorFieldNotFound);this._datasViewElt=O.checkInDOMById(r),this._converter=e,this._datasFieldNb=t,void 0!==n&&""!==n&&(this._separator=n),this._name=this._converter.fields[this._datasFieldNb],this.setValues()}return Object.defineProperty(e.prototype,"converter",{get:function(){return this._converter},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"datasViewElt",{get:function(){return this._datasViewElt},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"datasFieldNb",{get:function(){return this._datasFieldNb},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"selectedValues",{get:function(){return this._selectedValues},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"separator",{get:function(){return this._separator},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){return this._values},enumerable:!1,configurable:!0}),e.prototype.setValues=function(){for(var e=0,t=this._converter.datas;e"+e+" :",this._datasViewElt.eltDOM.innerHTML=r;var i=document.getElementById("freeDatas2HTML_"+this._datasViewElt.id),s=this;i.addEventListener("change",(function(e){if(s._selectedValues=[],s.isMultiple)for(var t=0;t"+t+"",e[r].innerHTML=t;var n=document.getElementById("freeDatas2HTMLSorting"+this._datasFieldNb),i=this;n.addEventListener("click",(function(e){e.preventDefault();var t=i._order;i._order=void 0===t||"desc"===t?"asc":"desc",i._converter.datasSortedField=i,i._converter.refreshView()}))}}(),function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function o(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))}),S=r(196).q,F=r(658),O=function(){function e(e,t,r){switch(void 0===t&&(t=""),this._datasViewElt=void 0,this.stopIfParseErrors=!1,this._datasSortingFunctions=[],this.datasFilters=[],this.datasSortingFields=[],this._fields2Rend=[],this.datasCounterElt=void 0,this._fields=[],this._datas=[],this._datas2Rend=[],this._nbDatasValid=0,this.datasRender=new g,e){case"CSV":this.parser=new u;break;case"HTML":this.parser=new c;break;case"JSON":this.parser=new f}""!==t.trim()?this.parser.datas2Parse=t:void 0!==r&&this.parser.setRemoteSource(r)}return e.checkInDOMById=function(e){var t=document.getElementById(e.id);if(null===t)throw new Error(F.converterElementNotFound+e.id);return e.eltDOM=t,e},Object.defineProperty(e.prototype,"datasViewElt",{set:function(t){this._datasViewElt=e.checkInDOMById(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"datas",{get:function(){return this._datas},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fields",{get:function(){return this._fields},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nbDatasValid",{get:function(){return this._nbDatasValid},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fields2Rend",{get:function(){return this._fields2Rend},set:function(e){if(0===e.length)this._fields2Rend=e;else{this._fields2Rend=[];for(var t=0,r=e;t0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]=n&&a fabrice@le-fab-lab.com"),e=void 0,t=void 0,i=function(){var e,t,r,n,i,s;return function(e,t){var r,n,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]').concat(e.anchor,""):"".concat(e.anchor,"")},r=function(e){return""!==e.url?'
  • ').concat(e.url,"
  • "):""},(n=new R({allBegining:"
      ",allEnding:"
    ",datasLinesDisplaying:"
    • ##1##
    • Mots-clés : ##2##.
    • ##0##
  • "})).fieldRenders=[{name:"anchor",rend2HTML:t},{name:"url",rend2HTML:r}],e.datasRender=n,(i=new y(e,2,{id:"filtre1"},",")).filter2HTML("Mots-clés"),e.datasFilters=[i],e.datasViewElt={id:"datas"},e.refreshView(),[3,3];case 2:return s=a.sent(),console.error(s),document.getElementById("datas").innerHTML='
    Désolé, mais un problème technique empêche l\'affichage des données.
    ',[3,3];case 3:return[2]}}))},new((n=void 0)||(n=Promise))((function(r,s){function a(e){try{l(i.next(e))}catch(e){s(e)}}function o(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,o)}l((i=i.apply(e,t||[])).next())}))})()})(); \ No newline at end of file diff --git a/public/JS/exampleWithMixedFields.app.js.LICENSE.txt b/public/JS/exampleWithMixedFields.app.js.LICENSE.txt new file mode 100644 index 0000000..67c5e95 --- /dev/null +++ b/public/JS/exampleWithMixedFields.app.js.LICENSE.txt @@ -0,0 +1,6 @@ +/* @license +Papa Parse +v5.3.1 +https://github.com/mholt/PapaParse +License: MIT +*/ diff --git a/public/datas/links.json b/public/datas/links.json new file mode 100644 index 0000000..9e0e69c --- /dev/null +++ b/public/datas/links.json @@ -0,0 +1,41 @@ +[ + { + "url": "https://developer.mozilla.org/fr/", + "anchor": "MDN Web Docs", + "keywords":"Mozilla, JavaScript, HTML, CSS" + }, + { + "url": "https://git-scm.com/book/fr/v2", + "anchor": "Pro Git book", + "keywords":"Git" + }, + { + "url": "https://jasmine.github.io/pages/docs_home.html", + "anchor": "Jasmine Documentation", + "keywords":"JavaScript, Test" + }, + { + "url": "https://www.typescriptlang.org/", + "anchor": "TypeScript Documentation", + "keywords":"TypeScript, JavaScript" + }, + { + "url": "https://karma-runner.github.io", + "anchor": "Karma.js", + "keywords":"Javascript, Test" + }, + { + "url": "https://www.papaparse.com/", + "anchor": "Papa Parse", + "keywords":"JavaScript, CSV" + }, + { + "url": "https://www.npmjs.com/package/natural-orderby", + "anchor": "natural-orderby", + "keywords":"TypeScript, JavaScript" + }, + { + "anchor": "Lien sans URL fournie", + "keywords":"Test" + } +] \ No newline at end of file diff --git a/public/examples.html b/public/examples.html index 2c2a330..5377820 100644 --- a/public/examples.html +++ b/public/examples.html @@ -32,6 +32,7 @@
  • Parser et afficher des données JSON, avec ajout d'un filtre, d'un moteur de recherche, pagination et compteur de résultats.
  • Parser et réafficher les données situées dans le code HTML de la page, avec filtre, pagination et adaptation à la taille de l'écran.
  • Utilisation d'une extension créant des liens de classement, dans le cas où les données ne sont pas listées dans un tableau.
  • +
  • Utilisation d'une extension permettant un affichage plus complexe par exemple en mixant le contenu de certains champs, ici en créant des liens hypertextes.
  • Un lien vers le code source TypeScript est fourni pour chaque exemple, de manière à ce que vous puissiez lire le code, tout en observant le résultat.

    diff --git a/public/withMixedFields.html b/public/withMixedFields.html new file mode 100644 index 0000000..5bff31b --- /dev/null +++ b/public/withMixedFields.html @@ -0,0 +1,51 @@ + + + + + + + + + + + + Afficher des données en TypeScript/JavaScript en mixant le contenu de différents champs + + + + + + +

    Mixer les données de différents champs

    + +
    +
    +
    + +
    +

    Si tout se passe bien, ce texte sera remplacé par un tableau de données extraites du fichier JSON.

    +
    + +
    +

    Cet exemple utilise un moteur de rendu alternatif à celui par défaut.

    +

    Il vous donne plus de souplesse sur la façon d’afficher les données extraites de la source (ici un fichier JSON), notamment en permettant d’utiliser le contenu de plusieurs champs pour créer le rendu d’un seul.

    +

    Dans le cas ci-dessus, le champ « url » est ainsi utilisé pour rendre cliquable le nom du lien (champ « anchor ») et inversement le champ « anchor » sert à l’attribut « title » lors de l’affichage du champ « url ».

    +

    La contre-partie est de nécessiter d’être plus vigilant lors de votre intégration, là où le moteur de rendu par défaut se contente d’afficher les données telles que présentes dans la source.

    +
    + + + + + + \ No newline at end of file diff --git a/src/build/demo/exampleWithMixedFields.js b/src/build/demo/exampleWithMixedFields.js new file mode 100644 index 0000000..2907d7c --- /dev/null +++ b/src/build/demo/exampleWithMixedFields.js @@ -0,0 +1,86 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + 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; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +import { FreeDatas2HTML, Selector } from "../FreeDatas2HTML"; +import { MixedFieldsRender } from "../extensions/MixedFieldsRender"; +var initialise = function () { return __awaiter(void 0, void 0, void 0, function () { + var converter, renderSettings, rendAnchor2HTML, rendUrl2HTML, myRender, filtre1, 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/links.json" }); + return [4, converter.run()]; + case 1: + _a.sent(); + renderSettings = { + allBegining: "
      ", + allEnding: "
    ", + datasLinesDisplaying: "
    • ##1##
    • Mots-cl\u00E9s : ##2##.
    • ##0##
  • " + }; + rendAnchor2HTML = function (values) { + if (values["url"] !== undefined && values["url"] !== "") + return "" + values["anchor"] + ""; + else + return "" + values["anchor"] + ""; + }; + rendUrl2HTML = function (values) { + if (values["url"] !== "") + return "
  • " + values["url"] + "
  • "; + else + return ""; + }; + myRender = new MixedFieldsRender(renderSettings); + myRender.fieldRenders = [{ name: "anchor", rend2HTML: rendAnchor2HTML }, { name: "url", rend2HTML: rendUrl2HTML }]; + converter.datasRender = myRender; + filtre1 = new Selector(converter, 2, { id: "filtre1" }, ","); + filtre1.filter2HTML("Mots-clés"); + converter.datasFilters = [filtre1]; + converter.datasViewElt = { id: "datas" }; + converter.refreshView(); + return [3, 3]; + case 2: + e_1 = _a.sent(); + console.error(e_1); + document.getElementById("datas").innerHTML = "
    D\u00E9sol\u00E9, mais un probl\u00E8me technique emp\u00EAche l'affichage des donn\u00E9es.
    "; + 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/exampleWithMixedFields.ts\nUn bug ? Une suggestion ? => fabrice@le-fab-lab.com"); +initialise(); diff --git a/src/demo/exampleWithMixedFields.ts b/src/demo/exampleWithMixedFields.ts new file mode 100644 index 0000000..5aad222 --- /dev/null +++ b/src/demo/exampleWithMixedFields.ts @@ -0,0 +1,57 @@ +import { FreeDatas2HTML, Selector } from "../FreeDatas2HTML"; +import { MixedFieldsRender } from "../extensions/MixedFieldsRender"; + +const initialise=async () => +{ + try + { + // Création d'un convertisseur parsant des données transmises en JSON : + const converter=new FreeDatas2HTML("JSON"); + converter.parser.setRemoteSource({ url: "http://localhost:8080/datas/links.json"}); + // Parsage des données, qui ne sont pas encore affichées : + await converter.run(); + + // Chaînes à utiliser par le moteur de rendu : + const renderSettings= + { + allBegining: `
      `, + allEnding: `
    `, + datasLinesDisplaying: `
    • ##1##
    • Mots-clés : ##2##.
    • ##0##
  • ` + }; + // Fonctions spécifiques pour créer les liens hypertextes : + const rendAnchor2HTML=(values: {[index: string]:string} ) : string => + { + if(values["url"] !== undefined && values["url"] !== "") // je considère que anchor est toujours renseigné, mais on pourrait tester. + return `${values["anchor"]}`; + else + return `${values["anchor"]}`; + }; + const rendUrl2HTML=(values: {[index: string]:string} ) : string => + { + if(values["url"] !== "") // si values["url"] = undefined, la fonction rendUrl2HTML() n'est pas appelée. + return `
  • ${values["url"]}
  • `; + else + return ""; + }; + const myRender=new MixedFieldsRender(renderSettings); + myRender.fieldRenders=[{ name:"anchor", rend2HTML: rendAnchor2HTML}, { name:"url", rend2HTML: rendUrl2HTML}]; + converter.datasRender=myRender; + + // Création d'un filtre sur le troisième champ : + let filtre1=new Selector(converter, 2, { id:"filtre1"}, "," ); + filtre1.filter2HTML("Mots-clés"); + converter.datasFilters=[filtre1]; + + // Affichage initial avec l'id de l'élément HTML devant afficher le compteur : + converter.datasViewElt={ id:"datas" }; + converter.refreshView(); + } + catch(e) + { + console.error(e); + document.getElementById("datas")!.innerHTML=`
    Désolé, mais un problème technique empêche l'affichage des données.
    `; + } +} + +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/exampleWithMixedFields.ts\nUn bug ? Une suggestion ? => fabrice@le-fab-lab.com"); +initialise(); \ No newline at end of file