1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-21 15:56:40 +02:00
TableFilter/src-es6/modules/store.js

35 lines
797 B
JavaScript
Raw Normal View History

2014-11-30 11:38:40 +01:00
import {Cookie} from '../cookie';
export class Store{
constructor(tf) {
var f = tf.fObj;
this.duration = !isNaN(f.set_cookie_duration) ?
parseInt(f.set_cookie_duration, 10) : 100000;
this.tf = tf;
}
saveFilterValues(name){
var tf = this.tf;
var flt_values = [];
//store filters' values
for(var i=0; i<tf.fltIds.length; i++){
var value = tf.GetFilterValue(i);
if (value === ''){
value = ' ';
}
flt_values.push(value);
}
//adds array size
flt_values.push(tf.fltIds.length);
//writes cookie
Cookie.write(
name,
flt_values.join(tf.separator),
this.duration
);
}
}