diff --git a/src/components/Results.tsx b/src/components/Results.tsx index 78ae946..20339f9 100644 --- a/src/components/Results.tsx +++ b/src/components/Results.tsx @@ -27,13 +27,26 @@ const styles = StyleSheet.create({ } as React.ViewStyle }); +const ITEM_ORDER = [ + 'score', + 'calc_time', + 'guesses', + 'crack_times_display', + 'online_throttling_100_per_hour', + 'online_no_throttling_10_per_second', + 'offline_slow_hashing_1e4_per_second', + 'offline_fast_hashing_1e10_per_second', + 'feedback', + 'sequence' +]; + interface Props { value: string; } interface State {} -export default class Result extends React.Component { +export default class Results extends React.Component { dataSource: any; constructor() { @@ -42,18 +55,30 @@ export default class Result extends React.Component { } parseData(results: any) { - const newResults = _.clone(results); + let newResults = _.clone(results); const hashTimes = Object.keys(newResults.crack_times_display).map(function (key) { const value = newResults.crack_times_display[key]; return {key, value}; }); + const guesses = [{ + key: 'guesses', + value: newResults.guesses * Math.pow(10, newResults.guesses_log10) + }]; delete newResults.crack_times_display; delete newResults.crack_times_seconds; + delete newResults.guesses_log10; + delete newResults.password; + delete newResults.guesses; const out = Object.keys(newResults).map(function (key) { const value = newResults[key]; return {key, value}; }); - return _.union(out, hashTimes); + const allResults = _.union(out, hashTimes, guesses); + let orderedResults : any[] = []; + allResults.forEach(function (result) { + orderedResults[ITEM_ORDER.indexOf(result.key)] = result; + }); + return orderedResults; } renderRow(rowData: any, sectionId: string, rowId: string) {