ilar06 commited on
Commit
81b9d8b
·
verified ·
1 Parent(s): 7002ad6

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +14 -2
index.html CHANGED
@@ -76,15 +76,27 @@
76
  });
77
 
78
  async function analyzeNutrition(text) {
 
 
 
 
79
  // Extract nutritional values (assuming sugar content is labeled as '당류' in Korean)
80
- const regex = /당류\s*:\s*(\d+(\.\d+)?)\s*g\s*/; // This regex might need adjustments based on label format
 
81
  const match = text.match(regex);
82
- let outputDiv = document.getElementById('output');
 
 
 
 
83
 
84
  if (match) {
85
  const sugarContent = parseFloat(match[1]);
86
  let message = `Sugar content: ${sugarContent}g - `;
87
 
 
 
 
88
  if (sugarContent > 20) {
89
  message += 'Dangerous';
90
  outputDiv.className = 'red';
 
76
  });
77
 
78
  async function analyzeNutrition(text) {
79
+
80
+ // Log the extracted text for debugging, see whether to keep or not
81
+ console.log("Analyzing text:", text);
82
+
83
  // Extract nutritional values (assuming sugar content is labeled as '당류' in Korean)
84
+ const regex = /당류\s*[::]\s*(\d+(\.\d+)?)\s*([gG]|그램)/;
85
+ // /당류\s*:\s*(\d+(\.\d+)?)\s*g\s*/; // This regex might need adjustments based on label format
86
  const match = text.match(regex);
87
+
88
+ // Log the match result for debugging, see whether to keep
89
+ console.log("Match result:", match);
90
+
91
+ // see if to put again let outputDiv = document.getElementById('output');
92
 
93
  if (match) {
94
  const sugarContent = parseFloat(match[1]);
95
  let message = `Sugar content: ${sugarContent}g - `;
96
 
97
+
98
+
99
+
100
  if (sugarContent > 20) {
101
  message += 'Dangerous';
102
  outputDiv.className = 'red';