String.prototype.base64_encode = function() { var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = this; // ----- do { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; } output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4); } while (i < input.length); return output; }; String.prototype.base64_decode = function() { var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; // remove all characters that are not A-Z, a-z, 0-9, +, /, or = input = this.replace(/[^A-Za-z0-9\+\/\=]/g, ""); do { enc1 = keyStr.indexOf(input.charAt(i++)); enc2 = keyStr.indexOf(input.charAt(i++)); enc3 = keyStr.indexOf(input.charAt(i++)); enc4 = keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } } while (i < input.length); return output; }; function $feedback(message) { try { alert(message); // ----- } catch(e) { } } function getQuestionKeyByID(question, id) { for(var q in question) { if(typeof(question[q]) == 'object' && parseInt(question[q].id) == id) { return q; // ----- } } return 0; // ----- } function getSelectedResponse(response) { var selected = ''; // ----- response.each(function(el) { if(el.checked) { selected += el.value + ';'; // ----- } }); return selected; // ----- } /** * verifica se è stata selezionata una risposta valida */ function checkSelectedResponse(response) { if(response.trim() == '') { return false; // ----- } else { return true; // ----- } } /** * verifica se è stato inserito un username valido * - almeno 3 caratteri * - massimo 15 caratteri * - presenza di caratteri speciali */ function checkUsername(username) { if(username.trim() == '' || username.trim().length < 3 || username.trim().length > 15) { return false; // ----- } else { // todo: verifica la presenza di caratteri speciali // ----- return true; // ----- } } /** * verifica se è stato inserita un password valida * - almeno 3 caratteri * - massimo 15 caratteri * - presenza di caratteri speciali* * - uguaglianza con la conferma */ function checkPassword(password, conferma) { if(password.trim() == '' || password.trim().length < 3 || password.trim().length > 15) { return false; // ----- } else { // todo: verifica la presenza di caratteri speciali // ----- if(password.trim() == conferma.trim()) { return true; // ----- } else { return false; // ----- } } } /** * verifica se è stato inserito un indirizzo email valido * - valore blank * - verifica indirizzo email */ function checkEmail(email) { if(email.trim() == '') { return false; // ----- } else { var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (pattern.test(email.trim())) { return true; // ----- } else { return false; // ----- } } } /** * verifica se è stato selezionato il check privacy */ function checkPrivacy(checked) { return checked; // ----- } /** * verifica se è stato selezionato il check termini di servizio */ function checkTerminiDiServizio(checked) { return checked; // ----- } /** * verifica se è stato inserito un nome valido * - valore blank * - presenza di caratteri speciali* */ function checkName(name) { if(name.trim() == '') { return false; // ----- } else { // todo: verifica la presenza di caratteri speciali // ----- return true; // ----- } } /** * verifica se è stato inserito un commento valido * - valore blank * - presenza di caratteri speciali* */ function checkComments(comments) { if(comments.trim() == '') { return false; // ----- } else { // todo: verifica la presenza di caratteri speciali // ----- return true; // ----- } } function getFileExtension(fileName) { var extension = fileName.split('.'); extension = extension[extension.length-1].split('?')[0]; return extension; } function getFileTypeByExtension(extension) { extension = extension.toLowerCase(); var types = {}; types.image = ['jpg','jpeg','gif','png']; types.video = ['mp4','avi','flv','swf']; types.audio = ['mp3','wav']; for(var i in types) { for(var k=0;kKevin


van Zonneveld', ''); // * returns 1: 'Kevin van Zonneveld' // * example 2: strip_tags('

Kevin van Zonneveld

', '

'); // * returns 2: '

Kevin van Zonneveld

' // * example 3: strip_tags("Kevin van Zonneveld", ""); // * returns 3: 'Kevin van Zonneveld' var key = '', tag = '', allowed = false; var matches = allowed_array = []; var replacer = function(search, replace, str) { return str.split(search).join(replace); }; // Build allowes tags associative array if (allowed_tags) { allowed_array = allowed_tags.match(/([a-zA-Z]+)/gi); } str += ''; // Match tags matches = str.match(/(<\/?[^>]+>)/gi); // Go through all HTML tags for (key in matches) { if (isNaN(key)) { // IE7 Hack continue; } // Save HTML tag html = matches[key].toString(); // Is tag not in allowed list? Remove from str! allowed = false; // Go through all allowed tags for (k in allowed_array) { // Init allowed_tag = allowed_array[k]; i = -1; if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+'>');} if (i != 0) { i = html.toLowerCase().indexOf('<'+allowed_tag+' ');} if (i != 0) { i = html.toLowerCase().indexOf('"; testo = strip_tags(testo, arrayTags); testo = testo.replace(/[\s]on\D+\s*=\s*['"].+['"]/gi,""); return testo; } function setEmbedSize(embed, format) { switch(format) { case 1: { var embed_width = 150; var embed_height = 114; }break; case 2: { var embed_width = 250; var embed_height = 190; }break; case 3: { var embed_width = 370; var embed_height = 310; }break; } embed = embed.replace(/width=['"]{1}\d+['"]{1}/gi,"width=\""+embed_width+"\""); embed = embed.replace(/height=['"]{1}\d+['"]{1}/gi,"height=\""+embed_height+"\""); return embed; } var LightBox = function() { this.element = 'lightbox'; // ----- }; LightBox.prototype = {}; // ----- LightBox.prototype.view = function(content) { var self = this; // ----- var body = document.getElementsByTagName('body')[0]; body.style.height = '100%'; body.style.width = '100%'; body.style.overflow = 'hidden'; // ----- var html = document.getElementsByTagName('html')[0]; html.style.height = '100%'; html.style.width = '100%'; html.style.overflow = 'hidden'; // ----- var ws = window.getSize(); // ----- var element = new Element('div'); var overlay = new Element('div', {'id': 'overlay'}).inject(element); var lightbox_content = new Element('div', {'id': 'lightbox_content', 'style': 'top: 80px; left: ' + Math.round((ws.size.x/2)-260) + 'px;'}).inject(element); // ----- content.inject(lightbox_content); element.inject($(this.element).empty()) // ----- if(window.ie) { lightbox_content.setStyle('top', 80); lightbox_content.setStyle('left', Math.round((ws.size.x/2)-260)); // ----- } }; LightBox.prototype.remove = function() { if(window.ie) { var body = document.getElementsByTagName('body')[0]; body.style.height = 'auto'; body.style.width = 'auto'; body.style.overflow = 'auto'; // ----- var html = document.getElementsByTagName('html')[0]; html.style.height = 'auto'; html.style.width = 'auto'; html.style.overflow = 'auto'; // ----- } else if(window.gecko) { var body = document.getElementsByTagName('body')[0]; body.style.height = 'auto'; body.style.width = 'auto'; body.style.overflow = 'visible'; // ----- var html = document.getElementsByTagName('html')[0]; html.style.height = 'auto'; html.style.width = 'auto'; html.style.overflow = 'visible'; // ----- } $(this.element).empty(); // ----- }; var YouKuki = function(language) { this.language = ((language != undefined) ? (language) : ($LANGUAGE)); // ----- // browser this.browser = { screen: { width: screen.width, height: screen.height, colorDepth: screen.colorDepth }, appName: navigator.appName, userAgent: navigator.userAgent }; this.cookie = null; this.site = null; // ----- this.initialize(); // ----- }; YouKuki.prototype = {}; // ----- YouKuki.prototype.initialize = function() { }; YouKuki.prototype.infoSondaggioCondiviso = function() { var element = new Element('div'); var baloon = new Element('div', {'class': 'baloon'}).inject(element); var close = new Element('div', {'id': 'close'}).inject(baloon); var close_link = new Element('a', {'href': 'javascript:;'}).setHTML('').inject(close); var cont = new Element('div', {'class': 'cont'}).inject(baloon); var intestazione = new Element('h2').setHTML('Sondaggio condiviso').inject(cont); var br = new Element('br').inject(cont); var content = new Element('div', {'class': 'contentLightbox'}).setHTML($YKK.language.lightbox.infoSondaggioCondiviso).inject(cont); var bottom = new Element('div', {'class': 'bottom'}).inject(element); // ----- $LIGHTBOX.view(element); // ----- close_link.addEvent('click', function(event) { event = new Event(event); event.stop(); // ----- $LIGHTBOX.remove(); // ----- }); }; YouKuki.prototype.infoDisabilitaSeven = function() { var element = new Element('div'); var baloon = new Element('div', {'class': 'baloon'}).inject(element); var close = new Element('div', {'id': 'close'}).inject(baloon); var close_link = new Element('a', {'href': 'javascript:;'}).setHTML('').inject(close); var cont = new Element('div', {'class': 'cont'}).inject(baloon); var intestazione = new Element('h2').setHTML('Disabilita 1 su 7').inject(cont); var br = new Element('br').inject(cont); var content = new Element('div', {'class': 'contentLightbox'}).setHTML($YKK.language.lightbox.infoDisabilitaSeven).inject(cont); var bottom = new Element('div', {'class': 'bottom'}).inject(element); // ----- $LIGHTBOX.view(element); // ----- close_link.addEvent('click', function(event) { event = new Event(event); event.stop(); // ----- $LIGHTBOX.remove(); // ----- }); }; YouKuki.prototype.infoSondaggiTematici = function() { var element = new Element('div'); var baloon = new Element('div', {'class': 'baloon'}).inject(element); var close = new Element('div', {'id': 'close'}).inject(baloon); var close_link = new Element('a', {'href': 'javascript:;'}).setHTML('').inject(close); var cont = new Element('div', {'class': 'cont'}).inject(baloon); var intestazione = new Element('h2').setHTML('Prendi qui i sondaggi tematici già pronti').inject(cont); var br = new Element('br').inject(cont); var content = new Element('div', {'class': 'contentLightbox'}).setHTML($YKK.language.lightbox.infoSondaggiTematici).inject(cont); var bottom = new Element('div', {'class': 'bottom'}).inject(element); // ----- $LIGHTBOX.view(element); // ----- close_link.addEvent('click', function(event) { event = new Event(event); event.stop(); // ----- $LIGHTBOX.remove(); // ----- }); }; YouKuki.prototype.infoPrivacy = function() { var element = new Element('div'); var baloon = new Element('div', {'class': 'baloon'}).inject(element); var close = new Element('div', {'id': 'close'}).inject(baloon); var close_link = new Element('a', {'href': 'javascript:;'}).setHTML('').inject(close); var cont = new Element('div', {'class': 'cont'}).inject(baloon); //var intestazione = new Element('h2').setHTML('Consenso Privacy').inject(cont); /*var intestazione = new Element('h2').setHTML($YKK.language.privacy.title).inject(cont); var br = new Element('br').inject(cont); var content = new Element('div', {'class': 'contentLightbox'}).setHTML($YKK.language.privacy.testo).inject(cont);*/ cont.innerHTML = $YKK.language.privacy; var bottom = new Element('div', {'class': 'bottom'}).inject(element); // ----- $LIGHTBOX.view(element); // ----- close_link.addEvent('click', function(event) { event = new Event(event); event.stop(); // ----- $LIGHTBOX.remove(); // ----- }); }; YouKuki.prototype.infoTerminiDiServizio = function() { var element = new Element('div'); var baloon = new Element('div', {'class': 'baloon'}).inject(element); var close = new Element('div', {'id': 'close'}).inject(baloon); var close_link = new Element('a', {'href': 'javascript:;'}).setHTML('').inject(close); var cont = new Element('div', {'class': 'cont'}).inject(baloon); //var intestazione = new Element('h2').setHTML('Condizioni d\'utilizzo del servizio').inject(cont); /*var intestazione = new Element('h2').setHTML($YKK.language.terminiServizio.title).inject(cont); var br = new Element('br').inject(cont); var content = new Element('div', {'class': 'contentLightbox'}).setHTML($YKK.language.terminiServizio.testo).inject(cont);*/ cont.innerHTML = $YKK.language.terminiServizio; var bottom = new Element('div', {'class': 'bottom'}).inject(element); // ----- $LIGHTBOX.view(element); // ----- close_link.addEvent('click', function(event) { event = new Event(event); event.stop(); // ----- $LIGHTBOX.remove(); // ----- }); }; var objCookie = function(row, readonly) { this.type = 'cookie'; this.readonly = ((readonly != undefined && readonly == true) ? (true) : (false)); // ----- this.id = row.id; this.ip = row.ip; this.timestamp = row.timestamp; this.tu = row.tu; // ----- }; objCookie.prototype = {}; // ----- var objSite = function(row, readonly) { this.type = 'site'; this.readonly = ((readonly != undefined && readonly == true) ? (true) : (false)); // ----- this.id = row.id; this.scheme = row.scheme; this.host = row.host; this.path = row.path; this.md5 = row.md5; // ----- }; objSite.prototype = {}; // ----- var elSignup = function(ccr, activatecode) { this.element = 'elSignup'; // ----- this.load((ccr != undefined) ? (ccr) : (''), (activatecode != undefined) ? (activatecode) : ('')); // ----- }; elSignup.prototype = {}; // ----- elSignup.prototype.load = function(ccr, activatecode) { var self = this; // ----- var url = _SERVICE_CORE; var xhr = new Ajax(url); // ----- var params = { fase: 'core__ccr', ccr: ccr, activatecode: activatecode }; xhr.addEvent('onComplete', function(json) { var response = Json.evaluate(json); // ----- switch(response.status) { default: case null: case undefined: case false: { self.toElement().inject($(self.element).empty()); // ----- }break; case true: { self.toElementComplete(response.feedback).inject($(self.element).empty()); // ----- }break; } }); xhr.request(params); // ----- }; elSignup.prototype.toElement = function(message) { var self = this; // ----- var element = new Element('div'); var feedback = new Element('div').inject(element); // ----- if(message != undefined) { new Element('p', {'class': 'feedback'}).setHTML(message).inject(feedback.empty()); // ----- } var baloon = new Element('div', {'class': 'baloon'}).inject(element); var form = new Element('form', {'id': 'registrazione', 'onsubmit': 'return false;'}).inject(baloon); var username_label = new Element('label', {'for': 'registrazione__username'}).setHTML(' ' + $YKK.language.registrazione.user + ' ').inject(form); var username_input = new Element('input', {'type': 'text', 'id': 'registrazione__username', 'name': 'registrazione__username'}).inject(form); var password_label = new Element('label', {'for': 'registrazione__password'}).setHTML(' ' + $YKK.language.registrazione.password + ' ').inject(form); var password_input = new Element('input', {'type': 'password', 'id': 'registrazione__password', 'name': 'registrazione__password'}).inject(form); var password_conferma_label = new Element('label', {'for': 'registrazione__conferma'}).setHTML(' ' + $YKK.language.registrazione.confermaPassword + ' ').inject(form); var password_conferma_input = new Element('input', {'type': 'password', 'id': 'registrazione__conferma', 'name': 'registrazione__conferma'}).inject(form); var email_label = new Element('label', {'for': 'registrazione__email'}).setHTML(' ' + $YKK.language.registrazione.eMail + ' ').inject(form); var email_input = new Element('input', {'type': 'text', 'id': 'registrazione__email', 'name': 'registrazione__email'}).inject(form); var privacy_label = new Element('label', {'for': 'registrazione__privacy'}).setHTML('' + $YKK.language.registrazione.consensoPrivacy + '').inject(form); var privacy_input = new Element('input', {'type': 'checkbox', 'id': 'registrazione__privacy', 'name': 'registrazione__privacy'}).inject(form); var br = new Element('br', {'class': 'clear'}).inject(form); var terminiservizio_label = new Element('label', {'for': 'registrazione__terminiservizio'}).setHTML('' + $YKK.language.registrazione.terminiServizio + '').inject(form); var terminiservizio_input = new Element('input', {'type': 'checkbox', 'id': 'registrazione__terminiservizio', 'name': 'registrazione__terminiservizio'}).inject(form); // ----- var btn = new Element('div', {'class': 'right', 'style': 'float: right;'}).inject(form); var btn_invia = new Element('input', {'type': 'image', 'src': _URL_MULTIMEDIA + '/images/butt_invia_1.gif'}).inject(btn); var btn_br = new Element('br', {'style': 'clear: both;'}).inject(btn); // ----- var br = new Element('br', {'style': 'clear: both;'}).inject(form); // ----- var bottom = new Element('div', {'class': 'bottom'}).inject(element); // ----- form.addEvent('submit', function(event) { event = new Event(event); event.stop(); // ----- var username = username_input.value.trim(); var password = password_input.value.trim(); var password_conferma = password_conferma_input.value.trim(); var email = email_input.value.trim(); var privacy = privacy_input.checked; var terminidiservizio = terminiservizio_input.checked; // ----- // check username if(!checkUsername(username)) { new Element('p', {'class': 'feedback', 'style': 'color: red;'}).setHTML($YKK.language.feedback.checkUsername).inject(feedback.empty()); // ----- return false; // ----- } // check password if(!checkPassword(password, password_conferma)) { new Element('p', {'class': 'feedback', 'style': 'color: red;'}).setHTML($YKK.language.feedback.checkPassword).inject(feedback.empty()); // ----- return false; // ----- } // check email if(!checkEmail(email)) { new Element('p', {'class': 'feedback', 'style': 'color: red;'}).setHTML($YKK.language.feedback.checkEmail).inject(feedback.empty()); // ----- return false; // ----- } // check privacy if(!checkPrivacy(privacy)) { new Element('p', {'class': 'feedback', 'style': 'color: red;'}).setHTML($YKK.language.feedback.checkPrivacy).inject(feedback.empty()); // ----- return false; // ----- } // check termini di servizio if(!checkTerminiDiServizio(terminidiservizio)) { new Element('p', {'class': 'feedback', 'style': 'color: red;'}).setHTML($YKK.language.feedback.checkTerminiDiServizio).inject(feedback.empty()); // ----- return false; // ----- } var params = { fase: 'core__registrazione', auth: (username + ':' + password + ':' + email).base64_encode() }; var url = _SERVICE_CORE; var xhr = new Ajax(url); // ----- xhr.addEvent('onComplete', function(json) { var response = Json.evaluate(json); // ----- switch(response.status) { default: case null: case undefined: case false: { new Element('p', {'class': 'feedback', 'style': 'color: red;'}).setHTML(response.feedback).inject(feedback.empty()); // ----- }break; case true: { location.replace(_URL_SIGNUP + '?ccr=' + response.ccr); // ----- }break; } }); xhr.request(params); // ----- }); return element; // ----- }; elSignup.prototype.toElementComplete = function(message) { var self = this; // ----- var element = new Element('div'); // ----- var baloon = new Element('div', {'class': 'baloon'}).inject(element); var feedback = new Element('p', {'class': 'feedback'}).setHTML(message).inject(baloon); // ----- var bottom = new Element('div', {'class': 'bottom'}).inject(element); // ----- return element; // ----- }; var elLogin = function() { this.element = 'elLogin'; // ----- this.toElement().inject($(this.element).empty()); // ----- }; elLogin.prototype = {}; // ----- elLogin.prototype.toElement = function(message) { var self = this; // ----- var element = new Element('div', {'id': 'login'}); var feedback = new Element('div').inject(element); // ----- if(message != undefined) { new Element('p', {'class': 'feedback'}).setHTML(message).inject(feedback.empty()); // ----- } var form = new Element('form', {'onsubmit': 'return false;'}).inject(element); var fieldset = new Element('fieldset',{'class': 'float-left'}).inject(form); var legend = new Element('legend').setHTML(' Login ').inject(fieldset); var div_username = new Element('div', {'class': 'inputTextLogin'}).inject(fieldset); var username_label = new Element('label', {'for': 'security__password'}).setHTML(' ' + $YKK.language.formLogIn.user + ' ').inject(div_username); var username_input = new Element('input', {'type': 'text', 'id': 'security__username', 'name': 'security__username'}).inject(div_username); var div_password = new Element('div', {'class': 'inputTextLogin'}).inject(fieldset); var password_label = new Element('label', {'for': 'security__password'}).setHTML(' ' + $YKK.language.formLogIn.password + ' ').inject(div_password); var password_input = new Element('input', {'type': 'password', 'id': 'security__password', 'name': 'security__password'}).inject(div_password); var recuperopassword = new Element('p').inject(div_password); var recuperopassword_link = new Element('a', {'href': 'javascript:;', 'title': $YKK.language.formLogIn.passwordDimenticata}).setHTML(' ' + $YKK.language.formLogIn.passwordDimenticata + ' ').inject(recuperopassword); // ----- var btn = new Element('div', {'class': 'inputBtnLogin'}).inject(form); var btn_login = new Element('input', {'type': 'image', 'src': _URL_MULTIMEDIA + '/images/butt_loginSmall.gif'}).inject(btn); // ----- var br = new Element('br', {'class': 'clear'}).inject(form); var br = new Element('br', {'class': 'clear'}).inject(element); // ----- recuperopassword_link.addEvent('click', function(event) { event = new Event(event); event.stop(); // ----- // vai al recupero password senza feedback self.toElementLostPassword().inject($(self.element).empty()); // ----- }); form.addEvent('submit', function(event) { event = new Event(event); event.stop(); // ----- var username = username_input.value.trim(); var password = password_input.value.trim(); // ----- // check username if(!checkUsername(username)) { new Element('p', {'class': 'feedback', 'style': 'color: red;'}).setHTML($YKK.language.feedback.checkUsername).inject(feedback.empty()); // ----- return false; // ----- } var params = { fase: 'core__login', auth: (username + ':' + password).base64_encode() }; var url = _SERVICE_CORE; var xhr = new Ajax(url); // ----- xhr.addEvent('onComplete', function(json) { var response = Json.evaluate(json); // ----- switch(response.status) { default: case null: case undefined: case false: { new Element('p', {'class': 'feedback', 'style': 'color: red;'}).setHTML(response.feedback).inject(feedback.empty()); // ----- }break; case true: { // aggiorna la pagina location.replace(_URL_MY); // ----- }break; } }); xhr.request(params); // ----- }); return element; // ----- }; elLogin.prototype.toElementLostPassword = function(message) { var self = this; // ----- var element = new Element('div', {'id': 'login', 'class': 'lostPwd'}); var feedback = new Element('div').inject(element); // ----- if(message != undefined) { new Element('p', {'class': 'feedback'}).setHTML(message).inject(feedback.empty()); // ----- } // ----- var form = new Element('form', {'onsubmit': 'return false;'}).inject(element); var fieldset = new Element('fieldset',{'class':'float-left'}).inject(form); var legend = new Element('legend').setHTML(' Login ').inject(fieldset); var divUser = new Element('div',{'class':'inputTextLogin'}).inject(fieldset); var username_label = new Element('label', {'for': 'recuperopassword__username'}).setHTML(' Username ').inject(divUser); var username_input = new Element('input', {'type': 'text', 'id': 'recuperopassword__username', 'name': 'recuperopassword__username'}).inject(divUser); var divMail = new Element('div',{'class':'inputTextLogin'}).inject(fieldset); var email_label = new Element('label', {'for': 'recuperopassword__email'}).setHTML(' Email ').inject(divMail); var email_input = new Element('input', {'type': 'text', 'id': 'recuperopassword__email', 'name': 'recuperopassword__email'}).inject(divMail); // ----- var btn = new Element('div', {'class': 'inputBtnRecupero'}).inject(form); var btn_invia = new Element('input', {'type': 'image', 'src': _URL_MULTIMEDIA + '/images/butt_invia_1Small.gif'}).inject(btn); var btn = new Element('div', {'class': 'inputBtnRecupero'}).inject(form); var btn_cancella = new Element('input', {'type': 'image', 'src': _URL_MULTIMEDIA + '/images/butt_cancella_1Small.gif'}).inject(btn); // ----- var br = new Element('br', {'class': 'clear'}).inject(element); var p = new Element('p').setHTML('Inserisci il tuo username e la tua email, la password ti verrà inviata entro pochi istanti').inject(element); var br = new Element('br', {'class': 'clear'}).inject(element); // ----- btn_cancella.addEvent('click', function(event) { event = new Event(event); event.stop(); // ----- // deve ritornare alla login senza feedback self.toElement().inject($(self.element).empty()); // ----- }); form.addEvent('submit', function(event) { event = new Event(event); event.stop(); // ----- var username = username_input.value.trim(); var email = email_input.value.trim(); // ----- // check username if(!checkUsername(username)) { new Element('p', {'class': 'feedback', 'style': 'color: red;'}).setHTML($YKK.language.feedback.checkUsername).inject(feedback.empty()); // ----- return false; // ----- } // check email if(!checkEmail(email)) { new Element('p', {'class': 'feedback', 'style': 'color: red;'}).setHTML($YKK.language.feedback.checkEmail).inject(feedback.empty()); // ----- return false; // ----- } var params = { fase: 'core__recuperapassword', auth: (username + ':' + email).base64_encode() }; var url = _SERVICE_CORE; var xhr = new Ajax(url); // ----- xhr.addEvent('onComplete', function(json) { var response = Json.evaluate(json); // ----- switch(response.status) { default: case null: case undefined: case false: { new Element('p', {'class': 'feedback', 'style': 'color: red;'}).setHTML(response.feedback).inject(feedback.empty()); // ----- }break; case true: { // deve ritornare alla login con il feedback self.toElement(response.feedback).inject($(self.element).empty()); // ----- }break; } }); xhr.request(params); // ----- }); return element; // ----- }; var $YKK = new YouKuki(); // -----