]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Catches GeoCookie JSON parsing error
authorchimo <chimo@chromic.org>
Sat, 31 May 2014 22:11:04 +0000 (18:11 -0400)
committerchimo <chimo@chromic.org>
Sat, 31 May 2014 22:11:04 +0000 (18:11 -0400)
js/util.js

index a2b10da8a440f2e146b0f02293ef05e50c2a7bb8..c3ca213f3a4287a103c4baa9e63b73605cee586a 100644 (file)
@@ -1177,18 +1177,22 @@ var SN = { // StatusNet
                                 }
                             }
                         } else {
-                            var cookieValue = JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));
-
-                            form.find('[name=lat]').val(cookieValue.NLat);
-                            form.find('[name=lon]').val(cookieValue.NLon);
-                            form.find('[name=location_ns]').val(cookieValue.NLNS);
-                            form.find('[name=location_id]').val(cookieValue.NLID);
-                            form.find('[name=notice_data-geo]').prop('checked', cookieValue.NDG);
-
-                            SN.U.NoticeGeoStatus(form, cookieValue.NLN, cookieValue.NLat, cookieValue.NLon, cookieValue.NLNU);
-                            label
-                                .attr('title', NoticeDataGeo_text.ShareDisable + ' (' + cookieValue.NLN + ')')
-                                .addClass('checked');
+                            try {
+                                var cookieValue = JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));
+
+                                form.find('[name=lat]').val(cookieValue.NLat);
+                                form.find('[name=lon]').val(cookieValue.NLon);
+                                form.find('[name=location_ns]').val(cookieValue.NLNS);
+                                form.find('[name=location_id]').val(cookieValue.NLID);
+                                form.find('[name=notice_data-geo]').prop('checked', cookieValue.NDG);
+
+                               SN.U.NoticeGeoStatus(form, cookieValue.NLN, cookieValue.NLat, cookieValue.NLon, cookieValue.NLNU);
+                                label
+                                    .attr('title', NoticeDataGeo_text.ShareDisable + ' (' + cookieValue.NLN + ')')
+                                    .addClass('checked');
+                            } catch (e) {
+                                console.log('Parsing error:', e);
+                            }
                         }
                     } else {
                         removeNoticeDataGeo();