diff --git a/Esempi/Autenticazione/autenticazione.html b/Esempi/Autenticazione/autenticazione.html
new file mode 100644
index 0000000..c679461
--- /dev/null
+++ b/Esempi/Autenticazione/autenticazione.html
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/Esempi/Autenticazione/handling-exception.js b/Esempi/Autenticazione/handling-exception.js
new file mode 100644
index 0000000..98325cb
--- /dev/null
+++ b/Esempi/Autenticazione/handling-exception.js
@@ -0,0 +1,63 @@
+var Messaggio = /** @class */ (function () {
+ function Messaggio() {
+ this.elemento = this.Crea();
+ }
+ Messaggio.prototype.Crea = function () {
+ var div = document.createElement('div');
+ var p = document.createElement('p');
+ div.appendChild(p);
+ return div;
+ };
+ Messaggio.prototype.InserisciMessaggio = function (stringa) {
+ var p = this.elemento.querySelector('p');
+ if (p) {
+ p.textContent = stringa;
+ }
+ };
+ Messaggio.prototype.Mostra = function () {
+ document.body.appendChild(this.elemento);
+ };
+ Messaggio.prototype.Distruggi = function () {
+ var _this = this;
+ setTimeout(function () {
+ if (_this.elemento.parentNode) {
+ _this.elemento.parentNode.removeChild(_this.elemento);
+ }
+ }, 5000);
+ };
+ return Messaggio;
+}());
+var ProgrammaAutorizzazione = /** @class */ (function () {
+ function ProgrammaAutorizzazione() {
+ }
+ ProgrammaAutorizzazione.Esegui = function () {
+ var autorizzazioneUtente = true;
+ var messaggioAutorizzazione = new Messaggio();
+ try {
+ var accessoUtente = this.VerificaAutorizzazione(autorizzazioneUtente);
+ messaggioAutorizzazione.InserisciMessaggio(accessoUtente);
+ messaggioAutorizzazione.Mostra();
+ }
+ catch (error) {
+ console.log(error);
+ messaggioAutorizzazione.InserisciMessaggio(error);
+ messaggioAutorizzazione.Mostra();
+ //ritorno messaggio
+ }
+ finally {
+ if (messaggioAutorizzazione) {
+ messaggioAutorizzazione.Distruggi();
+ }
+ }
+ };
+ ProgrammaAutorizzazione.VerificaAutorizzazione = function (autorizzazione) {
+ if (autorizzazione) {
+ return 'Utente Autorizzato';
+ }
+ else {
+ throw new Error("Utente non autorizzato");
+ }
+ };
+ return ProgrammaAutorizzazione;
+}());
+ProgrammaAutorizzazione.Esegui();
diff --git a/Esempi/Autenticazione/handling-exception.ts b/Esempi/Autenticazione/handling-exception.ts
new file mode 100644
index 0000000..1309eea
--- /dev/null
+++ b/Esempi/Autenticazione/handling-exception.ts
@@ -0,0 +1,72 @@
+class Messaggio {
+
+ private elemento: HTMLDivElement
+
+ constructor() {
+ this.elemento = this.Crea()
+ }
+
+ private Crea(): HTMLDivElement {
+ const div = document.createElement('div') as HTMLDivElement
+ const p = document.createElement('p') as HTMLParagraphElement
+ div.appendChild(p)
+
+ return div
+ }
+
+ public InserisciMessaggio(stringa:string) {
+ const p = this.elemento.querySelector('p')
+ if (p) {
+ p.textContent = stringa
+ }
+ }
+
+ public Mostra():void {
+ document.body.appendChild(this.elemento)
+ }
+
+ public Distruggi():void {
+ setTimeout(() => {
+ if (this.elemento.parentNode) {
+ this.elemento.parentNode.removeChild(this.elemento)
+ }
+ }, 5000);
+ }
+}
+
+
+
+class ProgrammaAutorizzazione {
+
+ static Esegui() {
+ let autorizzazioneUtente:boolean = false
+
+ let messaggioAutorizzazione: Messaggio = new Messaggio()
+ try {
+ let accessoUtente = this.VerificaAutorizzazione(autorizzazioneUtente)
+ messaggioAutorizzazione.InserisciMessaggio(accessoUtente)
+ messaggioAutorizzazione.Mostra()
+ } catch (error) {
+ console.log(error);
+ messaggioAutorizzazione.InserisciMessaggio(error)
+ messaggioAutorizzazione.Mostra()
+ //ritorno messaggio
+ } finally {
+ if (messaggioAutorizzazione) {
+ messaggioAutorizzazione.Distruggi()
+ }
+ }
+
+ }
+ static VerificaAutorizzazione(autorizzazione: boolean):string {
+ if (autorizzazione) {
+ return 'Utente Autorizzato'
+ } else {
+ throw new Error("Utente non autorizzato");
+ }
+ }
+
+}
+
+ProgrammaAutorizzazione.Esegui()
+
diff --git a/Esempi/Autenticazione/prova1.mts b/Esempi/Autenticazione/prova1.mts
new file mode 100644
index 0000000..33a1cdc
--- /dev/null
+++ b/Esempi/Autenticazione/prova1.mts
@@ -0,0 +1,5 @@
+export class Prova1 {
+ constructor(parameters) {
+
+ }
+}
\ No newline at end of file
diff --git a/parte2-css/pagine/blog.html b/parte2-css/pagine/blog.html
new file mode 100644
index 0000000..e2a522e
--- /dev/null
+++ b/parte2-css/pagine/blog.html
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+ Titolo blog
+
+
+
Inserisci introduzione
+
Inserisci introduzione
+
Inserisci introduzione
+
Sottotitolo
+
Paragrafo
+
Paragrafo
+
Paragrafo
+
Paragrafo
+
+
+
+
+
+
diff --git a/parte5-webcomponents/componenti/components.mjs b/parte5-webcomponents/componenti/components.mjs
new file mode 100644
index 0000000..cb0ff5c
--- /dev/null
+++ b/parte5-webcomponents/componenti/components.mjs
@@ -0,0 +1 @@
+export {};
diff --git a/parte5-webcomponents/componenti/components.mts b/parte5-webcomponents/componenti/components.mts
new file mode 100644
index 0000000..d750a71
--- /dev/null
+++ b/parte5-webcomponents/componenti/components.mts
@@ -0,0 +1 @@
+import { container } from "./container/container.mjs";
diff --git a/parte5-webcomponents/componenti/container/container.html b/parte5-webcomponents/componenti/container/container.html
new file mode 100644
index 0000000..fd39f76
--- /dev/null
+++ b/parte5-webcomponents/componenti/container/container.html
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/parte5-webcomponents/componenti/container/container.mjs b/parte5-webcomponents/componenti/container/container.mjs
new file mode 100644
index 0000000..c4518d3
--- /dev/null
+++ b/parte5-webcomponents/componenti/container/container.mjs
@@ -0,0 +1,9 @@
+import { AttaccaShadow, OttieniContentDaTemplate, OttieniTemplate } from "../function.mjs";
+export const container = customElements.define('container', class Container extends HTMLDivElement {
+ constructor() {
+ super();
+ const shadow = AttaccaShadow(this);
+ const templateContent = OttieniContentDaTemplate(OttieniTemplate('container-template'));
+ shadow.appendChild(templateContent);
+ }
+});
diff --git a/parte5-webcomponents/componenti/container/container.mts b/parte5-webcomponents/componenti/container/container.mts
new file mode 100644
index 0000000..839de81
--- /dev/null
+++ b/parte5-webcomponents/componenti/container/container.mts
@@ -0,0 +1,14 @@
+import { AttaccaShadow, OttieniContentDaTemplate, OttieniTemplate } from "../function.mjs"
+
+export const container = customElements.define('container',
+ class Container extends HTMLDivElement {
+ constructor() {
+ super()
+
+ const shadow = AttaccaShadow(this)
+ const templateContent = OttieniContentDaTemplate(OttieniTemplate('container-template'))
+
+ shadow.appendChild(templateContent)
+ }
+ }
+)
diff --git a/parte5-webcomponents/componenti/container/template.css b/parte5-webcomponents/componenti/container/template.css
new file mode 100644
index 0000000..e69de29
diff --git a/parte5-webcomponents/componenti/form/form.html b/parte5-webcomponents/componenti/form/form.html
new file mode 100644
index 0000000..8cf14b9
--- /dev/null
+++ b/parte5-webcomponents/componenti/form/form.html
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/parte5-webcomponents/componenti/form/form.mjs b/parte5-webcomponents/componenti/form/form.mjs
new file mode 100644
index 0000000..004d85a
--- /dev/null
+++ b/parte5-webcomponents/componenti/form/form.mjs
@@ -0,0 +1,12 @@
+import { InserisciTemplateNelloShadowDOM } from "../function.mjs";
+const formInfodit = customElements.define('form-infodit', class FormInfodit extends HTMLElement {
+ constructor() {
+ super();
+ //Creazione dello shadow Dom
+ const shadow = this.attachShadow({ mode: 'closed' });
+ //Prendiamo il contenuto del template e lo copiamo su una variabile
+ //const template = OttieniTemplateDaHTML('form.html','form-template') as Promise
+ //Attacchiamo la copia del template sullo shadow DOM
+ InserisciTemplateNelloShadowDOM(shadow, 'form.html', 'form-template');
+ }
+});
diff --git a/parte5-webcomponents/componenti/form/form.mts b/parte5-webcomponents/componenti/form/form.mts
new file mode 100644
index 0000000..0f2779b
--- /dev/null
+++ b/parte5-webcomponents/componenti/form/form.mts
@@ -0,0 +1,17 @@
+import { InserisciTemplateNelloShadowDOM } from "../function.mjs"
+
+const formInfodit = customElements.define('form-infodit',
+ class FormInfodit extends HTMLElement {
+ constructor() {
+ super()
+ //Creazione dello shadow Dom
+ const shadow = this.attachShadow({ mode: 'closed' })
+
+ //Prendiamo il contenuto del template e lo copiamo su una variabile
+ //const template = OttieniTemplateDaHTML('form.html','form-template') as Promise
+
+ //Attacchiamo la copia del template sullo shadow DOM
+ InserisciTemplateNelloShadowDOM(shadow,'form.html','form-template')
+ }
+ }
+)
\ No newline at end of file
diff --git a/parte5-webcomponents/componenti/form/prova.html b/parte5-webcomponents/componenti/form/prova.html
new file mode 100644
index 0000000..393ed49
--- /dev/null
+++ b/parte5-webcomponents/componenti/form/prova.html
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/parte5-webcomponents/componenti/function.mjs b/parte5-webcomponents/componenti/function.mjs
new file mode 100644
index 0000000..424e800
--- /dev/null
+++ b/parte5-webcomponents/componenti/function.mjs
@@ -0,0 +1,69 @@
+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());
+ });
+};
+/**
+ *
+ * @param elemento Per i custom Elements usa this
+ * @param aperto Predefinito = false
+ * @returns
+ */
+export function AttaccaShadow(elemento, aperto = false) {
+ if (!aperto) {
+ return elemento.attachShadow({ mode: 'closed' });
+ }
+ else {
+ return elemento.attachShadow({ mode: 'open' });
+ }
+}
+export function OttieniTemplate(id) {
+ return document.getElementById(id);
+}
+export function OttieniContentDaTemplate(template) {
+ return template.content;
+}
+// export function OttieniTemplateDaHTML(percorso: string, id_template:string): Node {
+// fetch(percorso)
+// .then(risposta => risposta.text())
+// .then(html => {
+// document.body.insertAdjacentHTML('beforeend',html)
+// const template = document.getElementById(id_template) as HTMLTemplateElement
+// const clone = template.cloneNode(true) as Node
+// return clone
+// })
+// }
+export function InserisciTemplateNelloShadowDOM(shadowRoot, percorso, id_template) {
+ return __awaiter(this, void 0, void 0, function* () {
+ try {
+ const risposta = yield fetch(percorso);
+ if (!risposta.ok) {
+ throw new Error(`Errore durante il caricamento del template: ${risposta.statusText}`);
+ }
+ const html = yield risposta.text();
+ // Verifica se il template è già presente nel DOM
+ if (!document.getElementById(id_template)) {
+ // Inserisci temporaneamente il template nel DOM per accedervi
+ document.body.insertAdjacentHTML('beforeend', html);
+ }
+ // Ottieni il template dal DOM
+ const template = document.getElementById(id_template);
+ if (!template) {
+ throw new Error(`Template con id "${id_template}" non trovato.`);
+ }
+ // Clona il contenuto del template
+ const clone = template.content.cloneNode(true);
+ // Appendi il clone allo shadowRoot
+ shadowRoot.appendChild(clone);
+ // Rimuovi il template temporaneamente inserito
+ template.remove();
+ }
+ catch (errore) {
+ console.error('Errore durante l\'inserimento del template nello shadow DOM:', errore);
+ }
+ });
+}
diff --git a/parte5-webcomponents/componenti/function.mts b/parte5-webcomponents/componenti/function.mts
new file mode 100644
index 0000000..8c82537
--- /dev/null
+++ b/parte5-webcomponents/componenti/function.mts
@@ -0,0 +1,68 @@
+
+/**
+ *
+ * @param elemento Per i custom Elements usa this
+ * @param aperto Predefinito = false
+ * @returns
+ */
+export function AttaccaShadow(elemento: Element, aperto = false) {
+ if (!aperto) {
+ return elemento.attachShadow({ mode: 'closed' })
+ } else {
+ return elemento.attachShadow({ mode: 'open' })
+ }
+}
+
+export function OttieniTemplate(id:string): HTMLTemplateElement {
+ return document.getElementById(id) as HTMLTemplateElement
+}
+
+export function OttieniContentDaTemplate(template: HTMLTemplateElement) {
+ return template.content
+}
+
+// export function OttieniTemplateDaHTML(percorso: string, id_template:string): Node {
+// fetch(percorso)
+// .then(risposta => risposta.text())
+// .then(html => {
+// document.body.insertAdjacentHTML('beforeend',html)
+// const template = document.getElementById(id_template) as HTMLTemplateElement
+// const clone = template.cloneNode(true) as Node
+
+// return clone
+// })
+// }
+
+export async function InserisciTemplateNelloShadowDOM(shadowRoot: ShadowRoot, percorso: string, id_template: string): Promise {
+ try {
+ const risposta = await fetch(percorso);
+ if (!risposta.ok) {
+ throw new Error(`Errore durante il caricamento del template: ${risposta.statusText}`);
+ }
+ const html = await risposta.text();
+
+ // Verifica se il template è già presente nel DOM
+ if (!document.getElementById(id_template)) {
+ // Inserisci temporaneamente il template nel DOM per accedervi
+ document.body.insertAdjacentHTML('beforeend', html);
+ }
+
+ // Ottieni il template dal DOM
+ const template = document.getElementById(id_template) as HTMLTemplateElement;
+ if (!template) {
+ throw new Error(`Template con id "${id_template}" non trovato.`);
+ }
+
+ // Clona il contenuto del template
+ const clone = template.content.cloneNode(true);
+
+ // Appendi il clone allo shadowRoot
+ shadowRoot.appendChild(clone);
+
+ // Rimuovi il template temporaneamente inserito
+ template.remove();
+
+ } catch (errore) {
+ console.error('Errore durante l\'inserimento del template nello shadow DOM:', errore);
+ }
+}
diff --git a/parte5-webcomponents/componenti/prodotti-casa/esempio.html b/parte5-webcomponents/componenti/prodotti-casa/esempio.html
new file mode 100644
index 0000000..7778819
--- /dev/null
+++ b/parte5-webcomponents/componenti/prodotti-casa/esempio.html
@@ -0,0 +1,10 @@
+
+ Detersivo
+ $10.00
+
+
+ Sapone Mani
+ $5.00
+
+
+
\ No newline at end of file
diff --git a/parte5-webcomponents/componenti/prodotti-casa/prodotti-casa.html b/parte5-webcomponents/componenti/prodotti-casa/prodotti-casa.html
new file mode 100644
index 0000000..7bacdf1
--- /dev/null
+++ b/parte5-webcomponents/componenti/prodotti-casa/prodotti-casa.html
@@ -0,0 +1,34 @@
+
+
+
+
+
+ Nome prodotto
+
+
+ €0.00
+
+
+
+
diff --git a/parte5-webcomponents/componenti/prodotti-casa/prodotti-casa.mjs b/parte5-webcomponents/componenti/prodotti-casa/prodotti-casa.mjs
new file mode 100644
index 0000000..bf9f64f
--- /dev/null
+++ b/parte5-webcomponents/componenti/prodotti-casa/prodotti-casa.mjs
@@ -0,0 +1,11 @@
+import { InserisciTemplateNelloShadowDOM } from "../function.mjs"
+
+customElements.define('prodotto-casa',
+ class ProdottoCasa extends HTMLElement {
+ constructor() {
+ super()
+
+ InserisciTemplateNelloShadowDOM(this.attachShadow({mode:'closed'}),'prodotti-casa.html','prodotto-casa-template')
+ }
+ }
+)
\ No newline at end of file
diff --git a/parte5-webcomponents/componenti/pulsante/pulsante.css b/parte5-webcomponents/componenti/pulsante/pulsante.css
new file mode 100644
index 0000000..42ca695
--- /dev/null
+++ b/parte5-webcomponents/componenti/pulsante/pulsante.css
@@ -0,0 +1,11 @@
+div {
+ width: max-content;
+ border: 1px solid;
+ border-radius: 5px;
+ margin: 10px;
+ padding: 5px 10px;
+ cursor: pointer;
+}
+.giallo {
+ background-color: yellow;
+}
\ No newline at end of file
diff --git a/parte5-webcomponents/componenti/pulsante/pulsante.html b/parte5-webcomponents/componenti/pulsante/pulsante.html
index 0464721..97ea431 100644
--- a/parte5-webcomponents/componenti/pulsante/pulsante.html
+++ b/parte5-webcomponents/componenti/pulsante/pulsante.html
@@ -1,15 +1,41 @@
-
-
-
\ No newline at end of file
+
+
+ }
+
+ customElements.define('mio-pulsante', Pulsante)
+
\ No newline at end of file
diff --git a/parte5-webcomponents/componenti/pulsante/pulsante.mjs b/parte5-webcomponents/componenti/pulsante/pulsante.mjs
new file mode 100644
index 0000000..c50785b
--- /dev/null
+++ b/parte5-webcomponents/componenti/pulsante/pulsante.mjs
@@ -0,0 +1,29 @@
+"use strict";
+class ElementoPersonalizzato {
+ /**
+ *
+ * @param nomeSelettore Dai un nome specifico per l'elemento
+ * @param css Crea una cartella per ogni componente e usa come percorso il nome della cartella e il file CSS
+ */
+ constructor(nomeSelettore, css) {
+ this.selettori = OttientiSelettori(nomeSelettore);
+ this.selettori.forEach(elemento => {
+ AggiungiEvento(elemento, 'click', () => elemento.classList.add('giallo'));
+ });
+ OttieniCSS(css);
+ }
+}
+const pulsante = new ElementoPersonalizzato('pulsante', 'pulsante/pulsante.css');
+function OttientiSelettori(nome) {
+ return document.querySelectorAll(nome);
+}
+function AggiungiEvento(element, type, funzione) {
+ element.addEventListener(type, funzione);
+}
+function OttieniCSS(href) {
+ let head = document.getElementsByTagName('HEAD')[0];
+ let link = document.createElement('link');
+ link.rel = 'stylesheet';
+ link.href = './componenti/' + href;
+ head.appendChild(link);
+}
diff --git a/parte5-webcomponents/componenti/pulsante/pulsante.mts b/parte5-webcomponents/componenti/pulsante/pulsante.mts
new file mode 100644
index 0000000..f77252e
--- /dev/null
+++ b/parte5-webcomponents/componenti/pulsante/pulsante.mts
@@ -0,0 +1,37 @@
+class ElementoPersonalizzato {
+ selettori: NodeListOf;
+
+ /**
+ *
+ * @param nomeSelettore Dai un nome specifico per l'elemento
+ * @param css Crea una cartella per ogni componente e usa come percorso il nome della cartella e il file CSS
+ */
+ constructor(
+ nomeSelettore: string, css: string
+ ) {
+ this.selettori = OttientiSelettori(nomeSelettore)
+ this.selettori.forEach(elemento => {
+ AggiungiEvento(elemento, 'click', () => elemento.classList.add('giallo'))
+ });
+ OttieniCSS(css)
+ }
+}
+
+const pulsante = new ElementoPersonalizzato('pulsante', 'pulsante/pulsante.css')
+
+function OttientiSelettori(nome:string): NodeListOf {
+ return document.querySelectorAll(nome)
+}
+
+function AggiungiEvento(element: Element, type: keyof HTMLElementEventMap, funzione: (this: HTMLElement, ev: Event) => any) {
+ element.addEventListener(type, funzione);
+}
+
+function OttieniCSS(href: string) {
+ let head = document.getElementsByTagName('HEAD')[0];
+ let link = document.createElement('link');
+ link.rel = 'stylesheet';
+ link.href = './componenti/' + href;
+ head.appendChild(link);
+}
+
diff --git a/parte5-webcomponents/componenti/pulsante/pulsante.ts b/parte5-webcomponents/componenti/pulsante/pulsante.ts
index d012a29..e69de29 100644
--- a/parte5-webcomponents/componenti/pulsante/pulsante.ts
+++ b/parte5-webcomponents/componenti/pulsante/pulsante.ts
@@ -1,17 +0,0 @@
-class Pulsante extends HTMLElement {
- constructor() {
- super();
-
- const shadow = this.attachShadow({mode: 'closed'})
- const template = document.getElementById('pulsante-template') as HTMLTemplateElement
-
- const templateClonato = template.content.cloneNode(true)
- shadow.appendChild(templateClonato)
-
- this.addEventListener('click', () => {
- this.classList.toggle('giallo')
- })
- }
-}
-
-customElements.define('mio-pulsante', Pulsante)
\ No newline at end of file
diff --git a/parte5-webcomponents/web-components.html b/parte5-webcomponents/web-components.html
index e537f10..9ad9fd6 100644
--- a/parte5-webcomponents/web-components.html
+++ b/parte5-webcomponents/web-components.html
@@ -8,41 +8,12 @@
-
-
-
-
-
- Ciao
+ Clicca
-
-
+
+