[ { "search": "// Function to update the carbon footprint value", "replace": "// Function to calculate the carbon emission value based on the action\nfunction calculateCarbonEmission(action) {\n let emissionValue = 0;\n\n // Add different emission values based on the action\n switch(action) {\n case 'car':\n emissionValue = 2;\n break;\n case 'bus':\n emissionValue = 1.5;\n break;\n case 'bike':\n emissionValue = 0;\n break;\n case 'walk':\n emissionValue = 0;\n break;\n default:\n emissionValue = 0;\n }\n\n return emissionValue;\n}\n\n// Function to update the carbon footprint value\nfunction updateCarbonFootprint(action) {\n let value = calculateCarbonEmission(action);\n carbonFootprint += value;\n $('#carbon-footprint').text(carbonFootprint);\n}" }, { "search": "// Event handler for the add button", "replace": "// Event handler for the add button\n$('#add-btn').on('click', function() {\n let action = $('#input-value').val().toLowerCase();\n\n // Check if the input value is valid\n if (action === '') {\n alert('Please enter a valid action.');\n } else {\n let value = calculateCarbonEmission(action);\n updateCarbonFootprint(value);\n $('#input-value').val('');\n }\n});" }, { "search": "", "replace": "" } ]