{"id":18336,"date":"2024-01-27T10:09:18","date_gmt":"2024-01-27T09:09:18","guid":{"rendered":"https:\/\/muratorimachines.com\/configuratore\/"},"modified":"2024-11-19T12:47:40","modified_gmt":"2024-11-19T11:47:40","slug":"find-your-machine","status":"publish","type":"page","link":"https:\/\/muratorimachines.com\/en\/find-your-machine\/","title":{"rendered":"Find your machine"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-page\" data-elementor-id=\"18336\" class=\"elementor elementor-18336 elementor-13798\" data-elementor-post-type=\"page\">\n\t\t\t\t<div class=\"elementor-element elementor-element-50082cc1 e-con-full e-flex e-con e-parent\" data-id=\"50082cc1\" data-element_type=\"container\" data-settings=\"{&quot;jet_parallax_layout_list&quot;:[]}\">\n\t\t\t\t<div class=\"elementor-element elementor-element-6d46995 elementor-widget elementor-widget-shortcode\" data-id=\"6d46995\" data-element_type=\"widget\" data-widget_type=\"shortcode.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-shortcode\"><div id=\"configurator_wrap\">\n    <div id=\"configurator\">\n        <div id=\"step-0\" data-step-id=\"0\" class=\"step\">\n            <div id=\"results\">\n                <div class=\"entity\" data-entity-type=\"materiale\">\n                    <img decoding=\"async\" src=\"https:\/\/muratorimachines.com\/wp-content\/uploads\/2024\/02\/materiale.png\" alt=\"\">\n                    <h3>Material<\/h3>\n                <\/div>\n                <div class=\"entity\" data-entity-type=\"prodotto\">\n                    <img decoding=\"async\" src=\"https:\/\/muratorimachines.com\/wp-content\/uploads\/2024\/02\/prodotto.png\" alt=\"\">\n                    <h3>Product<\/h3>\n                <\/div>\n                <div class=\"entity\" data-entity-type=\"settore\">\n                    <img decoding=\"async\" src=\"https:\/\/muratorimachines.com\/wp-content\/uploads\/2024\/02\/settore.png\" alt=\"\">\n                    <h3>Sector<\/h3>\n                <\/div>\n            <\/div>\n        <\/div>\n        <div id=\"step-1\" data-step-id=\"1\" class=\"step\">\n            <div class=\"preloader\" style=\"display: none;\">Loading...<\/div>\n            <h2><\/h2>\n            <div id=\"results\"><\/div>\n        <\/div>\n        <div id=\"step-2\" data-step-id=\"2\" class=\"step\">\n            <div class=\"preloader\" style=\"display: none;\">Loading...<\/div>\n            <h2><\/h2>\n            <div id=\"results\"><\/div>\n        <\/div>\n        <div id=\"step-3\" data-step-id=\"3\" class=\"step\">\n            <div class=\"preloader\" style=\"display: none;\">Loading...<\/div>\n            <h2><\/h2>\n            <div id=\"results\"><\/div>\n        <\/div>\n        <div id=\"step-4\" data-step-id=\"4\" class=\"step\">\n            <div class=\"preloader\" style=\"display: none;\">Loading...<\/div>\n            <h2><\/h2>\n            <div id=\"results\"><\/div>\n        <\/div>\n\n    <\/div>\n    <script>\n    jQuery(document).ready(function($) {\n        var configurator = $('#configurator');\n        var step = $('.step');\n        var entity = $('.entity');\n        var storedData = JSON.parse(localStorage.getItem('configData'));\n\n        if (storedData && Object.keys(storedData).length > 0) {\n            \/\/ Se configData \u00e8 popolato, cancella l'oggetto dal localStorage\n            localStorage.removeItem('configData');\n        }\n\n        \/\/ stringhe di traduzione\n        var noResultsString = 'No results found';\n\n        \/\/ Mostra il primo step\n        $('#step-0').show();\n\n        $('#configurator').on('click', '.entity', function() {\n            var entityType = $(this).data('entity-type');\n            var entityId = $(this).data('entity-id');\n            var stepId = $(this).closest('.step').data('step-id');\n\n            console.log(entityType, entityId, stepId);\n\n\n            \/\/ Mostra il preloader specifico per lo step corrente            \n            $('#step-' + (stepId + 1)).show();\n            $('#step-' + (stepId + 1) + ' .preloader').show();\n            $('#step-' + (stepId + 1) + ' #results').addClass('selectedResults');\n\n            \/\/ scroll page to selected div if data-entity-id is not macchina\n            if (entityType != 'macchina') {\n                setTimeout(() => {\n                    $('html, body').animate({\n                        scrollTop: $('#step-' + (stepId + 1)).offset().top - 66\n                    }, 1000);\n                }, 500);\n            } else {\n                \/\/ Redirect to macchina permalink\n                var permalink = $(this).data('permalink');\n                window.location.href = permalink;\n\n            }\n\n            if (stepId != 0) {\n                \/\/ Retrieve existing data from localStorage\n                var storedData = JSON.parse(localStorage.getItem('configData')) || {};\n\n                \/\/ Update or create the object with the new data\n                storedData[entityType] = {\n                    entityType: entityType,\n                    entityId: entityId,\n                    stepId: stepId\n                };\n\n                \/\/ Store the updated object back in localStorage\n                localStorage.setItem('configData', JSON.stringify(storedData));\n            }\n\n            updatedData = JSON.parse(localStorage.getItem('configData'));\n\n\n            if (stepId == 0) {\n                \/\/ Resetta i dati dei passi successivi\n                $('#step-2').hide();\n                $('#step-3').hide();\n                $('#step-4').hide();\n\n                \/\/ $('#step-0').addClass('active');\n                \/\/ $('#step-1').addClass('active');\n\n                $('#step-0 .entity').removeClass('selected');\n                $('#step-0 #results').addClass('selectedResults');\n            }\n\n            if (stepId == 1) {\n                \/\/ Resetta i dati dei passi successivi\n                $('#step-2').show();\n                $('#step-2').addClass('active');\n                $('#step-1 .entity').not(this).removeClass('selected');\n                $('#step-2 .entity').removeClass('selected');\n                $('#step-3 .entity').removeClass('selected');\n                $('#step-4 .entity').removeClass('selected');\n\n                \/\/$('#step-2').hide();\n                $('#step-3').hide();\n                $('#step-3 #results').html('');\n                $('#step-4').hide();\n                $('#step-4 #results').html('');\n            }\n\n            if (stepId == 2) {\n                \/\/ Resetta i dati dei passi successivi\n                $('#step-3').show();\n                \/\/$('#step-3').addClass('active');\n                $('#step-2 .entity').not(this).removeClass('selected');\n                $('#step-3 .entity').removeClass('selected');\n                $('#step-4 .entity').removeClass('selected');\n\n                $('#step-4').hide();\n                $('#step-4 #results').html('');\n            }\n\n            \/\/ read local storage\n            if (stepId == 3) {\n                if ((updatedData.settore) && (updatedData.settore.stepId == 1)) {\n                    \/\/ Resetta i dati dei passi successivi\n                    $('#step-4').show();\n                    \/\/$('#step-4').addClass('active');\n                    $('#step-3 .entity').not(this).removeClass('selected');\n                    $('#step-4 .entity').removeClass('selected');\n                } else {\n                    $('#step-4').hide();\n                    $('#step-4 #results').html('');\n                }\n\n            }\n\n\n            \/\/ if ((stepId == 3) && (entityType == 'settore')) {\n            \/\/     \/\/ Resetta i dati dei passi successivi\n            \/\/     $('#step-4').show();\n            \/\/     \/\/$('#step-4').addClass('active');\n            \/\/     $('#step-3 .entity').not(this).removeClass('selected');\n            \/\/     $('#step-4 .entity').removeClass('selected');\n            \/\/ } else {\n            \/\/     $('#step-4').hide();\n            \/\/     $('#step-4 #results').html('');\n            \/\/ }\n\n            $(this).addClass('selected');\n\n            \/\/ Ottieni il nonce di sicurezza di WordPress\n            var ajaxNonce = '74f039ecc4';\n\n            $.ajax({\n                url: 'https:\/\/muratorimachines.com\/wp-admin\/admin-ajax.php',\n                type: 'POST',\n                data: {\n                    action: 'get_entities',\n                    entity_type: entityType,\n                    entity_id: entityId,\n                    step_id: stepId,\n                    history: storedData,\n                    security: ajaxNonce, \/\/ Aggiungi il nonce di sicurezza\n                },\n                success: function(data) {\n\n                    function titoloSezione(postType) {\n                        var titolo = '';\n                        switch (postType) {\n                            case 'materiale':\n                                titolo =\n                                    \"Select a material\";\n                                break;\n                            case 'prodotto':\n                                titolo =\n                                    \"Select a product\";\n                                break;\n                            case 'settore':\n                                titolo =\n                                    \"Select a sector\";\n                                break;\n                        }\n                        return titolo;\n                    }\n\n\n\n                    $('#step-' + (stepId + 1) + ' .preloader').hide();\n\n                    switch (data.step_id) {\n                        case 0:\n                            \/\/ Aggiungi i prodotti allo step 1\n                            var step1 = $('#step-1 #results');\n                            step1.html('');\n                            $('#step-1 h2').html(titoloSezione(data.post_type));\n                            $.each(data.result, function(index, item) {\n                                var html =\n                                    '<div class=\"entity\" data-entity-type=\"' + data\n                                    .post_type + '\" data-entity-id=\"' + item.ID +\n                                    '\">';\n                                if (item.thumbnail != null && item.thumbnail !=\n                                    '') {\n                                    html += '<img decoding=\"async\" src=\"' + item.thumbnail +\n                                        '\" alt=\"' +\n                                        item.post_title + '\">';\n                                }\n                                html += '<h3>' + item.post_title + '<\/h3>';\n                                html += '<\/div>';\n                                step1.append(html);\n                            });\n                            break;\n                        case 1:\n                            var step2 = $('#step-2 #results');\n                            step2.html('');\n                            if (data.result == '') {\n                                $('#step-2 h2').html(noResultsString);\n                            } else {\n                                $('#step-2 h2').html(titoloSezione(data.post_type));\n                                $.each(data.result, function(index, item) {\n                                    var html =\n                                        '<div class=\"entity\" data-entity-type=\"' +\n                                        data\n                                        .post_type + '\" data-entity-id=\"' + item\n                                        .ID +\n                                        '\">';\n                                    if (item.thumbnail != null && item.thumbnail !=\n                                        '') {\n                                        html += '<img decoding=\"async\" src=\"' + item.thumbnail +\n                                            '\" alt=\"' +\n                                            item.post_title + '\">';\n                                    }\n                                    html += '<h3>' + item.post_title + '<\/h3>';\n                                    html += '<\/div>';\n                                    step2.append(html);\n                                });\n                            }\n                            break;\n                        case 2:\n                            var step3 = $('#step-3 #results');\n                            step3.html('');\n                            if (data.result == '') {\n                                $('#step-3 h2').html(noResultsString);\n                            } else {\n                                \/\/ eccezione per NO settore\n                                if (data.post_type == 'macchina') {\n                                    $('#step-3 h2').html(\n                                        ' Here are the machines that could be right for you'\n                                    );\n                                    $.each(data.result, function(index, item) {\n                                        var html =\n                                            '<div class=\"entity\" data-permalink=\"' +\n                                            item\n                                            .permalink + '\" data-entity-type=\"' +\n                                            data\n                                            .post_type + '\" data-entity-id=\"' + item\n                                            .ID +\n                                            '\">';\n                                        if (item.thumbnail != null && item\n                                            .thumbnail !=\n                                            '') {\n                                            html += '<img decoding=\"async\" src=\"' + item.thumbnail +\n                                                '\" alt=\"' +\n                                                item.post_title + '\">';\n                                        }\n                                        html += '<h3>' + item.post_title + '<\/h3>';\n                                        html += '<\/div>';\n                                        step3.append(html);\n                                    });\n                                } else {\n                                    $('#step-3 h2').html(titoloSezione(data.post_type));\n                                    $.each(data.result, function(index, item) {\n                                        var html =\n                                            '<div class=\"entity\" data-entity-type=\"' +\n                                            data\n                                            .post_type + '\" data-entity-id=\"' + item\n                                            .ID +\n                                            '\">';\n                                        if (item.thumbnail != null && item\n                                            .thumbnail !=\n                                            '') {\n                                            html += '<img decoding=\"async\" src=\"' + item.thumbnail +\n                                                '\" alt=\"' +\n                                                item.post_title + '\">';\n                                        }\n                                        html += '<h3>' + item.post_title + '<\/h3>';\n                                        html += '<\/div>';\n                                        step3.append(html);\n                                    });\n                                }\n\n                            }\n                            break;\n                        case 3:\n                            var step4 = $('#step-4 #results');\n                            if (data.result == '') {\n                                $('#step-4 h2').html(noResultsString);\n                            } else {\n                                $('#step-4 h2').html(\n                                    ' Here are the machines that could be right for you'\n                                );\n                                step4.html('');\n\n                                $.each(data.result, function(index, item) {\n                                    var html =\n                                        '<div class=\"entity\" data-permalink=\"' +\n                                        item\n                                        .permalink + '\" data-entity-type=\"' +\n                                        data\n                                        .post_type + '\" data-entity-id=\"' + item\n                                        .ID +\n                                        '\">';\n                                    if (item.thumbnail != null && item.thumbnail !=\n                                        '') {\n                                        html += '<img decoding=\"async\" src=\"' + item.thumbnail +\n                                            '\" alt=\"' +\n                                            item.post_title + '\">';\n                                    }\n                                    html += '<h3>' + item.post_title + '<\/h3>';\n                                    html += '<\/div>';\n                                    step4.append(html);\n                                });\n                            }\n                            break;\n                        case 4:\n                            break;\n                    }\n\n\n                }\n            });\n\n\n        });\n    });\n    <\/script><\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"","protected":false},"author":7,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"content-type":"","inline_featured_image":false,"footnotes":""},"class_list":["post-18336","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/muratorimachines.com\/en\/wp-json\/wp\/v2\/pages\/18336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/muratorimachines.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/muratorimachines.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/muratorimachines.com\/en\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/muratorimachines.com\/en\/wp-json\/wp\/v2\/comments?post=18336"}],"version-history":[{"count":7,"href":"https:\/\/muratorimachines.com\/en\/wp-json\/wp\/v2\/pages\/18336\/revisions"}],"predecessor-version":[{"id":18355,"href":"https:\/\/muratorimachines.com\/en\/wp-json\/wp\/v2\/pages\/18336\/revisions\/18355"}],"wp:attachment":[{"href":"https:\/\/muratorimachines.com\/en\/wp-json\/wp\/v2\/media?parent=18336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}