PageSourceSearch

https://www.aziendabellaria.com/lib/js/feedbacks.js?v=2023DB5DF11F2C3F30564C7B64531AA7

js aziendabellaria.com collected 2026-10-05 18:27:17 UTC 40,052 bytes, 773 lines download raw bytes

1"use strict";
2
3//Dishiaro più istanze della closure per utilizzo contemporaneo
4var commenttool = new commentclosure('commenttool');
5var commenttool1 = new commentclosure('commenttool1'); //Per utilizzo multiplo in pagina
6//var commenttool2 = new commentclosure('commenttool2'); //Per utilizzo multiplo in pagina
7
8//DEFINZIONE DELLA CLOSURE PER I COMMENTI!
9function commentclosure(varname) {
10
11    this.varname = varname; //Nome della variabile che istanzia lo scope, ad uso interno !!
12
13    this.commentsvisible = true; //Blocca la visualizzazione dei riepiloghi e della lista commenti
14    this.onlytotals = false; //Visualizzo solo i totali 
15    this.viewmode = 0; //Imposta la modalità di visualizzazione 0 - default completo di form inserimento 1 - scroller commenti ultimi 2- lista commenti senza form inserimento
16    this.mailadvice = true; //abilitazioneinvio mail di avviso inserimento di feedback per il gestore
17    this.templatehtml = 'feedbacklist.html'; //default template per visualizzazione dei commenti
18    this.templatehtmlinsert = 'feedbackinsert1.html'; //default template per visualizzazione dei commenti
19    this.noinsertform = false;
20    this.insertformup = false;
21
22    var mainscope = this;
23    this.message = '';
24    this.localcontainer = {};
25    this.objfiltro = {};
26
27    this.idpost = '';
28    this.idcontainer = '';
29    this.enablepager = false;
30    this.nomecliente = "";
31    this.cognomecliente = "";
32    this.emailcliente = "";
33    //this.idmailschedule = 0; //id newsletter per invio invito al feedback
34    //this.mailschedule = false; //abilitazione mail per inserimento in scheduler invio
35    //this.deltadays = 30;//intervallo dopo il quale inviare la mail al cliente per richiesta feedback
36
37
38    //this.rendercommentsloadref = function (idpost, idcontainer) { return rendercommentsloadref; }; //Mappare fuori una funzione interna
39    //function rendercommentsloadref(idpost, idcontainer) {
40    //    loadref(rendercomments, idpost, idcontainer, lng);
41    //}
42    this.rendercommentsloadref = function (idpost, idcontainer, templatecustom, enablepager, page, pagesize, maxrecord, onlytotals, viewmode, noinsertform, insertformup, templatehtmlinsert) {
43
44        if (templatehtmlinsert != '' && templatehtmlinsert != null)
45            mainscope.templatehtmlinsert = templatehtmlinsert;
46
47        if (templatecustom != '' && templatecustom != null)
48            mainscope.templatehtml = templatecustom;
49        if (noinsertform != '' && noinsertform != null)
50            mainscope.noinsertform = noinsertform;
51        if (insertformup != '' && insertformup != null)
52            mainscope.insertformup = insertformup;
53
54        if (onlytotals != '' && onlytotals != null)
55            mainscope.onlytotals = onlytotals;
56
57        if (viewmode != '' && viewmode != null)
58            mainscope.viewmode = viewmode;
59        //else
60        //    mainscope.viewmode = 0;
61
62        if (enablepager != '' && enablepager != null && enablepager == 'true') {
63            {
64                mainscope.enablepager = true;
65                mainscope.objfiltro['enablepager'] = enablepager;
66            }
67            if (!isNaN(Number(page)))
68                mainscope.objfiltro['page'] = Number(page);
69            else mainscope.objfiltro['page'] = 1;
70            if (!isNaN(Number(pagesize)))
71                mainscope.objfiltro['pagesize'] = Number(pagesize);
72            else mainscope.objfiltro['pagesize'] = 12;
73        }
74        if (maxrecord != '' && maxrecord != null) {
75            {
76                mainscope.enablepager = false;
77                mainscope.objfiltro['enablepager'] = false;
78                mainscope.objfiltro['maxrecord'] = maxrecord;
79            }
80        }
81        //loadref(mainscope.varname + '.rendercomments', idpost, idcontainer, lng); //Faccio la chiamata inserendola nella coda di controllo per caricamento dati di riferimento!
82        (function wait() {
83            if (typeof baseresources !== 'undefined' && baseresources != null && baseresources != '') {
84                loadref(mainscope.varname + '.rendercomments', idpost, idcontainer, lng);
84 //Faccio la chiamata inserendola nella coda di controllo per caricamento dati di riferimento(obsoleto, il loadref e solo fittizio)!
85            } else {
86                setTimeout(wait, 300);
87            }
88        })();
89
90    };
91    this.rendercomments = function (idpost, idcontainer) {
92
93        if (idpost == null || idpost == undefined || idpost.length == 0) {
94            // mainscope.commentsvisible = false; //Posso Bloccare la visualizzazzione dei commenti 
95            var idposttmp = $.getQueryString("idpost");
96            if (idposttmp != null && idposttmp != undefined && idposttmp.length != 0) {
97                idpost = idposttmp;
98            }
99            else
100                idpost = 0;
101        }
102        var idcliente = $.getQueryString("idcliente"); //Se in querystring c'è un cliente lo carico per la preselezione nei campi di inserimento
103        if (idcliente != null && idcliente != undefined && idcliente.length != 0) {
104            //Caricare nome cognome email cliente e inseririli nel form preinserimento
105            getcliente(idcliente, function (ret) {
106                if (ret != null && ret.length > 0) { mainscope.emailcliente = ret[0]["email"]; mainscope.nomecliente = ret[0]["nome"]; mainscope.cognomecliente = ret[0]["cognome"]; }
107            });
108        }
109
110        mainscope.objfiltro['id'] = idpost;
111        mainscope.idpost = idpost;
112        mainscope.idcontainer = idcontainer;
113
114        var tmpfilter = "";
115        if (username != null && username != '' && mainscope.viewmode == 0) {
116            mainscope.templatehtml = 'feedbacklist-admin.html';
117            mainscope.objfiltro['logged'] = true;
118            tmpfilter = mainscope.objfiltro;
119        }
120        if (mainscope.commentsvisible) tmpfilter = mainscope.objfiltro;
121
122        caricacommentsbyidpost(lng, tmpfilter, function (ret, mainscope) {
123            if (mainscope.onlytotals) {
124                if (mainscope.localcontainer.totaleapprovati > 0) {
125
126                    $("#" + mainscope.idcontainer).prepend("<span class='feedTotals'  id='" + mainscope.idcontainer + "-totals'></span>");
127                    $("#" + mainscope.idcontainer + "-totals").prepend(" (" + mainscope.localcontainer.totaleapprovati + ") <span class=\"rating\" disabled data-default-rating=" + mainscope.localcontainer.totalemediastars + "></span><br/><br/>");
128                    $("#" + mainscope.idcontainer + "-totals").prepend(GetResourcesValue('feedbacks1'));
129                    $("#" + mainscope.idcontainer + "-totals").prepend(GetResourcesValue('feedbackstitle1'));
130                    inizializzastars();
131
132                    //inseriamo i microdati per aggregaterating  
133                    //<div itemprop="aggregateRating" itemtype="http://schema.org/AggregateRating" itemscope><meta itemprop="reviewCount" content="89" /> <meta itemprop="ratingValue" content="4.4" /></div>
134                    $("#" + mainscope.idcontainer + "-totals").prepend('<div itemprop="aggregateRating" itemtype="http://schema.org/AggregateRating" itemscope><meta itemprop="reviewCount" content="' + mainscope.localcontainer.totaleapprovati + '" /> <meta itemprop="ratingValue" content="' + mainscope.localcontainer.totalemediastars + '" /></div>');
135
136                }
137            }
138            else
139                ShowList(mainscope.templatehtml, mainscope.idcontainer, mainscope.idcontainer + '-ctrl', mainscope.localcontainer.list,
140                    function () {
141                        switch (mainscope.viewmode) {
142                            case 1:     //Visualizzazione tipo scroller
143                                //inizializzaiomo lo scroller
144                                inizializzastars();
145                                //Inizializzo lo scroller
146                                jQuery(document).ready(function () {
147                                    var owl = jQuery("#" + mainscope.idcontainer + '-ctrl');
148                                    owl.owlCarousel({
149                                        items: [1],
150                                        autoPlay: 5000,
151                                        itemsDesktop: [1199, 1], // i/tems between 1000px and 601px
152                                        itemsTablet: [979, 1], // items between 600 and 0;
153                                        itemsMobile: [479, 1], // itemsMobile disabled - inherit from itemsTablet option
154                                        slideSpeed: 1000,
155                                        afterInit: lazyLoad,
156                                        afterMove: lazyLoad
157                                    });
158                                    // Custom Navigation Events
159                                    jQuery("#" + mainscope.idcontainer + '-ctrl' + "next").click(function () {
160                                        owl.trigger('owl.next');
161                                    });
162                                    jQuery("#" + mainscope.idcontainer + '-ctrl' + "prev").click(function () {
163                                        owl.trigger('owl.prev');
164                                    });
165                                });
166                                break;
167                            //case 2: //Visualizzazione tipo lista senza form inserimento
168                            //    var aperto = $('#' + mainscope.idcontainer + '-ctrl' + 'collapseOne').hasClass('show');
169
170                            //    //////////////////////////////////////////////////////////////////////
171                            //    //TOTALI Visualizziamo il riepilogo e la media totale delle recenzioni
172                            //    //////////////////////////////////////////////////////////////////////
173                            //    if ((mainscope.commentsvisible) || (username != null && username != '')) {
174                            //        $("#" + mainscope.idcontainer + '-ctrl').prepend(" (" + mainscope.localcontainer.totaleapprovati + ") <span class=\"rating\" disabled data-default-rating=" + mainscope.localcontainer.totalemediastars + "></span><br/><br/>");
175                            //        $("#" + mainscope.idcontainer + '-ctrl').prepend(GetResourcesValue('feedbacks'));
176                            //        //  $("#" + mainscope.idcontainer+ '-ctrl').prepend(GetResourcesValue('feedbackstitle'));
177                            //        inizializzastars();
178                            //    }
179                            //    /////////////////////////////////////////////////////////////////
180
181                            //    ///////////////////////////
182                            //    //GESTIONE PAGINAZIONE/////
183                            //    ///////////////////////////
184                            //    if (mainscope.enablepager && $("#" + mainscope.idcontainer + '-ctrl').length > 0) {
185                            //        $("#" + mainscope.idcontainer + '-ctrl').append("<li><div  id='" + mainscope.idcontainer + "-pager'></div></li>");
186                            //        inizializzapager(mainscope.idcontainer + '-pager');
187                            //    }
188                            //    ////////////////////////////////////
189                            //    inizializzastars();
190                            //    $('#' + mainscope.idcontainer + '-ctrl' + 'collapseOne').addClass('show');//Apro l'accordion per regolare le altezze delle textarea 
191                            //    $('textarea').autoHeight();
192                            //    if (!aperto)
193                            //        $('#' + mainscope.idcontainer + '-ctrl' + 'collapseOne').removeClass('show');//Chiudo l'accordion dopo aver ricalcolato le altezze se necessario
194                            //    ///////////////////////////////////
195
196                            //    break;
197
198                            default:
199                                /////////////////////////////////////////////////////////////////
200                                //TOTALI Visualizziamo il riepilogo e la media totale delle recenzioni
201                                /////////////////////////////////////////////////////////////////
202                                if ((mainscope.commentsvisible) || (username != null && username != '')) {
203                                    $("#" + mainscope.idcontainer).prepend("<div class='feedTotals container pt-1'  id='" + mainscope.idcontainer + "-totals'></div>");
204                                    $("#" + mainscope.idcontainer + "-totals").prepend(" (" + mainscope.localcontainer.totaleapprovati + ") <span class=\"rating\" disabled data-default-rating=" + mainscope.localcontainer.totalemediastars + "></span><br/><br/>");
205                                    $("#" + mainscope.idcontainer + "-totals").prepend(GetResourcesValue('feedbacks'));
206                                    $("#" + mainscope.idcontainer + "-totals").prepend(GetResourcesValue('feedbackstitle'));
207                                    inizializzastars();
208                                }
209                                /////////////////////////////////////////////////////////////////
210
211                                ///////////////////////////
212                                //GESTIONE PAGINAZIONE//
213                                ///////////////////////////
214                                if (mainscope.enablepager && $("#" + mainscope.idcontainer + '-ctrl').length > 0) {
215                                    $("#" + mainscope.idcontainer + '-ctrl').append("<li><div  id='" + mainscope.idcontainer + "-pager'></div></li>");
216                                    inizializzapager(mainscope.idcontainer + '-pager');
217                                }
218                                ///////////////////////////
219
220                                /////////////////////////////////////////////////////////////////
221                                //Inseriamo il tool per permettere l'inserimento di un comment
222                                /////////////////////////////////////////////////////////////////
223                                if (!mainscope.noinsertform) {
224                                    if (mainscope.insertformup)
225                                        $("#" + mainscope.idcontainer).prepend("<div  id='" + mainscope.idcontainer + "-head'></div>");
226                                    else
227                                        $("#" + mainscope.idcontainer).append("<div  id='" + mainscope.idcontainer + "-head'></div>");
228
229                                    var dummyarray = [];
230                                    //Precompliamo i campi necessari per il form di inserimento
231                                    var testonome = mainscope.nomecliente + ' ' + mainscope.cognomecliente;
232                                    if (mainscope.localcontainer.item.hasOwnProperty('Nome'))
233                                        mainscope.localcontainer.item['Nome'] = testonome.trim();
234                                    if (mainscope.localcontainer.item.hasOwnProperty('Email'))
235                                        mainscope.localcontainer.item['Email'] = mainscope.emailcliente;
236                                    dummyarray.push(mainscope.localcontainer.item);
237
238                                    var aperto1 = $('#' + mainscope.idcontainer + '-ctrl' + 'collapseOne').hasClass('show');
239
240                                    if (mainscope.localcontainer.item != '')
241                                        ShowList(mainscope.templatehtmlinsert, mainscope.idcontainer + '-head', mainscope.idcontainer + '-head-ctrl', dummyarray,
242                                            function () {
243                                                $('#' + mainscope.idcontainer + '-head-ctrl' + 'tresponse').html(mainscope.message);
244                                                //window.scroll(0, document.querySelector("#' + mainscope.idcontainer + 'tresponse").offsetTop - 0);
245                                                if (mainscope.message.length > 0)
246                                                    $('html, body').animate({ scrollTop: $("#" + mainscope.idcontainer + '-head-ctrl' + "tresponse").offset().top - 150 }, 100);
247                                                mainscope.message = "";
248
249                                                inizializzastars();
250                                                $('#' + mainscope.idcontainer + '-ctrl' + 'collapseOne').addClass('show');//Apro l'accordion per regolare le altezze delle textarea 
251                                                $('textarea').autoHeight();
252                                                if (!aperto1)
253                                                    $('#' + mainscope.idcontainer + '-ctrl' + 'collapseOne').removeClass('show');//Chiudo l'accordion dopo aver ricalcolato le altezze se necessario
254                                            });
255                                } else {
256                                    inizializzastars();
257                                    $('#' + mainscope.idcontainer + '-ctrl' + 'collapseOne').addClass('show');//Apro l'accordion per regolare le altezze delle textarea 
258                                    $('textarea').autoHeight();
259                                    if (!aperto1)
260                                        $('#' + mainscope.idcontainer + '-ctrl' + 'collapseOne').removeClass('show');//Chiudo l'accordion dopo aver ricalcolato le altezze se necessario
261                                }
262                                /////////////////////////////////////////////////////////////////
263                                break;
264                        }
265                    });
266        });
267        return;
268    };
269    function inizializzapager(idpager) {
270        var recordstotali = mainscope.localcontainer.recordstotali;
271        var page = mainscope.objfiltro['page'];
272        var pagesize = mainscope.objfiltro['pagesize'];
273        page = Number(page);
274        pagesize = Number(pagesize);
275
276        if (page > 1)
277            $("#" + idpager).append("<button  type='button' class='btn' id='" + idpager + "-prev'>" + GetResourcesValue("pagerindietro") + "</button>");
278        if (!isNaN(page) && !isNaN(pagesize))
279            if (!(((page + 1) * pagesize) - recordstotali >= pagesize))
280                $("#" + idpager).append("<button type='button' class='btn' id='" + idpager + "-next'>" + GetResourcesValue("pageravanti") + "</button>");
281
282        if ($("#" + idpager + '-next').length)
283            $("#" + idpager + '-next')[0].addEventListener('click', function (elem) {
284                console.log('avanti');
285                var recordstotali = mainscope.localcontainer.recordstotali;
286                var page = mainscope.objfiltro['page'];
287                var pagesize = mainscope.objfiltro['pagesize'];
288                page = Number(page);
289                pagesize = Number(pagesize);
290                if (!isNaN(page) && !isNaN(pagesize)) {
291                    page += 1;
292                    if ((page * pagesize) - recordstotali >= pagesize) { page -= 1; }
293                    else {
294                        mainscope.objfiltro['page'] = page;
295                        mainscope.rendercomments(mainscope.idpost, mainscope.idcontainer);
296                    }
297                }
298            });
299        if ($("#" + idpager + '-prev').length)
300            $("#" + idpager + '-prev')[0].addEventListener('click', function (elem) {
301                console.log('indietro');
302                var recordstotali = mainscope.localcontainer.recordstotali;
303                var page = mainscope.objfiltro['page'];
304                var pagesize = mainscope.objfiltro['pagesize'];
305                page = Number(page);
306                pagesize = Number(pagesize);
307                if (!isNaN(page) && !isNaN(pagesize)) {
308                    page -= 1;
309                    if (page < 1) { page = 1; }
310                    else {
311                        mainscope.objfiltro['page'] = page;
312                        mainscope.rendercomments(mainscope.idpost, mainscope.idcontainer);
313                    }
314                }
315            });
316    }
317
318    function inizializzastars() {
319        var ratings = document.getElementsByClassName('rating');
320        for (var i = 0; i < ratings.length; i++) {
321            var r = new SimpleStarRating(ratings[i]); //Inizializza la visualizzazione delle stelline
322
323            //evento per cattura i click di rating dagli utenti sugli elementi star!!!! 
324            ratings[i].addEventListener('rate', function (elem) {
325                console.log('Rating: ' + elem.detail);
326                var found = false;
327                var tmpId = $(elem.target).attr('idbind');
328                var valore = elem.detail;
329                var property = $(elem.target).attr('mybind');
330                if (tmpId != null && tmpId != '') //Aggiornamento vecchio
331                    for (var j = 0; j < mainscope.localcontainer.list.length; j++) {
332                        if (mainscope.localcontainer.list[j].hasOwnProperty(property)) {
333                            if (mainscope.localcontainer.list[j].Id == tmpId) {
334                                found = true;
335                                mainscope.localcontainer.list[j][property] = valore;
336                                console.log(mainscope.localcontainer.list[j][property]);
337                            }
338                        }
339                    }
340                else { //Nuovo valore
341                    if (mainscope.localcontainer.item.hasOwnProperty(property)) {
342                        found = true;
343                        if (!isNaN(Number(mainscope.idpost)))
344                            mainscope.localcontainer.item['Idpost'] = Number(mainscope.idpost);
345                        else
346                            mainscope.localcontainer.item['Idpost'] = 0;
347                        mainscope.localcontainer.item[property] = valore;
348                        console.log(mainscope.localcontainer.item[property]);
349                    }
350                }
351            });
352        }
353    }
354
355    this.initautocompleteclienti = function (idcontrollo) {
356        $("#" + idcontrollo).autocomplete({
357            source: pathAbs + commonhandlerpath + '?q=autocompleteclienti&r=20',
358            minLength: 0,
359            //appendTo: '#' + idcontrollo,
360            open: function () {
361                //console.log("OPEN");
362                setTimeout(function () {
363                    $('.ui-autocomplete').css('z-index', 99999999999999);
364                }, 0);
365            },
366            //open: function (event, ui) {
367            //    $('.ui-autocomplete').css('position', 'absolute');
368            //    $('.ui-autocomplete').css('z-index', 99999999999999);
369            //    $('.ui-autocomplete').css('top', '0px');
370            //    $('.ui-autocomplete').css('left', '0px');
371            //    setTimeout(function () {
372            //        $('.ui-autocomplete').css('z-index', 99999999999999);
373            //    }, 1);
374            //},
375            select: function (event, ui) {
376                if (ui.item != null) {
377                    $("#" + idcontrollo + "Hidden").val(ui.item.id);
378                    $("#" + idcontrollo).text(ui.item.label);
379                }
380            }
381        }).on("focus", function () {
382            $(this).autocomplete("search", "");
383        });
384
385    }
386
387    function getcliente(id, callback) {
388        var lng = lng || "I";
389        $.ajax({
390            url: pathAbs + commonhandlerpath,
391            contentType: "application/json; charset=utf-8",
392            global: false,
393            cache: false,
394            dataType: "text",
395            type: "POST",
396            //async: false,
397            data: { 'q': 'autocompleteclienti', 'term': id },
398            success: function (result) {
399                var parseditem = '';
400                if (result.length > 0)
401                    parseditem = JSON.parse(result);
402                callback(parseditem);
403            },
404            error: function (result) {
405                callback('');
406            },
407            falilure: function (result) {
408                callback('');
409            }
410        });
411    }
412
413
414    /* Al change del tag vado ad aggiornare la memoria generale per il successivo salvataggio
415     */
416    this.onchangeValue = function (elem) {
417        //console.log(elem);
418        var found = false;
419        var tmpId = $(elem).attr('idbind');
420        var property = $(elem).attr('mybind');
421
422        if ($(elem).attr('type') == 'checkbox') {
423            for (var j = 0; j < mainscope.localcontainer.list.length; j++) {
424                if (mainscope.localcontainer.list[j].hasOwnProperty(property)) {
425                    if (mainscope.localcontainer.list[j].Id == tmpId) {
426                        found = true;
427                        mainscope.localcontainer.list[j][property] = $(elem).is(":checked");
428                        console.log(mainscope.localcontainer.list[j][property]);
429                    }
430                }
431            }
432        }
433        else {
434            var newval = $(elem).val();
435            for (var j = 0; j < mainscope.localcontainer.list.length; j++) {
436                if (mainscope.localcontainer.list[j].hasOwnProperty(property)) {
437                    if (mainscope.localcontainer.list[j].Id == tmpId) {
438                        found = true;
439                        mainscope.localcontainer.list[j][property] = newval;
440                        mainscope.localcontainer.list[j][property + lng] = newval;
441                        console.log(mainscope.localcontainer.list[j][property]);
442                    }
443                }
444            }
445        }
446
447    };
448    this.onchangenewValue = function (elem) {
449        //console.log(elem);
450        var found = false;
451        var tmpId = 0;
452        var newval = $(elem).val();
453        var property = $(elem).attr('mybind');
454        if (mainscope.localcontainer.item.hasOwnProperty(property)) {
455            found = true;
456            if (!isNaN(Number(mainscope.idpost)))
457                mainscope.localcontainer.item['Idpost'] = Number(mainscope.idpost);
458            else
459                mainscope.localcontainer.item['Idpost'] = 0;
460
461            mainscope.localcontainer.item[property] = newval;
462            mainscope.localcontainer.item[property + lng] = newval;
463            console.log(mainscope.localcontainer.item[property]);
464        }
465    };
466
467
468    this.selectitem = function (elem) {
469        // console.log(elem);
470        //var found = false;
471        //var property = $(elem).attr('mybind');
472        //for (var j = 0; j < mainscope.localcontainer.list.length; j++) {
473        //    if (mainscope.localcontainer.list[j].hasOwnProperty(property)) {
474        //        if (mainscope.localcontainer.list[j].Id == tmpId) {
475        //            found = true;
476        //            mainscope.localcontainer.list[j][property] = newval;
477        //            console.log(mainscope.localcontainer.list[j][property]);
478        //        }
479        //    }
480        //}
481    };
482    this.insertitem = function (elem) {
483        //console.log(elem);
484        $(elem).attr("disabled", true);
485        var found = false;
486        var tmpId = 0;
487        if (mainscope.localcontainer.item != null) {
488            insertcomments(lng, mainscope.localcontainer.item, function (ret) {
489                console.log(ret);
490                if (ret == '' || ret == null) {
491                    mainscope.message = 'Recensione inserita in attesa di approvazione';
492                    if (mainscope.mailadvice) {
493                        mainscope.localcontainer.mail.Emailaddress.defaultsenderemail = mainscope.localcontainer.item['Email'];
494                        mainscope.localcontainer.mail.Emailaddress.defaultsendername = mainscope.localcontainer.item['Nome'];
495                        //Inserire i dati necessari per l'invio nella mail 
496                        mainscope.localcontainer.mail.Sparedict["Idpost"] = mainscope.localcontainer.item['Idpost']; //Id prodotto se presente
497                        mainscope.localcontainer.mail.Sparedict["Id"] = mainscope.localcontainer.item["Id"]; //id recensione inserita
498
499                        inviamail(lng, mainscope.localcontainer.mail, function (retinvio) {
500
501                        });
502                    }
503                }
504                else {
505                    mainscope.message = 'Errore: ' + ret;
506                }
507
508                // if (username != null && username != '')
509                mainscope.rendercomments(mainscope.idpost, mainscope.idcontainer);
510            });
511        }
512    };
513
514    this.updateitem = function (id) {
515        //console.log(elem);
516        var found = false;
517        var tmpId = id;
518        //var property = $(elem).attr('mybind');
519        for (var j = 0; j < mainscope.localcontainer.list.length; j++) {
520            if (mainscope.localcontainer.list[j].hasOwnProperty('Id')) {
521                if (mainscope.localcontainer.list[j].Id == tmpId) {
522                    found = true;
523                    console.log('update');
524                    console.log(mainscope.localcontainer.list[j]);
525                    updatecomments(lng, mainscope.localcontainer.list[j], function (ret) {
526                        console.log(ret);
527                        if (ret == '' || ret == null)
528                            //$('#' + mainscope.idcontainer + 'tresponse').html('Recenzione inserita in attesa di approvazione');
529                            mainscope.message = 'Recensione aggiornata';
530                        else
531                            //  $('#' + mainscope.idcontainer + 'tresponse').html('Errore: ' + ret);
532                            mainscope.message = 'Errore: ' + ret;
533                        mainscope.rendercomments(mainscope.idpost, mainscope.idcontainer);
534                    });
535                    // mainscope.localcontainer.list[j] //elemento da passare per l'aggiornamento
536                }
537            }
538        }
539    };
540
541    this.deleteitem = function (id) {
542        //console.log(elem);
543        var found = false;
544        var tmpId = id;
545        //var property = $(elem).attr('mybind');
546        for (var j = 0; j < mainscope.localcontainer.list.length; j++) {
547            if (mainscope.localcontainer.list[j].hasOwnProperty('Id')) {
548                if (mainscope.localcontainer.list[j].Id == tmpId) {
549                    found = true;
550                    console.log('delete');
551                    console.log(mainscope.localcontainer.list[j])
552                    // mainscope.localcontainer.list[j] //elemento da passare per l'aggiornamento
553                    deletecomments(lng, mainscope.localcontainer.list[j], function (ret) {
554                        console.log(ret);
555                        if (ret == '' || ret == null)
556                            //$('#tresponse').html('Recenzione inserita in attesa di approvazione');
557                            mainscope.message = 'Recenzione cancellata';
558                        else
559                            //  $('#tresponse').html('Errore: ' + ret);
560                            mainscope.message = 'Errore: ' + ret;
561                        mainscope.rendercomments(mainscope.idpost, mainscope.idcontainer);
562                    })
563                }
564            }
565        }
566    };
567
568    function caricacommentsbyidpost(lng, objfiltro, callback) {
569        var lng = lng || "I";
570        var objfiltro = objfiltro || {};
571
572        //Svuoto il contenitore dei commenti
573        mainscope.localcontainer = {};
574        mainscope.localcontainer["item"] = '';
575        mainscope.localcontainer["list"] = ''; 
576        mainscope.localcontainer["objfiltro"] = '';
577        mainscope.localcontainer["totaleapprovati"] = '';
578        mainscope.localcontainer["totalemediastars"] = '';
579        mainscope.localcontainer["recordstotali"] = '';
580        mainscope.localcontainer["mail"] = '';
581
582        $.ajax({
583            url: pathAbs + commenthandlerpath,
584            contentType: "application/json; charset=utf-8",
585            global: false,
586            cache: false,
587            dataType: "text",
588            type: "POST",
589            //async: false,
590            data: { 'q': 'caricacommenti', 'lng': lng, 'objfiltro': JSON.stringify(objfiltro) },
591            success: function (result) {
592                var parseddata = '';
593
594                if (result != '') {
595                    var parsedres = JSON.parse(result);
596                    mainscope.localcontainer["item"] = parsedres.item;//oggetto vuoto per update ed insert
597                    mainscope.localcontainer["mail"] = parsedres.mail;//oggetto vuoto per update ed insert
598                    mainscope.localcontainer["list"] = parsedres.list;//lista di ritorno
599                    mainscope.localcontainer["totaleapprovati"] = parsedres.totaleapprovati;// 
600                    mainscope.localcontainer["totalemediastars"] = parsedres.totalemediastars;// 
601                    mainscope.localcontainer["recordstotali"] = parsedres.recordstotali;// 
602                    mainscope.localcontainer["objfiltro"] = JSON.parse(result).objfiltro;//array oggetti json filtri usati nel caricamento dati
603                }
604                callback('', mainscope);
605            },
606            error: function (result) {
607                //sendmessage('fail creating link');
608                callback(result.responseText, mainscope);
609            }
610        });
611    };
612
613    function Validazionedati(item, callback) {
614
615        if (item.stelle == 0) {
616            callback('Dare una valutazione da 1 a 5'); return;
617        }
618        if (item["Nome"] == 0 || item["Nome"].length == 0) {
619            callback('Inserire nome o nickname'); return;
620        }
621        if (item["Email"] == 0 || item["Email"].length == 0 || !validateEmail(item["Email"])) {
622            callback('Inserire email'); return;
623        }
624        if (item["Titolo" + lng] == 0 || item["Titolo" + lng].length == 0) {
625            callback('Inserire un titolo per la recenzione'); return;
626        }
627        if (item["Testo" + lng] == 0 || item["Testo" + lng].length == 0) {
628            callback('Inserire un messaggio di testo per la recenzione'); return;
629        }
630
631        callback('');
632    }
633
634    function inviamail(lng, mail, callback) {
635        var lng = lng || "I";
636        var mail = mail || {};
637        //Campi di default passati nel costruttore
638        //mainscope.localcontainer.mail.Emailaddress.defaultdestemail
639        //mainscope.localcontainer.mail.Emailaddress.defaultdestname
640        //mainscope.localcontainer.mail.Emailaddress.defaultsenderemail
641        //mainscope.localcontainer.mail.Emailaddress.defaultsendername
642        $.ajax({
643            url: pathAbs + commenthandlerpath,
644            contentType: "application/json; charset=utf-8",
645            global: false,
646            cache: false,
647            dataType: "text",
648            type: "POST",
649            //async: false,
650            data: { 'q': 'inviamailfeedback', 'mail': JSON.stringify(mail), 'lng': lng },
651            success: function (result) {
652                callback('');
653
654            },
655            error: function (result) {
656
657                callback(result.responseText);
658            },
659            falilure: function (result) {
660
661                callback(result.responseText);
662            }
663        });
664    }
665
666    function updatecomments(lng, item, callback) {
667        var lng = lng || "I";
668        var item = item || {};
669
670        Validazionedati(item,
671            function (ret) {
672                $('#' + mainscope.idcontainer + '-head-ctrl' + 'tresponse').html(ret);
673                if (ret.length > 0) {
674                    $('html, body').animate({ scrollTop: $("#" + mainscope.idcontainer + '-head-ctrl' + "tresponse").offset().top - 150 }, 100);
675                    return;
676                }
677
678
679                $.ajax({
680                    url: pathAbs + commenthandlerpath,
681                    contentType: "application/json; charset=utf-8",
682                    global: false,
683                    cache: false,
684                    dataType: "text",
685                    type: "POST",
686                    //async: false,
687                    data: { 'q': 'updatecommenti', 'item': JSON.stringify(item), 'lng': lng },
688                    success: function (result) {
689                        callback('');
690                    },
691                    error: function (result) {
692                        //sendmessage('fail creating link');
693                        callback(result.responseText);
694                    },
695                    falilure: function (result) {
696                        //sendmessage('fail creating link');
697                        callback(result.responseText);
698                    }
699                });
700            });
701    }
702
703    function insertcomments(lng, item, callback) {
704        var lng = lng || "I";
705        var item = item || {};
706
707        Validazionedati(item,
708            function (ret) {
709                $('#' + mainscope.idcontainer + '-head-ctrl' + 'tresponse').html(ret);
710                if (ret.length > 0) {
711                    $('html, body').animate({ scrollTop: $("#" + mainscope.idcontainer + '-head-ctrl' + "tresponse").offset().top - 150 }, 100);
712                    $('#' + mainscope.idcontainer + '-head-ctrlinsertbtn').removeAttr("disabled");
713                    return;
714                }
715
716
717                $.ajax({
718                    url: pathAbs + commenthandlerpath,
719                    contentType: "application/json; charset=utf-8",
720                    global: false,
721                    cache: false,
722                    dataType: "text",
723                    type: "POST",
724                    //async: false,
725                    data: { 'q': 'insertcommenti', 'item': JSON.stringify(item), 'lng': lng },
726                    success: function (result) {
727                        //result contiene l'id del messaggio inserito
728                        mainscope.localcontainer.item["Id"] = result;
729                        callback('');
730                    },
731                    error: function (result) {
732                        //sendmessage('fail creating link');
733                        callback(result.responseText);
734                    },
735                    falilure: function (result) {
736                        //sendmessage('fail creating link');
737                        callback(result.responseText);
738                    }
739                });
740            });
741
742    }
743
744
745    function deletecomments(lng, item, callback) {
746        var lng = lng || "I";
747        var item = item || {};
748
749        $.ajax({
750            url: pathAbs + commenthandlerpath,
751            contentType: "application/json; charset=utf-8",
752            global: false,
753            cache: false,
754            dataType: "text",
755            type: "POST",
756            //async: false,
757            data: { 'q': 'deletecommenti', 'item': JSON.stringify(item), 'lng': lng },
758            success: function (result) {
759                callback('');
760            },
761            error: function (result) {
762                //sendmessage('fail creating link');
763                callback(result.responseText);
764            },
765            falilure: function (result) {
766                //sendmessage('fail creating link');
767                callback(result.responseText);
768            }
769        });
770    }
771
772
773};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.