This repository has been archived on 2024-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Lens/main.min.js
2021-02-01 23:17:02 +01:00

1 line
13 KiB
JavaScript

function _instanceof(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function _classCallCheck(e,t){if(!_instanceof(e,t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}function htmlEntities(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}var NodeLinks=function(){"use strict";function t(e){_classCallCheck(this,t),this.elLinks=e,this.lookup={documents:"Documenti",transactions:"Contabilit&agrave;",questions:"Domande",events:"Eventi",feedbacks:"Feedbacks"}}return _createClass(t,[{key:"computeHTML",value:function(){var t=this;if(!this.elLinks)return"";var e,n=!(this.html='<div class="linkList">'),i=[],a=null;return Object.keys(this.elLinks).includes("to")&&(a=this.elLinks.to),null!=a&&(0<(e=Object.keys(a)).length&&!n&&(this.html+='<span>Risorse collegate:</span><div data-role="collapsibleset" data-theme="a" data-content-theme="a">',n=!0),e.forEach(function(e){i=a[e],t.html+='<div data-role="collapsible"><h3>'+t.lookup[e]+"</h3>",i.forEach(function(e){t.html+='<p><button type="button" onclick="location.href=\'api/view/UID/'+e.UID+"/render';\">"+htmlEntities(e.title)+"</button></p>"}),t.html+="</div>"}),0<e.length&&!n&&(this.html+="</div>")),n=!1,null!=(a=this.elLinks.from)&&(0<(e=Object.keys(a)).length&&!n&&(this.html+='<span>Fanno riferimento a questa risorsa:</span><div data-role="collapsibleset" data-theme="a" data-content-theme="a">',n=!0),e.forEach(function(e){i=a[e],t.html+='<div data-role="collapsible"><h3>'+t.lookup[e]+"</h3>",i.forEach(function(e){t.html+='<p><button type="button" onclick="location.href=\'api/view/UID/'+e.UID+"/render';\">"+htmlEntities(e.title)+"</a></p>"}),t.html+="</div>"}),0<e.length&&!n&&(this.html+="</div>")),this.html+="</div>",this.html}}]),t}(),Tags=function(){"use strict";function t(e){_classCallCheck(this,t),this.tags=e}return _createClass(t,[{key:"computeHTML",value:function(){var t=this;null!=this.tags&&0<this.tags.length&&(this.html+='<div data-role="collapsible"><h3>Tag</h3>',this.tags.forEach(function(e){t.html+='<p><a href="api/view/tags/'+encodeURI(e)+'/render">'+htmlEntities(e)+"</a></p>"}))}}]),t}();function eurSet(e){}var ElementPreviewList=function(){"use strict";function e(){_classCallCheck(this,e),this.k2it={planned:"Previsto il",executed:"Effettuato il",amount:"Importo",title:"Titolo",shortDescription:"Descrizione breve",htmlDescription:"Testo in html",createdDate:"Data di creazione",publishedDate:"Data di pubblicazione",lastEditedDate:"Data di ultima modifica",thumbnailUrl:"Url anteprima",documentUrl:"Url documento",startDate:"Data inizio",endDate:"Data fine",participants:"Partecipanti",isAssembly:"Tipo",publishResultsDate:"Data pubblicazione dei risultati",questionTitle:"Titolo domanda",questionText:"Domanda",answerTitle:"Titolo risposta",answerText:"Risposta",askDate:"Data richiesta",answerDate:"Data risposta",asker:"Richiedente",replier:"Rispondente"}}return _createClass(e,[{key:"itLookup",value:function(e){return this.k2it[e]?this.k2it[e]:e}},{key:"itLookupPairDict",value:function(e,t){return{value:e[t]?e[t]:"",name:this.itLookup(t)}}},{key:"textGen",value:function(e,t){return t&&e?"<span><h3>"+htmlEntities(e)+"</h3><br/><p>"+htmlEntities(t)+"</p></span>":""}},{key:"listgen",value:function(e,t,n,i){var a=1<arguments.length&&void 0!==t?t:[],s=2<arguments.length&&void 0!==n?n:[],r=3<arguments.length&&void 0!==i?i:[],o="";if(e&&0<a.length){o+="<h3>"+htmlEntities(e)+"</h3><br />";for(var l,c,h=0;h<a.length;h++){a[h]&&(l=s[h]?s[h]:s[0]?s[0]:"white",c="<span>",r[h]&&(c='<span style="text-decoration: underline;" onclick="location.href=\'api/view/UID/'+r[h]+"';\">"),o+=c+'<span class="w3-tag w3-'+l+'">'+htmlEntities(a[h])+"</span></span>")}return o}}},{key:"conditonalTextGen",value:function(e,t,n,i){var a=3<arguments.length&&void 0!==i?i:"";return this.textGen(e,t?n:a)}},{key:"boolGen",value:function(e,t){var n=t?"S&igrave;":"No",i=t?"green":"red";return this.listgen(e,[n],[i],[])}},{key:"thumbnailGen",value:function(e,t,n,i){return'<img src="'+e+'" onclick="location.href=\''+e+'\';" style="max-width:'+(2<arguments.length&&void 0!==n?n:200)+"px;max-heght:"+(1<arguments.length&&void 0!==t?t:200)+'px;" alt="'+htmlEntities(3<arguments.length&&void 0!==i?i:"thumbnail")+'" />'}},{key:"tagsgen",value:function(e,t,n){var i=1<arguments.length&&void 0!==t?t:[],a=2<arguments.length&&void 0!==n?n:[],s="";if(e&&0<i.length){s+="<h3>"+htmlEntities(e)+"</h3><br />";for(var r,o=0;o<i.length;o++){i[o]&&(r=a[o]?a[o]:a[0]?a[0]:"black",s+='<span style="text-decoration: underline;" onclick="location.href=\'api/view/tags/'+i[o]+"/detailed/render';\">"+'<span class="w3-tag w3-'+r+'">'+htmlEntities(i[o])+"</span></span>")}return s}}},{key:"generateLi",value:function(e,t){var n,i=this,a="";switch(e){case"document":t.forEach(function(e){a+='<li>\n<a href="api/view/UID/'+e.UID+'/render">',a+='<h1 style="font-size:30px;">'+htmlEntities(e.title)+"</h1>",a+="<br /><hr />",a+="<span> "+i.thumbnailGen(e.thumbnailUrl,200,200,e.title)+"</span>",a+="<br /><hr />",a+="<h4>"+htmlEntities(e.shortDescription)+"</h4>",a+="<br /><hr />",a+="<span>"+i.listgen("Formato",[e.format.type,e.format.description],[e.format.uiColor])+"</span>",a+="<br /><hr />",n=i.itLookupPairDict(e,"publishedDate"),a+="<span> "+i.textGen(n.name,new TimeFormatter(n.value).compute("LLLL"))+"</span>",a+="<br /><hr />",a+="<span>"+i.tagsgen("Tag",e.tags)+"</span>",a+="<br /><hr />";var t=new NodeLinks(e.links);a+=t.computeHTML(),a+="</a></li>"});break;case"event":t.forEach(function(e){a+='<li>\n<a href="api/view/UID/'+e.UID+'/render">',a+='<h1 style="font-size:30px;">'+htmlEntities(e.title)+"</h1>",a+="<br /><hr />",a+="<span> "+i.thumbnailGen(e.thumbnailUrl,200,200,e.title)+"</span>",a+="<br /><hr />",a+="<h4>"+htmlEntities(e.shortDescription)+"</h4>",a+="<br /><hr />",a+=i.conditonalTextGen(" ",e.isAssembly,"È un assemblea"),a+="<br /><hr />",n=i.itLookupPairDict(e,"startDate"),a+="<span> "+i.textGen(n.name,new TimeFormatter(n.value).compute("LLLL"))+"</span>",a+="<br /><hr />",n=i.itLookupPairDict(e,"endDate"),a+="<span> "+i.textGen(n.name,new TimeFormatter(n.value).compute("LLLL"))+"</span>",a+="<br /><hr />",a+="<span> "+i.listgen("Partecipanti",e.participants)+"</span>",a+="<br /><hr />",n=i.itLookupPairDict(e,"publishedDate"),a+="<span> "+i.textGen(n.name,new TimeFormatter(n.value).compute("LLLL"))+"</span>",a+="<br /><hr />",a+="<span> "+i.tagsgen("Tag",e.tags)+"</span>",a+="<br /><hr />";var t=new NodeLinks(e.links);a+=t.computeHTML(),a+="</a></li>"});break;case"feedback":t.forEach(function(e){a+='<li>\n<a href="api/view/UID/'+e.UID+'/render">',a+='<h1 style="font-size:30px;">'+htmlEntities(e.title)+"</h1>",a+="<br /><hr />",a+="<br /><hr />",a+="<span> "+i.thumbnailGen(e.thumbnailUrl,200,200,e.title)+"</span>",a+="<br /><hr />",a+="<h4>"+htmlEntities(e.shortDescription)+"</h4>",a+="<br /><hr />",a+="<br /><hr />",n=i.itLookupPairDict(e,"startDate"),a+="<span> "+i.textGen(n.name,new TimeFormatter(n.value).compute("LLLL"))+"</span>",a+="<br /><hr />",n=i.itLookupPairDict(e,"endDate"),a+="<span> "+i.textGen(n.name,new TimeFormatter(n.value).compute("LLLL"))+"</span>",a+="<br /><hr />",n=i.itLookupPairDict(e,"publishResultsDate"),a+="<span> "+i.textGen(n.name,new TimeFormatter(n.value).compute("LLLL"))+"</span>",a+="<br /><hr />",i.itLookupPairDict(e,"publishedDate"),a+="<span> "+i.textGen(n.name,new TimeFormatter(n.value).compute("LLLL"))+"</span>",a+="<br /><hr />",a+="<span> "+i.tagsgen("Tag",e.tags)+"</span>";var t=new NodeLinks(e.links);a+=t.computeHTML(),a+="</a></li>"});break;case"question":t.forEach(function(e){a+='<li>\n<a href="api/view/UID/'+e.UID+'/render">',a+='<h1 style="font-size:30px;">'+htmlEntities(e.questionTitle)+"</h1>",a+="<br /><hr />",a+="<br /><hr />",a+="<span> "+i.thumbnailGen(e.thumbnailUrl,200,200,e.title)+"</span>",a+="<br /><hr />",n=i.itLookupPairDict(e,"publishedDate"),a+="<span> "+i.textGen(n.name,new TimeFormatter(n.value).compute("LLLL"))+"</span>",a+="<br /><hr />",a+="<span> "+i.tagsgen("Tag",e.tags)+"</span>";var t=new NodeLinks(e.links);a+=t.computeHTML(),a+="</a></li>"});break;case"transaction":t.forEach(function(e){a+="<tr>",a+="<td> "+i.thumbnailGen(e.thumbnailUrl,200,200,e.title)+"</td>",n=i.itLookupPairDict(e,"title"),a+="<td> "+i.textGen(" ",n.value)+"</td>",n=i.itLookupPairDict(e,"planned"),a+="<td> "+i.textGen(" ",new TimeFormatter(n.value).compute("LLLL"))+"</td>",n=i.itLookupPairDict(e,"executed"),a+="<td> "+i.textGen(" ",new TimeFormatter(n.value).compute("LLLL"))+"</td>",a+="<td>"+eurS(e.amount)+"</td>",a+="<td> "+i.textGen(" ",n.value)+"</td>",n=i.itLookupPairDict(e,"shortDescription"),a+="<td> "+i.textGen(" ",n.value)+"</td>",n=i.itLookupPairDict(e,"publishedDate"),a+="<td> "+i.textGen(" ",new TimeFormatter(n.value).compute("LLLL"))+"</td>",a+="<td> "+i.tagsgen(" ",e.tags)+"</td>",a+='<td><a href="api/view/UID/'+e.UID+'/render">link</a></td>',a+="</tr>"})}return a}}]),e}(),TimeFormatter=function(){"use strict";function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null;_classCallCheck(this,t),this.m=e?moment(e):moment(),"it"!=this.m.locale()&&this.m.locale("it",null)}return _createClass(t,[{key:"compute",value:function(e){return this.m.format(e)}}]),t}(),APIfetch=function(){"use strict";function t(e){_classCallCheck(this,t),this.epl=e}return _createClass(t,[{key:"fetchDocs",value:function(e,t){var n=0<arguments.length&&void 0!==e&&e,i=1<arguments.length&&void 0!==t&&t;$.post("api/view/documents/all/",{start:n,end:i},function(e){this.renderDocs(e)}.bind(this),"json")}},{key:"fetchEvents",value:function(e,t){var n=0<arguments.length&&void 0!==e&&e,i=1<arguments.length&&void 0!==t&&t;$.post("api/view/events/all/",{start:n,end:i},function(e){this.renderEvents(e)}.bind(this),"json")}},{key:"fetchFeedbacks",value:function(e,t){var n=0<arguments.length&&void 0!==e&&e,i=1<arguments.length&&void 0!==t&&t;$.post("api/view/feedbacks/all/",{start:n,end:i},function(e){this.renderFeedbacks(e)}.bind(this),"json")}},{key:"fetchQuestions",value:function(e,t){var n=0<arguments.length&&void 0!==e&&e,i=1<arguments.length&&void 0!==t&&t;$.post("api/view/questions/all/",{start:n,end:i},function(e){this.renderQuestions(e)}.bind(this),"json")}},{key:"fetchTransactions",value:function(e,t){var n=0<arguments.length&&void 0!==e&&e,i=1<arguments.length&&void 0!==t&&t;$.post("api/view/transactions/all/",{start:n,end:i},function(e){this.renderTransactions(e)}.bind(this),"json")}},{key:"renderTransactions",value:function(e){var t=(new ElementPreviewList).generateLi("transaction",e.data);console.log(t),$("#accountingList").html(t),$("#accountingList").enhanceWithin(),$("#accountingList").listview("refresh")}},{key:"renderFeedbacks",value:function(e){var t=(new ElementPreviewList).generateLi("feedback",e.data);$("#feedbacksList").html(t),$("#feedbacksList").enhanceWithin(),$("#feedbacksList").listview("refresh")}},{key:"renderQuestions",value:function(e){var t=(new ElementPreviewList).generateLi("question",e.data);$("#questionsList").html(t),$("#questionsList").enhanceWithin(),$("#questionsList").listview("refresh")}},{key:"renderDocs",value:function(e){var t=(new ElementPreviewList).generateLi("document",e.data);$("#documentsList").html(t),$("#documentsList").enhanceWithin(),$("#documentsList").listview("refresh")}},{key:"renderEvents",value:function(e){var t=(new ElementPreviewList).generateLi("event",e.data);$("#eventsList").html(t),$("#eventsList").enhanceWithin(),$("#eventsList").listview("refresh")}}]),t}();function eurS(e){return 0==e?'<h2 style="color:yellow">&euro;'+formatMoney(e,2,",","'")+"</h2>":e<0?'<h2 style="color:red">&euro;'+formatMoney(e,2,",","'")+"</h2>":'<h2 style="color:green">&euro;'+formatMoney(e,2,",","'")+"</h2>"}function formatMoney(e,t,n,i){t=isNaN(t=Math.abs(t))?2:t,n=void 0===n?".":n,i=void 0===i?",":i;var a=e<0?"-":"",s=String(parseInt(e=Math.abs(Number(e)||0).toFixed(t))),r=3<(r=s.length)?r%3:0;return a+(r?s.substr(0,r)+i:"")+s.substr(r).replace(/(\decSep{3})(?=\decSep)/g,"$1"+i)+(t?n+Math.abs(e-s).toFixed(t).slice(2):"")}function searchE(e,t){for(var n=0;n<e.length;n++){var i=e[n];if(i.name==t)return i.value}}var start,end,epl=new ElementPreviewList,api=new APIfetch(epl);function onKonamiCode(t){var n="",i="38384040373937396665";document.addEventListener("keydown",function(e){return(n+=""+e.keyCode)===i?t():void(i.indexOf(n)&&(n=""+e.keyCode))})}api.fetchDocs(),api.fetchEvents(),api.fetchFeedbacks(),api.fetchQuestions(),api.fetchTransactions(),$(document).delegate("form[data-act=search]","submit",function(){var e=$(this).serializeArray();switch(start=searchE(e,"start")?searchE(e,"start"):"false",end=searchE(e,"end")?searchE(e,"start"):"false",searchE(e,"search")){case"events":api.fetchEvents(start,end);break;case"documents":api.fetchDocs(start,end);break;case"feedbacks":api.fetchFeedbacks(start,end);break;case"questions":api.fetchQuestions(start,end);break;case"transactions":api.fetchTransactions(start,end)}return!1}),onKonamiCode(function(){window.open("https://www.youtube.com/watch?v=9YG9INjO91Y","_blank")});