Skip to content

Instantly share code, notes, and snippets.

@melissamcewen
Created October 2, 2017 18:42
Show Gist options
  • Save melissamcewen/a4ce4c3854fabad4dbe7039753ae6b86 to your computer and use it in GitHub Desktop.
Save melissamcewen/a4ce4c3854fabad4dbe7039753ae6b86 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/xociqeh
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var product = {
silicones: {
bad: [],
good: [],
possible: []
},
sulfates: {
bad: [],
good: [],
possible:[]
},
};
var badSilicones = [
"dimethicone",
"bisaminopropyl dimethicone",
"cetearyl methicone",
"cetyl dimethicone",
"cyclopentasiloxane",
"stearoxy dimethicone",
"stearyl dimethicone",
"trimethylsilylamodimethicone",
"amodimethicone",
"dimethiconol",
"behenoxy dimethicone",
"phenyl trimethicone",
"aminopropyl triethoxysilane",
"silicone"
];
var goodSilicones = [
"peg-dimethicone",
"dimethicone copolyol",
"dimethicone-pg diethylmonium chloride",
"pg-dimethicone",
"glycidoxy dimethicone crosspolymer",
"dimethicone hydroxypropyl trimonium chloride",
"hydroxyethyl acetomonium pg-dimethicone",
"stearalkonium dimethicone peg-8 phthalate",
"steardimonium hydroxypropyl panthenyl peg-7 dimethicone phosphate chloride",
];
var badSulfates = [
"alkylbenzene sulfonate",
"alkyl benzene sulfonate",
"ammonium laureth sulfate",
"ammonium lauryl sulfate",
"ammonium xylenesulfonate",
"sodium c14-16 olefin sulfonate",
"sodium cocoyl sarcosinate",
"sodium laureth sulfate",
"sodium lauryl sulfate",
"sodium lauryl sulfoacetate",
"sodium myreth sulfate",
"sodium Xylenesulfonate",
"tea-dodecylbenzenesulfonate",
"ethyl peg-15 cocamine sulfate",
"dioctyl sodium sulfosuccinate"
];
var goodSulfates = [
"behentrimonium methosulfate",
"disodium laureth sulfosuccinate",
];
var badAlcohols = [
"denatured alcohol",
"sd alcohol 40",
"witch hazel",
"isopropanol",
"ethanol",
"sd alcohol",
"propanol",
"propyl alcohol",
"isopropyl alcohol"
];
var goodAlcohols = [
"behenyl alcohol",
"cetearyl alcohol",
"ceteryl alcohol",
"cetyl alcohol",
"isocetyl alcohol",
"isostearyl alcohol",
"lauryl alcohol",
"myristyl alcohol",
"stearyl alcohol",
"c30-50 alcohols",
"lanolin alcohol"
];
var badWaxesOils = [
"castor oil",
"mineral oil",
"huile minerale",
"parrifidium liquidium",
"petrolatum",
"bees wax",
"beeswax",
"candelia wax",
"cire dabeille",
"cera alba"
];
//var ingredients = "AQUA / WATER / EAU, peg-dimethicone, coney, Silicone Quaternium-8, SODIUM LAURETH SULFATE, SODIUM LAURYL SULFATE, COCAMIDE MEA, GLYCOL DISTEARATE,SODIUM CHLORIDE, MEL / HONEY / MIEL,PPG-5-CETETH-20, ARGANIA SPINOSA KERNEL OIL, FUMARIC ACID, ROYAL JELLY, CARBOMER GLYCERIN, DIMETHICONE, ALOE BARBADENSIS / ALOE BARBADENSIS LEAF JUICE, SODIUM HYDROXIDE, ALCOHOL, PROPOLIS EXTRACT GUAR HYDROXYPROPYLTRIMONIUM CHLORIDE, CITRIC ACID, SODIUM BENZOATE, SALICYLIC ACID, CI 19140 / YELLOW 5, CARAMEL PARFUM / FRAGRANCE, COUMARIN, LIMONENE, BENZYL ALCOHOL, BENZYL SALICYLATE"
//var ingredients1 = "1101742 FS2 AQUA/WATER/EAU, cetyl alcohol, alcohol beer, sulfonates, behentrimonium methosulfate, SODIUM LAURETH SULFATE, CITRIC ACID, COCAMIDOPROPYL BETAINE, GLYCERIN, SODIUM HYDROXIDE, SODIUM CHLORIDE, HEXYLENE GLYCOL, SODIUM BENZOATE, PARFUM/FRAGRANCE, PYRUS MALUS FRUIT EXTRACT/APPLE FRUIT EXTRACT, SALICYLIC ACID, POLYQUATERNIUM-10, LINALOOL, HEXYL CINNAMAL, NIACINAMIDE, PYRIDOXINE HCl, SACCHARUM OFFICINARUM EXTRACT/SUGAR CANE EXTRACT/EXTRAIT DE CANNE A SUCRE, CAPRYLIC/CAPRIC TRIGLYCERIDE, HYDROXYPROPYLTRIMONIUM LEMON PROTEIN, SODIUM ACETATE, ISOPROPYL ALCOHOL, RUBUS FRUTICOSUS FRUIT EXTRACT/BLACKBERRY FRUIT EXTRACT, ACETUM/VINEGAR/VINAIGRE, PHENOXYETHANOL, CITRUS LIMON PEEL EXTRACT/LEMON PEEL EXTRACT, LEUCONOSTOC/RADISH ROOT FERMENT FILTRATE, CAMELLIA SINENSIS LEAF EXTRACT, MALPIGHIA PUNICIFOLIA FRUIT EXTRACT/ACEROLA FRUIT EXTRACT, POTASSIUM SORBATE. F.I.L.# D192859/1";
var ingredients1= "Petrolatum, Water (Aqua), Glycerin, Ceteareth 20, Mineral Oil (Paraffinum Liquidum), Polysorbate 20, Oleth 5, Propylene Glycol, Beeswax (Apis Mellifera), Hydroxylated Lanolin, Oleth 10, Cera Microcristallina (Microcrystalline Wax), Fragrance (Parfum), Phenoxyethanol, Methylparaben, Propylparaben, Benzyl Salicylate, Hexylcinnamal, Linalool, Limonene, Citronellol, Geraniol, Amyl Cinnamal, Benzyl Benzoate, Citral, Benzyl Alcohol";
function evaluateIngredients(ingredients){
var ingredientsList = ingredients.split(',');
// TODO need to handle slashs
var ingredientDetected = false;
ingredientsList.forEach(function(ingredient){
//clean up our string
var ingredientTest = ingredient.trim().toLowerCase();
// TODO need case for handling extremely long strings to warn them of issue
// detect cones
var cone = /cone/i;
if(cone.test(ingredientTest)) {
console.log("cone detected");
ingredientDetected = true;
console.log(ingredientTest);
// for now we only have one "good silicone" pattern so let's test for it
var goodSilicon = /quaternium/i
if (goodSilicon.test(ingredientTest)){
console.log("this is quaternium silicone");
} else if (goodSilicones.indexOf(ingredientTest) !== -1) {
console.log("this is another good silicone");
} else if (badSilicones.indexOf(ingredientTest) !== -1) {
console.log ("this is a bad silicone")
} else {
console.log("this is a silicone I don't know about yet, please check this list");
}
}
// detect sulfates
var sulfate = /sulfate/i;
var sulfo = /sulfo/i;
if(sulfate.test(ingredientTest)|| sulfo.test(ingredientTest)) {
console.log("sulfate detected");
ingredientDetected = true;
// seems like there is only one good sulfate so let's test for it
if (goodSulfates.indexOf(ingredientTest) !== -1){
console.log("this is a good sulfate called " + ingredientTest);
} else if (badSulfates.indexOf(ingredientTest) !== -1) {
console.log("this is a bad sulfate called " + ingredientTest);
} else {
console.log("this is a sulfate I don't know about yet, please check this list");
}
}
// detect alcohol
var alcohol = /alcohol/i;
var alcoholTest = badAlcohols.indexOf(ingredientTest);
if(alcohol.test(ingredientTest)|| alcoholTest !== -1){
console.log("alcohol detected");
ingredientDetected = true;
if(alcoholTest !== -1){
console.log("bad alcohol named " + badAlcohols[alcoholTest]);
} else if (goodAlcohols.indexOf(ingredientTest) !== -1){
console.log("good alcohol detected");
} else {
console.log("this is an alcohol I don't know about yet, please check this list");
}
};
// detect bad waxes and oils
var beeswax = /bees/i;
var mineral = /mineral/i;
var petro = /petro/i;
var waxOilTest = badWaxesOils.indexOf(ingredientTest);
// console.log(waxOilTest);
if(beeswax.test(ingredientTest)|| waxOilTest !== -1 || petro.test(ingredientTest) || mineral.test(ingredientTest)){
ingredientDetected = true;
console.log("wax oil detected");
if(waxOilTest !== -1){
console.log("bad waxoil named " + badWaxesOils[waxOilTest]);
} else {
var WaxOildetect = false;
badWaxesOils.forEach(function(baddy) {
var testing = ingredientTest.indexOf(baddy);
if(testing !== -1){
WaxOildetect = true;
console.log(ingredientTest + "looks like " + baddy);
}
});
if (WaxOildetect === false){
console.log("this a potentially unknown wax oil named" + ingredientTest);
}
}
}
});
if(ingredientDetected === false){
console.log("I can't find anything wrong with this ingredient list, but I'm still a baby bot and I'm learning. Check this list to be sure.");
}
}
evaluateIngredients(ingredients1);
</script>
<script id="jsbin-source-javascript" type="text/javascript">var product = {
silicones: {
bad: [],
good: [],
possible: []
},
sulfates: {
bad: [],
good: [],
possible:[]
},
};
var badSilicones = [
"dimethicone",
"bisaminopropyl dimethicone",
"cetearyl methicone",
"cetyl dimethicone",
"cyclopentasiloxane",
"stearoxy dimethicone",
"stearyl dimethicone",
"trimethylsilylamodimethicone",
"amodimethicone",
"dimethiconol",
"behenoxy dimethicone",
"phenyl trimethicone",
"aminopropyl triethoxysilane",
"silicone"
];
var goodSilicones = [
"peg-dimethicone",
"dimethicone copolyol",
"dimethicone-pg diethylmonium chloride",
"pg-dimethicone",
"glycidoxy dimethicone crosspolymer",
"dimethicone hydroxypropyl trimonium chloride",
"hydroxyethyl acetomonium pg-dimethicone",
"stearalkonium dimethicone peg-8 phthalate",
"steardimonium hydroxypropyl panthenyl peg-7 dimethicone phosphate chloride",
];
var badSulfates = [
"alkylbenzene sulfonate",
"alkyl benzene sulfonate",
"ammonium laureth sulfate",
"ammonium lauryl sulfate",
"ammonium xylenesulfonate",
"sodium c14-16 olefin sulfonate",
"sodium cocoyl sarcosinate",
"sodium laureth sulfate",
"sodium lauryl sulfate",
"sodium lauryl sulfoacetate",
"sodium myreth sulfate",
"sodium Xylenesulfonate",
"tea-dodecylbenzenesulfonate",
"ethyl peg-15 cocamine sulfate",
"dioctyl sodium sulfosuccinate"
];
var goodSulfates = [
"behentrimonium methosulfate",
"disodium laureth sulfosuccinate",
];
var badAlcohols = [
"denatured alcohol",
"sd alcohol 40",
"witch hazel",
"isopropanol",
"ethanol",
"sd alcohol",
"propanol",
"propyl alcohol",
"isopropyl alcohol"
];
var goodAlcohols = [
"behenyl alcohol",
"cetearyl alcohol",
"ceteryl alcohol",
"cetyl alcohol",
"isocetyl alcohol",
"isostearyl alcohol",
"lauryl alcohol",
"myristyl alcohol",
"stearyl alcohol",
"c30-50 alcohols",
"lanolin alcohol"
];
var badWaxesOils = [
"castor oil",
"mineral oil",
"huile minerale",
"parrifidium liquidium",
"petrolatum",
"bees wax",
"beeswax",
"candelia wax",
"cire dabeille",
"cera alba"
];
//var ingredients = "AQUA / WATER / EAU, peg-dimethicone, coney, Silicone Quaternium-8, SODIUM LAURETH SULFATE, SODIUM LAURYL SULFATE, COCAMIDE MEA, GLYCOL DISTEARATE,SODIUM CHLORIDE, MEL / HONEY / MIEL,PPG-5-CETETH-20, ARGANIA SPINOSA KERNEL OIL, FUMARIC ACID, ROYAL JELLY, CARBOMER GLYCERIN, DIMETHICONE, ALOE BARBADENSIS / ALOE BARBADENSIS LEAF JUICE, SODIUM HYDROXIDE, ALCOHOL, PROPOLIS EXTRACT GUAR HYDROXYPROPYLTRIMONIUM CHLORIDE, CITRIC ACID, SODIUM BENZOATE, SALICYLIC ACID, CI 19140 / YELLOW 5, CARAMEL PARFUM / FRAGRANCE, COUMARIN, LIMONENE, BENZYL ALCOHOL, BENZYL SALICYLATE"
//var ingredients1 = "1101742 FS2 AQUA/WATER/EAU, cetyl alcohol, alcohol beer, sulfonates, behentrimonium methosulfate, SODIUM LAURETH SULFATE, CITRIC ACID, COCAMIDOPROPYL BETAINE, GLYCERIN, SODIUM HYDROXIDE, SODIUM CHLORIDE, HEXYLENE GLYCOL, SODIUM BENZOATE, PARFUM/FRAGRANCE, PYRUS MALUS FRUIT EXTRACT/APPLE FRUIT EXTRACT, SALICYLIC ACID, POLYQUATERNIUM-10, LINALOOL, HEXYL CINNAMAL, NIACINAMIDE, PYRIDOXINE HCl, SACCHARUM OFFICINARUM EXTRACT/SUGAR CANE EXTRACT/EXTRAIT DE CANNE A SUCRE, CAPRYLIC/CAPRIC TRIGLYCERIDE, HYDROXYPROPYLTRIMONIUM LEMON PROTEIN, SODIUM ACETATE, ISOPROPYL ALCOHOL, RUBUS FRUTICOSUS FRUIT EXTRACT/BLACKBERRY FRUIT EXTRACT, ACETUM/VINEGAR/VINAIGRE, PHENOXYETHANOL, CITRUS LIMON PEEL EXTRACT/LEMON PEEL EXTRACT, LEUCONOSTOC/RADISH ROOT FERMENT FILTRATE, CAMELLIA SINENSIS LEAF EXTRACT, MALPIGHIA PUNICIFOLIA FRUIT EXTRACT/ACEROLA FRUIT EXTRACT, POTASSIUM SORBATE. F.I.L.# D192859/1";
var ingredients1= "Petrolatum, Water (Aqua), Glycerin, Ceteareth 20, Mineral Oil (Paraffinum Liquidum), Polysorbate 20, Oleth 5, Propylene Glycol, Beeswax (Apis Mellifera), Hydroxylated Lanolin, Oleth 10, Cera Microcristallina (Microcrystalline Wax), Fragrance (Parfum), Phenoxyethanol, Methylparaben, Propylparaben, Benzyl Salicylate, Hexylcinnamal, Linalool, Limonene, Citronellol, Geraniol, Amyl Cinnamal, Benzyl Benzoate, Citral, Benzyl Alcohol";
function evaluateIngredients(ingredients){
var ingredientsList = ingredients.split(',');
// TODO need to handle slashs
var ingredientDetected = false;
ingredientsList.forEach(function(ingredient){
//clean up our string
var ingredientTest = ingredient.trim().toLowerCase();
// TODO need case for handling extremely long strings to warn them of issue
// detect cones
var cone = /cone/i;
if(cone.test(ingredientTest)) {
console.log("cone detected");
ingredientDetected = true;
console.log(ingredientTest);
// for now we only have one "good silicone" pattern so let's test for it
var goodSilicon = /quaternium/i
if (goodSilicon.test(ingredientTest)){
console.log("this is quaternium silicone");
} else if (goodSilicones.indexOf(ingredientTest) !== -1) {
console.log("this is another good silicone");
} else if (badSilicones.indexOf(ingredientTest) !== -1) {
console.log ("this is a bad silicone")
} else {
console.log("this is a silicone I don't know about yet, please check this list");
}
}
// detect sulfates
var sulfate = /sulfate/i;
var sulfo = /sulfo/i;
if(sulfate.test(ingredientTest)|| sulfo.test(ingredientTest)) {
console.log("sulfate detected");
ingredientDetected = true;
// seems like there is only one good sulfate so let's test for it
if (goodSulfates.indexOf(ingredientTest) !== -1){
console.log("this is a good sulfate called " + ingredientTest);
} else if (badSulfates.indexOf(ingredientTest) !== -1) {
console.log("this is a bad sulfate called " + ingredientTest);
} else {
console.log("this is a sulfate I don't know about yet, please check this list");
}
}
// detect alcohol
var alcohol = /alcohol/i;
var alcoholTest = badAlcohols.indexOf(ingredientTest);
if(alcohol.test(ingredientTest)|| alcoholTest !== -1){
console.log("alcohol detected");
ingredientDetected = true;
if(alcoholTest !== -1){
console.log("bad alcohol named " + badAlcohols[alcoholTest]);
} else if (goodAlcohols.indexOf(ingredientTest) !== -1){
console.log("good alcohol detected");
} else {
console.log("this is an alcohol I don't know about yet, please check this list");
}
};
// detect bad waxes and oils
var beeswax = /bees/i;
var mineral = /mineral/i;
var petro = /petro/i;
var waxOilTest = badWaxesOils.indexOf(ingredientTest);
// console.log(waxOilTest);
if(beeswax.test(ingredientTest)|| waxOilTest !== -1 || petro.test(ingredientTest) || mineral.test(ingredientTest)){
ingredientDetected = true;
console.log("wax oil detected");
if(waxOilTest !== -1){
console.log("bad waxoil named " + badWaxesOils[waxOilTest]);
} else {
var WaxOildetect = false;
badWaxesOils.forEach(function(baddy) {
var testing = ingredientTest.indexOf(baddy);
if(testing !== -1){
WaxOildetect = true;
console.log(ingredientTest + "looks like " + baddy);
}
});
if (WaxOildetect === false){
console.log("this a potentially unknown wax oil named" + ingredientTest);
}
}
}
});
if(ingredientDetected === false){
console.log("I can't find anything wrong with this ingredient list, but I'm still a baby bot and I'm learning. Check this list to be sure.");
}
}
evaluateIngredients(ingredients1);</script></body>
</html>
var product = {
silicones: {
bad: [],
good: [],
possible: []
},
sulfates: {
bad: [],
good: [],
possible:[]
},
};
var badSilicones = [
"dimethicone",
"bisaminopropyl dimethicone",
"cetearyl methicone",
"cetyl dimethicone",
"cyclopentasiloxane",
"stearoxy dimethicone",
"stearyl dimethicone",
"trimethylsilylamodimethicone",
"amodimethicone",
"dimethiconol",
"behenoxy dimethicone",
"phenyl trimethicone",
"aminopropyl triethoxysilane",
"silicone"
];
var goodSilicones = [
"peg-dimethicone",
"dimethicone copolyol",
"dimethicone-pg diethylmonium chloride",
"pg-dimethicone",
"glycidoxy dimethicone crosspolymer",
"dimethicone hydroxypropyl trimonium chloride",
"hydroxyethyl acetomonium pg-dimethicone",
"stearalkonium dimethicone peg-8 phthalate",
"steardimonium hydroxypropyl panthenyl peg-7 dimethicone phosphate chloride",
];
var badSulfates = [
"alkylbenzene sulfonate",
"alkyl benzene sulfonate",
"ammonium laureth sulfate",
"ammonium lauryl sulfate",
"ammonium xylenesulfonate",
"sodium c14-16 olefin sulfonate",
"sodium cocoyl sarcosinate",
"sodium laureth sulfate",
"sodium lauryl sulfate",
"sodium lauryl sulfoacetate",
"sodium myreth sulfate",
"sodium Xylenesulfonate",
"tea-dodecylbenzenesulfonate",
"ethyl peg-15 cocamine sulfate",
"dioctyl sodium sulfosuccinate"
];
var goodSulfates = [
"behentrimonium methosulfate",
"disodium laureth sulfosuccinate",
];
var badAlcohols = [
"denatured alcohol",
"sd alcohol 40",
"witch hazel",
"isopropanol",
"ethanol",
"sd alcohol",
"propanol",
"propyl alcohol",
"isopropyl alcohol"
];
var goodAlcohols = [
"behenyl alcohol",
"cetearyl alcohol",
"ceteryl alcohol",
"cetyl alcohol",
"isocetyl alcohol",
"isostearyl alcohol",
"lauryl alcohol",
"myristyl alcohol",
"stearyl alcohol",
"c30-50 alcohols",
"lanolin alcohol"
];
var badWaxesOils = [
"castor oil",
"mineral oil",
"huile minerale",
"parrifidium liquidium",
"petrolatum",
"bees wax",
"beeswax",
"candelia wax",
"cire dabeille",
"cera alba"
];
//var ingredients = "AQUA / WATER / EAU, peg-dimethicone, coney, Silicone Quaternium-8, SODIUM LAURETH SULFATE, SODIUM LAURYL SULFATE, COCAMIDE MEA, GLYCOL DISTEARATE,SODIUM CHLORIDE, MEL / HONEY / MIEL,PPG-5-CETETH-20, ARGANIA SPINOSA KERNEL OIL, FUMARIC ACID, ROYAL JELLY, CARBOMER GLYCERIN, DIMETHICONE, ALOE BARBADENSIS / ALOE BARBADENSIS LEAF JUICE, SODIUM HYDROXIDE, ALCOHOL, PROPOLIS EXTRACT GUAR HYDROXYPROPYLTRIMONIUM CHLORIDE, CITRIC ACID, SODIUM BENZOATE, SALICYLIC ACID, CI 19140 / YELLOW 5, CARAMEL PARFUM / FRAGRANCE, COUMARIN, LIMONENE, BENZYL ALCOHOL, BENZYL SALICYLATE"
//var ingredients1 = "1101742 FS2 AQUA/WATER/EAU, cetyl alcohol, alcohol beer, sulfonates, behentrimonium methosulfate, SODIUM LAURETH SULFATE, CITRIC ACID, COCAMIDOPROPYL BETAINE, GLYCERIN, SODIUM HYDROXIDE, SODIUM CHLORIDE, HEXYLENE GLYCOL, SODIUM BENZOATE, PARFUM/FRAGRANCE, PYRUS MALUS FRUIT EXTRACT/APPLE FRUIT EXTRACT, SALICYLIC ACID, POLYQUATERNIUM-10, LINALOOL, HEXYL CINNAMAL, NIACINAMIDE, PYRIDOXINE HCl, SACCHARUM OFFICINARUM EXTRACT/SUGAR CANE EXTRACT/EXTRAIT DE CANNE A SUCRE, CAPRYLIC/CAPRIC TRIGLYCERIDE, HYDROXYPROPYLTRIMONIUM LEMON PROTEIN, SODIUM ACETATE, ISOPROPYL ALCOHOL, RUBUS FRUTICOSUS FRUIT EXTRACT/BLACKBERRY FRUIT EXTRACT, ACETUM/VINEGAR/VINAIGRE, PHENOXYETHANOL, CITRUS LIMON PEEL EXTRACT/LEMON PEEL EXTRACT, LEUCONOSTOC/RADISH ROOT FERMENT FILTRATE, CAMELLIA SINENSIS LEAF EXTRACT, MALPIGHIA PUNICIFOLIA FRUIT EXTRACT/ACEROLA FRUIT EXTRACT, POTASSIUM SORBATE. F.I.L.# D192859/1";
var ingredients1= "Petrolatum, Water (Aqua), Glycerin, Ceteareth 20, Mineral Oil (Paraffinum Liquidum), Polysorbate 20, Oleth 5, Propylene Glycol, Beeswax (Apis Mellifera), Hydroxylated Lanolin, Oleth 10, Cera Microcristallina (Microcrystalline Wax), Fragrance (Parfum), Phenoxyethanol, Methylparaben, Propylparaben, Benzyl Salicylate, Hexylcinnamal, Linalool, Limonene, Citronellol, Geraniol, Amyl Cinnamal, Benzyl Benzoate, Citral, Benzyl Alcohol";
function evaluateIngredients(ingredients){
var ingredientsList = ingredients.split(',');
// TODO need to handle slashs
var ingredientDetected = false;
ingredientsList.forEach(function(ingredient){
//clean up our string
var ingredientTest = ingredient.trim().toLowerCase();
// TODO need case for handling extremely long strings to warn them of issue
// detect cones
var cone = /cone/i;
if(cone.test(ingredientTest)) {
console.log("cone detected");
ingredientDetected = true;
console.log(ingredientTest);
// for now we only have one "good silicone" pattern so let's test for it
var goodSilicon = /quaternium/i
if (goodSilicon.test(ingredientTest)){
console.log("this is quaternium silicone");
} else if (goodSilicones.indexOf(ingredientTest) !== -1) {
console.log("this is another good silicone");
} else if (badSilicones.indexOf(ingredientTest) !== -1) {
console.log ("this is a bad silicone")
} else {
console.log("this is a silicone I don't know about yet, please check this list");
}
}
// detect sulfates
var sulfate = /sulfate/i;
var sulfo = /sulfo/i;
if(sulfate.test(ingredientTest)|| sulfo.test(ingredientTest)) {
console.log("sulfate detected");
ingredientDetected = true;
// seems like there is only one good sulfate so let's test for it
if (goodSulfates.indexOf(ingredientTest) !== -1){
console.log("this is a good sulfate called " + ingredientTest);
} else if (badSulfates.indexOf(ingredientTest) !== -1) {
console.log("this is a bad sulfate called " + ingredientTest);
} else {
console.log("this is a sulfate I don't know about yet, please check this list");
}
}
// detect alcohol
var alcohol = /alcohol/i;
var alcoholTest = badAlcohols.indexOf(ingredientTest);
if(alcohol.test(ingredientTest)|| alcoholTest !== -1){
console.log("alcohol detected");
ingredientDetected = true;
if(alcoholTest !== -1){
console.log("bad alcohol named " + badAlcohols[alcoholTest]);
} else if (goodAlcohols.indexOf(ingredientTest) !== -1){
console.log("good alcohol detected");
} else {
console.log("this is an alcohol I don't know about yet, please check this list");
}
};
// detect bad waxes and oils
var beeswax = /bees/i;
var mineral = /mineral/i;
var petro = /petro/i;
var waxOilTest = badWaxesOils.indexOf(ingredientTest);
// console.log(waxOilTest);
if(beeswax.test(ingredientTest)|| waxOilTest !== -1 || petro.test(ingredientTest) || mineral.test(ingredientTest)){
ingredientDetected = true;
console.log("wax oil detected");
if(waxOilTest !== -1){
console.log("bad waxoil named " + badWaxesOils[waxOilTest]);
} else {
var WaxOildetect = false;
badWaxesOils.forEach(function(baddy) {
var testing = ingredientTest.indexOf(baddy);
if(testing !== -1){
WaxOildetect = true;
console.log(ingredientTest + "looks like " + baddy);
}
});
if (WaxOildetect === false){
console.log("this a potentially unknown wax oil named" + ingredientTest);
}
}
}
});
if(ingredientDetected === false){
console.log("I can't find anything wrong with this ingredient list, but I'm still a baby bot and I'm learning. Check this list to be sure.");
}
}
evaluateIngredients(ingredients1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment