PageSourceSearch

https://www.photocity.it/includes/master/js-css/searchpy.js?QPGPV2101316

js photocity.it collected 2026-10-02 08:15:04 UTC 16,787 bytes, 436 lines download raw bytes

1// ---------------------------------------------------------------------------
2var pathAjax_Search = '/includes/master/searchpy_ajax.aspx'; 
3
4var tagComSearch1 = 1; // ricerca prodotto
5var tagComSearch2 = 2; // ricerca faq
6var tagComSearch3 = 3; // set link
7var tagComSearch30 = 30; // ricerca solo prodotti
8
9function pad(str, max) {  
10    str = "0000000000" + str;
11    return str.slice(-max);
12} 
13
14
15function callajax_sessionStorageSearch() {
16    var session = "";
17    try {
18        if (sessionStorage.getItem("sessionTabSearch")) {
19            session = sessionStorage.getItem("sessionTabSearch");
20        }
21        else {
22            var rnd = 1 + Math.floor(Math.random() * 10000);
23            var dt = new Date();
24            var strDate = pad((dt.getMonth() + 1), 2) + pad(dt.getDate(), 2);
25            var time = pad(dt.getHours(), 2) + pad(dt.getMinutes(), 2) + pad(dt.getSeconds(), 2);
26            session = "D" + strDate + "." + time + "." + pad(rnd, 5);
27            sessionStorage.setItem("sessionTabSearch", session);
28        }
29    }
30    catch (e) { }
31    return session;
32}
33function callajax_removeSessionStorageSearch() {
34    try {
35        if (sessionStorage.getItem("sessionTabSearch")) {
36            sessionStorage.removeItem("sessionTabSearch");
37        }
38    }
39    catch (e) { }
40}
41
42
43
44//#################################################################
45function callajax_GoAjaxSearch(paramAjax, myCallback) {
46
47    try {
48
49        $.post
50            (
51            pathAjax_Search, paramAjax,
52            function (Risposta) {
53
54                rispostaJson = JSON.parse(Risposta);
55
56                $('#popupSearchPY-titolo').html("Non ho trovato dati");
57
58                if (rispostaJson.iEsito < 0) {
59                    return;
60                }
61
62                paramAjax.iEsito = rispostaJson.iEsito;
63                paramAjax.sEsito = rispostaJson.sEsito;
64                paramAjax.Risposta = rispostaJson.lista;
65                if (myCallback) {
66                    myCallback();
67                } 
68
69                //......................................................................................   
70
71            });
72
73    } catch (e) {
74        config_alert(e.description + ' #-cstudio-K1');
75        return false;
76    }
77}
78
79//------------------------------------------------------------------------
80function callajax_ricerca(imode,txt) {
81    txt = txt.replace(/</g, " ").replace(/'/g, " ").replace(/%/g, " ");
82
83    //------------------------------------------------------------------
84    // SE DIVERSO DA 1E 2, SETTO A 1
85    //------------------------------------------------------------------
86    if (imode != tagComSearch1 && imode != tagComSearch2)
87        imode = tagComSearch1;
88    //------------------------------------------------------------------
89
90    var paramAjax = new Object();
91    paramAjax.iMode = imode;
92    paramAjax.session = callajax_sessionStorageSearch();
93    paramAjax.testo = txt;
94    callajax_GoAjaxSearch(paramAjax, function () {
95        $('#popupSearchPY-titolo').html("Risultati trovati: " + paramAjax.Risposta.length);
96        $("#popupSearchPY-contentricerca").html("");
97        var lista = paramAjax.Risposta;
98        if (lista.length == 0) {
99            $("#popupSearchPY-contentricerca").html("Non ho trovato dati con il testo inserito");
100        }
101        for (var x = 0; x < lista.length; x++) {
102            var id = lista[x].id;
103            var titolo = lista[x].titolo;
104            var descrizione = lista[x].descrizione;
105            var url = lista[x].url;
106            var image = lista[x].image;
107
108            var div = ""; 
109            div += "<div class='search_container_row row' idsearch='" + id + "' url='" + url + "'>";
110            div += "  <div class='search_container_row_image'><img src='" + image + "' class='img-responsive'  idsearch='" + id + "' onerror='javascript:searchpy_errorimage(" + id + ")'/></div>";
111            div += "  <div class='search_container_row_testo'>";
112            div += "    <span class='h5'><b>" + titolo + "</b></span><br />";
113            div += "    <span class='h5'>" + descrizione + "</span>";
114            div += "  </div>";
115
116            div += "</div>";
117
118            $("#popupSearchPY-contentricerca").append(div);
119
120            $(".search_container_row[idsearch=" + id + "]").click(function () {
121                var url = $(this).attr("url");
122                callajax_setLink(id, url);
123                /*
124                if (url.substring(0, 1) == "/")
125                    location.href = url;
126                else
127                    window.open(url);
128                */
129            });
130
131        }
132    });
133}
134//------------------------------------------------------------------------
135function callajax_ricercaFAQ(imode, txt) {
136    txt = txt.replace(/</g, " ").replace(/'/g, " ").replace(/%/g, " ");
137
138    //------------------------------------------------------------------
139    // SE DIVERSO DA 1E 2, SETTO A 1
140    //------------------------------------------------------------------
141    if (imode != tagComSearch1 && imode != tagComSearch2 && imode != tagComSearch30)
142        imode = tagComSearch1;
143    //------------------------------------------------------------------
144
145    var paramAjax = new Object();
146    paramAjax.iMode = imode;
147    paramAjax.session = callajax_sessionStorageSearch();
148    paramAjax.testo = txt;
149    callajax_GoAjaxSearch(paramAjax, function () {
150        $('#popupSearchPY-titoloFAQ').html("Risultati trovati: " + paramAjax.Risposta.length);
151        $("#popupSearchPY-contentricercaFAQ").html("");
152        var lista = paramAjax.Risposta;
153        if (lista.length == 0) {
154            $("#popupSearchPY-contentricercaFAQ").html("Non ho trovato dati con il testo inserito");
155        }
156        for (var x = 0; x < lista.length; x++) {
157            var id = lista[x].id;
158            var titolo = lista[x].titolo;
159            var descrizione = lista[x].descrizione;
160            var url = lista[x].url;
161            var image = lista[x].image;
162
163            var div = "";
164            div += "<div class='search_container_FAQ_row row' idsearch='" + id + "' url='" + url + "'>";
165            div += "  <div class='search_container_FAQ_row_image'><img src='" + image + "' class='img-responsive'  idsearch='" + id + "' onerror='javascript:searchpy_errorimage(" + id + ")'/></div>";
166            div += "  <div class='search_container_FAQ_row_testo'>";
167            div += "    <span class='h5'><b>" + titolo + "</b></span><br />";
168            div += "    <span class='h5'>" + descrizione + "</span>";
169            div += "  </div>";
170
171            div += "</div>";
172
173            $("#popupSearchPY-contentricercaFAQ").append(div);
174
175            $(".search_container_FAQ_row[idsearch=" + id + "]").click(function () {
176                var url = $(this).attr("url");
177                callajax_setLink(id, url);
178                /*
179                if (url.substring(0, 1) == "/")
180                    location.href = url;
181                else
182                    window.open(url);
183                */
184            });
185
186        }
187    });
188}
189 
190//------------------------------------------------------------------------
191function callajax_ricercaDesktop(imode, txt) {
192    txt = txt.replace(/</g, " ").replace(/'/g, " ").replace(/%/g, " ");
193    //------------------------------------------------------------------
194    // SE DIVERSO DA 1E 2, SETTO A 1
195    //------------------------------------------------------------------
196    if (imode != tagComSearch1 && imode != tagComSearch2)
197        imode = tagComSearch1;
198    //------------------------------------------------------------------
199
200    var paramAjax = new Object();
201    paramAjax.iMode = imode;
202    paramAjax.session = callajax_sessionStorageSearch();
203    paramAjax.testo = txt;
204    callajax_GoAjaxSearch(paramAjax, function () {
205        //$('#popupSearchPY-titolo').html("Risultati trovati: " + paramAjax.Risposta.length);
206        $("#popupSearchPY-contentricercadesktop").html("");
207        var lista = paramAjax.Risposta;
208        if (lista.length == 0) {
209            $("#popupSearchPY-contentricercadesktop").html("<div style='margin:15px;width:90%;'>Non ho trovato dati con il testo inserito</div>");
210        }
211        for (var x = 0; x < lista.length; x++) {
212            var id          = lista[x].id;
213            var titolo      = lista[x].titolo;
214            var descrizione = lista[x].descrizione;
215            var url         = lista[x].url;
216            var image       = lista[x].image;
217
218            var div = "";
219            div += "<div class='search_container_desktop_row row' idsearch='" + id + "' url='" + url + "'>";
220            div += "  <div class='search_container_desktop_row_image'>
220<img src='" + image + "' class='img-responsive'  idsearch='" + id + "' onerror='javascript:searchpy_errorimage(" + id + ")'/></div>";
221            div += "  <div class='search_container_desktop_row_testo'>";
222            div += "    <span class='h5'><b>" + titolo + "</b></span><br />";
223            div += "    <span class='h5'>" + descrizione + "</span>";
224            div += "  </div>";
225
226            div += "</div>";
227
228            $("#popupSearchPY-contentricercadesktop").append(div);
229
230            $(".search_container_desktop_row[idsearch=" + id + "]").click(function () {
231                var url = $(this).attr("url");
232                callajax_setLink(id, url);
233            });
234
235        }
236    });
237}
238
239
240function callajax_setLink(idfc,url) {
241
242    var paramAjax = new Object();
243    paramAjax.iMode = tagComSearch3;
244    paramAjax.idfc = idfc;
245    paramAjax.url = url;
246    callajax_GoAjaxSearch(paramAjax, function () {
247        var url = paramAjax.url;
248        if (url.substring(0, 1) == "/")
249            location.href = url;
250        else
251            window.open(url);
252    });
253}
254
255
256
257
258
259
260
261function searchpy_errorimage(id) {
262    var obj = $(".search_container_row_image img[idsearch=" + id + "]");
263    console.log(obj.length);
264    if (obj.length > 0 && (!obj.attr("mod"))) {
265        obj.attr("mod", 1).attr("src", "https://images.photocity.it/image/no_image_search.jpg");
266    }
267}
268
269// ---------------------------------------------------------------------------
270 
271$(function () {
272    $(".icosearchpopup").click(function () { 
273        creaPopupSearch(1); // prodotti
274    });
275    $(".icosearchpopupfaq").click(function () {
276        creaPopupSearch(2); // faq
277    });
278});
279
280
281function creaPopupSearch(tipo) {
282    if ($("#popupSearchPY").length > 0) {
283        $("#popupSearchPY").remove();
284        callajax_removeSessionStorageSearch();
285    }
286
287    var ph = "Cerca";
288    if (tipo == 2) {
289        ph = "Hai bisogno di aiuto?";
290    }
291
292//    if ($("#popupSearchPY").length == 0) {
293        var popup = "";
294        popup += "<div class='modal fade' id='popupSearchPY' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>";
295        popup += "  <div class='modal-dialog'>";
296        popup += "    <div class='modal-content'>";
297        popup += "      <div class='modal-header boxPopupPattern-header'>";
298        popup += "        <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>&times;</button>";
299        popup += "        <h5 class='modal-title' id='popupSearchPY-titolo'> Come possiamo aiutarti </h5>";
300        popup += "      </div>";
301        popup += "      <div class='modal-body'>";
302        popup += "        <div class='input-group'>";
303        popup += "          <input type='text' value='' id='popupSearchPY-textricerca' tipo='" + tipo + "' class='form-control' autocomplete='off' placeholder='" + ph + "' aria-describedby='basic-addon1' >";
304        popup += "          <span class='input-group-addon' id='popupSearchPY-cercaricerca'><span class='glyphicon glyphicon-search' aria-hidden='true'></span> Cerca</span>";
305        popup += "        </div>";
306        popup += "        <div id='popupSearchPY-contentricerca' class='popupSearchPY-contentricerca'></div>";
307
308        if (tipo != 3) { // ricerca in assistenza
309          popup += "        <div id='popupSearchPY-fine text-right'>Non hai trovato quello che cerchi? <a href='/assistenza/contattaci.aspx'>Contattaci</a></div>";
310        }
311        popup += "      </div>";
312        popup += "    </div>";
313        popup += "  </div>";
314        popup += "</div>";
315
316        $("body").append(popup);
317
318        $("#popupSearchPY-contentricerca").html("");
319
320    /*
321    $("#popupSearchPY-cercaricerca").click(function (e) {
322        $("#popupSearchPY-content").css("display", "");
323
324        var txt = $("#popupSearchPY-textricerca").val().replace(/[^@0-9A-Za-z_\s]/, '').trim();
325        if (txt.length >= 3) {
326            $("#popupSearchPY-content").css("display", "block");
327            callajax_ricerca($("#popupSearchPY-textricerca").attr("tipo"), txt);
328        }
329        else {
330            alert("Inserire almento 3 caratteri per la ricerca")
331        }
332    });
333
334    $('#popupSearchPY-textricerca').on('keypress', function (e) {
335        return e.which !== 13;
336    });
337
338    $("#popupSearchPY-textricerca").keyup(function (e) {
339        var code = e.keyCode || e.which;
340        if (code == 13) {
341            $("#popupSearchPY-cercaricerca").trigger("click");
342        }
343
344    });
345*/
346
347
348
349    //$("#popupSearchPY").modal("show");
350    openModalPY('popupSearchPY');
351
352}
353
354//-------------------------------------------------------------------------------------------
355//-- MOBILE ---------------------------------------------------------------------------------
356//-------------------------------------------------------------------------------------------
357$(document).on("click", "#popupSearchPY-cercaricerca", function () {
358    $("#popupSearchPY-content").css("display", "");
359
360    var txt = $("#popupSearchPY-textricerca").val().replace(/[^@0-9A-Za-z_\s]/, '').trim();
361    if (txt.length >= 3) {
362        $("#popupSearchPY-content").css("display", "block");
363        callajax_ricerca($("#popupSearchPY-textricerca").attr("tipo"), txt);
364    }
365    else {
366        alert("Inserire almento 3 caratteri per la ricerca")
367    }
368});
369$(document).on("keypress", "#popupSearchPY-textricerca", function (e) {
370    return e.which !== 13;
371});
372$(document).on("keyup", "#popupSearchPY-textricerca", function (e) {
373    var code = e.keyCode || e.which;
374    if (code == 13) {
375        $("#popupSearchPY-cercaricerca").trigger("click");
376    }
377});
378//-------------------------------------------------------------------------------------------
379//-- FAQ ------------------------------------------------------------------------------------
380//-------------------------------------------------------------------------------------------
381$(document).on("click", "#popupSearchPY-cercaricercaFAQ", function () {
382    $("#popupSearchPY-contentFAQ").css("display", "");
383
384    var txt = $("#popupSearchPY-textricercaFAQ").val().replace(/[^@0-9A-Za-z_\s]/, '').trim();
385    if (txt.length >= 3) {
386        $("#popupSearchPY-contentFAQ").css("display", "block");
387        callajax_ricercaFAQ($("#popupSearchPY-textricercaFAQ").attr("tipo"), txt);
388    }
389    else {
390        alert("Inserire almento 3 caratteri per la ricerca")
391    }
392});
393$(document).on("keypress", "#popupSearchPY-textricercaFAQ", function (e) {
394    return e.which !== 13;
395});
396$(document).on("keyup", "#popupSearchPY-textricercaFAQ", function (e) {
397    var code = e.keyCode || e.which;
398    if (code == 13) {
399        $("#popupSearchPY-cercaricercaFAQ").trigger("click");
400    }
401});
402
403
404$(document).on("click", "#popupSearchPY-cercaricercaFAQ2", function () {
405    $("#popupSearchPY-contentFAQ").css("display", "");
406    var txt = $("#popupSearchPY-textricercaFAQ2").val().replace(/[^@0-9A-Za-z_\s]/, '').trim();
407    if (txt.length >= 3) {
408        $("#popupSearchPY-contentFAQ").css("display", "block");
409        callajax_ricercaFAQ(30, txt);
410    }
411    else {
412        alert("Inserire almento 3 caratteri per la ricerca")
413    }
414});
415$(document).on("keypress", "#popupSearchPY-textricercaFAQ2", function (e) {
416    return e.which !== 13;
417});
418$(document).on("keyup", "#popupSearchPY-textricercaFAQ2", function (e) {
419    var code = e.keyCode || e.which;
420    if (code == 13) {
421        $("#popupSearchPY-cercaricercaFAQ2").trigger("click");
422    }
423});
424
425
426
427$(document).on("click", "#popupSearchPY-contentcloseFAQ", function (e) {
428    $("#popupSearchPY-contentFAQ").css("display", "");
429    $("#popupSearchPY-textricercaFAQ").val("").focus();
430
431});
432
433
434//-------------------------------------------------------------------------------------------
435
436

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.