Bladeren bron

Merge pull request #67 from jeffreysnell/feature/65/local-store

Adding support for saving cards to the local store
Robert Autenrieth 8 jaren geleden
bovenliggende
commit
ad6ffe0d77
1 gewijzigde bestanden met toevoegingen van 26 en 1 verwijderingen
  1. 26
    1
      generator/js/ui.js

+ 26
- 1
generator/js/ui.js Bestand weergeven

192
         $("#card-color").val("").change();
192
         $("#card-color").val("").change();
193
     }
193
     }
194
 
194
 
195
+    local_store_save();
195
     ui_render_selected_card();
196
     ui_render_selected_card();
196
 }
197
 }
197
 
198
 
429
     ui_render_selected_card();
430
     ui_render_selected_card();
430
 }
431
 }
431
 
432
 
433
+
434
+//Adding support for local store
435
+function local_store_save() {
436
+    if(window.localStorage){
437
+        try {
438
+            localStorage.setItem("card_data", JSON.stringify(card_data));
439
+        } catch (e){
440
+            //if the local store save failed should we notify the user that the data is not being saved?
441
+            console.log(e);
442
+        }
443
+    }
444
+}
445
+function local_store_load() {
446
+    if(window.localStorage){
447
+        try {
448
+            card_data = JSON.parse(localStorage.getItem("card_data")) || card_data;
449
+        } catch (e){
450
+            //if the local store load failed should we notify the user that the data load failed?
451
+            console.log(e);
452
+        }
453
+    }
454
+}
455
+
432
 $(document).ready(function () {
456
 $(document).ready(function () {
457
+    local_store_load();
433
     ui_setup_color_selector();
458
     ui_setup_color_selector();
434
     $('.icon-list').typeahead({source:icon_names});
459
     $('.icon-list').typeahead({source:icon_names});
435
 
460
 
477
 
502
 
478
     $("#sort-execute").click(ui_sort_execute);
503
     $("#sort-execute").click(ui_sort_execute);
479
     $("#filter-execute").click(ui_filter_execute);
504
     $("#filter-execute").click(ui_filter_execute);
480
-    
505
+
481
     ui_update_card_list();
506
     ui_update_card_list();
482
 });
507
 });
483
 
508
 

Laden…
Annuleren
Opslaan