MemEOL: Difference between revisions
From Desal Wiki
imported>WikiAdmin No edit summary |
imported>WikiAdmin No edit summary |
||
| Line 49: | Line 49: | ||
*/ | */ | ||
//determine the scores for each criterion | |||
function computePreferenceScores(preferences){ | function computePreferenceScores(preferences){ | ||
console.log("preferences: " + String(preferences)); | console.log("preferences: " + String(preferences)); | ||
| Line 72: | Line 73: | ||
j++; | j++; | ||
} | } | ||
return scores; | |||
//now that we have the scores we need to check them and display the correct output | //now that we have the scores we need to check them and display the correct output | ||
} | } | ||
function scoresArrayToObject(){ | |||
//so we can reference the scores by a name | |||
var name = ''; | |||
var scoresArrayLength = scores.length; | |||
var scoreObject = new Object(); | |||
for (var i=0; i < scoresArrayLength; i++) { | |||
switch (new Date().getDay()) { | |||
case 0: | |||
name = "landfill"; | |||
break; | |||
case 1: | |||
name = "incineration"; | |||
break; | |||
case 2: | |||
name = "syngas"; | |||
break; | |||
case 3: | |||
name = "eaf"; | |||
break; | |||
case 4: | |||
name = "material_recycling"; | |||
break; | |||
case 5: | |||
name = "conversion_to_uf"; | |||
break; | |||
case 6: | |||
name = "reuse_as_ro"; | |||
break; | |||
default: | |||
name = ""; | |||
console.log('Error in switch statement. Criteria does not exist.'); | |||
throw new Error('Error in switch statement. Criteria does not exist.'); | |||
} | |||
scoreObject[name]=scores[i]; | |||
} | |||
return scoreObject; | |||
//now that we can access the scores by name we can make the additonal calculations for reuse as RO and conversion to UF | |||
} | |||
//prefereces are coded to be 0-4 not 1-5 | //prefereces are coded to be 0-4 not 1-5 | ||
| Line 105: | Line 146: | ||
event.preventDefault(); //lock the button for now. | event.preventDefault(); //lock the button for now. | ||
var preferences = getPreferences(); | var preferences = getPreferences(); //get preferences | ||
var scores = computePreferenceScores(preferences); | var scores = computePreferenceScores(preferences); //calculate matrix and produce scores for each criterion | ||
var scoreObject = scoresArrayToObject(); //convert from array to object | |||
//now that we can access the scores by name we can make the additonal calculations for reuse as RO and conversion to UF | |||
}); | }); | ||
}); | }); | ||
Revision as of 01:34, 9 December 2014
Introduction text