@@ -16,13 +16,34 @@ var QueryResultDb = function () {
16
16
17
17
/**
18
18
* Store data that was sent by catching a window message in starter.js
19
- * @param {type } data Event.data object
19
+ * @param {type } obj Event.data object
20
20
*/
21
- QueryResultDb . prototype . saveQueryResults = function ( data ) {
21
+ QueryResultDb . prototype . saveQueryResults = function ( obj ) {
22
22
23
- console . log ( "Saving new query results" , data ) ;
23
+ /**
24
+ * Removing description-data of the results due to large data
25
+ */
26
+ var remove_description = false ;
24
27
25
- if ( ! data . data )
28
+ if ( remove_description && obj . data && obj . data . result ) {
29
+
30
+ for ( var i = 0 ; i < obj . data . result . length ; i ++ ) {
31
+
32
+ var res = obj . data . result [ i ] ;
33
+
34
+ if ( res . description !== undefined ) {
35
+ res . description = "TRUNCATED AT SAVING TO LOCALSTORAGE" ;
36
+ }
37
+
38
+ if ( res . v2DataItem !== undefined && res . v2DataItem . description !== undefined ) {
39
+ res . v2DataItem . description = "TRUNCATED AT SAVING TO LOCALSTORAGE" ;
40
+ }
41
+ }
42
+ }
43
+
44
+ console . log ( "Saving new query results" , obj ) ;
45
+
46
+ if ( ! obj . data )
26
47
return ;
27
48
28
49
@@ -32,14 +53,17 @@ QueryResultDb.prototype.saveQueryResults = function (data) {
32
53
throw ( "Could not get a free key for storing the query-data in local storage" ) ;
33
54
34
55
35
- data . data . id = key ;
36
- var value = JSON . stringify ( data . data ) ;
56
+ obj . data . id = key ;
37
57
58
+ var value = JSON . stringify ( obj . data ) ;
59
+
60
+ console . log ( "Saving new query with length " + value . length ) ;
61
+
38
62
if ( this . compress )
39
63
value = LZString . compress ( value ) ;
40
64
41
-
42
- this . forceStoring ( this . prefix + key , value )
65
+
66
+ this . forceStoring ( this . prefix + key , value ) ;
43
67
44
68
} ;
45
69
@@ -51,20 +75,20 @@ QueryResultDb.prototype.saveQueryResults = function (data) {
51
75
* @param {type } key
52
76
* @param {type } val
53
77
*/
54
- QueryResultDb . prototype . forceStoring = function ( key , val ) {
78
+ QueryResultDb . prototype . forceStoring = function ( key , val ) {
55
79
try {
56
80
//console.log("Storing a query with key " + key);
57
81
localStorage . setItem ( key , val ) ;
58
82
59
83
} catch ( QuotaExceededError ) {
60
-
84
+
61
85
var key_to_delete = this . getOldestKey ( ) ;
62
86
console . log ( "Oops. Storage full. Deleting value '" + this . prefix + key_to_delete + "'" ) ;
63
87
64
88
if ( key_to_delete === null ) {
65
89
throw ( "Can't get a key for deleting an old query from local storage!" ) ;
66
90
}
67
-
91
+
68
92
delete localStorage [ this . prefix + key_to_delete ] ;
69
93
this . forceStoring ( key , val ) ;
70
94
//delete localStorage[this.prefix + key_to_delete];
0 commit comments