src/ztfy/myams/resources/js/myams-widgets.js
changeset 206 02a40997d8cb
parent 142 0201f1422bd7
--- a/src/ztfy/myams/resources/js/myams-widgets.js	Fri May 12 14:03:02 2017 +0200
+++ b/src/ztfy/myams/resources/js/myams-widgets.js	Thu Oct 26 14:45:34 2017 +0200
@@ -88,24 +88,30 @@
 							continue;
 						}
 						widget = settings.widget[key];
-						var widgetId = $('#' + widget.id);
+						if (!widget.id) {
+							continue;
+						}
+						var mywidget = $('#' + widget.id);
+						if (!mywidget.exists()) {
+							continue;
+						}
 						if (widget.style) {
-							widgetId.removeClassPrefix('ams-widget-color-')
+							mywidget.removeClassPrefix('ams-widget-color-')
 									.addClass(widget.style)
 									.attr('data-widget-attstyle', widget.style);
 						}
 						if (widget.hidden === 1) {
-							widgetId.hide(1);
+							mywidget.hide(1);
 						} else {
-							widgetId.show(1)
+							mywidget.show(1)
 									.removeAttr('data-widget-hidden');
 						}
 						if (widget.collapsed === 1) {
-							widgetId.addClass('ams-widget-collapsed')
+							mywidget.addClass('ams-widget-collapsed')
 									.children('div')
 									.hide(1);
 						}
-						var title = widgetId.children('header').children('h2');
+						var title = mywidget.children('header').children('h2');
 						if (title.text() !== widget.title) {
 							title.text(widget.title);
 						}
@@ -338,7 +344,7 @@
 					uid = +new Date();
 				try {
 					self.storage.setItem(uid, uid);
-					result = self.storage.getItem(uid) === uid;
+					result = parseInt(self.storage.getItem(uid)) === uid;
 					self.storage.removeItem(uid);
 					return result;
 				} catch (e) {}