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(''+allowed_tag) ;}
// Determine
if (i == 0) {
allowed = true;
break;
}
}
if (!allowed) {
str = replacer(html, "", str); // Custom replace. No regexing
}
}
return str;
}
function checkTags(testo)
{
var arrayTags = " ";
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 objSurvey = function(row, readonly, element) {
this.type = 'survey';
this.readonly = ((readonly != undefined && readonly == false) ? (false) : (true));
this.element = ((element != undefined) ? (element) : (false));
this.lightbox = false;
// -----
this.mode = null;
this.view = null;
this.selected_question = 0;
this.open = [];
// -----
this.survey = {
id: row.id,
uid: row.uid,
format: row.format,
template: row.template,
language: row.language,
share: row.share,
code: row.code,
statistiche: row.statistiche,
question: row.question
/*available: ((row.available != undefined && row.available == true) ? (true) : (false))*/
};
// available
this.available = function() {
// qui devo effettuare un controllo di validità
// per chi lo necessita in visualizzazione
return true;
// -----
};
};
objSurvey.prototype = {};
// -----
objSurvey.prototype.toElement = function(lightbox) {
switch(this.mode) {
default:
case null:
case undefined:
case 'survey': {
if(!this.readonly) {
if(lightbox) {
return this.toElementSurvey(this.selected_question).lightbox();
// -----
}
else {
return this.toElementSurvey(this.selected_question);
// -----
}
}
else {
this.mode = 'results';
return this.toElement(lightbox);
// -----
}
}break;
case 'results': {
if(lightbox) {
return this.toElementResults(this.selected_question).lightbox();
// -----
}
else {
return this.toElementResults(this.selected_question);
// -----
}
}break;
case 'code': {
if(lightbox) {
return this.toElementCode(this.survey.code).lightbox();
// -----
}
else {
return this.toElementCode(this.survey.code);
// -----
}
}break;
}
};
objSurvey.prototype.toElementSurvey = function(q) {
var self = this;
// -----
var q = parseInt((q != undefined) ? (q) : (0));
var question = this.survey.question[q];
var type = parseInt(question.type);
// -----
var element = new Element('div');
// -----
var baloon = new Element('div', {'class': 'baloon'}).inject(element);
// -----
// close lightbox button
if(this.lightbox) {
var close = new Element('div', {'id': 'close'}).inject(baloon);
var close_link = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(close);
// -----
close_link.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
self.lightbox = false;
// -----
$LIGHTBOX.remove();
// -----
});
}
var form = new Element('form', {'name': 'question' + question.id}).inject(baloon);
var request = new Element('h2').setHTML(question.request).inject(form);
// -----
// media
switch(parseInt(question.media.type)) {
default:
case null:
case undefined: {
// no media
}break;
// image
case 1: {
var br = new Element('br').inject(form);
// -----
var path = _URL_MULTIMEDIA + '/media/' + self.survey.id + '/' + question.id;
var question_media_filename = path + '/' + question.media.filename + '_' + 'hp' + '.' + question.media.extension;
// -----
var embed = ' ';
var media = new Element('div').setHTML(embed).inject(form);
// -----
}break;
// video
case 2: {
var br = new Element('br').inject(form);
// -----
var embed_width = 396;
var embed_height = 332;
var path = _URL_MULTIMEDIA + '/media/' + self.survey.id + '/' + question.id;
var question_media_filename = path + '/' + question.media.filename + '_' + 'hp' + '.' + question.media.extension;
// -----
var embed = ' ';
var media = new Element('div').setHTML(embed).inject(form);
// -----
}break;
case 3: {
var br = new Element('br').inject(form);
// -----
var embed_width = 396;
var embed_height = 332;
// -----
//var embed = ' ';
var embed = question.media.embed;
var media = new Element('div').setHTML(embed).inject(form);
// -----
}break;
}
var response = [];
// -----
switch(type) {
case 1: {
var ul = new Element('ul').inject(form);
// -----
question.response.each(function(el) {
var li = new Element('li').inject(ul);
// -----
var input = new Element('input', {'type': 'checkbox', 'name': 'response', 'value': el.id}).inject(li);
var label = new Element('label').setHTML(' ' + el.response + ' ').inject(li);
// -----
response.push(input);
// -----
});
}break;
case 2: {
var ul = new Element('ul').inject(form);
// -----
question.response.each(function(el) {
var li = new Element('li').inject(ul);
// -----
var input = new Element('input', {'type': 'radio', 'name': 'response', 'value': el.id}).inject(li);
var label = new Element('label').setHTML(' ' + el.response + ' ').inject(li);
// -----
response.push(input);
// -----
});
}break;
case 3: {
var response = new Element('textarea', {'rows': '6', 'id': 'rispostaAperta'}).inject(form);
// -----
}break;
};
var br = new Element('br', {'style': 'line-height: 30px;'}).inject(form);
// -----
var btn = new Element('div', {'class': 'right'}).inject(form);
var btn_vota = new Element('img', {'src': _URL_MULTIMEDIA + '/images/butt_invia.gif', 'class': 'butt_invia'}).inject(btn);
// -----
btn_vota.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
var selected_response = ((type == 1 || type == 2) ? (getSelectedResponse(response)) : (response.value.trim()));
// -----
if(!checkSelectedResponse(selected_response)) {
$feedback($YKK.language.feedback.checkSelectedResponse);
// -----
return false;
// -----
}
var url = _SERVICE_RESPONSE;
var xhr = new Ajax(url);
// -----
// params
var params = {
fase: 'response__vota',
c: $COOKIE.id, // cookie_id,
h: $SITE.id, // site_id,
s: self.survey.id, // survey_id,
q: question.id, // question_id,
t: type, // type,
r: selected_response //response
};
// complete
xhr.addEvent('onComplete', function(json) {
var response = Json.evaluate(json);
// -----
// check status
switch(response.status) {
default:
case null:
case undefined:
case false: {
$feedback(response.feedback);
// -----
}break;
case true: {
// status
if(response.next_question) {
self.mode = 'survey';
self.selected_question = getQuestionKeyByID(self.survey.question, response.next_question);
// -----
}
else {
self.mode = 'results';
self.selected_question = 0;
// -----
}
switch(self.lightbox) {
default:
case null:
case undefined:
case false: {
self.toElement().inject($(self.element).empty());
// -----
}break;
case true: {
self.toElement(true)
// -----
}break;
}
}break;
};
});
// request
xhr.request(params);
// -----
});
var point = new Element('div', {'id':'point'}).inject(element);
// -----
element.lightbox = function() {
$LIGHTBOX.view(element);
// -----
};
return element;
// -----
};
objSurvey.prototype.toElementResults = function(q) {
var self = this;
// -----
var q = parseInt((q != undefined) ? (q) : (0));
var question = this.survey.question[q];
var type = parseInt(question.type);
// -----
switch(type) {
case 1:
case 2: {
switch(this.view) {
default:
case 'chart': { var element = this.toElementResultsChart(question); }break;
case 'table': { var element = this.toElementResultsTable(question); }break;
}
}break;
case 3: {
switch(this.view) {
default:
case 'cloud': { var element = this.toElementResultsCloud(question); }break;
case 'open': { var element = this.toElementResultsOpen(question); }break;
}
}break;
}
element.lightbox = function() {
$LIGHTBOX.view(element);
// -----
};
return element;
// -----
};
objSurvey.prototype.toElementResultsChart = function(question) {
var self = this;
// -----
// fix view
this.view = 'chart';
// -----
var element = new Element('div');
// -----
var baloon = new Element('div', {'class': 'baloon'}).inject(element);
// -----
// close lightbox button
if(this.lightbox) {
var close = new Element('div', {'id': 'close'}).inject(baloon);
var close_link = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(close);
// -----
close_link.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
self.lightbox = false;
// -----
$LIGHTBOX.remove();
// -----
});
}
var cont = new Element('div', {'class': 'cont'}).inject(baloon);
var request = new Element('h2').setHTML(question.request).inject(cont);
var response = new Element('ul').inject(cont);
// -----
var total = 0;
// -----
question.response.each(function(el) {
total = total + parseInt(el.n_response);
// -----
});
question.response.each(function(el) {
var perc = Math.round((el.n_response*100)/total);
var p = (perc) ? (perc) : (0);
var width = Math.round((p*285)/100);
var img_width = (width) ? (width) : (0);
// -----
var li = new Element('li').inject(response);
// -----
var res = new Element('div', {'class': 'res'}).setHTML(p + '%').inject(li);
var answer = new Element('div', {'class': 'answer'}).setHTML('' + el.response + ' ').inject(li);
var img = new Element('div', {'class': 'imgRes'}).setHTML(' ').inject(li);
var numb = new Element('div', {'class': 'numb'}).setHTML(el.n_response + ' risp.').inject(li);
// -----
});
// barra di navigazione
this.toElementNavigate(question).inject(element);
// -----
return element;
// -----
};
objSurvey.prototype.toElementResultsTable = function(question) {
var self = this;
// -----
// fix view
this.view = 'table';
// -----
var element = new Element('div');
// -----
var baloon = new Element('div', {'class': 'baloon'}).inject(element);
// -----
// close lightbox button
if(this.lightbox) {
var close = new Element('div', {'id': 'close'}).inject(baloon);
var close_link = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(close);
// -----
close_link.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
self.lightbox = false;
// -----
$LIGHTBOX.remove();
// -----
});
}
var table = new Element('table', {'id': 'risposte', 'border': '0', 'cellpadding': '0', 'cellspacing': '0'}).inject(baloon);
var request = new Element('caption').setHTML(question.request).inject(table);
var response_head = new Element('thead').inject(table);
var response_head_tr = new Element('tr').inject(response_head);
var response_head_th_label = new Element('th', {'class': 'domanda'}).setHTML('risposta').inject(response_head_tr);
var response_head_th_risposte = new Element('th').setHTML('n° risp. ').inject(response_head_tr);
var response_head_th_precentuale = new Element('th').setHTML('% ').inject(response_head_tr);
var response = new Element('tbody').inject(table);
// -----
var total = 0;
// -----
question.response.each(function(el) {
total = total + parseInt(el.n_response);
// -----
});
question.response.each(function(el) {
var perc = Math.round((el.n_response*100)/total);
var p = (perc) ? (perc) : (0);
// -----
var tr = new Element('tr').inject(response);
// -----
var res = new Element('td').setHTML('' + el.response + ' ').inject(tr);
var numb = new Element('td').setHTML(el.n_response + ' risp.').inject(tr);
var img = new Element('td').setHTML(((!isNaN(perc)) ? (perc) : (0)) + '%').inject(tr);
// -----
});
// barra di navigazione
this.toElementNavigate(question).inject(element);
// -----
return element;
// -----
};
objSurvey.prototype.toElementResultsCloud = function(question) {
var self = this;
// -----
// fix view
this.view = 'cloud';
// -----
var element = new Element('div');
// -----
var baloon = new Element('div', {'class': 'baloon'}).inject(element);
// -----
// close lightbox button
if(this.lightbox) {
var close = new Element('div', {'id': 'close'}).inject(baloon);
var close_link = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(close);
// -----
close_link.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
self.lightbox = false;
// -----
$LIGHTBOX.remove();
// -----
});
}
var cont = new Element('div', {'class': 'cont'}).inject(baloon);
var request = new Element('h2').setHTML(question.request).inject(cont);
var cloud = new Element('div', {'class': 'cloud'}).inject(cont);
// -----
// sort
question.cloud.sort(function(a, b) {
if(a.tag > b.tag) return 1;
if(a.tag < b.tag) return -1;
return 0;
// -----
});
// cloud
question.cloud.each(function(el) {
var tag = new Element('a', {'href': 'javascript:;', 'class': 'link' + el.size}).setHTML(' ' + el.tag + ' ').inject(cloud);
// -----
tag.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
self.open = [];
// -----
var url = _SERVICE_RESPONSE;
var xhr = new Ajax(url);
// -----
var params = {
fase: 'response__open_by_question',
survey: self.survey.id,
question: self.survey.question[self.selected_question].id,
tag: el.tag
};
xhr.addEvent('onComplete', function(json) {
var response = Json.evaluate(json);
// -----
self.open = response.open;
self.view = 'open';
// -----
switch(self.lightbox) {
default:
case null:
case undefined:
case false: {
self.toElement().inject($(self.element).empty());
// -----
}break;
case true: {
self.toElement(true)
// -----
}break;
}
});
xhr.request(params);
// -----
})
});
// barra di navigazione
this.toElementNavigate(question).inject(element);
// -----
return element;
// -----
};
objSurvey.prototype.toElementResultsOpen = function(question, i) {
var self = this;
// -----
// index open response
var i = parseInt((i != undefined) ? (i) : (0));
// -----
// fix view
this.view = 'open';
// -----
var element = new Element('div');
// -----
var baloon = new Element('div', {'class': 'baloon'}).inject(element);
// -----
// close lightbox button
if(this.lightbox) {
var close = new Element('div', {'id': 'close'}).inject(baloon);
var close_link = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(close);
// -----
close_link.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
self.lightbox = false;
// -----
$LIGHTBOX.remove();
// -----
});
}
var cont = new Element('div', {'class': 'cont'}).inject(baloon);
var request = new Element('h2').setHTML(question.request).inject(cont);
var open = new Element('div', {'id': 'openAnswer'}).inject(cont);
// -----
var blockquote = new Element('blockquote').inject(open);
var blockquote_p = new Element('p').setHTML(this.open[i]).inject(blockquote);
// -----
var leggi_un_altra = new Element('div', {'class': 'al-right'}).inject(cont);
var leggi_un_altra_link = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(leggi_un_altra);
// -----
leggi_un_altra_link.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
element.replaceWith(self.toElementResultsOpen(question, (((i + 1) <= (self.open.length - 1)) ? (i + 1) : (0))));
// -----
});
// barra di navigazione
this.toElementNavigate(question).inject(element);
// -----
return element;
// -----
};
objSurvey.prototype.toElementNavigate = function(question) {
var self = this;
// -----
var element = new Element('div', {'id': 'point'});
// -----
var buttons = new Element('div', {'class': 'buttons'}).inject(element);
// -----
switch(this.view) {
case 'chart': {
var table = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(buttons);
var csv = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(buttons);
// -----
table.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
self.view = 'table';
// -----
switch(self.lightbox) {
default:
case null:
case undefined:
case false: {
self.toElement().inject($(self.element).empty());
// -----
}break;
case true: {
self.toElement(true)
// -----
}break;
}
});
csv.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
var url = _SERVICE_SURVEY + '?fase=survey__csv';
url += '&id=' + self.survey.id;
// -----
var win = window.open(url);
// -----
});
}break;
case 'table': {
var chart = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(buttons);
var csv = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(buttons);
// -----
chart.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
self.view = 'chart';
// -----
switch(self.lightbox) {
default:
case null:
case undefined:
case false: {
self.toElement().inject($(self.element).empty());
// -----
}break;
case true: {
self.toElement(true)
// -----
}break;
}
});
csv.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
var url = _SERVICE_SURVEY + '?fase=survey__csv&survey=' + self.survey.id;
var win = window.open(url);
// -----
});
}break;
case 'cloud': {
}break;
case 'open': {
var cloud = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(buttons);
// -----
cloud.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
self.view = 'cloud';
// -----
switch(self.lightbox) {
default:
case null:
case undefined:
case false: {
self.toElement().inject($(self.element).empty());
// -----
}break;
case true: {
self.toElement(true)
// -----
}break;
}
});
}break;
}
// esiste una domanda precedente
if(this.selected_question > 0) {
var prev = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(buttons);
// -----
prev.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
self.selected_question = (self.selected_question - 1);
// -----
switch(self.lightbox) {
default:
case null:
case undefined:
case false: {
self.toElement().inject($(self.element).empty());
// -----
}break;
case true: {
self.toElement(true)
// -----
}break;
}
});
}
// esiste una domanda successiva
if(this.selected_question < (this.survey.question.length-1)) {
var next = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(buttons);
// -----
next.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
self.selected_question = (self.selected_question + 1);
// -----
switch(self.lightbox) {
default:
case null:
case undefined:
case false: {
self.toElement().inject($(self.element).empty());
// -----
}break;
case true: {
self.toElement(true)
// -----
}break;
}
});
}
return element;
// -----
};
objSurvey.prototype.toElementCode = function(code) {
var self = this;
// -----
var element = new Element('div');
// -----
var baloon = new Element('div', {'class': 'baloon'}).inject(element);
// -----
// close lightbox button
if(this.lightbox) {
var close = new Element('div', {'id': 'close'}).inject(baloon);
var close_link = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(close);
// -----
close_link.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
self.lightbox = false;
// -----
$LIGHTBOX.remove();
// -----
});
}
var cont = new Element('div', {'class': 'cont'}).inject(baloon);
var intestazione = new Element('h2').setHTML('Prendi qui il codice html da inserire nelle tue pagine').inject(cont);
var br = new Element('br').inject(cont);
var textarea = new Element('textarea', {'id': 'codice', 'cols': '5', 'row': '3'}).setText(code.trim()).inject(cont);
var bottom = new Element('div', {'class':'bottom'}).inject(element);
// -----
element.lightbox = function() {
$LIGHTBOX.view(element);
// -----
};
return element;
// -----
};
var elSurveyLive = function() {
this.element = 'elSurveyLive';
// -----
this.live = {
piu_popolari: [],
piu_recenti: [],
piu_votati: []
};
this.load();
// -----
};
elSurveyLive.prototype = {};
// -----
elSurveyLive.prototype.load = function() {
var self = this;
// -----
var url = _SERVICE_SURVEY;
var xhr = new Ajax(url);
// -----
var params = {
fase: 'survey__live'
}
xhr.addEvent('onComplete', function(json) {
var response = Json.evaluate(json);
// -----
switch(response.status) {
default:
case null:
case undefined:
case false: {
$feedback(response.feedback);
// -----
}break;
case true: {
self.live.piu_popolari = [];
self.live.piu_recenti = [];
self.live.piu_votati = [];
// -----
response.live.sondaggi_piu_popolari.each(function(el) {
self.live.piu_popolari.push(new objSurvey(el, false));
// -----
});
response.live.sondaggi_piu_recenti.each(function(el) {
self.live.piu_recenti.push(new objSurvey(el, false));
// -----
});
response.live.sondaggi_piu_votati.each(function(el) {
self.live.piu_votati.push(new objSurvey(el, false));
// -----
});
self.toElement().inject($(self.element).empty());
// -----
}break;
}
});
xhr.request(params);
// -----
};
elSurveyLive.prototype.toElement = function() {
var self = this;
// -----
var element = new Element('div');
// -----
var baloon = new Element('div', {'class': 'baloon'}).inject(element);
// -----
// SONDAGGI PIU' POPOLARI
if(this.live.piu_popolari.length == 0) {
var table = new Element('table', {'id': 'utente', 'border': '0', 'cellpadding': '0', 'cellspacing': '0'}).inject(baloon);
var table_caption = new Element('caption').setHTML('Sondaggi piú popolari').inject(table);
var table_tbody = new Element('tbody').inject(table);
var tr = new Element('tr').inject(table_tbody);
var td = new Element('td').setHTML($YKK.language.sondaggiInCorso.noSurveys).inject(tr);
// -----
}
else {
var table = new Element('table', {'id': 'utente', 'border': '0', 'cellpadding': '0', 'cellspacing': '0'}).inject(baloon);
var table_caption = new Element('caption').setHTML('Sondaggi piú popolari').inject(table);
var table_thead = new Element('thead').inject(table);
var table_thead_tr = new Element('tr').inject(table_thead);
var table_tfoot = new Element('tfoot').inject(table);
var table_tfoot_tr = new Element('tr').inject(table_tfoot);
var table_tbody = new Element('tbody').inject(table);
// -----
var th = new Element('th', {'class':'domanda', 'colspan':'2'}).setHTML($YKK.language.sondaggiInCorso.titoloDomanda).inject(table_thead_tr);
var th_risposte = new Element('th').inject(table_thead_tr);
var th_risposte_link = new Element('a', {'href': 'javascript:;', 'title': $YKK.language.sondaggiInCorso.risposte}).setHTML($YKK.language.sondaggiInCorso.risposte).inject(th_risposte);
var th_giorni = new Element('th').inject(table_thead_tr);
var th_giorni_link = new Element('a', {'href': 'javascript:;', 'title': $YKK.language.sondaggiInCorso.giorni}).setHTML($YKK.language.sondaggiInCorso.giorni).inject(th_giorni);
// ----
var table_tfoot_td_record = new Element('td', {'colspan': '2'}).inject(table_tfoot_tr);
var table_tfoot_td_paginazione = new Element('td', {'colspan': '4', 'class': 'paginazione'}).inject(table_tfoot_tr);
// -----
this.live.piu_popolari.each(function(el, i) {
var tr = new Element('tr').inject(table_tbody);
// -----
var td = new Element('td', {'width': '270', 'valign': 'top', 'colspan': '2'}).inject(tr);
var title = new Element('a', {'href': 'javascript:;'}).setHTML(el.survey.question[0].request).inject(td);
// -----
title.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
el.lightbox = true;
// -----
var url = _SERVICE_RESPONSE;
var xhr = new Ajax(url);
// -----
var params = {
fase: 'response__check',
cookie: $COOKIE.id,
site: $SITE.id,
survey: el.survey.id
};
xhr.addEvent('onComplete', function(json) {
var response = Json.evaluate(json);
// -----
switch(response.status) {
default:
case null:
case undefined:
case false: {
el.mode = 'results';
el.toElement(true);
// -----
}break;
case true: {
el.mode = 'survey';
el.toElement(true);
// -----
}break;
}
});
xhr.request(params);
// -----
});
var td_risposte = new Element('td', {'valign': 'top'}).setHTML(el.survey.statistiche.response).inject(tr);
var td_giorni = new Element('td', {'valign': 'top'}).setHTML(el.survey.statistiche.giorni).inject(tr);
// -----
var td = new Element('td', {'width': '20', 'valign': 'top'}).inject(tr);
var code = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(td);
// -----
code.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
el.lightbox = true;
// -----
el.mode = 'code';
el.toElement(true);
// -----
});
var td = new Element('td', {'width': '20', 'valign': 'top'}).inject(tr);
var site = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(td);
// -----
site.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
var url = _SERVICE_SURVEY;
var xhr = new Ajax(url);
// -----
var params = {
fase: 'survey__url_last_view',
survey: el.survey.id
};
xhr.addEvent('onComplete', function(json) {
var response = Json.evaluate(json);
// -----
switch(response.status) {
default:
case null:
case undefined:
case false: {
// el.mode = 'results';
// el.toElement(true);
// -----
$feedback(response.feedback);
// -----
}break;
case true: {
// el.mode = 'survey';
// el.toElement(true);
// -----
// da correggere con campo del db appropriato
var url_last_view = ((response.url_last_view.scheme == '') ? ('http') : (response.url_last_view.scheme)) + '://' + response.url_last_view.host + response.url_last_view.path;
// -----
window.open(url_last_view, 'ykk_url_last_view');
// -----
}break;
}
});
xhr.request(params);
// -----
});
});
}
// SONDAGGI PIU' RECENTI
// verifica se ci sono survey da visualizzare
if(this.live.piu_recenti.length == 0) {
var table = new Element('table', {'id': 'utente', 'border': '0', 'cellpadding': '0', 'cellspacing': '0'}).inject(baloon);
var table_caption = new Element('caption').setHTML('Sondaggi piú recenti').inject(table);
var table_tbody = new Element('tbody').inject(table);
var tr = new Element('tr').inject(table_tbody);
var td = new Element('td').setHTML($YKK.language.sondaggiInCorso.noSurveys).inject(tr);
// -----
}
else {
var table = new Element('table', {'id': 'utente', 'border': '0', 'cellpadding': '0', 'cellspacing': '0'}).inject(baloon);
var table_caption = new Element('caption').setHTML('Sondaggi piú recenti').inject(table);
var table_thead = new Element('thead').inject(table);
var table_thead_tr = new Element('tr').inject(table_thead);
var table_tfoot = new Element('tfoot').inject(table);
var table_tfoot_tr = new Element('tr').inject(table_tfoot);
var table_tbody = new Element('tbody').inject(table);
// -----
var th = new Element('th', {'class':'domanda', 'colspan':'2'}).setHTML($YKK.language.sondaggiInCorso.titoloDomanda).inject(table_thead_tr);
var th_risposte = new Element('th').inject(table_thead_tr);
var th_risposte_link = new Element('a', {'href': 'javascript:;', 'title': $YKK.language.sondaggiInCorso.risposte}).setHTML($YKK.language.sondaggiInCorso.risposte).inject(th_risposte);
var th_giorni = new Element('th').inject(table_thead_tr);
var th_giorni_link = new Element('a', {'href': 'javascript:;', 'title': $YKK.language.sondaggiInCorso.giorni}).setHTML($YKK.language.sondaggiInCorso.giorni).inject(th_giorni);
// -----
var table_tfoot_td_record = new Element('td', {'colspan': '2'}).inject(table_tfoot_tr);
var table_tfoot_td_paginazione = new Element('td', {'colspan': '4', 'class': 'paginazione'}).inject(table_tfoot_tr);
// -----
this.live.piu_recenti.each(function(el, i) {
var tr = new Element('tr').inject(table_tbody);
// -----
var td = new Element('td', {'width': '270', 'valign': 'top', 'colspan': '2'}).inject(tr);
var title = new Element('a', {'href': 'javascript:;'}).setHTML(el.survey.question[0].request).inject(td);
// -----
title.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
el.lightbox = true;
// -----
var url = _SERVICE_RESPONSE;
var xhr = new Ajax(url);
// -----
var params = {
fase: 'response__check',
cookie: $COOKIE.id,
site: $SITE.id,
survey: el.survey.id
};
xhr.addEvent('onComplete', function(json) {
var response = Json.evaluate(json);
// -----
switch(response.status) {
default:
case null:
case undefined:
case false: {
el.mode = 'results';
el.toElement(true);
// -----
}break;
case true: {
el.mode = 'survey';
el.toElement(true);
// -----
}break;
}
});
xhr.request(params);
// -----
});
var td_risposte = new Element('td', {'valign': 'top'}).setHTML(el.survey.statistiche.response).inject(tr);
var td_giorni = new Element('td', {'valign': 'top'}).setHTML(el.survey.statistiche.giorni).inject(tr);
// -----
var td = new Element('td', {'width': '20', 'valign': 'top'}).inject(tr);
var code = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(td);
// -----
code.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
el.lightbox = true;
// -----
el.mode = 'code';
el.toElement(true);
// -----
});
var td = new Element('td', {'width': '20', 'valign': 'top'}).inject(tr);
var site = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(td);
// -----
site.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
var url = _SERVICE_SURVEY;
var xhr = new Ajax(url);
// -----
var params = {
fase: 'survey__url_last_view',
survey: el.survey.id
};
xhr.addEvent('onComplete', function(json) {
var response = Json.evaluate(json);
// -----
switch(response.status) {
default:
case null:
case undefined:
case false: {
// el.mode = 'results';
// el.toElement(true);
// -----
$feedback(response.feedback);
// -----
}break;
case true: {
// el.mode = 'survey';
// el.toElement(true);
// -----
// da correggere con campo del db appropriato
var url_last_view = ((response.url_last_view.scheme == '') ? ('http') : (response.url_last_view.scheme)) + '://' + response.url_last_view.host + response.url_last_view.path;
// -----
window.open(url_last_view, 'ykk_url_last_view');
// -----
}break;
}
});
xhr.request(params);
// -----
});
});
}
// SONDAGGI PIU' VOTATI
// verifica se ci sono survey da visualizzare
if(this.live.piu_votati.length == 0) {
var table = new Element('table', {'id': 'utente', 'border': '0', 'cellpadding': '0', 'cellspacing': '0'}).inject(baloon);
var table_caption = new Element('caption').setHTML('Sondaggi piú votati').inject(table);
var table_tbody = new Element('tbody').inject(table);
var tr = new Element('tr').inject(table_tbody);
var td = new Element('td').setHTML($YKK.language.sondaggiInCorso.noSurveys).inject(tr);
// -----
}
else {
var table = new Element('table', {'id': 'utente', 'border': '0', 'cellpadding': '0', 'cellspacing': '0'}).inject(baloon);
var table_caption = new Element('caption').setHTML('Sondaggi piú votati').inject(table);
var table_thead = new Element('thead').inject(table);
var table_thead_tr = new Element('tr').inject(table_thead);
var table_tfoot = new Element('tfoot').inject(table);
var table_tfoot_tr = new Element('tr').inject(table_tfoot);
var table_tbody = new Element('tbody').inject(table);
// -----
var th = new Element('th', {'class':'domanda', 'colspan':'2'}).setHTML($YKK.language.sondaggiInCorso.titoloDomanda).inject(table_thead_tr);
var th_risposte = new Element('th').inject(table_thead_tr);
var th_risposte_link = new Element('a', {'href': 'javascript:;', 'title': $YKK.language.sondaggiInCorso.risposte}).setHTML($YKK.language.sondaggiInCorso.risposte).inject(th_risposte);
var th_giorni = new Element('th').inject(table_thead_tr);
var th_giorni_link = new Element('a', {'href': 'javascript:;', 'title': $YKK.language.sondaggiInCorso.giorni}).setHTML($YKK.language.sondaggiInCorso.giorni).inject(th_giorni);
// ----
var table_tfoot_td_record = new Element('td', {'colspan': '2'}).inject(table_tfoot_tr);
var table_tfoot_td_paginazione = new Element('td', {'colspan': '4', 'class': 'paginazione'}).inject(table_tfoot_tr);
// -----
this.live.piu_votati.each(function(el, i) {
var tr = new Element('tr').inject(table_tbody);
// -----
var td = new Element('td', {'width': '270', 'valign': 'top', 'colspan': '2'}).inject(tr);
var title = new Element('a', {'href': 'javascript:;'}).setHTML(el.survey.question[0].request).inject(td);
// -----
title.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
el.lightbox = true;
// -----
var url = _SERVICE_RESPONSE;
var xhr = new Ajax(url);
// -----
var params = {
fase: 'response__check',
cookie: $COOKIE.id,
site: $SITE.id,
survey: el.survey.id
};
xhr.addEvent('onComplete', function(json) {
var response = Json.evaluate(json);
// -----
switch(response.status) {
default:
case null:
case undefined:
case false: {
el.mode = 'results';
el.toElement(true);
// -----
}break;
case true: {
el.mode = 'survey';
el.toElement(true);
// -----
}break;
}
});
xhr.request(params);
// -----
});
var td_risposte = new Element('td', {'valign': 'top'}).setHTML(el.survey.statistiche.response).inject(tr);
var td_giorni = new Element('td', {'valign': 'top'}).setHTML(el.survey.statistiche.giorni).inject(tr);
// -----
var td = new Element('td', {'width': '20', 'valign': 'top'}).inject(tr);
var code = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(td);
// -----
code.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
el.lightbox = true;
// -----
el.mode = 'code';
el.toElement(true);
// -----
});
var td = new Element('td', {'width': '20', 'valign': 'top'}).inject(tr);
var site = new Element('a', {'href': 'javascript:;'}).setHTML(' ').inject(td);
// -----
site.addEvent('click', function(event) {
event = new Event(event);
event.stop();
// -----
var url = _SERVICE_SURVEY;
var xhr = new Ajax(url);
// -----
var params = {
fase: 'survey__url_last_view',
survey: el.survey.id
};
xhr.addEvent('onComplete', function(json) {
var response = Json.evaluate(json);
// -----
switch(response.status) {
default:
case null:
case undefined:
case false: {
// el.mode = 'results';
// el.toElement(true);
// -----
$feedback(response.feedback);
// -----
}break;
case true: {
// el.mode = 'survey';
// el.toElement(true);
// -----
// da correggere con campo del db appropriato
var url_last_view = ((response.url_last_view.scheme == '') ? ('http') : (response.url_last_view.scheme)) + '://' + response.url_last_view.host + response.url_last_view.path;
// -----
window.open(url_last_view, 'ykk_url_last_view');
// -----
}break;
}
});
xhr.request(params);
// -----
});
});
}
var bottom = new Element('div', {'class': 'bottom'}).inject(element);
// -----
var legenda = new Element('div', {'id': 'legenda'}).inject(element);
var legenda_code_img = new Element('img', {'src': _URL_MULTIMEDIA + '/images/ico_codice.gif', 'title': $YKK.language.sondaggiInCorso.codice, 'border': '0'}).inject(legenda);
var legenda_code_txt = new Element('span').setHTML(' ' + $YKK.language.sondaggiInCorso.codice + ' ').inject(legenda);
var legenda_site_img = new Element('img', {'src': _URL_MULTIMEDIA + '/images/ico_site.gif', 'title': $YKK.language.sondaggiInCorso.site, 'border': '0'}).inject(legenda);
var legenda_site_txt = new Element('span').setHTML(' ' + $YKK.language.sondaggiInCorso.site + ' ').inject(legenda);
// -----
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 elStatistiche = function() {
this.element = 'elStatistiche';
// -----
// statistiche
this.statistiche = {};
// -----
this.load();
// -----
};
elStatistiche.prototype = {};
// -----
elStatistiche.prototype.load = function() {
var self = this;
// -----
var url = _SERVICE_STATISTICHE;
var xhr = new Ajax(url);
// -----
var params = {
fase: 'statistiche__all'
};
xhr.addEvent('onComplete', function(json) {
var response = Json.evaluate(json);
// -----
switch(response.status) {
default:
case null:
case undefined:
case false: {
$feeback(response.feed)
}break;
case true: {
self.statistiche = response.statistiche;
self.toElement().inject($(self.element).empty());
// -----
}break;
}
});
xhr.request(params);
// -----
};
elStatistiche.prototype.toElement = function() {
var self = this;
// -----
var element = new Element('div', {'id': 'stats'});
// -----
var siti_youkuki_attivi = new Element('div', {'class': 'descr'}).setHTML($YKK.language.statisticheYK.sitiAttivi).inject(element);
var siti_youkuki_attivi_value = new Element('div', {'class': 'res'}).setHTML(this.statistiche.siti_youkuki_attivi).inject(element);
var sondaggi_prodotti_da_youkuki = new Element('div', {'class': 'descr'}).setHTML($YKK.language.statisticheYK.totaleSondaggi).inject(element);
var sondaggi_prodotti_da_youkuki_value = new Element('div', {'class': 'res'}).setHTML(this.statistiche.sondaggi_prodotti_da_youkuki).inject(element);
var risposte_raccolte_da_youkuki = new Element('div', {'class': 'descr'}).setHTML($YKK.language.statisticheYK.totaleRisposte).inject(element);
var risposte_raccolte_da_youkuki_value = new Element('div', {'class': 'res'}).setHTML(this.statistiche.risposte_raccolte_da_youkuki).inject(element);
var sondaggi_prodotti_da_youkuki_solo_oggi = new Element('div', {'class': 'descr'}).setHTML($YKK.language.statisticheYK.sondaggiOggi).inject(element);
var sondaggi_prodotti_da_youkuki_solo_oggi_value = new Element('div', {'class': 'res'}).setHTML(this.statistiche.sondaggi_prodotti_da_youkuki_solo_oggi).inject(element);
var risposte_raccolte_da_youkuki_solo_oggi = new Element('div', {'class': 'descr'}).setHTML($YKK.language.statisticheYK.risposteOggi).inject(element);
var risposte_raccolte_da_youkuki_solo_oggi_value = new Element('div', {'class': 'res'}).setHTML(this.statistiche.risposte_raccolte_da_youkuki_solo_oggi).inject(element);
// -----
return element;
// -----
};
var $YKK = new YouKuki();
// -----