-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.js
182 lines (163 loc) · 5.63 KB
/
temp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
function find_unique_characters( string ){
var unique='';
for(var i=0; i<string.length; i++){
if(string.lastIndexOf(string[i]) == string.indexOf(string[i])){
unique += string[i];
}
}
return unique;
}
console.log(find_unique_characters('baraban'));
// aimport moment from 'moment';
// import assign from 'lodash/object/assign';
// var relArray = [
// {
// name: 'Intro to psychology',
// author: 'Brennan Erbeznik',
// last_studied: "2015-10-02 13:34:05.7000"
// },
// {
// name: 'Cognitive Science',
// author: 'Nathan Lomeli',
// last_studied: "2015-09-25 13:34:05.7000"
// },
// {
// name: 'American History',
// author: 'Benjamin Franklin',
// last_studied: "2015-09-12 13:34:05.7000"
// },
// {
// name: 'Computer Science 101',
// author: 'Larry Page',
// last_studied: "2015-10-05 13:34:05.7000"
// },
// {
// name: 'Intro to biology',
// author: 'Nathan Lomeli',
// last_studied: "2015-10-05 09:34:05.7000"
// },
// {
// name: 'American History',
// author: 'Benjamin Franklin',
// last_studied: "2015-08-01 13:34:05.7000"
// },
// {
// name: 'Computer Science 101',
// author: 'Larry Page',
// last_studied: "2015-07-05 13:34:05.7000"
// },
// {
// name: 'Intro to biology',
// author: 'Nathan Lomeli',
// last_studied: "2015-08-05 09:34:05.7000"
// }
// ];
// // var sorted_sets = relArray.reduce(function(list, set) {
// // const date = moment(set['last_studied']);
// // const today = moment();
// // const date_month = moment(set['last_studied']).format('MMMM');
// // const today_month = moment().format('MMMM');
// // let diff = today.diff(date, 'days');
// // if (diff > 30 && today_month !== date_month) {
// // list[set] = list[set] || [];
// // list[set]['category'] = list[set]['category'] || [];
// // list[set]['category'].push(date_month)
// // }
// // return list;
// // }, []);
// var sorted_sets = relArray.map((set) => {
// const date = moment(set['last_studied']);
// const today = moment();
// const date_month = moment(set['last_studied']).format('MMMM');
// const today_month = moment().format('MMMM');
// let diff = today.diff(date, 'days');
// if (diff > 30 && today_month !== date_month) {
// return assign({}, set, {time_ago: date_month})
// } else if (diff <= 7) {
// return assign({}, set, {time_ago: 'Last studied'})
// } else if (diff > 7 && diff < 14) {
// return assign({}, set, {time_ago: 'Last week'})
// } else if (diff > 14 && diff < 21) {
// return assign({}, set, {time_ago: '2 weeks ago'})
// } else if (diff > 21) {
// return assign({}, set, {time_ago: '3 weeks ago'})
// }
// })
// console.log(sorted_sets);
// var ProductCategoryRow = React.createClass({
// render: function() {
// return (<tr><th colSpan="2">{this.props.category}</th></tr>);
// }
// });
// var ProductRow = React.createClass({
// render: function() {
// var name = this.props.product.stocked ?
// this.props.product.name :
// <span style={{color: 'red'}}>
// {this.props.product.name}
// </span>;
// return (
// <tr>
// <td>{name}</td>
// <td>{this.props.product.price}</td>
// </tr>
// );
// }
// });
// var ProductTable = React.createClass({
// render: function() {
// var rows = [];
// var lastCategory = null;
// this.props.products.forEach(function(product) {
// if (product.category !== lastCategory) {
// rows.push(<ProductCategoryRow category={product.category} key={product.category} />);
// }
// rows.push(<ProductRow product={product} key={product.name} />);
// lastCategory = product.category;
// });
// return (
// <table>
// <thead>
// <tr>
// <th>Name</th>
// <th>Price</th>
// </tr>
// </thead>
// <tbody>{rows}</tbody>
// </table>
// );
// }
// });
// var SearchBar = React.createClass({
// render: function() {
// return (
// <form>
// <input type="text" placeholder="Search..." />
// <p>
// <input type="checkbox" />
// {' '}
// Only show products in stock
// </p>
// </form>
// );
// }
// });
// var FilterableProductTable = React.createClass({
// render: function() {
// return (
// <div>
// <SearchBar />
// <ProductTable products={this.props.products} />
// </div>
// );
// }
// });
// var PRODUCTS = [
// {category: 'Sporting Goods', price: '$49.99', stocked: true, name: 'Football'},
// {category: 'Sporting Goods', price: '$9.99', stocked: true, name: 'Baseball'},
// {category: 'Sporting Goods', price: '$29.99', stocked: false, name: 'Basketball'},
// {category: 'Electronics', price: '$99.99', stocked: true, name: 'iPod Touch'},
// {category: 'Electronics', price: '$399.99', stocked: false, name: 'iPhone 5'},
// {category: 'Electronics', price: '$199.99', stocked: true, name: 'Nexus 7'}
// ];
// React.render(<FilterableProductTable products={PRODUCTS} />, document.body);