File size: 11,255 Bytes
fba6023
 
 
 
a5c43b6
fba6023
a5c43b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fba6023
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154b83f
 
 
a5c43b6
 
154b83f
 
 
 
 
 
 
 
 
 
fba6023
a5c43b6
fba6023
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154b83f
 
 
 
 
fba6023
154b83f
 
 
 
 
 
a5c43b6
154b83f
a5c43b6
 
fba6023
 
 
 
 
 
 
 
 
a5c43b6
fba6023
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
document.addEventListener('DOMContentLoaded', function() {
    const form = document.getElementById('troubleshootForm');
    const resultsContainer = document.getElementById('resultsContainer');
    const solutionsList = document.getElementById('solutionsList');
    // Database of solutions and PDF documents
    const solutionsDatabase = {
        "pdf": [
            {
                title: "User Manual",
                description: "Complete user manual for your coffee machine",
                pdfUrl: "/manuals/user-manual.pdf",
                difficulty: "Easy",
                time: "Varies"
            },
            {
                title: "Installation Guide",
                description: "Step-by-step installation instructions",
                pdfUrl: "/manuals/installation-guide.pdf",
                difficulty: "Medium",
                time: "30 minutes"
            },
            {
                title: "Troubleshooting Guide",
                description: "Comprehensive troubleshooting reference",
                pdfUrl: "/manuals/troubleshooting-guide.pdf",
                difficulty: "Easy",
                time: "Varies"
            },
            {
                title: "Cleaning Instructions",
                description: "Detailed cleaning and maintenance procedures",
                pdfUrl: "/manuals/cleaning-instructions.pdf",
                difficulty: "Medium",
                time: "20 minutes"
            }
        ],
"no power": [
            {
                title: "Check Power Connection",
                description: "Ensure the machine is properly plugged into a working power outlet. Try a different outlet to rule out electrical issues.",
                steps: [
                    "Unplug the machine from the power source",
                    "Check the power cord for any visible damage",
                    "Plug into a different outlet",
                    "Try turning the machine on again"
                ],
                difficulty: "Easy",
                time: "2 minutes"
            },
            {
                title: "Reset Circuit Breaker",
                description: "The machine may have tripped an internal circuit breaker. Locate and reset the breaker switch.",
                steps: [
                    "Locate the circuit breaker (usually at the back or bottom of the machine)",
                    "Press the reset button if available",
                    "Wait 30 seconds before turning the machine back on"
                ],
                difficulty: "Medium",
                time: "5 minutes"
            }
        ],
        "no water flow": [
            {
                title: "Check Water Tank",
                description: "Ensure the water tank is properly seated and filled with fresh water.",
                steps: [
                    "Remove and reinsert the water tank",
                    "Fill with fresh, cold water",
                    "Ensure tank is properly seated in its position"
                ],
                difficulty: "Easy",
                time: "1 minute"
            },
            {
                title: "Descale the Machine",
                description: "Mineral buildup may be blocking water flow. Perform a descaling cycle.",
                steps: [
                    "Prepare descaling solution as per manufacturer instructions",
                    "Run descaling cycle",
                    "Rinse thoroughly with fresh water"
                ],
                difficulty: "Medium",
                time: "20 minutes"
            }
        ],
        "weak coffee": [
            {
                title: "Adjust Grind Size",
                description: "If using fresh beans, try a finer grind setting for stronger extraction.",
                steps: [
                    "Access grind settings (consult your manual for location)",
                    "Adjust to a finer setting",
                    "Brew a test shot and adjust further if needed"
                ],
                difficulty: "Easy",
                time: "3 minutes"
            },
            {
                title: "Clean Brew Group",
                description: "Coffee oils and residue can affect flavor. Clean the brew group thoroughly.",
                steps: [
                    "Remove brew group according to manual instructions",
                    "Clean with warm water and soft brush",
                    "Dry completely before reinserting"
                ],
                difficulty: "Medium",
                time: "10 minutes"
            }
        ]
    };

    form.addEventListener('submit', function(e) {
        e.preventDefault();
        
        const machineModel = document.getElementById('machineModel').value;
        const issueDescription = document.getElementById('issueDescription').value.toLowerCase();
        
        // Simple keyword matching (in a real app, this would be more sophisticated)
        let matchedSolutions = [];
        
        if (issueDescription.includes('power') || issueDescription.includes('turn on')) {
            matchedSolutions = matchedSolutions.concat(solutionsDatabase['no power']);
        }
        
        if (issueDescription.includes('water') || issueDescription.includes('flow')) {
            matchedSolutions = matchedSolutions.concat(solutionsDatabase['no water flow']);
        }
        
        if (issueDescription.includes('weak') || issueDescription.includes('taste') || issueDescription.includes('flavor')) {
            matchedSolutions = matchedSolutions.concat(solutionsDatabase['weak coffee']);
        }
        // Enhanced PDF guide search
        const pdfKeywords = ['manual', 'guide', 'document', 'pdf', 'instructions', 'reference', 'tutorial', 
                            'quick fix', 'troubleshoot', 'how to', 'help', 'support', 'fix', 'solution'];
        if (pdfKeywords.some(keyword => issueDescription.includes(keyword))) {
            matchedSolutions = matchedSolutions.concat(solutionsDatabase['pdf']);
        } else {
            // Also show PDF guides for any technical issue
            const technicalKeywords = ['power', 'water', 'flow', 'weak', 'taste', 'flavor', 'leak', 'noise', 
                                     'error', 'code', 'not working', 'broken', 'issue', 'problem'];
            if (technicalKeywords.some(keyword => issueDescription.includes(keyword))) {
                matchedSolutions = matchedSolutions.concat(solutionsDatabase['pdf'].filter(pdf => 
                    pdf.title.toLowerCase().includes('troubleshooting') || 
                    pdf.title.toLowerCase().includes('guide')
                ));
            }
        }
// If no matches, show a generic message
        if (matchedSolutions.length === 0) {
            matchedSolutions.push({
                title: "No Exact Match Found",
                description: "We couldn't find an exact match for your issue, but here are some general troubleshooting steps:",
steps: [
                    "Turn the machine off and unplug it for 2 minutes, then restart",
                    "Check all connections and water reservoirs",
                    "Consult your user manual for model-specific guidance",
                    "Contact our support team for further assistance"
                ],
                difficulty: "Varies",
                time: "Varies"
            });
        }
        
        // Display solutions
        displaySolutions(matchedSolutions);
    });
    
    function displaySolutions(solutions) {
        solutionsList.innerHTML = '';
        
        solutions.forEach((solution, index) => {
            const solutionElement = document.createElement('div');
            solutionElement.className = `solution-card bg-gray-50 rounded-lg p-6 border border-gray-200`;
            solutionElement.style.animationDelay = `${index * 0.1}s`;
            
            solutionElement.innerHTML = `
                <div class="flex justify-between items-start mb-4">
                    <h3 class="text-xl font-semibold text-gray-800">${solution.title}</h3>
                    <div class="flex items-center space-x-2">
                        <span class="px-2 py-1 text-xs font-medium rounded-full ${solution.difficulty === 'Easy' ? 'bg-green-100 text-green-800' : 'bg-yellow-100 text-yellow-800'}">
                            ${solution.difficulty}
                        </span>
                        <span class="px-2 py-1 text-xs font-medium rounded-full bg-blue-100 text-blue-800">
                            ${solution.time}
                        </span>
                    </div>
                </div>
                <p class="text-gray-600 mb-4">${solution.description}</p>
                <div class="space-y-2">
                    <h4 class="font-medium text-gray-700">Steps:</h4>
                    <ol class="list-decimal list-inside space-y-1 text-gray-600">
                        ${solution.steps.map(step => `<li>${step}</li>`).join('')}
                    </ol>
                </div>
                ${solution.pdfUrl ? `
                <div class="mt-4">
                    <h4 class="font-medium text-gray-700 mb-2">Quick Fix Guide:</h4>
                    <div class="flex items-center mb-3">
                        <i data-feather="file-text" class="text-blue-500 mr-2"></i>
                        <span class="text-sm text-gray-600">${solution.title}</span>
                    </div>
                    <pdf-viewer></pdf-viewer>
                    <div class="mt-3 flex space-x-3">
                        <a href="${solution.pdfUrl}" target="_blank" class="inline-flex items-center px-3 py-2 border border-transparent text-sm leading-4 font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
                            <i data-feather="external-link" class="mr-1 w-4 h-4"></i>
                            Open Full Screen
                        </a>
                        <a href="${solution.pdfUrl}" download class="inline-flex items-center px-3 py-2 border border-gray-300 text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
                            <i data-feather="download" class="mr-1 w-4 h-4"></i>
                            Download
                        </a>
                    </div>
                    <script>
                        // Load the PDF after the element is rendered
                        setTimeout(() => {
                            const viewer = document.querySelector('#solution-${index} pdf-viewer');
                            if (viewer) viewer.loadPdf('${solution.pdfUrl}');
                        }, 100);
                    </script>
                </div>
                ` : ''}
${index < solutions.length - 1 ? '<div class="border-t border-gray-200 mt-6 pt-6"></div>' : ''}
`;
            
            solutionsList.appendChild(solutionElement);
        });
        
        resultsContainer.classList.remove('hidden');
        resultsContainer.scrollIntoView({ behavior: 'smooth' });
    }
});